Skip to content

Commit

Permalink
chore(db): move mod tables to db-api (#14540)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
DaniPopes and mattsse authored Feb 17, 2025
1 parent 336c3d1 commit 482f455
Show file tree
Hide file tree
Showing 106 changed files with 269 additions and 274 deletions.
8 changes: 1 addition & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
7 changes: 5 additions & 2 deletions crates/cli/commands/src/db/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion crates/cli/commands/src/db/clear.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
6 changes: 4 additions & 2 deletions crates/cli/commands/src/db/diff.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
16 changes: 9 additions & 7 deletions crates/cli/commands/src/db/get.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/db/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 4 additions & 2 deletions crates/cli/commands/src/db/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 1 addition & 2 deletions crates/cli/commands/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/recover/storage_tries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
7 changes: 5 additions & 2 deletions crates/cli/commands/src/stage/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions crates/cli/commands/src/stage/dump/execution.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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<N, E, C>(
Expand Down
7 changes: 3 additions & 4 deletions crates/cli/commands/src/stage/dump/hashing_account.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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::{
providers::{ProviderNodeTypes, StaticFileProvider},
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<N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>>(
Expand Down
7 changes: 3 additions & 4 deletions crates/cli/commands/src/stage/dump/hashing_storage.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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::{
providers::{ProviderNodeTypes, StaticFileProvider},
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<N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>>(
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/stage/dump/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/stage/dump/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions crates/cli/commands/src/test_vectors/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions crates/engine/tree/src/tree/trie_updates.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::collections::BTreeSet;

use alloy_primitives::{map::HashMap, B256};
use reth_db::DatabaseError;
use reth_trie::{
trie_cursor::{TrieCursor, TrieCursorFactory},
updates::{StorageTrieUpdates, TrieUpdates},
BranchNodeCompact, Nibbles,
};
use std::collections::BTreeSet;
use tracing::warn;

#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions crates/net/downloaders/src/bodies/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions crates/optimism/cli/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/cli/src/commands/import_receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion crates/prune/prune/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/prune/prune/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
5 changes: 2 additions & 3 deletions crates/prune/prune/src/db_ext.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions crates/prune/prune/src/error.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/prune/prune/src/segments/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 482f455

Please sign in to comment.