diff --git a/Cargo.lock b/Cargo.lock index cc494cfab..0f0aabc3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7006,7 +7006,6 @@ dependencies = [ "alloy-primitives", "arbitrary", "assert_matches", - "bytes", "codspeed-criterion-compat", "derive_more", "eyre", @@ -7022,18 +7021,14 @@ dependencies = [ "reth-nippy-jar", "reth-primitives", "reth-primitives-traits", - "reth-prune-types", - "reth-stages-types", "reth-storage-errors", "reth-tracing", - "reth-trie-common", "rustc-hash 2.1.1", "serde", "serde_json", "strum", "sysinfo", "tempfile", - "test-fuzz", "thiserror 2.0.11", ] @@ -9543,7 +9538,6 @@ dependencies = [ "alloy-rpc-types-engine", "auto_impl", "reth-chainspec", - "reth-db", "reth-db-api", "reth-ethereum-primitives", "reth-execution-types", @@ -9778,11 +9772,11 @@ dependencies = [ "proptest-arbitrary-interop", "rand 0.8.5", "rayon", - "reth-db", "reth-execution-errors", "reth-metrics", "reth-primitives", "reth-provider", + "reth-storage-errors", "reth-trie", "reth-trie-common", "reth-trie-db", diff --git a/bin/reth/src/commands/debug_cmd/merkle.rs b/bin/reth/src/commands/debug_cmd/merkle.rs index 133b1d78a..ad75f3df6 100644 --- a/bin/reth/src/commands/debug_cmd/merkle.rs +++ b/bin/reth/src/commands/debug_cmd/merkle.rs @@ -11,8 +11,7 @@ use reth_cli_runner::CliContext; use reth_cli_util::get_secret_key; use reth_config::Config; use reth_consensus::{Consensus, ConsensusError}; -use reth_db::tables; -use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; +use reth_db_api::{cursor::DbCursorRO, tables, transaction::DbTx}; use reth_ethereum_primitives::EthPrimitives; use reth_evm::execute::{BlockExecutorProvider, Executor}; use reth_network::{BlockDownloaderProvider, NetworkHandle}; diff --git a/crates/cli/commands/src/db/checksum.rs b/crates/cli/commands/src/db/checksum.rs index 76d92962f..40f0d22f6 100644 --- a/crates/cli/commands/src/db/checksum.rs +++ b/crates/cli/commands/src/db/checksum.rs @@ -5,8 +5,11 @@ use crate::{ use ahash::RandomState; use clap::Parser; use reth_chainspec::EthereumHardforks; -use reth_db::{DatabaseEnv, RawKey, RawTable, RawValue, TableViewer, Tables}; -use reth_db_api::{cursor::DbCursorRO, table::Table, transaction::DbTx}; +use reth_db::DatabaseEnv; +use reth_db_api::{ + cursor::DbCursorRO, table::Table, transaction::DbTx, RawKey, RawTable, RawValue, TableViewer, + Tables, +}; use reth_db_common::DbTool; use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter}; use reth_provider::{providers::ProviderNodeTypes, DBProvider}; diff --git a/crates/cli/commands/src/db/clear.rs b/crates/cli/commands/src/db/clear.rs index fe7845361..713683aad 100644 --- a/crates/cli/commands/src/db/clear.rs +++ b/crates/cli/commands/src/db/clear.rs @@ -1,9 +1,10 @@ use clap::{Parser, Subcommand}; -use reth_db::{static_file::iter_static_files, TableViewer, Tables}; +use reth_db::static_file::iter_static_files; use reth_db_api::{ database::Database, table::Table, transaction::{DbTx, DbTxMut}, + TableViewer, Tables, }; use reth_node_builder::NodeTypesWithDB; use reth_provider::{ProviderFactory, StaticFileProviderFactory}; diff --git a/crates/cli/commands/src/db/diff.rs b/crates/cli/commands/src/db/diff.rs index c1346b374..407281bf1 100644 --- a/crates/cli/commands/src/db/diff.rs +++ b/crates/cli/commands/src/db/diff.rs @@ -1,6 +1,8 @@ use clap::Parser; -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 reth_db::{open_db_read_only, tables_to_generic, DatabaseEnv}; +use reth_db_api::{ + cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx, Tables, +}; use reth_db_common::DbTool; use reth_node_builder::{NodeTypesWithDBAdapter, NodeTypesWithEngine}; use reth_node_core::{ diff --git a/crates/cli/commands/src/db/get.rs b/crates/cli/commands/src/db/get.rs index 5fb234f0b..a7f2f9c14 100644 --- a/crates/cli/commands/src/db/get.rs +++ b/crates/cli/commands/src/db/get.rs @@ -1,13 +1,13 @@ use alloy_consensus::Header; use alloy_primitives::{hex, BlockHash}; use clap::Parser; -use reth_db::{ - static_file::{ - ColumnSelectorOne, ColumnSelectorTwo, HeaderWithHashMask, ReceiptMask, TransactionMask, - }, +use reth_db::static_file::{ + ColumnSelectorOne, ColumnSelectorTwo, HeaderWithHashMask, ReceiptMask, TransactionMask, +}; +use reth_db_api::{ + table::{Decompress, DupSort, Table}, tables, RawKey, RawTable, Receipts, TableViewer, Transactions, }; -use reth_db_api::table::{Decompress, DupSort, Table}; use reth_db_common::DbTool; use reth_node_api::{ReceiptTy, TxTy}; use reth_node_builder::NodeTypesWithDB; @@ -207,8 +207,10 @@ mod tests { use super::*; use alloy_primitives::{Address, B256}; use clap::{Args, Parser}; - use reth_db::{AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory}; - use reth_db_api::models::{storage_sharded_key::StorageShardedKey, ShardedKey}; + use reth_db_api::{ + models::{storage_sharded_key::StorageShardedKey, ShardedKey}, + AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory, + }; use std::str::FromStr; /// A helper type to parse Args more easily diff --git a/crates/cli/commands/src/db/list.rs b/crates/cli/commands/src/db/list.rs index 63eca1d86..69316cca3 100644 --- a/crates/cli/commands/src/db/list.rs +++ b/crates/cli/commands/src/db/list.rs @@ -3,8 +3,8 @@ use alloy_primitives::hex; use clap::Parser; use eyre::WrapErr; use reth_chainspec::EthereumHardforks; -use reth_db::{DatabaseEnv, RawValue, TableViewer, Tables}; -use reth_db_api::{database::Database, table::Table}; +use reth_db::DatabaseEnv; +use reth_db_api::{database::Database, table::Table, RawValue, TableViewer, Tables}; use reth_db_common::{DbTool, ListFilter}; use reth_node_builder::{NodeTypesWithDBAdapter, NodeTypesWithEngine}; use std::{cell::RefCell, sync::Arc}; diff --git a/crates/cli/commands/src/db/stats.rs b/crates/cli/commands/src/db/stats.rs index 3cce7229c..6dd688d25 100644 --- a/crates/cli/commands/src/db/stats.rs +++ b/crates/cli/commands/src/db/stats.rs @@ -5,8 +5,8 @@ use eyre::WrapErr; use human_bytes::human_bytes; use itertools::Itertools; use reth_chainspec::EthereumHardforks; -use reth_db::{mdbx, static_file::iter_static_files, DatabaseEnv, TableViewer, Tables}; -use reth_db_api::database::Database; +use reth_db::{mdbx, static_file::iter_static_files, DatabaseEnv}; +use reth_db_api::{database::Database, TableViewer, Tables}; use reth_db_common::DbTool; use reth_fs_util as fs; use reth_node_builder::{NodePrimitives, NodeTypesWithDB, NodeTypesWithDBAdapter}; diff --git a/crates/cli/commands/src/db/tui.rs b/crates/cli/commands/src/db/tui.rs index 1a9fae7f8..d540d3387 100644 --- a/crates/cli/commands/src/db/tui.rs +++ b/crates/cli/commands/src/db/tui.rs @@ -10,8 +10,10 @@ use ratatui::{ widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap}, Frame, Terminal, }; -use reth_db::RawValue; -use reth_db_api::table::{Table, TableRow}; +use reth_db_api::{ + table::{Table, TableRow}, + RawValue, +}; use std::{ io, time::{Duration, Instant}, diff --git a/crates/cli/commands/src/import.rs b/crates/cli/commands/src/import.rs index 1353bb69d..592ab11c9 100644 --- a/crates/cli/commands/src/import.rs +++ b/crates/cli/commands/src/import.rs @@ -7,8 +7,7 @@ use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_cli::chainspec::ChainSpecParser; use reth_config::Config; use reth_consensus::{ConsensusError, FullConsensus}; -use reth_db::tables; -use reth_db_api::transaction::DbTx; +use reth_db_api::{tables, transaction::DbTx}; use reth_downloaders::{ bodies::bodies::BodiesDownloaderBuilder, file_client::{ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE}, diff --git a/crates/cli/commands/src/recover/storage_tries.rs b/crates/cli/commands/src/recover/storage_tries.rs index 4ae32ff8f..0ff87d8e5 100644 --- a/crates/cli/commands/src/recover/storage_tries.rs +++ b/crates/cli/commands/src/recover/storage_tries.rs @@ -4,9 +4,9 @@ use clap::Parser; use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_cli::chainspec::ChainSpecParser; use reth_cli_runner::CliContext; -use reth_db::tables; use reth_db_api::{ cursor::{DbCursorRO, DbDupCursorRW}, + tables, transaction::DbTx, }; use reth_provider::{BlockNumReader, HeaderProvider, ProviderError}; diff --git a/crates/cli/commands/src/stage/drop.rs b/crates/cli/commands/src/stage/drop.rs index a786efa26..7aff50db6 100644 --- a/crates/cli/commands/src/stage/drop.rs +++ b/crates/cli/commands/src/stage/drop.rs @@ -4,8 +4,11 @@ use clap::Parser; use itertools::Itertools; use reth_chainspec::EthChainSpec; use reth_cli::chainspec::ChainSpecParser; -use reth_db::{mdbx::tx::Tx, static_file::iter_static_files, tables, DatabaseError}; -use reth_db_api::transaction::{DbTx, DbTxMut}; +use reth_db::{mdbx::tx::Tx, static_file::iter_static_files, DatabaseError}; +use reth_db_api::{ + tables, + transaction::{DbTx, DbTxMut}, +}; use reth_db_common::{ init::{insert_genesis_header, insert_genesis_history, insert_genesis_state}, DbTool, diff --git a/crates/cli/commands/src/stage/dump/execution.rs b/crates/cli/commands/src/stage/dump/execution.rs index 313ca88f5..d2dd2e808 100644 --- a/crates/cli/commands/src/stage/dump/execution.rs +++ b/crates/cli/commands/src/stage/dump/execution.rs @@ -1,10 +1,8 @@ -use std::sync::Arc; - use super::setup; use reth_consensus::{noop::NoopConsensus, ConsensusError, FullConsensus}; -use reth_db::{tables, DatabaseEnv}; +use reth_db::DatabaseEnv; use reth_db_api::{ - cursor::DbCursorRO, database::Database, table::TableImporter, transaction::DbTx, + cursor::DbCursorRO, database::Database, table::TableImporter, tables, transaction::DbTx, }; use reth_db_common::DbTool; use reth_evm::{execute::BlockExecutorProvider, noop::NoopBlockExecutorProvider}; @@ -15,6 +13,7 @@ use reth_provider::{ DatabaseProviderFactory, ProviderFactory, }; use reth_stages::{stages::ExecutionStage, Stage, StageCheckpoint, UnwindInput}; +use std::sync::Arc; use tracing::info; pub(crate) async fn dump_execution_stage( diff --git a/crates/cli/commands/src/stage/dump/hashing_account.rs b/crates/cli/commands/src/stage/dump/hashing_account.rs index 97452cee8..8b9ba5e93 100644 --- a/crates/cli/commands/src/stage/dump/hashing_account.rs +++ b/crates/cli/commands/src/stage/dump/hashing_account.rs @@ -1,10 +1,8 @@ -use std::sync::Arc; - use super::setup; use alloy_primitives::BlockNumber; use eyre::Result; -use reth_db::{tables, DatabaseEnv}; -use reth_db_api::{database::Database, table::TableImporter}; +use reth_db::DatabaseEnv; +use reth_db_api::{database::Database, table::TableImporter, tables}; use reth_db_common::DbTool; use reth_node_core::dirs::{ChainPath, DataDirPath}; use reth_provider::{ @@ -12,6 +10,7 @@ use reth_provider::{ DatabaseProviderFactory, ProviderFactory, }; use reth_stages::{stages::AccountHashingStage, Stage, StageCheckpoint, UnwindInput}; +use std::sync::Arc; use tracing::info; pub(crate) async fn dump_hashing_account_stage>>( diff --git a/crates/cli/commands/src/stage/dump/hashing_storage.rs b/crates/cli/commands/src/stage/dump/hashing_storage.rs index 06b064bc0..265048354 100644 --- a/crates/cli/commands/src/stage/dump/hashing_storage.rs +++ b/crates/cli/commands/src/stage/dump/hashing_storage.rs @@ -1,9 +1,7 @@ -use std::sync::Arc; - use super::setup; use eyre::Result; -use reth_db::{tables, DatabaseEnv}; -use reth_db_api::{database::Database, table::TableImporter}; +use reth_db::DatabaseEnv; +use reth_db_api::{database::Database, table::TableImporter, tables}; use reth_db_common::DbTool; use reth_node_core::dirs::{ChainPath, DataDirPath}; use reth_provider::{ @@ -11,6 +9,7 @@ use reth_provider::{ DatabaseProviderFactory, ProviderFactory, }; use reth_stages::{stages::StorageHashingStage, Stage, StageCheckpoint, UnwindInput}; +use std::sync::Arc; use tracing::info; pub(crate) async fn dump_hashing_storage_stage>>( diff --git a/crates/cli/commands/src/stage/dump/merkle.rs b/crates/cli/commands/src/stage/dump/merkle.rs index e1eb24180..744a4e81f 100644 --- a/crates/cli/commands/src/stage/dump/merkle.rs +++ b/crates/cli/commands/src/stage/dump/merkle.rs @@ -5,8 +5,8 @@ use alloy_primitives::BlockNumber; use eyre::Result; use reth_config::config::EtlConfig; use reth_consensus::noop::NoopConsensus; -use reth_db::{tables, DatabaseEnv}; -use reth_db_api::{database::Database, table::TableImporter}; +use reth_db::DatabaseEnv; +use reth_db_api::{database::Database, table::TableImporter, tables}; use reth_db_common::DbTool; use reth_evm::noop::NoopBlockExecutorProvider; use reth_exex::ExExManagerHandle; diff --git a/crates/cli/commands/src/stage/dump/mod.rs b/crates/cli/commands/src/stage/dump/mod.rs index 6593181c4..ae74b189e 100644 --- a/crates/cli/commands/src/stage/dump/mod.rs +++ b/crates/cli/commands/src/stage/dump/mod.rs @@ -3,9 +3,9 @@ use crate::common::{AccessRights, CliNodeComponents, CliNodeTypes, Environment, use clap::Parser; use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_cli::chainspec::ChainSpecParser; -use reth_db::{init_db, mdbx::DatabaseArguments, tables, DatabaseEnv}; +use reth_db::{init_db, mdbx::DatabaseArguments, DatabaseEnv}; use reth_db_api::{ - cursor::DbCursorRO, database::Database, models::ClientVersion, table::TableImporter, + cursor::DbCursorRO, database::Database, models::ClientVersion, table::TableImporter, tables, transaction::DbTx, }; use reth_db_common::DbTool; diff --git a/crates/cli/commands/src/test_vectors/tables.rs b/crates/cli/commands/src/test_vectors/tables.rs index c51d5063e..c26bb6ccd 100644 --- a/crates/cli/commands/src/test_vectors/tables.rs +++ b/crates/cli/commands/src/test_vectors/tables.rs @@ -8,8 +8,10 @@ use proptest::{ test_runner::{TestRng, TestRunner}, }; use proptest_arbitrary_interop::arb; -use reth_db::tables; -use reth_db_api::table::{DupSort, Table, TableRow}; +use reth_db_api::{ + table::{DupSort, Table, TableRow}, + tables, +}; use reth_fs_util as fs; use reth_primitives::TransactionSigned; use std::collections::HashSet; diff --git a/crates/engine/tree/src/tree/trie_updates.rs b/crates/engine/tree/src/tree/trie_updates.rs index 6ada60ea0..959e37398 100644 --- a/crates/engine/tree/src/tree/trie_updates.rs +++ b/crates/engine/tree/src/tree/trie_updates.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeSet; - use alloy_primitives::{map::HashMap, B256}; use reth_db::DatabaseError; use reth_trie::{ @@ -7,6 +5,7 @@ use reth_trie::{ updates::{StorageTrieUpdates, TrieUpdates}, BranchNodeCompact, Nibbles, }; +use std::collections::BTreeSet; use tracing::warn; #[derive(Debug)] diff --git a/crates/net/downloaders/src/bodies/test_utils.rs b/crates/net/downloaders/src/bodies/test_utils.rs index eb87f1c2b..0e5e26507 100644 --- a/crates/net/downloaders/src/bodies/test_utils.rs +++ b/crates/net/downloaders/src/bodies/test_utils.rs @@ -4,8 +4,8 @@ use alloy_consensus::BlockHeader; use alloy_primitives::B256; -use reth_db::{tables, DatabaseEnv}; -use reth_db_api::{database::Database, transaction::DbTxMut}; +use reth_db::DatabaseEnv; +use reth_db_api::{database::Database, tables, transaction::DbTxMut}; use reth_network_p2p::bodies::response::BlockResponse; use reth_primitives::{BlockBody, SealedBlock, SealedHeader}; use reth_primitives_traits::Block; diff --git a/crates/optimism/cli/src/commands/import.rs b/crates/optimism/cli/src/commands/import.rs index a2d10a10a..26347d9d1 100644 --- a/crates/optimism/cli/src/commands/import.rs +++ b/crates/optimism/cli/src/commands/import.rs @@ -7,8 +7,7 @@ use reth_cli_commands::{ import::build_import_pipeline, }; use reth_consensus::noop::NoopConsensus; -use reth_db::tables; -use reth_db_api::transaction::DbTx; +use reth_db_api::{tables, transaction::DbTx}; use reth_downloaders::file_client::{ChunkedFileReader, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE}; use reth_node_builder::BlockTy; use reth_node_core::version::SHORT_VERSION; diff --git a/crates/optimism/cli/src/commands/import_receipts.rs b/crates/optimism/cli/src/commands/import_receipts.rs index 6aaa604d0..4d7e61286 100644 --- a/crates/optimism/cli/src/commands/import_receipts.rs +++ b/crates/optimism/cli/src/commands/import_receipts.rs @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf}; use clap::Parser; use reth_cli::chainspec::ChainSpecParser; use reth_cli_commands::common::{AccessRights, CliNodeTypes, Environment, EnvironmentArgs}; -use reth_db::tables; +use reth_db_api::tables; use reth_downloaders::{ file_client::{ChunkedFileReader, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE}, receipt_file_client::ReceiptFileClient, diff --git a/crates/prune/prune/Cargo.toml b/crates/prune/prune/Cargo.toml index f772ff546..094570b87 100644 --- a/crates/prune/prune/Cargo.toml +++ b/crates/prune/prune/Cargo.toml @@ -15,7 +15,6 @@ workspace = true # reth reth-chainspec.workspace = true reth-exex-types.workspace = true -reth-db.workspace = true reth-db-api.workspace = true reth-errors.workspace = true reth-provider.workspace = true diff --git a/crates/prune/prune/src/builder.rs b/crates/prune/prune/src/builder.rs index 4fd566171..26992e78e 100644 --- a/crates/prune/prune/src/builder.rs +++ b/crates/prune/prune/src/builder.rs @@ -2,7 +2,7 @@ use crate::{segments::SegmentSet, Pruner}; use alloy_eips::eip2718::Encodable2718; use reth_chainspec::MAINNET; use reth_config::PruneConfig; -use reth_db::{table::Value, transaction::DbTxMut}; +use reth_db_api::{table::Value, transaction::DbTxMut}; use reth_exex_types::FinishedExExHeight; use reth_primitives_traits::NodePrimitives; use reth_provider::{ diff --git a/crates/prune/prune/src/db_ext.rs b/crates/prune/prune/src/db_ext.rs index 143cb5e27..63ab87c44 100644 --- a/crates/prune/prune/src/db_ext.rs +++ b/crates/prune/prune/src/db_ext.rs @@ -1,12 +1,11 @@ -use std::{fmt::Debug, ops::RangeBounds}; - use crate::PruneLimiter; -use reth_db::{ +use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW, RangeWalker}, table::{Table, TableRow}, transaction::DbTxMut, DatabaseError, }; +use std::{fmt::Debug, ops::RangeBounds}; use tracing::debug; pub(crate) trait DbTxPruneExt: DbTxMut { diff --git a/crates/prune/prune/src/error.rs b/crates/prune/prune/src/error.rs index a2cbaebc1..4cd61f657 100644 --- a/crates/prune/prune/src/error.rs +++ b/crates/prune/prune/src/error.rs @@ -1,5 +1,4 @@ -use reth_db::DatabaseError; -use reth_errors::RethError; +use reth_errors::{DatabaseError, RethError}; use reth_provider::ProviderError; use reth_prune_types::PruneSegmentError; use thiserror::Error; diff --git a/crates/prune/prune/src/segments/receipts.rs b/crates/prune/prune/src/segments/receipts.rs index 50a21031f..2c94b5e4a 100644 --- a/crates/prune/prune/src/segments/receipts.rs +++ b/crates/prune/prune/src/segments/receipts.rs @@ -6,7 +6,7 @@ //! node after static file producer has finished use crate::{db_ext::DbTxPruneExt, segments::PruneInput, PrunerError}; -use reth_db::{table::Value, tables, transaction::DbTxMut}; +use reth_db_api::{table::Value, tables, transaction::DbTxMut}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ errors::provider::ProviderResult, BlockReader, DBProvider, NodePrimitivesProvider, @@ -88,7 +88,7 @@ mod tests { FoldWhile::{Continue, Done}, Itertools, }; - use reth_db::tables; + use reth_db_api::tables; use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader}; use reth_prune_types::{ PruneCheckpoint, PruneInterruptReason, PruneMode, PruneProgress, PruneSegment, diff --git a/crates/prune/prune/src/segments/set.rs b/crates/prune/prune/src/segments/set.rs index d7bbee104..c99defe08 100644 --- a/crates/prune/prune/src/segments/set.rs +++ b/crates/prune/prune/src/segments/set.rs @@ -3,7 +3,7 @@ use crate::segments::{ UserReceipts, }; use alloy_eips::eip2718::Encodable2718; -use reth_db::{table::Value, transaction::DbTxMut}; +use reth_db_api::{table::Value, transaction::DbTxMut}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ providers::StaticFileProvider, BlockReader, DBProvider, PruneCheckpointWriter, diff --git a/crates/prune/prune/src/segments/static_file/headers.rs b/crates/prune/prune/src/segments/static_file/headers.rs index 7d100f4e2..eb597b222 100644 --- a/crates/prune/prune/src/segments/static_file/headers.rs +++ b/crates/prune/prune/src/segments/static_file/headers.rs @@ -1,5 +1,3 @@ -use std::num::NonZeroUsize; - use crate::{ db_ext::DbTxPruneExt, segments::{PruneInput, Segment}, @@ -7,7 +5,7 @@ use crate::{ }; use alloy_primitives::BlockNumber; use itertools::Itertools; -use reth_db::{ +use reth_db_api::{ cursor::{DbCursorRO, RangeWalker}, tables, transaction::DbTxMut, @@ -17,6 +15,7 @@ use reth_prune_types::{ PruneMode, PrunePurpose, PruneSegment, SegmentOutput, SegmentOutputCheckpoint, }; use reth_static_file_types::StaticFileSegment; +use std::num::NonZeroUsize; use tracing::trace; /// Number of header tables to prune in one step @@ -199,8 +198,7 @@ mod tests { }; use alloy_primitives::{BlockNumber, B256, U256}; use assert_matches::assert_matches; - use reth_db::tables; - use reth_db_api::transaction::DbTx; + use reth_db_api::{tables, transaction::DbTx}; use reth_provider::{ DatabaseProviderFactory, PruneCheckpointReader, PruneCheckpointWriter, StaticFileProviderFactory, diff --git a/crates/prune/prune/src/segments/static_file/receipts.rs b/crates/prune/prune/src/segments/static_file/receipts.rs index 6cdc53759..6a84cce9c 100644 --- a/crates/prune/prune/src/segments/static_file/receipts.rs +++ b/crates/prune/prune/src/segments/static_file/receipts.rs @@ -2,7 +2,7 @@ use crate::{ segments::{PruneInput, Segment}, PrunerError, }; -use reth_db::{table::Value, transaction::DbTxMut}; +use reth_db_api::{table::Value, transaction::DbTxMut}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ errors::provider::ProviderResult, providers::StaticFileProvider, BlockReader, DBProvider, diff --git a/crates/prune/prune/src/segments/static_file/transactions.rs b/crates/prune/prune/src/segments/static_file/transactions.rs index f3e5c3ffa..7005ae15e 100644 --- a/crates/prune/prune/src/segments/static_file/transactions.rs +++ b/crates/prune/prune/src/segments/static_file/transactions.rs @@ -3,7 +3,7 @@ use crate::{ segments::{PruneInput, Segment}, PrunerError, }; -use reth_db::{table::Value, tables, transaction::DbTxMut}; +use reth_db_api::{table::Value, tables, transaction::DbTxMut}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ providers::StaticFileProvider, BlockReader, DBProvider, StaticFileProviderFactory, @@ -98,7 +98,7 @@ mod tests { FoldWhile::{Continue, Done}, Itertools, }; - use reth_db::tables; + use reth_db_api::tables; use reth_provider::{ DatabaseProviderFactory, PruneCheckpointReader, PruneCheckpointWriter, StaticFileProviderFactory, diff --git a/crates/prune/prune/src/segments/user/account_history.rs b/crates/prune/prune/src/segments/user/account_history.rs index 92d62f3c9..25e26e806 100644 --- a/crates/prune/prune/src/segments/user/account_history.rs +++ b/crates/prune/prune/src/segments/user/account_history.rs @@ -4,8 +4,7 @@ use crate::{ PrunerError, }; use itertools::Itertools; -use reth_db::{tables, transaction::DbTxMut}; -use reth_db_api::models::ShardedKey; +use reth_db_api::{models::ShardedKey, tables, transaction::DbTxMut}; use reth_provider::DBProvider; use reth_prune_types::{ PruneMode, PrunePurpose, PruneSegment, SegmentOutput, SegmentOutputCheckpoint, @@ -133,7 +132,7 @@ mod tests { }; use alloy_primitives::{BlockNumber, B256}; use assert_matches::assert_matches; - use reth_db::{tables, BlockNumberList}; + use reth_db_api::{tables, BlockNumberList}; use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader}; use reth_prune_types::{ PruneCheckpoint, PruneInterruptReason, PruneMode, PruneProgress, PruneSegment, diff --git a/crates/prune/prune/src/segments/user/history.rs b/crates/prune/prune/src/segments/user/history.rs index 4e2218af2..9d95b2fd3 100644 --- a/crates/prune/prune/src/segments/user/history.rs +++ b/crates/prune/prune/src/segments/user/history.rs @@ -1,11 +1,10 @@ use alloy_primitives::BlockNumber; -use reth_db::{BlockNumberList, RawKey, RawTable, RawValue}; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, models::ShardedKey, table::Table, transaction::DbTxMut, - DatabaseError, + BlockNumberList, DatabaseError, RawKey, RawTable, RawValue, }; use reth_provider::DBProvider; diff --git a/crates/prune/prune/src/segments/user/receipts.rs b/crates/prune/prune/src/segments/user/receipts.rs index 97708ad6d..ecb0f3423 100644 --- a/crates/prune/prune/src/segments/user/receipts.rs +++ b/crates/prune/prune/src/segments/user/receipts.rs @@ -2,7 +2,7 @@ use crate::{ segments::{PruneInput, Segment}, PrunerError, }; -use reth_db::{table::Value, transaction::DbTxMut}; +use reth_db_api::{table::Value, transaction::DbTxMut}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ errors::provider::ProviderResult, BlockReader, DBProvider, NodePrimitivesProvider, diff --git a/crates/prune/prune/src/segments/user/receipts_by_logs.rs b/crates/prune/prune/src/segments/user/receipts_by_logs.rs index 4706b560b..b413a7039 100644 --- a/crates/prune/prune/src/segments/user/receipts_by_logs.rs +++ b/crates/prune/prune/src/segments/user/receipts_by_logs.rs @@ -4,7 +4,7 @@ use crate::{ PrunerError, }; use alloy_consensus::TxReceipt; -use reth_db::{table::Value, tables, transaction::DbTxMut}; +use reth_db_api::{table::Value, tables, transaction::DbTxMut}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ BlockReader, DBProvider, NodePrimitivesProvider, PruneCheckpointWriter, TransactionsProvider, @@ -230,8 +230,7 @@ mod tests { use crate::segments::{PruneInput, PruneLimiter, ReceiptsByLogs, Segment}; use alloy_primitives::B256; use assert_matches::assert_matches; - use reth_db::tables; - use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; + use reth_db_api::{cursor::DbCursorRO, tables, transaction::DbTx}; use reth_primitives_traits::InMemorySize; use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader, TransactionsProvider}; use reth_prune_types::{PruneMode, PruneSegment, ReceiptsLogPruneConfig}; diff --git a/crates/prune/prune/src/segments/user/sender_recovery.rs b/crates/prune/prune/src/segments/user/sender_recovery.rs index be5a7842c..e0a1938aa 100644 --- a/crates/prune/prune/src/segments/user/sender_recovery.rs +++ b/crates/prune/prune/src/segments/user/sender_recovery.rs @@ -3,7 +3,7 @@ use crate::{ segments::{PruneInput, Segment}, PrunerError, }; -use reth_db::{tables, transaction::DbTxMut}; +use reth_db_api::{tables, transaction::DbTxMut}; use reth_provider::{BlockReader, DBProvider, TransactionsProvider}; use reth_prune_types::{ PruneMode, PrunePurpose, PruneSegment, SegmentOutput, SegmentOutputCheckpoint, @@ -89,7 +89,7 @@ mod tests { FoldWhile::{Continue, Done}, Itertools, }; - use reth_db::tables; + use reth_db_api::tables; use reth_primitives_traits::SignedTransaction; use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader}; use reth_prune_types::{PruneCheckpoint, PruneMode, PruneProgress, PruneSegment}; diff --git a/crates/prune/prune/src/segments/user/storage_history.rs b/crates/prune/prune/src/segments/user/storage_history.rs index dd2c79d96..f4616c630 100644 --- a/crates/prune/prune/src/segments/user/storage_history.rs +++ b/crates/prune/prune/src/segments/user/storage_history.rs @@ -4,8 +4,11 @@ use crate::{ PrunerError, }; use itertools::Itertools; -use reth_db::{tables, transaction::DbTxMut}; -use reth_db_api::models::{storage_sharded_key::StorageShardedKey, BlockNumberAddress}; +use reth_db_api::{ + models::{storage_sharded_key::StorageShardedKey, BlockNumberAddress}, + tables, + transaction::DbTxMut, +}; use reth_provider::DBProvider; use reth_prune_types::{PruneMode, PrunePurpose, PruneSegment, SegmentOutputCheckpoint}; use rustc_hash::FxHashMap; @@ -136,7 +139,7 @@ mod tests { }; use alloy_primitives::{BlockNumber, B256}; use assert_matches::assert_matches; - use reth_db::{tables, BlockNumberList}; + use reth_db_api::{tables, BlockNumberList}; use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader}; use reth_prune_types::{PruneCheckpoint, PruneMode, PruneProgress, PruneSegment}; use reth_stages::test_utils::{StorageKind, TestStageDB}; diff --git a/crates/prune/prune/src/segments/user/transaction_lookup.rs b/crates/prune/prune/src/segments/user/transaction_lookup.rs index 73ba14236..aaa01c1f3 100644 --- a/crates/prune/prune/src/segments/user/transaction_lookup.rs +++ b/crates/prune/prune/src/segments/user/transaction_lookup.rs @@ -5,7 +5,7 @@ use crate::{ }; use alloy_eips::eip2718::Encodable2718; use rayon::prelude::*; -use reth_db::{tables, transaction::DbTxMut}; +use reth_db_api::{tables, transaction::DbTxMut}; use reth_provider::{BlockReader, DBProvider}; use reth_prune_types::{PruneMode, PrunePurpose, PruneSegment, SegmentOutputCheckpoint}; use tracing::{instrument, trace}; @@ -116,7 +116,7 @@ mod tests { FoldWhile::{Continue, Done}, Itertools, }; - use reth_db::tables; + use reth_db_api::tables; use reth_primitives_traits::SignedTransaction; use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader}; use reth_prune_types::{ diff --git a/crates/stages/stages/benches/setup/account_hashing.rs b/crates/stages/stages/benches/setup/account_hashing.rs index 9926c1f3d..7954919b1 100644 --- a/crates/stages/stages/benches/setup/account_hashing.rs +++ b/crates/stages/stages/benches/setup/account_hashing.rs @@ -2,9 +2,8 @@ use super::constants; use alloy_primitives::BlockNumber; -use reth_db::tables; use reth_db_api::{ - cursor::DbCursorRO, database::Database, transaction::DbTx, DatabaseError as DbError, + cursor::DbCursorRO, database::Database, tables, transaction::DbTx, DatabaseError as DbError, }; use reth_stages::{ stages::{AccountHashingStage, SeedOpts}, diff --git a/crates/stages/stages/benches/setup/mod.rs b/crates/stages/stages/benches/setup/mod.rs index c98dc05cc..a24604458 100644 --- a/crates/stages/stages/benches/setup/mod.rs +++ b/crates/stages/stages/benches/setup/mod.rs @@ -1,9 +1,10 @@ #![allow(unreachable_pub)] use alloy_primitives::{Address, B256, U256}; use itertools::concat; -use reth_db::{tables, test_utils::TempDatabase, Database, DatabaseEnv}; +use reth_db::{test_utils::TempDatabase, Database, DatabaseEnv}; use reth_db_api::{ cursor::DbCursorRO, + tables, transaction::{DbTx, DbTxMut}, }; use reth_primitives::{Account, SealedBlock, SealedHeader}; diff --git a/crates/stages/stages/src/stages/bodies.rs b/crates/stages/stages/src/stages/bodies.rs index fd4e373a5..c8ead8463 100644 --- a/crates/stages/stages/src/stages/bodies.rs +++ b/crates/stages/stages/src/stages/bodies.rs @@ -1,7 +1,10 @@ use super::missing_static_data_error; use futures_util::TryStreamExt; -use reth_db::{tables, transaction::DbTx}; -use reth_db_api::{cursor::DbCursorRO, transaction::DbTxMut}; +use reth_db_api::{ + cursor::DbCursorRO, + tables, + transaction::{DbTx, DbTxMut}, +}; use reth_network_p2p::bodies::{downloader::BodyDownloader, response::BlockResponse}; use reth_primitives::StaticFileSegment; use reth_provider::{ @@ -36,19 +39,19 @@ use tracing::*; /// /// The bodies are processed and data is inserted into these tables: /// -/// - [`BlockOmmers`][reth_db::tables::BlockOmmers] -/// - [`BlockBodies`][reth_db::tables::BlockBodyIndices] -/// - [`Transactions`][reth_db::tables::Transactions] -/// - [`TransactionBlocks`][reth_db::tables::TransactionBlocks] +/// - [`BlockOmmers`][reth_db_api::tables::BlockOmmers] +/// - [`BlockBodies`][reth_db_api::tables::BlockBodyIndices] +/// - [`Transactions`][reth_db_api::tables::Transactions] +/// - [`TransactionBlocks`][reth_db_api::tables::TransactionBlocks] /// /// # Genesis /// /// This stage expects that the genesis has been inserted into the appropriate tables: /// /// - The header tables (see [`HeaderStage`][crate::stages::HeaderStage]) -/// - The [`BlockOmmers`][reth_db::tables::BlockOmmers] table -/// - The [`BlockBodies`][reth_db::tables::BlockBodyIndices] table -/// - The [`Transactions`][reth_db::tables::Transactions] table +/// - The [`BlockOmmers`][reth_db_api::tables::BlockOmmers] table +/// - The [`BlockBodies`][reth_db_api::tables::BlockBodyIndices] table +/// - The [`Transactions`][reth_db_api::tables::Transactions] table #[derive(Debug)] pub struct BodyStage { /// The body downloader. diff --git a/crates/stages/stages/src/stages/execution.rs b/crates/stages/stages/src/stages/execution.rs index 85094df28..3eae99c5e 100644 --- a/crates/stages/stages/src/stages/execution.rs +++ b/crates/stages/stages/src/stages/execution.rs @@ -674,8 +674,10 @@ mod tests { use alloy_rlp::Decodable; use assert_matches::assert_matches; use reth_chainspec::ChainSpecBuilder; - use reth_db::transaction::DbTx; - use reth_db_api::{models::AccountBeforeTx, transaction::DbTxMut}; + use reth_db_api::{ + models::AccountBeforeTx, + transaction::{DbTx, DbTxMut}, + }; use reth_ethereum_consensus::EthBeaconConsensus; use reth_evm::execute::BasicBlockExecutorProvider; use reth_evm_ethereum::execute::EthExecutionStrategyFactory; diff --git a/crates/stages/stages/src/stages/hashing_account.rs b/crates/stages/stages/src/stages/hashing_account.rs index d256883e1..7d882a0df 100644 --- a/crates/stages/stages/src/stages/hashing_account.rs +++ b/crates/stages/stages/src/stages/hashing_account.rs @@ -1,10 +1,11 @@ use alloy_primitives::{keccak256, B256}; use itertools::Itertools; use reth_config::config::{EtlConfig, HashingConfig}; -use reth_db::{tables, RawKey, RawTable, RawValue}; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, + tables, transaction::{DbTx, DbTxMut}, + RawKey, RawTable, RawValue, }; use reth_etl::Collector; use reth_primitives::Account; diff --git a/crates/stages/stages/src/stages/hashing_storage.rs b/crates/stages/stages/src/stages/hashing_storage.rs index 7967aa854..eaf1a50f9 100644 --- a/crates/stages/stages/src/stages/hashing_storage.rs +++ b/crates/stages/stages/src/stages/hashing_storage.rs @@ -1,11 +1,11 @@ use alloy_primitives::{bytes::BufMut, keccak256, B256}; use itertools::Itertools; use reth_config::config::{EtlConfig, HashingConfig}; -use reth_db::tables; use reth_db_api::{ cursor::{DbCursorRO, DbDupCursorRW}, models::{BlockNumberAddress, CompactU256}, table::Decompress, + tables, transaction::{DbTx, DbTxMut}, }; use reth_etl::Collector; diff --git a/crates/stages/stages/src/stages/headers.rs b/crates/stages/stages/src/stages/headers.rs index cbec9c9ae..b8aca8c3b 100644 --- a/crates/stages/stages/src/stages/headers.rs +++ b/crates/stages/stages/src/stages/headers.rs @@ -4,11 +4,12 @@ use alloy_primitives::{BlockHash, BlockNumber, Bytes, B256}; use futures_util::StreamExt; use reth_config::config::EtlConfig; use reth_consensus::HeaderValidator; -use reth_db::{table::Value, tables, transaction::DbTx, RawKey, RawTable, RawValue}; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, - transaction::DbTxMut, - DbTxUnwindExt, + table::Value, + tables, + transaction::{DbTx, DbTxMut}, + DbTxUnwindExt, RawKey, RawTable, RawValue, }; use reth_etl::Collector; use reth_network_p2p::headers::{downloader::HeaderDownloader, error::HeadersDownloaderError}; @@ -36,7 +37,7 @@ use tracing::*; /// the perceived highest block on the network. /// /// The headers are processed and data is inserted into static files, as well as into the -/// [`HeaderNumbers`][reth_db::tables::HeaderNumbers] table. +/// [`HeaderNumbers`][reth_db_api::tables::HeaderNumbers] table. /// /// NOTE: This stage downloads headers in reverse and pushes them to the ETL [`Collector`]. It then /// proceeds to push them sequentially to static files. The stage checkpoint is not updated until diff --git a/crates/stages/stages/src/stages/index_account_history.rs b/crates/stages/stages/src/stages/index_account_history.rs index 38c238e5d..27eaf6cd1 100644 --- a/crates/stages/stages/src/stages/index_account_history.rs +++ b/crates/stages/stages/src/stages/index_account_history.rs @@ -1,8 +1,7 @@ use super::{collect_history_indices, load_history_indices}; use alloy_primitives::Address; use reth_config::config::{EtlConfig, IndexHistoryConfig}; -use reth_db::tables; -use reth_db_api::{models::ShardedKey, table::Decode, transaction::DbTxMut}; +use reth_db_api::{models::ShardedKey, table::Decode, tables, transaction::DbTxMut}; use reth_provider::{DBProvider, HistoryWriter, PruneCheckpointReader, PruneCheckpointWriter}; use reth_prune_types::{PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment}; use reth_stages_api::{ @@ -150,7 +149,6 @@ mod tests { }; use alloy_primitives::{address, BlockNumber, B256}; use itertools::Itertools; - use reth_db::BlockNumberList; use reth_db_api::{ cursor::DbCursorRO, models::{ @@ -158,6 +156,7 @@ mod tests { StoredBlockBodyIndices, }, transaction::DbTx, + BlockNumberList, }; use reth_provider::{providers::StaticFileWriter, DatabaseProviderFactory}; use reth_testing_utils::generators::{ diff --git a/crates/stages/stages/src/stages/index_storage_history.rs b/crates/stages/stages/src/stages/index_storage_history.rs index ba61e6312..2845acede 100644 --- a/crates/stages/stages/src/stages/index_storage_history.rs +++ b/crates/stages/stages/src/stages/index_storage_history.rs @@ -1,10 +1,10 @@ use super::{collect_history_indices, load_history_indices}; use crate::{StageCheckpoint, StageId}; use reth_config::config::{EtlConfig, IndexHistoryConfig}; -use reth_db::tables; use reth_db_api::{ models::{storage_sharded_key::StorageShardedKey, AddressStorageKey, BlockNumberAddress}, table::Decode, + tables, transaction::DbTxMut, }; use reth_provider::{DBProvider, HistoryWriter, PruneCheckpointReader, PruneCheckpointWriter}; @@ -155,7 +155,6 @@ mod tests { }; use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256}; use itertools::Itertools; - use reth_db::BlockNumberList; use reth_db_api::{ cursor::DbCursorRO, models::{ @@ -163,6 +162,7 @@ mod tests { StoredBlockBodyIndices, }, transaction::DbTx, + BlockNumberList, }; use reth_primitives::StorageEntry; use reth_provider::{providers::StaticFileWriter, DatabaseProviderFactory}; diff --git a/crates/stages/stages/src/stages/merkle.rs b/crates/stages/stages/src/stages/merkle.rs index 3d36964a7..4880a5ee9 100644 --- a/crates/stages/stages/src/stages/merkle.rs +++ b/crates/stages/stages/src/stages/merkle.rs @@ -2,8 +2,10 @@ use alloy_consensus::BlockHeader; use alloy_primitives::{BlockNumber, Sealable, B256}; use reth_codecs::Compact; use reth_consensus::ConsensusError; -use reth_db::tables; -use reth_db_api::transaction::{DbTx, DbTxMut}; +use reth_db_api::{ + tables, + transaction::{DbTx, DbTxMut}, +}; use reth_primitives::{GotExpected, SealedHeader}; use reth_provider::{ DBProvider, HeaderProvider, ProviderError, StageCheckpointReader, StageCheckpointWriter, diff --git a/crates/stages/stages/src/stages/mod.rs b/crates/stages/stages/src/stages/mod.rs index 9a2fb6552..7ced0d1b9 100644 --- a/crates/stages/stages/src/stages/mod.rs +++ b/crates/stages/stages/src/stages/mod.rs @@ -48,14 +48,13 @@ mod tests { use alloy_primitives::{address, hex_literal::hex, keccak256, BlockNumber, B256, U256}; use alloy_rlp::Decodable; use reth_chainspec::ChainSpecBuilder; - use reth_db::{ - mdbx::{cursor::Cursor, RW}, - tables, AccountsHistory, - }; + use reth_db::mdbx::{cursor::Cursor, RW}; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, table::Table, + tables, transaction::{DbTx, DbTxMut}, + AccountsHistory, }; use reth_ethereum_consensus::EthBeaconConsensus; use reth_evm_ethereum::execute::EthExecutorProvider; diff --git a/crates/stages/stages/src/stages/prune.rs b/crates/stages/stages/src/stages/prune.rs index 4bd298827..bf3b146cb 100644 --- a/crates/stages/stages/src/stages/prune.rs +++ b/crates/stages/stages/src/stages/prune.rs @@ -1,4 +1,4 @@ -use reth_db::{table::Value, transaction::DbTxMut}; +use reth_db_api::{table::Value, transaction::DbTxMut}; use reth_primitives::NodePrimitives; use reth_provider::{ BlockReader, DBProvider, PruneCheckpointReader, PruneCheckpointWriter, diff --git a/crates/stages/stages/src/stages/s3/mod.rs b/crates/stages/stages/src/stages/s3/mod.rs index 18e8a99c7..c4dbf49ef 100644 --- a/crates/stages/stages/src/stages/s3/mod.rs +++ b/crates/stages/stages/src/stages/s3/mod.rs @@ -5,7 +5,7 @@ use downloader::{DownloaderError, S3DownloaderResponse}; mod filelist; use filelist::DOWNLOAD_FILE_LIST; -use reth_db::transaction::DbTxMut; +use reth_db_api::transaction::DbTxMut; use reth_primitives::StaticFileSegment; use reth_provider::{ DBProvider, StageCheckpointReader, StageCheckpointWriter, StaticFileProviderFactory, diff --git a/crates/stages/stages/src/stages/sender_recovery.rs b/crates/stages/stages/src/stages/sender_recovery.rs index bfa66fc1a..b180a9989 100644 --- a/crates/stages/stages/src/stages/sender_recovery.rs +++ b/crates/stages/stages/src/stages/sender_recovery.rs @@ -1,11 +1,13 @@ use alloy_primitives::{Address, TxNumber}; use reth_config::config::SenderRecoveryConfig; use reth_consensus::ConsensusError; -use reth_db::{static_file::TransactionMask, table::Value, tables, RawValue}; +use reth_db::static_file::TransactionMask; use reth_db_api::{ cursor::DbCursorRW, + table::Value, + tables, transaction::{DbTx, DbTxMut}, - DbTxUnwindExt, + DbTxUnwindExt, RawValue, }; use reth_primitives::{GotExpected, NodePrimitives, StaticFileSegment}; use reth_primitives_traits::SignedTransaction; @@ -35,7 +37,7 @@ type RecoveryResultSender = mpsc::Sender Result { if input.target_reached() { return Ok(ExecOutput::done(input.checkpoint())) diff --git a/crates/stages/stages/src/stages/tx_lookup.rs b/crates/stages/stages/src/stages/tx_lookup.rs index 42ffd0542..c0539b718 100644 --- a/crates/stages/stages/src/stages/tx_lookup.rs +++ b/crates/stages/stages/src/stages/tx_lookup.rs @@ -2,10 +2,12 @@ use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{TxHash, TxNumber}; use num_traits::Zero; use reth_config::config::{EtlConfig, TransactionLookupConfig}; -use reth_db::{table::Value, tables, RawKey, RawValue}; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, + table::Value, + tables, transaction::DbTxMut, + RawKey, RawValue, }; use reth_etl::Collector; use reth_primitives::NodePrimitives; @@ -259,7 +261,7 @@ mod tests { }; use alloy_primitives::{BlockNumber, B256}; use assert_matches::assert_matches; - use reth_db::transaction::DbTx; + use reth_db_api::transaction::DbTx; use reth_primitives::SealedBlock; use reth_provider::{ providers::StaticFileWriter, BlockBodyIndicesProvider, DatabaseProviderFactory, diff --git a/crates/stages/stages/src/stages/utils.rs b/crates/stages/stages/src/stages/utils.rs index add013d40..21adf3b18 100644 --- a/crates/stages/stages/src/stages/utils.rs +++ b/crates/stages/stages/src/stages/utils.rs @@ -1,13 +1,12 @@ //! Utils for `stages`. use alloy_primitives::{BlockNumber, TxNumber}; use reth_config::config::EtlConfig; -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}, - DatabaseError, + BlockNumberList, DatabaseError, }; use reth_etl::Collector; use reth_primitives::StaticFileSegment; diff --git a/crates/stages/stages/src/test_utils/test_db.rs b/crates/stages/stages/src/test_utils/test_db.rs index 9f13986d2..6e688c60a 100644 --- a/crates/stages/stages/src/test_utils/test_db.rs +++ b/crates/stages/stages/src/test_utils/test_db.rs @@ -1,7 +1,6 @@ use alloy_primitives::{keccak256, Address, BlockNumber, TxHash, TxNumber, B256, U256}; use reth_chainspec::MAINNET; use reth_db::{ - tables, test_utils::{create_test_rw_db, create_test_rw_db_with_path, create_test_static_files_dir}, DatabaseEnv, }; @@ -11,6 +10,7 @@ use reth_db_api::{ database::Database, models::{AccountBeforeTx, StoredBlockBodyIndices}, table::Table, + tables, transaction::{DbTx, DbTxMut}, DatabaseError as DbError, }; diff --git a/crates/static-file/static-file/src/segments/headers.rs b/crates/static-file/static-file/src/segments/headers.rs index dff80a23f..5232061ca 100644 --- a/crates/static-file/static-file/src/segments/headers.rs +++ b/crates/static-file/static-file/src/segments/headers.rs @@ -1,8 +1,7 @@ use crate::segments::Segment; use alloy_primitives::BlockNumber; use reth_codecs::Compact; -use reth_db::{table::Value, tables}; -use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; +use reth_db_api::{cursor::DbCursorRO, table::Value, tables, transaction::DbTx}; use reth_primitives_traits::NodePrimitives; use reth_provider::{providers::StaticFileWriter, DBProvider, StaticFileProviderFactory}; use reth_static_file_types::StaticFileSegment; diff --git a/crates/static-file/static-file/src/segments/receipts.rs b/crates/static-file/static-file/src/segments/receipts.rs index 1490fb152..0c556f781 100644 --- a/crates/static-file/static-file/src/segments/receipts.rs +++ b/crates/static-file/static-file/src/segments/receipts.rs @@ -1,8 +1,7 @@ use crate::segments::Segment; use alloy_primitives::BlockNumber; use reth_codecs::Compact; -use reth_db::{table::Value, tables}; -use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; +use reth_db_api::{cursor::DbCursorRO, table::Value, tables, transaction::DbTx}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ providers::StaticFileWriter, BlockReader, DBProvider, StaticFileProviderFactory, diff --git a/crates/static-file/static-file/src/segments/transactions.rs b/crates/static-file/static-file/src/segments/transactions.rs index 5b686cfe1..74cb58ed7 100644 --- a/crates/static-file/static-file/src/segments/transactions.rs +++ b/crates/static-file/static-file/src/segments/transactions.rs @@ -1,8 +1,7 @@ use crate::segments::Segment; use alloy_primitives::BlockNumber; use reth_codecs::Compact; -use reth_db::{table::Value, tables}; -use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; +use reth_db_api::{cursor::DbCursorRO, table::Value, tables, transaction::DbTx}; use reth_primitives_traits::NodePrimitives; use reth_provider::{ providers::StaticFileWriter, BlockReader, DBProvider, StaticFileProviderFactory, diff --git a/crates/static-file/static-file/src/static_file_producer.rs b/crates/static-file/static-file/src/static_file_producer.rs index 3f9cbd3cb..491419ef4 100644 --- a/crates/static-file/static-file/src/static_file_producer.rs +++ b/crates/static-file/static-file/src/static_file_producer.rs @@ -5,7 +5,7 @@ use alloy_primitives::BlockNumber; use parking_lot::Mutex; use rayon::prelude::*; use reth_codecs::Compact; -use reth_db::table::Value; +use reth_db_api::table::Value; use reth_primitives_traits::NodePrimitives; use reth_provider::{ providers::StaticFileWriter, BlockReader, ChainStateBlockReader, DBProvider, diff --git a/crates/storage/db-api/Cargo.toml b/crates/storage/db-api/Cargo.toml index ce6fb7fd2..3a3dc7482 100644 --- a/crates/storage/db-api/Cargo.toml +++ b/crates/storage/db-api/Cargo.toml @@ -18,7 +18,7 @@ reth-db-models = { workspace = true, features = ["reth-codec"] } reth-primitives = { workspace = true, features = ["reth-codec"] } reth-primitives-traits = { workspace = true, features = ["serde", "reth-codec"] } reth-stages-types = { workspace = true, features = ["serde", "reth-codec"] } -reth-prune-types = { workspace = true, features = ["reth-codec"] } +reth-prune-types = { workspace = true, features = ["serde", "reth-codec"] } reth-storage-errors.workspace = true reth-trie-common.workspace = true @@ -96,3 +96,4 @@ op = [ "reth-codecs/op", "reth-primitives-traits/op", ] +bench = [] diff --git a/crates/storage/db-api/src/lib.rs b/crates/storage/db-api/src/lib.rs index db4cb1000..96a3253a3 100644 --- a/crates/storage/db-api/src/lib.rs +++ b/crates/storage/db-api/src/lib.rs @@ -61,17 +61,27 @@ /// Common types used throughout the abstraction. pub mod common; + /// Cursor database traits. pub mod cursor; + /// Database traits. pub mod database; + /// Database metrics trait extensions. pub mod database_metrics; + pub mod mock; + /// Table traits pub mod table; + +pub mod tables; +pub use tables::*; + /// Transaction database traits. pub mod transaction; + /// Re-exports pub use reth_storage_errors::db::{DatabaseError, DatabaseWriteOperation}; diff --git a/crates/storage/db/src/tables/codecs/fuzz/inputs.rs b/crates/storage/db-api/src/tables/codecs/fuzz/inputs.rs similarity index 92% rename from crates/storage/db/src/tables/codecs/fuzz/inputs.rs rename to crates/storage/db-api/src/tables/codecs/fuzz/inputs.rs index da15c112e..9fe7c0cb1 100644 --- a/crates/storage/db/src/tables/codecs/fuzz/inputs.rs +++ b/crates/storage/db-api/src/tables/codecs/fuzz/inputs.rs @@ -1,6 +1,6 @@ //! Curates the input coming from the fuzzer for certain types. -use reth_db_api::models::IntegerList; +use crate::models::IntegerList; use serde::{Deserialize, Serialize}; /// Makes sure that the list provided by the fuzzer is not empty and pre-sorted diff --git a/crates/storage/db/src/tables/codecs/fuzz/mod.rs b/crates/storage/db-api/src/tables/codecs/fuzz/mod.rs similarity index 97% rename from crates/storage/db/src/tables/codecs/fuzz/mod.rs rename to crates/storage/db-api/src/tables/codecs/fuzz/mod.rs index f6b68897e..1e9d50afd 100644 --- a/crates/storage/db/src/tables/codecs/fuzz/mod.rs +++ b/crates/storage/db-api/src/tables/codecs/fuzz/mod.rs @@ -14,7 +14,7 @@ macro_rules! impl_fuzzer_with_input { #[allow(non_snake_case)] #[cfg(any(test, feature = "bench"))] pub mod $name { - use reth_db_api::table; + use crate::table; #[allow(unused_imports)] use reth_primitives_traits::*; @@ -23,7 +23,7 @@ macro_rules! impl_fuzzer_with_input { use super::inputs::*; #[allow(unused_imports)] - use reth_db_api::models::*; + use crate::models::*; /// Encodes and decodes table types returning its encoded size and the decoded object. /// This method is used for benchmarking, so its parameter should be the actual type that is being tested. diff --git a/crates/storage/db/src/tables/codecs/mod.rs b/crates/storage/db-api/src/tables/codecs/mod.rs similarity index 100% rename from crates/storage/db/src/tables/codecs/mod.rs rename to crates/storage/db-api/src/tables/codecs/mod.rs diff --git a/crates/storage/db/src/tables/mod.rs b/crates/storage/db-api/src/tables/mod.rs similarity index 95% rename from crates/storage/db/src/tables/mod.rs rename to crates/storage/db-api/src/tables/mod.rs index 961fd41e9..9573424a2 100644 --- a/crates/storage/db/src/tables/mod.rs +++ b/crates/storage/db-api/src/tables/mod.rs @@ -5,7 +5,7 @@ //! This module defines the tables in reth, as well as some table-related abstractions: //! //! - [`codecs`] integrates different codecs into [`Encode`] and [`Decode`] -//! - [`models`](reth_db_api::models) defines the values written to tables +//! - [`models`](crate::models) defines the values written to tables //! //! # Database Tour //! @@ -16,12 +16,7 @@ pub mod codecs; mod raw; pub use raw::{RawDupSort, RawKey, RawTable, RawValue, TableRawRow}; -#[cfg(feature = "mdbx")] -pub(crate) mod utils; - -use alloy_consensus::Header; -use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256}; -use reth_db_api::{ +use crate::{ models::{ accounts::BlockNumberAddress, blocks::{HeaderHash, StoredBlockOmmers}, @@ -31,6 +26,8 @@ use reth_db_api::{ }, table::{Decode, DupSort, Encode, Table, TableInfo}, }; +use alloy_consensus::Header; +use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256}; use reth_primitives::{Receipt, StorageEntry, TransactionSigned}; use reth_primitives_traits::{Account, Bytecode}; use reth_prune_types::{PruneCheckpoint, PruneSegment}; @@ -54,8 +51,10 @@ pub enum TableType { /// # Example /// /// ``` -/// use reth_db::{TableViewer, Tables}; -/// use reth_db_api::table::{DupSort, Table}; +/// use reth_db_api::{ +/// table::{DupSort, Table}, +/// TableViewer, Tables, +/// }; /// /// struct MyTableViewer; /// @@ -143,9 +142,9 @@ macro_rules! tables { } } - impl$(<$($generic),*>)? reth_db_api::table::Table for $name$(<$($generic),*>)? + impl$(<$($generic),*>)? $crate::table::Table for $name$(<$($generic),*>)? where - $value: reth_db_api::table::Value + 'static + $value: $crate::table::Value + 'static $($(,$generic: Send + Sync)*)? { const NAME: &'static str = table_names::$name; @@ -163,9 +162,6 @@ macro_rules! tables { )* // Tables enum. - // NOTE: the ordering of the enum does not matter, but it is assumed that the discriminants - // start at 0 and increment by 1 for each variant (the default behavior). - // See for example `reth_db::implementation::mdbx::tx::Tx::db_handles`. /// A table in the database. #[derive(Clone, Copy, PartialEq, Eq, Hash)] @@ -281,8 +277,7 @@ macro_rules! tables { /// # Examples /// /// ``` - /// use reth_db::{Tables, tables_to_generic}; - /// use reth_db_api::table::Table; + /// use reth_db_api::{table::Table, Tables, tables_to_generic}; /// /// let table = Tables::Headers; /// let result = tables_to_generic!(table, |GenericTable| ::NAME); @@ -553,11 +548,11 @@ impl Encode for ChainStateKey { } impl Decode for ChainStateKey { - fn decode(value: &[u8]) -> Result { + fn decode(value: &[u8]) -> Result { match value { [0] => Ok(Self::LastFinalizedBlock), [1] => Ok(Self::LastSafeBlockBlock), - _ => Err(reth_db_api::DatabaseError::Decode), + _ => Err(crate::DatabaseError::Decode), } } } diff --git a/crates/storage/db/src/tables/raw.rs b/crates/storage/db-api/src/tables/raw.rs similarity index 97% rename from crates/storage/db/src/tables/raw.rs rename to crates/storage/db-api/src/tables/raw.rs index 18fe0da23..96208a25d 100644 --- a/crates/storage/db/src/tables/raw.rs +++ b/crates/storage/db-api/src/tables/raw.rs @@ -1,5 +1,7 @@ -use crate::DatabaseError; -use reth_db_api::table::{Compress, Decode, Decompress, DupSort, Encode, Key, Table, Value}; +use crate::{ + table::{Compress, Decode, Decompress, DupSort, Encode, Key, Table, Value}, + DatabaseError, +}; use serde::{Deserialize, Serialize}; /// Tuple with `RawKey` and `RawValue`. diff --git a/crates/storage/db-common/Cargo.toml b/crates/storage/db-common/Cargo.toml index 28dbc33e9..cf86d41c3 100644 --- a/crates/storage/db-common/Cargo.toml +++ b/crates/storage/db-common/Cargo.toml @@ -11,7 +11,6 @@ repository.workspace = true # reth reth-chainspec.workspace = true reth-primitives.workspace = true -reth-db = { workspace = true, features = ["mdbx"] } reth-db-api.workspace = true reth-provider.workspace = true reth-config.workspace = true @@ -41,6 +40,7 @@ serde_json.workspace = true tracing.workspace = true [dev-dependencies] +reth-db = { workspace = true, features = ["mdbx"] } reth-primitives-traits.workspace = true reth-provider = { workspace = true, features = ["test-utils"] } alloy-consensus.workspace = true diff --git a/crates/storage/db-common/src/db_tool/mod.rs b/crates/storage/db-common/src/db_tool/mod.rs index 9f5f06a35..322496465 100644 --- a/crates/storage/db-common/src/db_tool/mod.rs +++ b/crates/storage/db-common/src/db_tool/mod.rs @@ -2,13 +2,12 @@ use boyer_moore_magiclen::BMByte; use eyre::Result; -use reth_db::{RawTable, TableRawRow}; use reth_db_api::{ cursor::{DbCursorRO, DbDupCursorRO}, database::Database, table::{Decode, Decompress, DupSort, Table, TableRow}, transaction::{DbTx, DbTxMut}, - DatabaseError, + DatabaseError, RawTable, TableRawRow, }; use reth_fs_util as fs; use reth_node_types::NodeTypesWithDB; diff --git a/crates/storage/db-common/src/init.rs b/crates/storage/db-common/src/init.rs index 1771527a7..3027e12e0 100644 --- a/crates/storage/db-common/src/init.rs +++ b/crates/storage/db-common/src/init.rs @@ -6,8 +6,7 @@ use alloy_primitives::{map::HashMap, Address, B256, U256}; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::config::EtlConfig; -use reth_db::tables; -use reth_db_api::{transaction::DbTxMut, DatabaseError}; +use reth_db_api::{tables, transaction::DbTxMut, DatabaseError}; use reth_etl::Collector; use reth_primitives::{ Account, Bytecode, GotExpected, NodePrimitives, StaticFileSegment, StorageEntry, diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index 619a97821..ff1276346 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -15,32 +15,23 @@ workspace = true # reth reth-db-api.workspace = true reth-primitives = { workspace = true, features = ["reth-codec"] } -reth-primitives-traits = { workspace = true, features = ["reth-codec"] } reth-fs-util.workspace = true reth-storage-errors.workspace = true reth-nippy-jar.workspace = true -reth-prune-types = { workspace = true, features = ["reth-codec", "serde"] } -reth-stages-types.workspace = true -reth-trie-common = { workspace = true, features = ["serde"] } reth-tracing.workspace = true # ethereum alloy-primitives.workspace = true -alloy-consensus.workspace = true # mdbx reth-libmdbx = { workspace = true, optional = true, features = ["return-borrowed", "read-tx-timeouts"] } eyre = { workspace = true, optional = true } -# codecs -serde = { workspace = true, default-features = false } - # metrics reth-metrics = { workspace = true, optional = true } metrics = { workspace = true, optional = true } # misc -bytes.workspace = true page_size = { version = "0.6.0", optional = true } thiserror.workspace = true tempfile = { workspace = true, optional = true } @@ -55,11 +46,13 @@ strum = { workspace = true, features = ["derive"], optional = true } [dev-dependencies] # reth libs with arbitrary reth-primitives = { workspace = true, features = ["arbitrary"] } +reth-primitives-traits = { workspace = true, features = ["reth-codec"] } serde_json.workspace = true tempfile.workspace = true -test-fuzz.workspace = true parking_lot.workspace = true +alloy-consensus.workspace = true +serde.workspace = true pprof = { workspace = true, features = ["flamegraph", "frame-pointer", "criterion"] } criterion.workspace = true @@ -85,23 +78,17 @@ test-utils = [ "arbitrary", "parking_lot", "reth-primitives/test-utils", - "reth-primitives-traits/test-utils", "reth-db-api/test-utils", "reth-nippy-jar/test-utils", - "reth-trie-common/test-utils", - "reth-prune-types/test-utils", - "reth-stages-types/test-utils", + "reth-primitives-traits/test-utils", ] -bench = [] +bench = ["reth-db-api/bench"] arbitrary = [ "reth-primitives/arbitrary", "reth-db-api/arbitrary", - "reth-primitives-traits/arbitrary", - "reth-trie-common/arbitrary", "alloy-primitives/arbitrary", - "reth-prune-types/arbitrary", - "reth-stages-types/arbitrary", "alloy-consensus/arbitrary", + "reth-primitives-traits/arbitrary", ] optimism = ["reth-db-api/optimism"] op = [ diff --git a/crates/storage/db/benches/criterion.rs b/crates/storage/db/benches/criterion.rs index abfc8be33..6cfbe8791 100644 --- a/crates/storage/db/benches/criterion.rs +++ b/crates/storage/db/benches/criterion.rs @@ -6,11 +6,12 @@ use criterion::{ criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion, }; use pprof::criterion::{Output, PProfProfiler}; -use reth_db::{tables::*, test_utils::create_test_rw_db_with_path}; +use reth_db::test_utils::create_test_rw_db_with_path; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW}, database::Database, table::{Compress, Decode, Decompress, DupSort, Encode, Table}, + tables::*, transaction::{DbTx, DbTxMut}, }; use reth_fs_util as fs; diff --git a/crates/storage/db/src/implementation/mdbx/cursor.rs b/crates/storage/db/src/implementation/mdbx/cursor.rs index ec5f3b7c2..d946316a2 100644 --- a/crates/storage/db/src/implementation/mdbx/cursor.rs +++ b/crates/storage/db/src/implementation/mdbx/cursor.rs @@ -1,8 +1,8 @@ //! Cursor wrapper for libmdbx-sys. +use super::utils::*; use crate::{ metrics::{DatabaseEnvMetrics, Operation}, - tables::utils::*, DatabaseError, }; use reth_db_api::{ diff --git a/crates/storage/db/src/implementation/mdbx/mod.rs b/crates/storage/db/src/implementation/mdbx/mod.rs index a41388b57..c92ddb841 100644 --- a/crates/storage/db/src/implementation/mdbx/mod.rs +++ b/crates/storage/db/src/implementation/mdbx/mod.rs @@ -33,6 +33,8 @@ use tx::Tx; pub mod cursor; pub mod tx; +mod utils; + /// 1 KB in bytes pub const KILOBYTE: usize = 1024; /// 1 MB in bytes diff --git a/crates/storage/db/src/implementation/mdbx/tx.rs b/crates/storage/db/src/implementation/mdbx/tx.rs index 09be53a5f..563abdf05 100644 --- a/crates/storage/db/src/implementation/mdbx/tx.rs +++ b/crates/storage/db/src/implementation/mdbx/tx.rs @@ -1,9 +1,8 @@ //! Transaction wrapper for libmdbx-sys. -use super::cursor::Cursor; +use super::{cursor::Cursor, utils::*}; use crate::{ metrics::{DatabaseEnvMetrics, Operation, TransactionMode, TransactionOutcome}, - tables::utils::decode_one, DatabaseError, }; use reth_db_api::{ diff --git a/crates/storage/db/src/tables/utils.rs b/crates/storage/db/src/implementation/mdbx/utils.rs similarity index 93% rename from crates/storage/db/src/tables/utils.rs rename to crates/storage/db/src/implementation/mdbx/utils.rs index 0948ee108..76fbbcad7 100644 --- a/crates/storage/db/src/tables/utils.rs +++ b/crates/storage/db/src/implementation/mdbx/utils.rs @@ -1,7 +1,9 @@ //! Small database table utilities and helper functions. -use crate::DatabaseError; -use reth_db_api::table::{Decode, Decompress, Table, TableRow}; +use crate::{ + table::{Decode, Decompress, Table, TableRow}, + DatabaseError, +}; use std::borrow::Cow; /// Helper function to decode a `(key, value)` pair. diff --git a/crates/storage/db/src/lib.rs b/crates/storage/db/src/lib.rs index ff740375e..8af9e4b3a 100644 --- a/crates/storage/db/src/lib.rs +++ b/crates/storage/db/src/lib.rs @@ -20,7 +20,6 @@ pub mod lockfile; #[cfg(feature = "mdbx")] mod metrics; pub mod static_file; -pub mod tables; #[cfg(feature = "mdbx")] mod utils; pub mod version; @@ -29,7 +28,6 @@ pub mod version; pub mod mdbx; pub use reth_storage_errors::db::{DatabaseError, DatabaseWriteOperation}; -pub use tables::*; #[cfg(feature = "mdbx")] pub use utils::is_database_empty; diff --git a/crates/storage/provider/src/providers/blockchain_provider.rs b/crates/storage/provider/src/providers/blockchain_provider.rs index 14a130a67..021380132 100644 --- a/crates/storage/provider/src/providers/blockchain_provider.rs +++ b/crates/storage/provider/src/providers/blockchain_provider.rs @@ -21,8 +21,11 @@ use reth_chain_state::{ MemoryOverlayStateProvider, }; use reth_chainspec::{ChainInfo, EthereumHardforks}; -use reth_db::{models::BlockNumberAddress, transaction::DbTx, Database}; -use reth_db_api::models::{AccountBeforeTx, StoredBlockBodyIndices}; +use reth_db_api::{ + models::{AccountBeforeTx, BlockNumberAddress, StoredBlockBodyIndices}, + transaction::DbTx, + Database, +}; use reth_evm::{ConfigureEvmEnv, EvmEnv}; use reth_execution_types::ExecutionOutcome; use reth_node_types::{BlockTy, HeaderTy, NodeTypesWithDB, ReceiptTy, TxTy}; @@ -789,11 +792,12 @@ mod tests { use reth_chainspec::{ ChainSpec, ChainSpecBuilder, ChainSpecProvider, EthereumHardfork, MAINNET, }; - use reth_db::{ + use reth_db_api::{ + cursor::DbCursorRO, models::{AccountBeforeTx, StoredBlockBodyIndices}, tables, + transaction::DbTx, }; - use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; use reth_errors::ProviderError; use reth_execution_types::{Chain, ExecutionOutcome}; use reth_primitives::{EthPrimitives, Receipt, RecoveredBlock, SealedBlock, StaticFileSegment}; diff --git a/crates/storage/provider/src/providers/consistent.rs b/crates/storage/provider/src/providers/consistent.rs index e26aee1dc..904160a0e 100644 --- a/crates/storage/provider/src/providers/consistent.rs +++ b/crates/storage/provider/src/providers/consistent.rs @@ -17,8 +17,7 @@ use alloy_primitives::{ }; use reth_chain_state::{BlockState, CanonicalInMemoryState, MemoryOverlayStateProviderRef}; use reth_chainspec::{ChainInfo, EthereumHardforks}; -use reth_db::models::BlockNumberAddress; -use reth_db_api::models::{AccountBeforeTx, StoredBlockBodyIndices}; +use reth_db_api::models::{AccountBeforeTx, BlockNumberAddress, StoredBlockBodyIndices}; use reth_execution_types::{BundleStateInit, ExecutionOutcome, RevertsInit}; use reth_node_types::{BlockTy, HeaderTy, ReceiptTy, TxTy}; use reth_primitives::{Account, RecoveredBlock, SealedBlock, SealedHeader, StorageEntry}; @@ -1485,7 +1484,7 @@ mod tests { use itertools::Itertools; use rand::Rng; use reth_chain_state::{ExecutedBlock, ExecutedBlockWithTrieUpdates, NewCanonicalChain}; - use reth_db::models::AccountBeforeTx; + use reth_db_api::models::AccountBeforeTx; use reth_execution_types::ExecutionOutcome; use reth_primitives::{RecoveredBlock, SealedBlock}; use reth_storage_api::{BlockReader, BlockSource, ChangeSetReader}; diff --git a/crates/storage/provider/src/providers/database/chain.rs b/crates/storage/provider/src/providers/database/chain.rs index 3f0201efb..f9cb8749b 100644 --- a/crates/storage/provider/src/providers/database/chain.rs +++ b/crates/storage/provider/src/providers/database/chain.rs @@ -1,5 +1,5 @@ use crate::{providers::NodeTypesForProvider, DatabaseProvider}; -use reth_db::transaction::{DbTx, DbTxMut}; +use reth_db_api::transaction::{DbTx, DbTxMut}; use reth_node_types::{FullNodePrimitives, FullSignedTx}; use reth_primitives_traits::FullBlockHeader; use reth_storage_api::{ChainStorageReader, ChainStorageWriter, EthStorage}; diff --git a/crates/storage/provider/src/providers/database/mod.rs b/crates/storage/provider/src/providers/database/mod.rs index 54b21d023..f3b0e6a63 100644 --- a/crates/storage/provider/src/providers/database/mod.rs +++ b/crates/storage/provider/src/providers/database/mod.rs @@ -669,9 +669,9 @@ mod tests { use reth_chainspec::ChainSpecBuilder; use reth_db::{ mdbx::DatabaseArguments, - tables, test_utils::{create_test_static_files_dir, ERROR_TEMPDIR}, }; + use reth_db_api::tables; use reth_primitives::StaticFileSegment; use reth_primitives_traits::SignedTransaction; use reth_prune_types::{PruneMode, PruneModes}; diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 52dffe2fe..314ba9f83 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -29,19 +29,17 @@ use alloy_primitives::{ use itertools::Itertools; use rayon::slice::ParallelSliceMut; use reth_chainspec::{ChainInfo, ChainSpecProvider, EthChainSpec, EthereumHardforks}; -use reth_db::{ - cursor::DbDupCursorRW, tables, BlockNumberList, PlainAccountState, PlainStorageState, -}; use reth_db_api::{ - cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO}, + cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW}, database::Database, models::{ sharded_key, storage_sharded_key::StorageShardedKey, AccountBeforeTx, BlockNumberAddress, ShardedKey, StoredBlockBodyIndices, }, table::Table, + tables, transaction::{DbTx, DbTxMut}, - DatabaseError, + BlockNumberList, DatabaseError, PlainAccountState, PlainStorageState, }; use reth_execution_types::{Chain, ExecutionOutcome}; use reth_network_p2p::headers::downloader::SyncTarget; @@ -316,7 +314,7 @@ impl DatabaseProvider HashingWriter for DatabaseProvi let (state_root, trie_updates) = StateRoot::from_tx(&self.tx) .with_prefix_sets(prefix_sets) .root_with_updates() - .map_err(reth_db::DatabaseError::from)?; + .map_err(reth_db_api::DatabaseError::from)?; if state_root != expected_state_root { return Err(ProviderError::StateRootMismatch(Box::new(RootMismatch { root: GotExpected { got: state_root, expected: expected_state_root }, diff --git a/crates/storage/provider/src/providers/mod.rs b/crates/storage/provider/src/providers/mod.rs index 3d8193a5e..f194cef49 100644 --- a/crates/storage/provider/src/providers/mod.rs +++ b/crates/storage/provider/src/providers/mod.rs @@ -1,7 +1,7 @@ //! Contains the main provider types and traits for interacting with the blockchain's storage. use reth_chainspec::EthereumHardforks; -use reth_db::table::Value; +use reth_db_api::table::Value; use reth_node_types::{FullNodePrimitives, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine}; mod database; diff --git a/crates/storage/provider/src/providers/state/historical.rs b/crates/storage/provider/src/providers/state/historical.rs index 447535a1b..6b72a2d2a 100644 --- a/crates/storage/provider/src/providers/state/historical.rs +++ b/crates/storage/provider/src/providers/state/historical.rs @@ -4,12 +4,13 @@ use crate::{ }; use alloy_eips::merge::EPOCH_SLOTS; use alloy_primitives::{map::B256Map, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256}; -use reth_db::{tables, BlockNumberList}; use reth_db_api::{ cursor::{DbCursorRO, DbDupCursorRO}, models::{storage_sharded_key::StorageShardedKey, ShardedKey}, table::Table, + tables, transaction::DbTx, + BlockNumberList, }; use reth_primitives::{Account, Bytecode}; use reth_storage_api::{ @@ -541,10 +542,11 @@ mod tests { AccountReader, HistoricalStateProvider, HistoricalStateProviderRef, StateProvider, }; use alloy_primitives::{address, b256, Address, B256, U256}; - use reth_db::{tables, BlockNumberList}; use reth_db_api::{ models::{storage_sharded_key::StorageShardedKey, AccountBeforeTx, ShardedKey}, + tables, transaction::{DbTx, DbTxMut}, + BlockNumberList, }; use reth_primitives::{Account, StorageEntry}; use reth_storage_api::{ diff --git a/crates/storage/provider/src/providers/state/latest.rs b/crates/storage/provider/src/providers/state/latest.rs index dc7632921..334c4bfcf 100644 --- a/crates/storage/provider/src/providers/state/latest.rs +++ b/crates/storage/provider/src/providers/state/latest.rs @@ -3,8 +3,7 @@ use crate::{ HashedPostStateProvider, StateProvider, StateRootProvider, }; use alloy_primitives::{map::B256Map, Address, BlockNumber, Bytes, StorageKey, StorageValue, B256}; -use reth_db::tables; -use reth_db_api::{cursor::DbDupCursorRO, transaction::DbTx}; +use reth_db_api::{cursor::DbDupCursorRO, tables, transaction::DbTx}; use reth_primitives::{Account, Bytecode}; use reth_storage_api::{ DBProvider, StateCommitmentProvider, StateProofProvider, StorageRootProvider, diff --git a/crates/storage/provider/src/providers/static_file/jar.rs b/crates/storage/provider/src/providers/static_file/jar.rs index c87fc45d7..794d96984 100644 --- a/crates/storage/provider/src/providers/static_file/jar.rs +++ b/crates/storage/provider/src/providers/static_file/jar.rs @@ -10,12 +10,12 @@ use alloy_consensus::transaction::TransactionMeta; use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals, BlockHashOrNumber}; use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256, U256}; use reth_chainspec::ChainInfo; -use reth_db::{ +use reth_db::static_file::{ + BlockHashMask, BodyIndicesMask, HeaderMask, HeaderWithHashMask, OmmersMask, ReceiptMask, + StaticFileCursor, TDWithHashMask, TotalDifficultyMask, TransactionMask, WithdrawalsMask, +}; +use reth_db_api::{ models::StoredBlockBodyIndices, - static_file::{ - BlockHashMask, BodyIndicesMask, HeaderMask, HeaderWithHashMask, OmmersMask, ReceiptMask, - StaticFileCursor, TDWithHashMask, TotalDifficultyMask, TransactionMask, WithdrawalsMask, - }, table::{Decompress, Value}, }; use reth_node_types::{FullNodePrimitives, NodePrimitives}; diff --git a/crates/storage/provider/src/providers/static_file/manager.rs b/crates/storage/provider/src/providers/static_file/manager.rs index f0e5f05d4..8b7893459 100644 --- a/crates/storage/provider/src/providers/static_file/manager.rs +++ b/crates/storage/provider/src/providers/static_file/manager.rs @@ -22,11 +22,13 @@ use reth_db::{ iter_static_files, BlockHashMask, BodyIndicesMask, HeaderMask, HeaderWithHashMask, ReceiptMask, StaticFileCursor, TDWithHashMask, TransactionMask, }, - table::{Decompress, Value}, - tables, }; use reth_db_api::{ - cursor::DbCursorRO, models::StoredBlockBodyIndices, table::Table, transaction::DbTx, + cursor::DbCursorRO, + models::StoredBlockBodyIndices, + table::{Decompress, Table, Value}, + tables, + transaction::DbTx, }; use reth_nippy_jar::{NippyJar, NippyJarChecker, CONFIG_FILE_EXTENSION}; use reth_node_types::{FullNodePrimitives, NodePrimitives}; diff --git a/crates/storage/provider/src/providers/static_file/mod.rs b/crates/storage/provider/src/providers/static_file/mod.rs index 6ea76e4b3..162c1599f 100644 --- a/crates/storage/provider/src/providers/static_file/mod.rs +++ b/crates/storage/provider/src/providers/static_file/mod.rs @@ -61,11 +61,10 @@ mod tests { use alloy_consensus::{Header, Transaction}; use alloy_primitives::{BlockHash, TxNumber, B256, U256}; use rand::seq::SliceRandom; - use reth_db::{ - test_utils::create_test_static_files_dir, CanonicalHeaders, HeaderNumbers, - HeaderTerminalDifficulties, Headers, + use reth_db::test_utils::create_test_static_files_dir; + use reth_db_api::{ + transaction::DbTxMut, CanonicalHeaders, HeaderNumbers, HeaderTerminalDifficulties, Headers, }; - use reth_db_api::transaction::DbTxMut; use reth_primitives::{ static_file::{find_fixed_range, SegmentRangeInclusive, DEFAULT_BLOCKS_PER_STATIC_FILE}, EthPrimitives, Receipt, TransactionSigned, diff --git a/crates/storage/provider/src/providers/static_file/writer.rs b/crates/storage/provider/src/providers/static_file/writer.rs index d106745fb..8274b0eda 100644 --- a/crates/storage/provider/src/providers/static_file/writer.rs +++ b/crates/storage/provider/src/providers/static_file/writer.rs @@ -6,8 +6,9 @@ use alloy_consensus::BlockHeader; use alloy_primitives::{BlockHash, BlockNumber, TxNumber, U256}; use parking_lot::{lock_api::RwLockWriteGuard, RawRwLock, RwLock}; use reth_codecs::Compact; -use reth_db::models::{StoredBlockBodyIndices, StoredBlockOmmers, StoredBlockWithdrawals}; -use reth_db_api::models::CompactU256; +use reth_db_api::models::{ + CompactU256, StoredBlockBodyIndices, StoredBlockOmmers, StoredBlockWithdrawals, +}; use reth_nippy_jar::{NippyJar, NippyJarError, NippyJarWriter}; use reth_node_types::NodePrimitives; use reth_primitives::{ diff --git a/crates/storage/provider/src/test_utils/blocks.rs b/crates/storage/provider/src/test_utils/blocks.rs index e72ea7fdf..cfce13fe6 100644 --- a/crates/storage/provider/src/test_utils/blocks.rs +++ b/crates/storage/provider/src/test_utils/blocks.rs @@ -8,8 +8,7 @@ use alloy_primitives::{ use alloy_consensus::Header; use alloy_eips::eip4895::{Withdrawal, Withdrawals}; use alloy_primitives::PrimitiveSignature as Signature; -use reth_db::tables; -use reth_db_api::{database::Database, models::StoredBlockBodyIndices}; +use reth_db_api::{database::Database, models::StoredBlockBodyIndices, tables}; use reth_node_types::NodeTypes; use reth_primitives::{ Account, BlockBody, Receipt, RecoveredBlock, SealedBlock, SealedHeader, Transaction, diff --git a/crates/storage/provider/src/test_utils/mock.rs b/crates/storage/provider/src/test_utils/mock.rs index fd177cc58..873a60806 100644 --- a/crates/storage/provider/src/test_utils/mock.rs +++ b/crates/storage/provider/src/test_utils/mock.rs @@ -16,8 +16,10 @@ use alloy_primitives::{ }; use parking_lot::Mutex; use reth_chainspec::{ChainInfo, EthChainSpec}; -use reth_db::mock::{DatabaseMock, TxMock}; -use reth_db_api::models::{AccountBeforeTx, StoredBlockBodyIndices}; +use reth_db_api::{ + mock::{DatabaseMock, TxMock}, + models::{AccountBeforeTx, StoredBlockBodyIndices}, +}; use reth_execution_types::ExecutionOutcome; use reth_node_types::NodeTypes; use reth_primitives::{ diff --git a/crates/storage/provider/src/writer/mod.rs b/crates/storage/provider/src/writer/mod.rs index 47e9242ac..ae30df93a 100644 --- a/crates/storage/provider/src/writer/mod.rs +++ b/crates/storage/provider/src/writer/mod.rs @@ -5,7 +5,7 @@ use crate::{ }; use alloy_consensus::BlockHeader; use reth_chain_state::{ExecutedBlock, ExecutedBlockWithTrieUpdates}; -use reth_db::transaction::{DbTx, DbTxMut}; +use reth_db_api::transaction::{DbTx, DbTxMut}; use reth_errors::ProviderResult; use reth_primitives::{NodePrimitives, StaticFileSegment}; use reth_primitives_traits::SignedTransaction; @@ -228,10 +228,10 @@ mod tests { test_utils::create_test_provider_factory, AccountReader, StorageTrieWriter, TrieWriter, }; use alloy_primitives::{keccak256, map::HashMap, Address, B256, U256}; - use reth_db::tables; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO}, models::{AccountBeforeTx, BlockNumberAddress}, + tables, transaction::{DbTx, DbTxMut}, }; use reth_execution_types::ExecutionOutcome; diff --git a/crates/storage/storage-api/Cargo.toml b/crates/storage/storage-api/Cargo.toml index fc46af864..8a29c95df 100644 --- a/crates/storage/storage-api/Cargo.toml +++ b/crates/storage/storage-api/Cargo.toml @@ -22,7 +22,6 @@ reth-stages-types.workspace = true reth-storage-errors.workspace = true reth-trie.workspace = true reth-trie-db.workspace = true -reth-db.workspace = true revm-database.workspace = true reth-ethereum-primitives.workspace = true diff --git a/crates/storage/storage-api/src/chain.rs b/crates/storage/storage-api/src/chain.rs index 2d1853988..83eace1a9 100644 --- a/crates/storage/storage-api/src/chain.rs +++ b/crates/storage/storage-api/src/chain.rs @@ -4,10 +4,10 @@ use alloy_consensus::Header; use alloy_primitives::BlockNumber; use core::marker::PhantomData; use reth_chainspec::{ChainSpecProvider, EthereumHardforks}; -use reth_db::tables; use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, models::{StoredBlockOmmers, StoredBlockWithdrawals}, + tables, transaction::{DbTx, DbTxMut}, DbTxUnwindExt, }; diff --git a/crates/storage/storage-api/src/hashing.rs b/crates/storage/storage-api/src/hashing.rs index f3a244506..911dfbdef 100644 --- a/crates/storage/storage-api/src/hashing.rs +++ b/crates/storage/storage-api/src/hashing.rs @@ -29,7 +29,7 @@ pub trait HashingWriter: Send + Sync { range: impl RangeBounds, ) -> ProviderResult>>; - /// Inserts all accounts into the `AccountsHistory` table. + /// Inserts all accounts into [`AccountsHistory`][reth_db_api::tables::AccountsHistory] table. /// /// # Returns /// diff --git a/crates/trie/db/Cargo.toml b/crates/trie/db/Cargo.toml index b7e51be9c..18060e774 100644 --- a/crates/trie/db/Cargo.toml +++ b/crates/trie/db/Cargo.toml @@ -15,9 +15,7 @@ workspace = true # reth reth-primitives-traits.workspace = true reth-execution-errors.workspace = true -reth-db.workspace = true reth-db-api.workspace = true -reth-storage-errors.workspace = true reth-trie.workspace = true revm.workspace = true diff --git a/crates/trie/db/src/commitment.rs b/crates/trie/db/src/commitment.rs index c608aefff..47bfccb46 100644 --- a/crates/trie/db/src/commitment.rs +++ b/crates/trie/db/src/commitment.rs @@ -2,7 +2,7 @@ use crate::{ DatabaseHashedCursorFactory, DatabaseProof, DatabaseStateRoot, DatabaseStorageRoot, DatabaseTrieCursorFactory, DatabaseTrieWitness, }; -use reth_db::transaction::DbTx; +use reth_db_api::transaction::DbTx; use reth_trie::{ proof::Proof, witness::TrieWitness, KeccakKeyHasher, KeyHasher, StateRoot, StorageRoot, }; diff --git a/crates/trie/db/src/hashed_cursor.rs b/crates/trie/db/src/hashed_cursor.rs index c6011ed10..04ee663d7 100644 --- a/crates/trie/db/src/hashed_cursor.rs +++ b/crates/trie/db/src/hashed_cursor.rs @@ -1,8 +1,9 @@ use alloy_primitives::{B256, U256}; -use reth_db::tables; use reth_db_api::{ cursor::{DbCursorRO, DbDupCursorRO}, + tables, transaction::DbTx, + DatabaseError, }; use reth_primitives_traits::Account; use reth_trie::hashed_cursor::{HashedCursor, HashedCursorFactory, HashedStorageCursor}; @@ -29,14 +30,14 @@ impl HashedCursorFactory for DatabaseHashedCursorFactory<'_, TX> { type StorageCursor = DatabaseHashedStorageCursor<::DupCursor>; - fn hashed_account_cursor(&self) -> Result { + fn hashed_account_cursor(&self) -> Result { Ok(DatabaseHashedAccountCursor(self.0.cursor_read::()?)) } fn hashed_storage_cursor( &self, hashed_address: B256, - ) -> Result { + ) -> Result { Ok(DatabaseHashedStorageCursor::new( self.0.cursor_dup_read::()?, hashed_address, @@ -62,11 +63,11 @@ where { type Value = Account; - fn seek(&mut self, key: B256) -> Result, reth_db::DatabaseError> { + fn seek(&mut self, key: B256) -> Result, DatabaseError> { self.0.seek(key) } - fn next(&mut self) -> Result, reth_db::DatabaseError> { + fn next(&mut self) -> Result, DatabaseError> { self.0.next() } } @@ -95,14 +96,11 @@ where { type Value = U256; - fn seek( - &mut self, - subkey: B256, - ) -> Result, reth_db::DatabaseError> { + fn seek(&mut self, subkey: B256) -> Result, DatabaseError> { Ok(self.cursor.seek_by_key_subkey(self.hashed_address, subkey)?.map(|e| (e.key, e.value))) } - fn next(&mut self) -> Result, reth_db::DatabaseError> { + fn next(&mut self) -> Result, DatabaseError> { Ok(self.cursor.next_dup_val()?.map(|e| (e.key, e.value))) } } @@ -111,7 +109,7 @@ impl HashedStorageCursor for DatabaseHashedStorageCursor where C: DbCursorRO + DbDupCursorRO, { - fn is_storage_empty(&mut self) -> Result { + fn is_storage_empty(&mut self) -> Result { Ok(self.cursor.seek_exact(self.hashed_address)?.is_none()) } } diff --git a/crates/trie/db/src/prefix_set.rs b/crates/trie/db/src/prefix_set.rs index e8dd85251..08ab9cba4 100644 --- a/crates/trie/db/src/prefix_set.rs +++ b/crates/trie/db/src/prefix_set.rs @@ -4,10 +4,10 @@ use alloy_primitives::{ }; use core::{marker::PhantomData, ops::RangeInclusive}; use derive_more::Deref; -use reth_db::tables; use reth_db_api::{ cursor::DbCursorRO, models::{AccountBeforeTx, BlockNumberAddress}, + tables, transaction::DbTx, DatabaseError, }; diff --git a/crates/trie/db/src/state.rs b/crates/trie/db/src/state.rs index 31ebc24ab..757e0b98e 100644 --- a/crates/trie/db/src/state.rs +++ b/crates/trie/db/src/state.rs @@ -3,14 +3,14 @@ use alloy_primitives::{ map::{AddressMap, B256Map}, Address, BlockNumber, B256, U256, }; -use reth_db::tables; use reth_db_api::{ cursor::DbCursorRO, models::{AccountBeforeTx, BlockNumberAddress}, + tables, transaction::DbTx, + DatabaseError, }; use reth_execution_errors::StateRootError; -use reth_storage_errors::db::DatabaseError; use reth_trie::{ hashed_cursor::HashedPostStateCursorFactory, trie_cursor::InMemoryTrieCursorFactory, updates::TrieUpdates, HashedPostState, HashedStorage, KeccakKeyHasher, KeyHasher, StateRoot, diff --git a/crates/trie/db/src/storage.rs b/crates/trie/db/src/storage.rs index 5b143ac7e..e7f9bb479 100644 --- a/crates/trie/db/src/storage.rs +++ b/crates/trie/db/src/storage.rs @@ -1,7 +1,8 @@ use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory}; use alloy_primitives::{keccak256, map::hash_map, Address, BlockNumber, B256}; -use reth_db::{cursor::DbCursorRO, models::BlockNumberAddress, tables, DatabaseError}; -use reth_db_api::transaction::DbTx; +use reth_db_api::{ + cursor::DbCursorRO, models::BlockNumberAddress, tables, transaction::DbTx, DatabaseError, +}; use reth_execution_errors::StorageRootError; use reth_trie::{ hashed_cursor::HashedPostStateCursorFactory, HashedPostState, HashedStorage, StorageRoot, diff --git a/crates/trie/db/src/trie_cursor.rs b/crates/trie/db/src/trie_cursor.rs index 4dddc5c4d..ad6b8eac1 100644 --- a/crates/trie/db/src/trie_cursor.rs +++ b/crates/trie/db/src/trie_cursor.rs @@ -1,13 +1,10 @@ use alloy_primitives::B256; -use reth_db::{ - cursor::{DbCursorRW, DbDupCursorRW}, - tables, -}; use reth_db_api::{ - cursor::{DbCursorRO, DbDupCursorRO}, + cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW}, + tables, transaction::DbTx, + DatabaseError, }; -use reth_storage_errors::db::DatabaseError; use reth_trie::{ trie_cursor::{TrieCursor, TrieCursorFactory}, updates::StorageTrieUpdates, diff --git a/crates/trie/db/tests/walker.rs b/crates/trie/db/tests/walker.rs index 2194a2fad..4833afa1c 100644 --- a/crates/trie/db/tests/walker.rs +++ b/crates/trie/db/tests/walker.rs @@ -1,8 +1,7 @@ #![allow(missing_docs)] use alloy_primitives::B256; -use reth_db::tables; -use reth_db_api::{cursor::DbCursorRW, transaction::DbTxMut}; +use reth_db_api::{cursor::DbCursorRW, tables, transaction::DbTxMut}; use reth_provider::test_utils::create_test_provider_factory; use reth_trie::{ prefix_set::PrefixSetMut, trie_cursor::TrieCursor, walker::TrieWalker, BranchNodeCompact, diff --git a/crates/trie/parallel/Cargo.toml b/crates/trie/parallel/Cargo.toml index 3390a00c8..7fd964b42 100644 --- a/crates/trie/parallel/Cargo.toml +++ b/crates/trie/parallel/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] # reth reth-primitives.workspace = true -reth-db.workspace = true +reth-storage-errors.workspace = true reth-trie.workspace = true reth-trie-common.workspace = true reth-trie-db.workspace = true @@ -57,7 +57,6 @@ metrics = ["reth-metrics", "dep:metrics", "reth-trie/metrics"] test-utils = [ "reth-trie/test-utils", "reth-trie-common/test-utils", - "reth-db/test-utils", "reth-primitives/test-utils", "reth-provider/test-utils", "reth-trie-db/test-utils", diff --git a/crates/trie/parallel/src/proof.rs b/crates/trie/parallel/src/proof.rs index 29cc15f0a..2be21dedd 100644 --- a/crates/trie/parallel/src/proof.rs +++ b/crates/trie/parallel/src/proof.rs @@ -5,12 +5,12 @@ use alloy_primitives::{ }; use alloy_rlp::{BufMut, Encodable}; use itertools::Itertools; -use reth_db::DatabaseError; use reth_execution_errors::StorageRootError; use reth_provider::{ providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory, ProviderError, StateCommitmentProvider, }; +use reth_storage_errors::db::DatabaseError; use reth_trie::{ hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory}, node_iter::{TrieElement, TrieNodeIter}, diff --git a/crates/trie/parallel/src/root.rs b/crates/trie/parallel/src/root.rs index 9ee8ed71e..0ace371ff 100644 --- a/crates/trie/parallel/src/root.rs +++ b/crates/trie/parallel/src/root.rs @@ -4,12 +4,12 @@ use crate::{stats::ParallelTrieTracker, storage_root_targets::StorageRootTargets use alloy_primitives::B256; use alloy_rlp::{BufMut, Encodable}; use itertools::Itertools; -use reth_db::DatabaseError; use reth_execution_errors::StorageRootError; use reth_provider::{ providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory, ProviderError, StateCommitmentProvider, }; +use reth_storage_errors::db::DatabaseError; use reth_trie::{ hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory}, node_iter::{TrieElement, TrieNodeIter}, @@ -166,7 +166,7 @@ where let (storage_root, _, updates) = match storage_roots.remove(&hashed_address) { Some(rx) => rx.recv().map_err(|_| { ParallelStateRootError::StorageRoot(StorageRootError::Database( - reth_db::DatabaseError::Other(format!( + DatabaseError::Other(format!( "channel closed for {hashed_address}" )), )) diff --git a/testing/ef-tests/src/models.rs b/testing/ef-tests/src/models.rs index 03b0d82e7..912ce5070 100644 --- a/testing/ef-tests/src/models.rs +++ b/testing/ef-tests/src/models.rs @@ -5,9 +5,9 @@ use alloy_consensus::Header as RethHeader; use alloy_eips::eip4895::Withdrawals; use alloy_primitives::{keccak256, Address, Bloom, Bytes, B256, B64, U256}; use reth_chainspec::{ChainSpec, ChainSpecBuilder}; -use reth_db::tables; use reth_db_api::{ cursor::DbDupCursorRO, + tables, transaction::{DbTx, DbTxMut}, }; use reth_primitives::{Account as RethAccount, Bytecode, SealedHeader, StorageEntry};