chore(db): move mod tables to db-api (#14540)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
DaniPopes
2025-02-17 21:53:39 +01:00
committed by GitHub
parent 336c3d1fac
commit 482f4557eb
106 changed files with 269 additions and 274 deletions

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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<TX: DbTx + DbTxMut + 'static, N: NodeTypesForProvider> DatabaseProvider<TX,
let (new_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)?;
let parent_number = range.start().saturating_sub(1);
let parent_state_root = self
@ -2590,7 +2588,7 @@ impl<TX: DbTxMut + DbTx + 'static, N: NodeTypes> 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 },

View File

@ -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;

View File

@ -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::{

View File

@ -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,

View File

@ -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};

View File

@ -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};

View File

@ -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,

View File

@ -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::{

View File

@ -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,

View File

@ -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::{

View File

@ -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;