diff --git a/crates/exex/exex/Cargo.toml b/crates/exex/exex/Cargo.toml index e2a364988b..ec86deb6f4 100644 --- a/crates/exex/exex/Cargo.toml +++ b/crates/exex/exex/Cargo.toml @@ -29,7 +29,6 @@ reth-evm.workspace = true reth-prune-types.workspace = true reth-revm.workspace = true reth-stages-api.workspace = true -reth-db-api.workspace = true ## async tokio.workspace = true @@ -48,6 +47,7 @@ reth-blockchain-tree.workspace = true reth-db-common.workspace = true reth-node-api.workspace = true reth-provider = { workspace = true, features = ["test-utils"] } +reth-db-api.workspace = true secp256k1.workspace = true diff --git a/crates/exex/exex/src/backfill.rs b/crates/exex/exex/src/backfill.rs index 0b5895643d..36f0057343 100644 --- a/crates/exex/exex/src/backfill.rs +++ b/crates/exex/exex/src/backfill.rs @@ -1,17 +1,17 @@ -use reth_db_api::database::Database; use reth_evm::execute::{ BatchExecutor, BlockExecutionError, BlockExecutionOutput, BlockExecutorProvider, Executor, }; use reth_node_api::FullNodeComponents; use reth_primitives::{Block, BlockNumber, BlockWithSenders, Receipt}; use reth_primitives_traits::format_gas_throughput; -use reth_provider::{Chain, FullProvider, ProviderError, TransactionVariant}; +use reth_provider::{ + BlockReader, Chain, HeaderProvider, ProviderError, StateProviderFactory, TransactionVariant, +}; use reth_prune_types::PruneModes; use reth_revm::database::StateProviderDatabase; use reth_stages_api::ExecutionStageThresholds; use reth_tracing::tracing::{debug, trace}; use std::{ - marker::PhantomData, ops::RangeInclusive, time::{Duration, Instant}, }; @@ -51,14 +51,13 @@ impl BackfillJobFactory { impl BackfillJobFactory { /// Creates a new backfill job for the given range. - pub fn backfill(&self, range: RangeInclusive) -> BackfillJob { + pub fn backfill(&self, range: RangeInclusive) -> BackfillJob { BackfillJob { executor: self.executor.clone(), provider: self.provider.clone(), prune_modes: self.prune_modes.clone(), range, thresholds: self.thresholds.clone(), - _db: PhantomData, } } } @@ -80,20 +79,18 @@ impl BackfillJobFactory<(), ()> { /// It implements [`Iterator`] that executes blocks in batches according to the provided thresholds /// and yields [`Chain`] #[derive(Debug)] -pub struct BackfillJob { +pub struct BackfillJob { executor: E, provider: P, prune_modes: PruneModes, thresholds: ExecutionStageThresholds, range: RangeInclusive, - _db: PhantomData, } -impl Iterator for BackfillJob +impl Iterator for BackfillJob where E: BlockExecutorProvider, - DB: Database, - P: FullProvider, + P: HeaderProvider + BlockReader + StateProviderFactory, { type Item = Result; @@ -106,11 +103,10 @@ where } } -impl BackfillJob +impl BackfillJob where E: BlockExecutorProvider, - DB: Database, - P: FullProvider, + P: BlockReader + HeaderProvider + StateProviderFactory, { fn execute_range(&mut self) -> Result { let mut executor = self.executor.batch_executor(StateProviderDatabase::new( @@ -197,21 +193,16 @@ where } } -impl BackfillJob { +impl BackfillJob { /// Converts the backfill job into a single block backfill job. - pub fn into_single_blocks(self) -> SingleBlockBackfillJob { + pub fn into_single_blocks(self) -> SingleBlockBackfillJob { self.into() } } -impl From> for SingleBlockBackfillJob { - fn from(value: BackfillJob) -> Self { - Self { - executor: value.executor, - provider: value.provider, - range: value.range, - _db: PhantomData, - } +impl From> for SingleBlockBackfillJob { + fn from(value: BackfillJob) -> Self { + Self { executor: value.executor, provider: value.provider, range: value.range } } } @@ -220,18 +211,16 @@ impl From> for SingleBlockBackfillJob /// It implements [`Iterator`] which executes a block each time the /// iterator is advanced and yields ([`BlockWithSenders`], [`BlockExecutionOutput`]) #[derive(Debug)] -pub struct SingleBlockBackfillJob { +pub struct SingleBlockBackfillJob { executor: E, provider: P, range: RangeInclusive, - _db: PhantomData, } -impl Iterator for SingleBlockBackfillJob +impl Iterator for SingleBlockBackfillJob where E: BlockExecutorProvider, - DB: Database, - P: FullProvider, + P: HeaderProvider + BlockReader + StateProviderFactory, { type Item = Result<(BlockWithSenders, BlockExecutionOutput), BlockExecutionError>; @@ -240,11 +229,10 @@ where } } -impl SingleBlockBackfillJob +impl SingleBlockBackfillJob where E: BlockExecutorProvider, - DB: Database, - P: FullProvider, + P: HeaderProvider + BlockReader + StateProviderFactory, { fn execute_block( &self,