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

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

View File

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

View File

@ -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<D: BodyDownloader> {
/// The body downloader.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<(u64, Address), Box<SenderRecove
/// The sender recovery stage iterates over existing transactions,
/// recovers the transaction signer and stores them
/// in [`TransactionSenders`][reth_db::tables::TransactionSenders] table.
/// in [`TransactionSenders`][reth_db_api::tables::TransactionSenders] table.
#[derive(Clone, Debug)]
pub struct SenderRecoveryStage {
/// The size of inserted items after which the control
@ -70,9 +72,9 @@ where
}
/// Retrieve the range of transactions to iterate over by querying
/// [`BlockBodyIndices`][reth_db::tables::BlockBodyIndices],
/// [`BlockBodyIndices`][reth_db_api::tables::BlockBodyIndices],
/// collect transactions within that range, recover signer for each transaction and store
/// entries in the [`TransactionSenders`][reth_db::tables::TransactionSenders] table.
/// entries in the [`TransactionSenders`][reth_db_api::tables::TransactionSenders] table.
fn execute(&mut self, provider: &Provider, input: ExecInput) -> Result<ExecOutput, StageError> {
if input.target_reached() {
return Ok(ExecOutput::done(input.checkpoint()))

View File

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

View File

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

View File

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