chore: split db abstraction into new crate (#8594)

This commit is contained in:
Oliver
2024-06-04 23:45:57 +02:00
committed by GitHub
parent a8095740fc
commit 51a28f22da
183 changed files with 825 additions and 755 deletions

57
Cargo.lock generated
View File

@ -2594,6 +2594,7 @@ dependencies = [
"alloy-rlp",
"rayon",
"reth-db",
"reth-db-api",
"reth-evm-ethereum",
"reth-primitives",
"reth-provider",
@ -6180,6 +6181,7 @@ dependencies = [
"reth-consensus",
"reth-consensus-common",
"reth-db",
"reth-db-api",
"reth-db-common",
"reth-discv4",
"reth-discv5",
@ -6284,6 +6286,7 @@ dependencies = [
"reth-config",
"reth-consensus",
"reth-db",
"reth-db-api",
"reth-downloaders",
"reth-engine-primitives",
"reth-errors",
@ -6328,6 +6331,7 @@ dependencies = [
"reth-blockchain-tree-api",
"reth-consensus",
"reth-db",
"reth-db-api",
"reth-evm",
"reth-evm-ethereum",
"reth-execution-errors",
@ -6440,16 +6444,12 @@ dependencies = [
"eyre",
"iai-callgrind",
"metrics",
"modular-bitfield",
"once_cell",
"page_size",
"parity-scale-codec",
"paste",
"pprof",
"proptest",
"proptest-derive",
"rand 0.8.5",
"reth-codecs",
"reth-db-api",
"reth-fs-util",
"reth-libmdbx",
"reth-metrics",
@ -6467,6 +6467,32 @@ dependencies = [
"thiserror",
]
[[package]]
name = "reth-db-api"
version = "0.2.0-beta.8"
dependencies = [
"arbitrary",
"assert_matches",
"bytes",
"criterion",
"derive_more",
"iai-callgrind",
"metrics",
"modular-bitfield",
"parity-scale-codec",
"paste",
"pprof",
"proptest",
"proptest-derive",
"rand 0.8.5",
"reth-codecs",
"reth-primitives",
"reth-storage-errors",
"serde",
"serde_json",
"test-fuzz",
]
[[package]]
name = "reth-db-common"
version = "0.2.0-beta.8"
@ -6475,6 +6501,7 @@ dependencies = [
"reth-codecs",
"reth-config",
"reth-db",
"reth-db-api",
"reth-etl",
"reth-primitives",
"reth-provider",
@ -6575,6 +6602,7 @@ dependencies = [
"reth-config",
"reth-consensus",
"reth-db",
"reth-db-api",
"reth-metrics",
"reth-network-p2p",
"reth-network-types",
@ -6790,7 +6818,7 @@ name = "reth-etl"
version = "0.2.0-beta.8"
dependencies = [
"rayon",
"reth-db",
"reth-db-api",
"reth-primitives",
"tempfile",
]
@ -7117,7 +7145,7 @@ dependencies = [
name = "reth-node-api"
version = "0.2.0-beta.8"
dependencies = [
"reth-db",
"reth-db-api",
"reth-engine-primitives",
"reth-evm",
"reth-network",
@ -7143,6 +7171,7 @@ dependencies = [
"reth-config",
"reth-consensus",
"reth-db",
"reth-db-api",
"reth-db-common",
"reth-downloaders",
"reth-evm",
@ -7197,6 +7226,7 @@ dependencies = [
"reth-config",
"reth-consensus-common",
"reth-db",
"reth-db-api",
"reth-discv4",
"reth-discv5",
"reth-engine-primitives",
@ -7265,7 +7295,7 @@ dependencies = [
"humantime",
"pin-project",
"reth-beacon-consensus",
"reth-db",
"reth-db-api",
"reth-network",
"reth-network-api",
"reth-primitives",
@ -7451,6 +7481,7 @@ dependencies = [
"reth-blockchain-tree-api",
"reth-codecs",
"reth-db",
"reth-db-api",
"reth-errors",
"reth-evm",
"reth-execution-types",
@ -7481,6 +7512,7 @@ dependencies = [
"rayon",
"reth-config",
"reth-db",
"reth-db-api",
"reth-errors",
"reth-metrics",
"reth-primitives",
@ -7739,6 +7771,7 @@ dependencies = [
"reth-config",
"reth-consensus",
"reth-db",
"reth-db-api",
"reth-downloaders",
"reth-etl",
"reth-evm",
@ -7772,7 +7805,7 @@ dependencies = [
"futures-util",
"metrics",
"reth-consensus",
"reth-db",
"reth-db-api",
"reth-errors",
"reth-metrics",
"reth-network-p2p",
@ -7796,6 +7829,7 @@ dependencies = [
"parking_lot 0.12.3",
"rayon",
"reth-db",
"reth-db-api",
"reth-nippy-jar",
"reth-primitives",
"reth-provider",
@ -7823,7 +7857,7 @@ name = "reth-storage-api"
version = "0.2.0-beta.8"
dependencies = [
"auto_impl",
"reth-db",
"reth-db-api",
"reth-execution-types",
"reth-primitives",
"reth-storage-errors",
@ -7940,6 +7974,7 @@ dependencies = [
"proptest",
"rayon",
"reth-db",
"reth-db-api",
"reth-execution-errors",
"reth-metrics",
"reth-primitives",
@ -7967,6 +8002,7 @@ dependencies = [
"rand 0.8.5",
"rayon",
"reth-db",
"reth-db-api",
"reth-execution-errors",
"reth-metrics",
"reth-primitives",
@ -8168,6 +8204,7 @@ dependencies = [
"jsonrpsee",
"reth",
"reth-db",
"reth-db-api",
"reth-node-ethereum",
"tokio",
]

View File

@ -69,6 +69,7 @@ members = [
"crates/storage/codecs/",
"crates/storage/codecs/derive/",
"crates/storage/db/",
"crates/storage/db-api/",
"crates/storage/db-common",
"crates/storage/errors/",
"crates/storage/libmdbx-rs/",
@ -240,6 +241,7 @@ reth-config = { path = "crates/config" }
reth-consensus = { path = "crates/consensus/consensus" }
reth-consensus-common = { path = "crates/consensus/common" }
reth-db = { path = "crates/storage/db" }
reth-db-api = { path = "crates/storage/db-api" }
reth-db-common = { path = "crates/storage/db-common" }
reth-discv4 = { path = "crates/net/discv4" }
reth-discv5 = { path = "crates/net/discv5" }

View File

@ -18,6 +18,7 @@ reth-config.workspace = true
reth-primitives = { workspace = true, features = ["arbitrary", "clap"] }
reth-fs-util.workspace = true
reth-db = { workspace = true, features = ["mdbx"] }
reth-db-api.workspace = true
reth-exex.workspace = true
reth-provider = { workspace = true }
reth-evm.workspace = true

View File

@ -4,10 +4,8 @@ use crate::{
};
use ahash::RandomState;
use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx, DatabaseEnv, RawKey,
RawTable, RawValue, TableViewer, Tables,
};
use reth_db::{DatabaseEnv, RawKey, RawTable, RawValue, TableViewer, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use std::{
hash::{BuildHasher, Hasher},
sync::Arc,

View File

@ -1,10 +1,9 @@
use clap::{Parser, Subcommand};
use reth_db::{
use reth_db::{static_file::iter_static_files, TableViewer, Tables};
use reth_db_api::{
database::Database,
static_file::iter_static_files,
table::Table,
transaction::{DbTx, DbTxMut},
TableViewer, Tables,
};
use reth_primitives::{static_file::find_fixed_range, StaticFileSegment};
use reth_provider::{ProviderFactory, StaticFileProviderFactory};

View File

@ -4,10 +4,8 @@ use crate::{
utils::DbTool,
};
use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, open_db_read_only, table::Table, tables_to_generic,
transaction::DbTx, DatabaseEnv, Tables,
};
use reth_db::{open_db_read_only, tables_to_generic, DatabaseEnv, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use std::{
collections::HashMap,
fmt::Debug,
@ -95,7 +93,7 @@ where
T::Key: Hash,
T::Value: PartialEq,
{
let table = T::TABLE;
let table = T::NAME;
info!("Analyzing table {table}...");
let result = find_diffs_advanced::<T>(&primary_tx, &secondary_tx)?;

View File

@ -1,11 +1,13 @@
use crate::utils::DbTool;
use clap::Parser;
use reth_db::{
database::Database,
static_file::{ColumnSelectorOne, ColumnSelectorTwo, HeaderMask, ReceiptMask, TransactionMask},
table::{Decompress, DupSort, Table},
tables, RawKey, RawTable, Receipts, TableViewer, Transactions,
};
use reth_db_api::{
database::Database,
table::{Decompress, DupSort, Table},
};
use reth_primitives::{BlockHash, Header, StaticFileSegment};
use reth_provider::StaticFileProviderFactory;
use tracing::error;
@ -200,10 +202,8 @@ pub(crate) fn maybe_json_value_parser(value: &str) -> Result<String, eyre::Error
mod tests {
use super::*;
use clap::{Args, Parser};
use reth_db::{
models::{storage_sharded_key::StorageShardedKey, ShardedKey},
AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory,
};
use reth_db::{AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory};
use reth_db_api::models::{storage_sharded_key::StorageShardedKey, ShardedKey};
use reth_primitives::{Address, B256};
use std::str::FromStr;

View File

@ -2,7 +2,8 @@ use super::tui::DbListTUI;
use crate::utils::{DbTool, ListFilter};
use clap::Parser;
use eyre::WrapErr;
use reth_db::{database::Database, table::Table, DatabaseEnv, RawValue, TableViewer, Tables};
use reth_db::{DatabaseEnv, RawValue, TableViewer, Tables};
use reth_db_api::{database::Database, table::Table};
use reth_primitives::hex;
use std::{cell::RefCell, sync::Arc};
use tracing::error;

View File

@ -4,9 +4,8 @@ use comfy_table::{Cell, Row, Table as ComfyTable};
use eyre::WrapErr;
use human_bytes::human_bytes;
use itertools::Itertools;
use reth_db::{
database::Database, mdbx, static_file::iter_static_files, DatabaseEnv, TableViewer, Tables,
};
use reth_db::{mdbx, static_file::iter_static_files, DatabaseEnv, TableViewer, Tables};
use reth_db_api::database::Database;
use reth_fs_util as fs;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::static_file::{find_fixed_range, SegmentRangeInclusive};

View File

@ -10,10 +10,8 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap},
Frame, Terminal,
};
use reth_db::{
table::{Table, TableRow},
RawValue,
};
use reth_db::RawValue;
use reth_db_api::table::{Table, TableRow};
use std::{
io,
time::{Duration, Instant},

View File

@ -12,7 +12,8 @@ use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::{database::Database, DatabaseEnv};
use reth_db::DatabaseEnv;
use reth_db_api::database::Database;
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
headers::reverse_headers::ReverseHeadersDownloaderBuilder,

View File

@ -12,7 +12,8 @@ use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::{cursor::DbCursorRO, tables, transaction::DbTx, DatabaseEnv};
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
use reth_evm::execute::{BatchBlockExecutionOutput, BatchExecutor, BlockExecutorProvider};
use reth_network::NetworkHandle;
use reth_network_api::NetworkInfo;

View File

@ -10,7 +10,8 @@ use futures::{Stream, StreamExt};
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::{database::Database, tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::{database::Database, transaction::DbTx};
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
file_client::{ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE},

View File

@ -10,7 +10,8 @@ use crate::{
};
use clap::Parser;
use reth_consensus::noop::NoopConsensus;
use reth_db::{tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::transaction::DbTx;
use reth_downloaders::file_client::{
ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE,
};

View File

@ -3,7 +3,8 @@
use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_db::{database::Database, tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::{database::Database, transaction::DbTx};
use reth_downloaders::{
file_client::{ChunkedFileReader, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE},
receipt_file_client::ReceiptFileClient,

View File

@ -3,7 +3,7 @@
use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_config::config::EtlConfig;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_db_common::init::init_from_state_dump;
use reth_primitives::B256;
use reth_provider::ProviderFactory;

View File

@ -1,9 +1,9 @@
use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use clap::Parser;
use reth_cli_runner::CliContext;
use reth_db::{
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRW},
tables,
transaction::DbTx,
};
use reth_provider::{BlockNumReader, HeaderProvider, ProviderError};

View File

@ -7,7 +7,8 @@ use crate::{
};
use clap::Parser;
use itertools::Itertools;
use reth_db::{static_file::iter_static_files, tables, transaction::DbTxMut, DatabaseEnv};
use reth_db::{static_file::iter_static_files, tables, DatabaseEnv};
use reth_db_api::transaction::DbTxMut;
use reth_db_common::init::{insert_genesis_header, insert_genesis_history, insert_genesis_state};
use reth_primitives::{stage::StageId, static_file::find_fixed_range, StaticFileSegment};
use reth_provider::{providers::StaticFileWriter, StaticFileProviderFactory};

View File

@ -1,8 +1,8 @@
use super::setup;
use crate::{macros::block_executor, utils::DbTool};
use reth_db::{
cursor::DbCursorRO, database::Database, table::TableImporter, tables, transaction::DbTx,
DatabaseEnv,
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{
cursor::DbCursorRO, database::Database, table::TableImporter, transaction::DbTx,
};
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::stage::StageCheckpoint;

View File

@ -1,7 +1,8 @@
use super::setup;
use crate::utils::DbTool;
use eyre::Result;
use reth_db::{database::Database, table::TableImporter, tables, DatabaseEnv};
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{database::Database, table::TableImporter};
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::{stage::StageCheckpoint, BlockNumber};
use reth_provider::{providers::StaticFileProvider, ProviderFactory};

View File

@ -1,7 +1,8 @@
use super::setup;
use crate::utils::DbTool;
use eyre::Result;
use reth_db::{database::Database, table::TableImporter, tables, DatabaseEnv};
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{database::Database, table::TableImporter};
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::stage::StageCheckpoint;
use reth_provider::{providers::StaticFileProvider, ProviderFactory};

View File

@ -2,7 +2,8 @@ use super::setup;
use crate::{macros::block_executor, utils::DbTool};
use eyre::Result;
use reth_config::config::EtlConfig;
use reth_db::{database::Database, table::TableImporter, tables, DatabaseEnv};
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{database::Database, table::TableImporter};
use reth_exex::ExExManagerHandle;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::{stage::StageCheckpoint, BlockNumber, PruneModes};

View File

@ -8,10 +8,10 @@ use crate::{
use crate::args::DatadirArgs;
use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, init_db, mdbx::DatabaseArguments,
models::client_version::ClientVersion, table::TableImporter, tables, transaction::DbTx,
DatabaseEnv,
use reth_db::{init_db, mdbx::DatabaseArguments, tables, DatabaseEnv};
use reth_db_api::{
cursor::DbCursorRO, database::Database, models::ClientVersion, table::TableImporter,
transaction::DbTx,
};
use reth_node_core::dirs::PlatformPath;
use std::path::PathBuf;

View File

@ -4,7 +4,7 @@ use clap::{Parser, Subcommand};
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
use reth_exex::ExExManagerHandle;
use reth_node_core::args::NetworkArgs;

View File

@ -7,10 +7,8 @@ use proptest::{
strategy::{Strategy, ValueTree},
test_runner::TestRunner,
};
use reth_db::{
table::{DupSort, Table, TableRow},
tables,
};
use reth_db::tables;
use reth_db_api::table::{DupSort, Table, TableRow};
use reth_fs_util as fs;
use tracing::error;

View File

@ -2,12 +2,13 @@
use boyer_moore_magiclen::BMByte;
use eyre::Result;
use reth_db::{
use reth_db::{RawTable, TableRawRow};
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRO},
database::Database,
table::{Decode, Decompress, DupSort, Table, TableRow},
transaction::{DbTx, DbTxMut},
DatabaseError, RawTable, TableRawRow,
DatabaseError,
};
use reth_fs_util as fs;
use reth_primitives::ChainSpec;

View File

@ -17,6 +17,7 @@ reth-primitives.workspace = true
reth-storage-errors.workspace = true
reth-execution-errors.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-evm.workspace = true
reth-revm.workspace = true
reth-provider.workspace = true
@ -41,7 +42,7 @@ linked_hash_set = "0.1.4"
[dev-dependencies]
reth-db = { workspace = true, features = ["test-utils"] }
reth-primitives = { workspace = true , features = ["test-utils"] }
reth-primitives = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
reth-evm = { workspace = true, features = ["test-utils"] }
reth-testing-utils.workspace = true

View File

@ -10,7 +10,7 @@ use reth_blockchain_tree_api::{
BlockAttachment, BlockStatus, BlockValidationKind, CanonicalOutcome, InsertPayloadOk,
};
use reth_consensus::{Consensus, ConsensusError};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_evm::execute::BlockExecutorProvider;
use reth_execution_errors::{BlockExecutionError, BlockValidationError};
use reth_primitives::{
@ -1377,7 +1377,8 @@ mod tests {
use assert_matches::assert_matches;
use linked_hash_set::LinkedHashSet;
use reth_consensus::test_utils::TestConsensus;
use reth_db::{tables, test_utils::TempDatabase, transaction::DbTxMut, DatabaseEnv};
use reth_db::{tables, test_utils::TempDatabase, DatabaseEnv};
use reth_db_api::transaction::DbTxMut;
use reth_evm::test_utils::MockExecutorProvider;
use reth_evm_ethereum::execute::EthExecutorProvider;
#[cfg(not(feature = "optimism"))]

View File

@ -10,7 +10,7 @@ use reth_blockchain_tree_api::{
BlockAttachment, BlockValidationKind,
};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_evm::execute::{BlockExecutionOutput, BlockExecutorProvider, Executor};
use reth_execution_errors::BlockExecutionError;
use reth_primitives::{

View File

@ -1,9 +1,8 @@
//! Blockchain tree externals.
use reth_consensus::Consensus;
use reth_db::{
cursor::DbCursorRO, database::Database, static_file::HeaderMask, tables, transaction::DbTx,
};
use reth_db::{static_file::HeaderMask, tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, transaction::DbTx};
use reth_primitives::{BlockHash, BlockNumber, StaticFileSegment};
use reth_provider::{ProviderFactory, StaticFileProviderFactory, StatsReader};
use reth_storage_errors::provider::ProviderResult;

View File

@ -7,7 +7,7 @@ use reth_blockchain_tree_api::{
BlockValidationKind, BlockchainTreeEngine, BlockchainTreeViewer, CanonicalOutcome,
InsertPayloadOk,
};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_evm::execute::BlockExecutorProvider;
use reth_primitives::{
BlockHash, BlockNumHash, BlockNumber, Receipt, SealedBlock, SealedBlockWithSenders,

View File

@ -17,7 +17,7 @@ reth-blockchain-tree-api.workspace = true
reth-primitives.workspace = true
reth-stages-api.workspace = true
reth-errors.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-provider.workspace = true
reth-rpc-types.workspace = true
reth-tasks.workspace = true
@ -74,5 +74,5 @@ optimism = [
"reth-provider/optimism",
"reth-blockchain-tree/optimism",
"reth-ethereum-consensus/optimism",
"reth-rpc/optimism"
"reth-rpc/optimism",
]

View File

@ -6,7 +6,7 @@ use crate::{
};
use futures::FutureExt;
use metrics::Counter;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_errors::{RethError, RethResult};
use reth_primitives::BlockNumber;
use reth_prune::{Pruner, PrunerError, PrunerWithResult};

View File

@ -5,7 +5,7 @@ use crate::{
hooks::EngineHookDBAccessLevel,
};
use futures::FutureExt;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_errors::RethResult;
use reth_primitives::{static_file::HighestStaticFiles, BlockNumber};
use reth_static_file::{StaticFileProducer, StaticFileProducerWithResult};

View File

@ -4,7 +4,7 @@ use reth_blockchain_tree_api::{
error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind},
BlockStatus, BlockValidationKind, BlockchainTreeEngine, CanonicalOutcome, InsertPayloadOk,
};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_engine_primitives::{EngineTypes, PayloadAttributes, PayloadBuilderAttributes};
use reth_errors::{BlockValidationError, ProviderResult, RethError, RethResult};
use reth_network_p2p::{
@ -2178,7 +2178,8 @@ mod tests {
mod fork_choice_updated {
use super::*;
use reth_db::{tables, test_utils::create_test_static_files_dir, transaction::DbTxMut};
use reth_db::{tables, test_utils::create_test_static_files_dir};
use reth_db_api::transaction::DbTxMut;
use reth_primitives::U256;
use reth_provider::providers::StaticFileProvider;
use reth_rpc_types::engine::ForkchoiceUpdateError;

View File

@ -5,7 +5,7 @@ use crate::{
ConsensusEngineLiveSyncProgress, EthBeaconConsensus,
};
use futures::FutureExt;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_network_p2p::{
bodies::client::BodiesClient,
full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient},

View File

@ -9,7 +9,7 @@ repository.workspace = true
[dependencies]
tempfile.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
rayon.workspace = true
[dev-dependencies]

View File

@ -22,7 +22,7 @@ use std::{
};
use rayon::prelude::*;
use reth_db::table::{Compress, Encode, Key, Value};
use reth_db_api::table::{Compress, Encode, Key, Value};
use tempfile::{NamedTempFile, TempDir};
/// An ETL (extract, transform, load) data collector.

View File

@ -23,6 +23,7 @@ reth-network-types.workspace = true
# optional deps for the test-utils feature
reth-db = { workspace = true, optional = true }
reth-db-api = { workspace = true, optional = true }
reth-testing-utils = { workspace = true, optional = true }
# eth
@ -50,6 +51,7 @@ itertools.workspace = true
[dev-dependencies]
reth-db = { workspace = true, features = ["test-utils"] }
reth-db-api.workspace = true
reth-consensus = { workspace = true, features = ["test-utils"] }
reth-network-p2p = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
@ -65,5 +67,11 @@ rand.workspace = true
tempfile.workspace = true
[features]
test-utils = ["dep:tempfile", "reth-db/test-utils", "reth-consensus/test-utils", "reth-network-p2p/test-utils", "reth-testing-utils"]
test-utils = [
"dep:tempfile",
"dep:reth-db-api",
"reth-db/test-utils",
"reth-consensus/test-utils",
"reth-network-p2p/test-utils",
"reth-testing-utils",
]

View File

@ -2,7 +2,8 @@
#![allow(dead_code)]
use reth_db::{database::Database, tables, transaction::DbTxMut, DatabaseEnv};
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{database::Database, transaction::DbTxMut};
use reth_network_p2p::bodies::response::BlockResponse;
use reth_primitives::{Block, BlockBody, SealedBlock, SealedHeader, B256};
use std::collections::HashMap;

View File

@ -15,6 +15,7 @@ workspace = true
reth-primitives.workspace = true
reth-fs-util.workspace = true
reth-db = { workspace = true, features = ["mdbx"] }
reth-db-api.workspace = true
reth-storage-errors = { workspace = true, features = ["clap"] }
reth-provider.workspace = true
reth-network = { workspace = true, features = ["serde"] }

View File

@ -9,7 +9,7 @@ use hyper::{
use metrics::describe_gauge;
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use metrics_util::layers::{PrefixLayer, Stack};
use reth_db::database_metrics::DatabaseMetrics;
use reth_db_api::database_metrics::DatabaseMetrics;
use reth_metrics::metrics::Unit;
use reth_provider::providers::StaticFileProvider;
use reth_tasks::TaskExecutor;

View File

@ -13,7 +13,7 @@ use discv5::ListenConfig;
use metrics_exporter_prometheus::PrometheusHandle;
use once_cell::sync::Lazy;
use reth_config::{config::PruneConfig, Config};
use reth_db::{database::Database, database_metrics::DatabaseMetrics};
use reth_db_api::{database::Database, database_metrics::DatabaseMetrics};
use reth_network::{NetworkBuilder, NetworkConfig, NetworkManager};
use reth_network_p2p::headers::client::HeadersClient;
use reth_primitives::{

View File

@ -1,5 +1,5 @@
//! Version information for reth.
use reth_db::models::client_version::ClientVersion;
use reth_db_api::models::ClientVersion;
use reth_rpc_types::engine::ClientCode;
/// The client code for Reth

View File

@ -14,7 +14,7 @@ workspace = true
# reth
reth-evm.workspace = true
reth-provider.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-engine-primitives.workspace = true
reth-transaction-pool.workspace = true
reth-network.workspace = true

View File

@ -1,7 +1,7 @@
//! Traits for configuring a node.
use crate::{primitives::NodePrimitives, ConfigureEvm, EngineTypes};
use reth_db::{
use reth_db_api::{
database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetrics},
};

View File

@ -21,6 +21,7 @@ reth-exex.workspace = true
reth-evm.workspace = true
reth-provider.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-rpc-engine-api.workspace = true
reth-rpc.workspace = true
reth-rpc-layer.workspace = true

View File

@ -10,11 +10,13 @@ use crate::{
};
use futures::Future;
use reth_db::{
database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetrics},
test_utils::{create_test_rw_db_with_path, tempdir_path, TempDatabase},
DatabaseEnv,
};
use reth_db_api::{
database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetrics},
};
use reth_exex::ExExContext;
use reth_network::{NetworkBuilder, NetworkConfig, NetworkHandle};
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};

View File

@ -5,7 +5,7 @@ use rayon::ThreadPoolBuilder;
use reth_auto_seal_consensus::MiningMode;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::{config::EtlConfig, PruneConfig};
use reth_db::{database::Database, database_metrics::DatabaseMetrics};
use reth_db_api::{database::Database, database_metrics::DatabaseMetrics};
use reth_db_common::init::{init_genesis, InitDatabaseError};
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
use reth_evm::noop::NoopBlockExecutorProvider;

View File

@ -2,7 +2,7 @@
use reth_config::{config::StageConfig, PruneConfig};
use reth_consensus::Consensus;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
headers::reverse_headers::ReverseHeadersDownloaderBuilder,

View File

@ -18,7 +18,7 @@ reth-network-api.workspace = true
reth-stages.workspace = true
reth-prune.workspace = true
reth-static-file.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-primitives.workspace = true
reth-rpc-types.workspace = true

View File

@ -5,7 +5,7 @@ use futures::Stream;
use reth_beacon_consensus::{
BeaconConsensusEngineEvent, ConsensusEngineLiveSyncProgress, ForkchoiceStatus,
};
use reth_db::{database::Database, database_metrics::DatabaseMetadata};
use reth_db_api::{database::Database, database_metrics::DatabaseMetadata};
use reth_network::{NetworkEvent, NetworkHandle};
use reth_network_api::PeersInfo;
use reth_primitives::{

View File

@ -15,6 +15,7 @@ workspace = true
# reth
reth-primitives.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-errors.workspace = true
reth-provider.workspace = true
reth-tokio-util.workspace = true

View File

@ -1,6 +1,6 @@
use crate::{segments::SegmentSet, Pruner};
use reth_config::PruneConfig;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{FinishedExExHeight, PruneModes, MAINNET};
use reth_provider::ProviderFactory;
use std::time::Duration;

View File

@ -5,7 +5,7 @@ use crate::{
segments::{PruneInput, Segment},
Metrics, PrunerError, PrunerEvent,
};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{
BlockNumber, FinishedExExHeight, PruneLimiter, PruneMode, PruneProgress, PrunePurpose,
PruneSegment, StaticFileSegment,

View File

@ -4,7 +4,8 @@ use crate::{
},
PrunerError,
};
use reth_db::{database::Database, models::ShardedKey, tables};
use reth_db::tables;
use reth_db_api::{database::Database, models::ShardedKey};
use reth_primitives::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment};
use reth_provider::DatabaseProviderRW;
use tracing::{instrument, trace};

View File

@ -5,10 +5,10 @@ use crate::{
PrunerError,
};
use itertools::Itertools;
use reth_db::{
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, RangeWalker},
database::Database,
tables,
transaction::DbTxMut,
};
@ -188,7 +188,8 @@ where
#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use reth_db::{tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::transaction::DbTx;
use reth_primitives::{
BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress,
PruneSegment, B256, U256,

View File

@ -1,10 +1,11 @@
use reth_db::{
use reth_db::BlockNumberList;
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
models::ShardedKey,
table::Table,
transaction::DbTxMut,
BlockNumberList, DatabaseError,
DatabaseError,
};
use reth_primitives::BlockNumber;
use reth_provider::DatabaseProviderRW;

View File

@ -14,7 +14,7 @@ pub use account_history::AccountHistory;
pub use headers::Headers;
pub use receipts::Receipts;
pub use receipts_by_logs::ReceiptsByLogs;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{
BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress,
PruneSegment, TxNumber,

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, PruneOutputCheckpoint, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneCheckpoint, PruneMode, PruneProgress, PruneSegment};
use reth_provider::{
errors::provider::ProviderResult, DatabaseProviderRW, PruneCheckpointWriter,

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{
PruneCheckpoint, PruneMode, PruneProgress, PrunePurpose, PruneSegment, ReceiptsLogPruneConfig,
MINIMUM_PRUNING_DISTANCE,
@ -216,7 +217,8 @@ impl<DB: Database> Segment<DB> for ReceiptsByLogs {
mod tests {
use crate::segments::{receipts_by_logs::ReceiptsByLogs, PruneInput, Segment};
use assert_matches::assert_matches;
use reth_db::{cursor::DbCursorRO, tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
use reth_primitives::{PruneLimiter, PruneMode, PruneSegment, ReceiptsLogPruneConfig, B256};
use reth_provider::{PruneCheckpointReader, TransactionsProvider};
use reth_stages::test_utils::{StorageKind, TestStageDB};

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, PruneOutputCheckpoint, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneMode, PruneProgress, PruneSegment};
use reth_provider::{DatabaseProviderRW, TransactionsProvider};
use tracing::{instrument, trace};

View File

@ -2,7 +2,7 @@ use crate::segments::{
AccountHistory, Receipts, ReceiptsByLogs, Segment, SenderRecovery, StorageHistory,
TransactionLookup,
};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::PruneModes;
/// Collection of [Segment]. Thread-safe, allocated on the heap.

View File

@ -4,10 +4,10 @@ use crate::{
},
PrunerError,
};
use reth_db::{
use reth_db::tables;
use reth_db_api::{
database::Database,
models::{storage_sharded_key::StorageShardedKey, BlockNumberAddress},
tables,
};
use reth_primitives::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment};
use reth_provider::DatabaseProviderRW;

View File

@ -3,7 +3,8 @@ use crate::{
PrunerError,
};
use rayon::prelude::*;
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneMode, PruneProgress, PruneSegment};
use reth_provider::{DatabaseProviderRW, TransactionsProvider};
use tracing::{instrument, trace};

View File

@ -2,7 +2,8 @@ use crate::{
segments::{PruneInput, PruneOutput, PruneOutputCheckpoint, Segment},
PrunerError,
};
use reth_db::{database::Database, tables};
use reth_db::tables;
use reth_db_api::database::Database;
use reth_primitives::{PruneMode, PruneProgress, PruneSegment};
use reth_provider::{DatabaseProviderRW, TransactionsProvider};
use tracing::{instrument, trace};

View File

@ -14,7 +14,7 @@ workspace = true
# reth
reth-primitives.workspace = true
reth-provider.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-static-file.workspace = true
reth-network-p2p.workspace = true
reth-tokio-util.workspace = true

View File

@ -1,5 +1,5 @@
use crate::{pipeline::BoxedStage, MetricEventsSender, Pipeline, Stage, StageSet};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{stage::StageId, BlockNumber, B256};
use reth_provider::ProviderFactory;
use reth_static_file::StaticFileProducer;

View File

@ -3,7 +3,7 @@ mod event;
pub use crate::pipeline::ctrl::ControlFlow;
pub use event::*;
use futures_util::Future;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{
constants::BEACON_CONSENSUS_REORG_UNWIND_DEPTH,
stage::{PipelineTarget, StageCheckpoint, StageId},

View File

@ -1,5 +1,5 @@
use crate::Stage;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::stage::StageId;
use std::{
collections::HashMap,

View File

@ -1,5 +1,5 @@
use crate::error::StageError;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{
stage::{StageCheckpoint, StageId},
BlockNumber, TxNumber,

View File

@ -1,7 +1,7 @@
#![allow(missing_docs)]
use crate::{ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::stage::StageId;
use reth_provider::DatabaseProviderRW;
use std::collections::VecDeque;

View File

@ -17,6 +17,7 @@ reth-codecs.workspace = true
reth-config.workspace = true
reth-consensus.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-etl.workspace = true
reth-evm.workspace = true
reth-exex.workspace = true

View File

@ -1,8 +1,9 @@
#![allow(unreachable_pub)]
use super::constants;
use reth_db::{
cursor::DbCursorRO, database::Database, tables, transaction::DbTx, DatabaseError as DbError,
use reth_db::tables;
use reth_db_api::{
cursor::DbCursorRO, database::Database, transaction::DbTx, DatabaseError as DbError,
};
use reth_primitives::{stage::StageCheckpoint, BlockNumber};
use reth_stages::{

View File

@ -1,11 +1,9 @@
#![allow(unreachable_pub)]
use itertools::concat;
use reth_db::{
use reth_db::{tables, test_utils::TempDatabase, DatabaseEnv};
use reth_db_api::{
cursor::DbCursorRO,
tables,
test_utils::TempDatabase,
transaction::{DbTx, DbTxMut},
DatabaseEnv,
};
use reth_primitives::{Account, Address, SealedBlock, B256, U256};
use reth_stages::{

View File

@ -42,7 +42,7 @@ use crate::{
};
use reth_config::config::StageConfig;
use reth_consensus::Consensus;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_evm::execute::BlockExecutorProvider;
use reth_network_p2p::{bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader};
use reth_primitives::PruneModes;

View File

@ -6,11 +6,11 @@ use std::{
use futures_util::TryStreamExt;
use tracing::*;
use reth_db::{
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
models::{StoredBlockBodyIndices, StoredBlockOmmers, StoredBlockWithdrawals},
tables,
transaction::DbTxMut,
};
use reth_network_p2p::bodies::{downloader::BodyDownloader, response::BlockResponse};
@ -614,24 +614,19 @@ mod tests {
}
mod test_utils {
use std::{
collections::{HashMap, VecDeque},
ops::RangeInclusive,
pin::Pin,
sync::Arc,
task::{Context, Poll},
use crate::{
stages::bodies::BodyStage,
test_utils::{
ExecuteStageTestRunner, StageTestRunner, TestRunnerError, TestStageDB,
UnwindStageTestRunner,
},
};
use futures_util::Stream;
use reth_db::{
use reth_db::{static_file::HeaderMask, tables, test_utils::TempDatabase, DatabaseEnv};
use reth_db_api::{
cursor::DbCursorRO,
models::{StoredBlockBodyIndices, StoredBlockOmmers},
static_file::HeaderMask,
tables,
test_utils::TempDatabase,
transaction::{DbTx, DbTxMut},
DatabaseEnv,
};
use reth_network_p2p::{
bodies::{
@ -653,13 +648,12 @@ mod tests {
generators,
generators::{random_block_range, random_signed_tx},
};
use crate::{
stages::bodies::BodyStage,
test_utils::{
ExecuteStageTestRunner, StageTestRunner, TestRunnerError, TestStageDB,
UnwindStageTestRunner,
},
use std::{
collections::{HashMap, VecDeque},
ops::RangeInclusive,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
/// The block hash of the genesis block.

View File

@ -1,9 +1,8 @@
use crate::stages::MERKLE_STAGE_DEFAULT_CLEAN_THRESHOLD;
use num_traits::Zero;
use reth_config::config::ExecutionConfig;
use reth_db::{
cursor::DbCursorRO, database::Database, static_file::HeaderMask, tables, transaction::DbTx,
};
use reth_db::{static_file::HeaderMask, tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, transaction::DbTx};
use reth_evm::execute::{BatchBlockExecutionOutput, BatchExecutor, BlockExecutorProvider};
use reth_exex::{ExExManagerHandle, ExExNotification};
use reth_primitives::{
@ -654,7 +653,7 @@ mod tests {
use crate::test_utils::TestStageDB;
use alloy_rlp::Decodable;
use assert_matches::assert_matches;
use reth_db::{models::AccountBeforeTx, transaction::DbTxMut};
use reth_db_api::{models::AccountBeforeTx, transaction::DbTxMut};
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_execution_errors::BlockValidationError;
use reth_primitives::{

View File

@ -1,4 +1,4 @@
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::stage::{StageCheckpoint, StageId};
use reth_provider::DatabaseProviderRW;
use reth_stages_api::{ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput};

View File

@ -1,11 +1,10 @@
use itertools::Itertools;
use reth_config::config::{EtlConfig, HashingConfig};
use reth_db::{
use reth_db::{tables, RawKey, RawTable, RawValue};
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
tables,
transaction::{DbTx, DbTxMut},
RawKey, RawTable, RawValue,
};
use reth_etl::Collector;
use reth_primitives::{
@ -64,7 +63,7 @@ impl AccountHashingStage {
provider: &DatabaseProviderRW<DB>,
opts: SeedOpts,
) -> Result<Vec<(reth_primitives::Address, reth_primitives::Account)>, StageError> {
use reth_db::models::AccountBeforeTx;
use reth_db_api::models::AccountBeforeTx;
use reth_primitives::U256;
use reth_provider::providers::StaticFileWriter;
use reth_testing_utils::{

View File

@ -1,12 +1,11 @@
use itertools::Itertools;
use reth_config::config::{EtlConfig, HashingConfig};
use reth_db::{
codecs::CompactU256,
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRW},
database::Database,
models::BlockNumberAddress,
models::{BlockNumberAddress, CompactU256},
table::Decompress,
tables,
transaction::{DbTx, DbTxMut},
};
use reth_etl::Collector;
@ -219,7 +218,7 @@ mod tests {
};
use assert_matches::assert_matches;
use rand::Rng;
use reth_db::{
use reth_db_api::{
cursor::{DbCursorRW, DbDupCursorRO},
models::StoredBlockBodyIndices,
};

View File

@ -2,12 +2,11 @@ use futures_util::StreamExt;
use reth_codecs::Compact;
use reth_config::config::EtlConfig;
use reth_consensus::Consensus;
use reth_db::{
use reth_db::{tables, RawKey, RawTable, RawValue};
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
tables,
transaction::DbTxMut,
RawKey, RawTable, RawValue,
};
use reth_etl::Collector;
use reth_network_p2p::headers::{downloader::HeaderDownloader, error::HeadersDownloaderError};

View File

@ -1,8 +1,7 @@
use super::{collect_history_indices, load_history_indices};
use reth_config::config::{EtlConfig, IndexHistoryConfig};
use reth_db::{
database::Database, models::ShardedKey, table::Decode, tables, transaction::DbTxMut,
};
use reth_db::tables;
use reth_db_api::{database::Database, models::ShardedKey, table::Decode, transaction::DbTxMut};
use reth_primitives::{
stage::{StageCheckpoint, StageId},
Address, PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment,
@ -148,14 +147,14 @@ mod tests {
TestStageDB, UnwindStageTestRunner,
};
use itertools::Itertools;
use reth_db::{
use reth_db::BlockNumberList;
use reth_db_api::{
cursor::DbCursorRO,
models::{
sharded_key, sharded_key::NUM_OF_INDICES_IN_SHARD, AccountBeforeTx,
StoredBlockBodyIndices,
},
transaction::DbTx,
BlockNumberList,
};
use reth_primitives::{address, BlockNumber, B256};
use reth_provider::providers::StaticFileWriter;

View File

@ -1,10 +1,10 @@
use super::{collect_history_indices, load_history_indices};
use reth_config::config::{EtlConfig, IndexHistoryConfig};
use reth_db::{
use reth_db::tables;
use reth_db_api::{
database::Database,
models::{storage_sharded_key::StorageShardedKey, AddressStorageKey, BlockNumberAddress},
table::Decode,
tables,
transaction::DbTxMut,
};
use reth_primitives::{
@ -155,14 +155,14 @@ mod tests {
TestStageDB, UnwindStageTestRunner,
};
use itertools::Itertools;
use reth_db::{
use reth_db::BlockNumberList;
use reth_db_api::{
cursor::DbCursorRO,
models::{
sharded_key, storage_sharded_key::NUM_OF_INDICES_IN_SHARD, ShardedKey,
StoredBlockBodyIndices,
},
transaction::DbTx,
BlockNumberList,
};
use reth_primitives::{address, b256, Address, BlockNumber, StorageEntry, B256, U256};
use reth_provider::providers::StaticFileWriter;

View File

@ -1,8 +1,8 @@
use reth_codecs::Compact;
use reth_consensus::ConsensusError;
use reth_db::{
use reth_db::tables;
use reth_db_api::{
database::Database,
tables,
transaction::{DbTx, DbTxMut},
};
use reth_primitives::{
@ -367,7 +367,7 @@ mod tests {
TestRunnerError, TestStageDB, UnwindStageTestRunner,
};
use assert_matches::assert_matches;
use reth_db::cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO};
use reth_db_api::cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO};
use reth_primitives::{
keccak256, stage::StageUnitCheckpoint, SealedBlock, StaticFileSegment, StorageEntry, U256,
};

View File

@ -43,14 +43,16 @@ mod tests {
use crate::test_utils::{StorageKind, TestStageDB};
use alloy_rlp::Decodable;
use reth_db::{
cursor::{DbCursorRO, DbCursorRW},
mdbx::{cursor::Cursor, RW},
table::Table,
tables,
test_utils::TempDatabase,
transaction::{DbTx, DbTxMut},
AccountsHistory, DatabaseEnv,
};
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
table::Table,
transaction::{DbTx, DbTxMut},
};
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_exex::ExExManagerHandle;
use reth_primitives::{

View File

@ -1,12 +1,10 @@
use reth_config::config::SenderRecoveryConfig;
use reth_consensus::ConsensusError;
use reth_db::{
use reth_db::{static_file::TransactionMask, tables, RawValue};
use reth_db_api::{
cursor::DbCursorRW,
database::Database,
static_file::TransactionMask,
tables,
transaction::{DbTx, DbTxMut},
RawValue,
};
use reth_primitives::{
stage::{EntitiesCheckpoint, StageCheckpoint, StageId},
@ -284,7 +282,7 @@ struct FailedSenderRecoveryError {
#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use reth_db::cursor::DbCursorRO;
use reth_db_api::cursor::DbCursorRO;
use reth_primitives::{
stage::StageUnitCheckpoint, BlockNumber, PruneCheckpoint, PruneMode, SealedBlock,
TransactionSigned, B256,

View File

@ -1,11 +1,10 @@
use num_traits::Zero;
use reth_config::config::{EtlConfig, TransactionLookupConfig};
use reth_db::{
use reth_db::{tables, RawKey, RawValue};
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
tables,
transaction::{DbTx, DbTxMut},
RawKey, RawValue,
};
use reth_etl::Collector;
use reth_primitives::{

View File

@ -1,11 +1,12 @@
//! Utils for `stages`.
use reth_config::config::EtlConfig;
use reth_db::{
use reth_db::BlockNumberList;
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
models::sharded_key::NUM_OF_INDICES_IN_SHARD,
table::{Decompress, Table},
transaction::{DbTx, DbTxMut},
BlockNumberList, DatabaseError,
DatabaseError,
};
use reth_etl::Collector;
use reth_primitives::BlockNumber;

View File

@ -1,6 +1,6 @@
use super::TEST_STAGE_ID;
use crate::{StageSet, StageSetBuilder};
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_stages_api::{test_utils::TestStage, ExecOutput, StageError, UnwindOutput};
use std::collections::VecDeque;

View File

@ -1,15 +1,18 @@
use reth_db::{
tables,
test_utils::{
create_test_rw_db, create_test_rw_db_with_path, create_test_static_files_dir, TempDatabase,
},
DatabaseEnv,
};
use reth_db_api::{
common::KeyValue,
cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO},
database::Database,
models::{AccountBeforeTx, StoredBlockBodyIndices},
table::Table,
tables,
test_utils::{
create_test_rw_db, create_test_rw_db_with_path, create_test_static_files_dir, TempDatabase,
},
transaction::{DbTx, DbTxMut},
DatabaseEnv, DatabaseError as DbError,
DatabaseError as DbError,
};
use reth_primitives::{
keccak256, Account, Address, BlockNumber, Receipt, SealedBlock, SealedHeader,

View File

@ -15,6 +15,7 @@ workspace = true
# reth
reth-primitives.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-provider.workspace = true
reth-storage-errors.workspace = true
reth-nippy-jar.workspace = true

View File

@ -1,8 +1,6 @@
use crate::segments::{dataset_for_compression, prepare_jar, Segment, SegmentHeader};
use reth_db::{
cursor::DbCursorRO, database::Database, static_file::create_static_file_T1_T2_T3, tables,
transaction::DbTx, RawKey, RawTable,
};
use reth_db::{static_file::create_static_file_T1_T2_T3, tables, RawKey, RawTable};
use reth_db_api::{cursor::DbCursorRO, database::Database, transaction::DbTx};
use reth_primitives::{static_file::SegmentConfig, BlockNumber, StaticFileSegment};
use reth_provider::{
providers::{StaticFileProvider, StaticFileWriter},

View File

@ -9,9 +9,8 @@ pub use headers::Headers;
mod receipts;
pub use receipts::Receipts;
use reth_db::{
cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx, RawKey, RawTable,
};
use reth_db::{RawKey, RawTable};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use reth_nippy_jar::NippyJar;
use reth_primitives::{
static_file::{

View File

@ -1,8 +1,6 @@
use crate::segments::{dataset_for_compression, prepare_jar, Segment};
use reth_db::{
cursor::DbCursorRO, database::Database, static_file::create_static_file_T1, tables,
transaction::DbTx,
};
use reth_db::{static_file::create_static_file_T1, tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, transaction::DbTx};
use reth_primitives::{
static_file::{SegmentConfig, SegmentHeader},
BlockNumber, StaticFileSegment, TxNumber,

View File

@ -1,8 +1,6 @@
use crate::segments::{dataset_for_compression, prepare_jar, Segment};
use reth_db::{
cursor::DbCursorRO, database::Database, static_file::create_static_file_T1, tables,
transaction::DbTx,
};
use reth_db::{static_file::create_static_file_T1, tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, transaction::DbTx};
use reth_primitives::{
static_file::{SegmentConfig, SegmentHeader},
BlockNumber, StaticFileSegment, TxNumber,

View File

@ -3,7 +3,7 @@
use crate::{segments, segments::Segment, StaticFileProducerEvent};
use parking_lot::Mutex;
use rayon::prelude::*;
use reth_db::database::Database;
use reth_db_api::database::Database;
use reth_primitives::{static_file::HighestStaticFiles, BlockNumber, PruneModes};
use reth_provider::{providers::StaticFileWriter, ProviderFactory, StaticFileProviderFactory};
use reth_storage_errors::provider::ProviderResult;
@ -228,7 +228,8 @@ mod tests {
StaticFileProducer, StaticFileProducerInner, StaticFileTargets,
};
use assert_matches::assert_matches;
use reth_db::{database::Database, test_utils::TempDatabase, transaction::DbTx, DatabaseEnv};
use reth_db::{test_utils::TempDatabase, DatabaseEnv};
use reth_db_api::{database::Database, transaction::DbTx};
use reth_primitives::{
static_file::HighestStaticFiles, PruneModes, StaticFileSegment, B256, U256,
};

View File

@ -0,0 +1,71 @@
[package]
name = "reth-db-api"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "Database abstraction used in reth."
[lints]
workspace = true
[dependencies]
# reth
reth-codecs.workspace = true
reth-primitives.workspace = true
reth-storage-errors.workspace = true
# codecs
modular-bitfield.workspace = true
parity-scale-codec = { version = "3.2.1", features = ["bytes"] }
serde = { workspace = true, default-features = false }
# metrics
metrics.workspace = true
# misc
derive_more.workspace = true
bytes.workspace = true
# arbitrary utils
arbitrary = { workspace = true, features = ["derive"], optional = true }
proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }
[dev-dependencies]
# reth libs with arbitrary
reth-primitives = { workspace = true, features = ["arbitrary"] }
reth-codecs.workspace = true
rand.workspace = true
serde_json.workspace = true
test-fuzz.workspace = true
pprof = { workspace = true, features = [
"flamegraph",
"frame-pointer",
"criterion",
] }
criterion.workspace = true
iai-callgrind = "0.10.2"
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
paste.workspace = true
assert_matches.workspace = true
[features]
test-utils = ["arbitrary"]
arbitrary = [
"reth-primitives/arbitrary",
"dep:arbitrary",
"dep:proptest",
"dep:proptest-derive",
]
optimism = []

View File

@ -1,4 +1,4 @@
use crate::{abstraction::table::*, DatabaseError};
use crate::{table::*, DatabaseError};
/// A key-value pair for table `T`.
pub type KeyValue<T> = (<T as Table>::Key, <T as Table>::Value);
@ -17,23 +17,3 @@ pub type IterPairResult<T> = Option<Result<KeyValue<T>, DatabaseError>>;
/// A value only result for table `T`.
pub type ValueOnlyResult<T> = Result<Option<<T as Table>::Value>, DatabaseError>;
// Sealed trait helper to prevent misuse of the Database API.
mod sealed {
use crate::{database::Database, mock::DatabaseMock};
use std::sync::Arc;
/// Sealed trait to limit the implementers of the Database trait.
pub trait Sealed: Sized {}
impl<DB: Database> Sealed for &DB {}
impl<DB: Database> Sealed for Arc<DB> {}
#[cfg(feature = "mdbx")]
impl Sealed for crate::DatabaseEnv {}
impl Sealed for DatabaseMock {}
#[cfg(any(test, feature = "test-utils"))]
impl<DB: Database> Sealed for crate::test_utils::TempDatabase<DB> {}
}
pub(crate) use sealed::Sealed;

Some files were not shown because too many files have changed in this diff Show More