Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove chain_spec from ExecutorFactory #6523

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ mod tests {
);
let provider_factory = create_test_provider_factory_with_chain_spec(chain_spec.clone());
let consensus = Arc::new(TestConsensus::default());
let executor_factory = TestExecutorFactory::new(chain_spec.clone());
let executor_factory = TestExecutorFactory::default();
executor_factory.extend(exec_res);

TreeExternals::new(provider_factory, consensus, executor_factory)
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ mod tests {
fn build(self, chain_spec: Arc<ChainSpec>) -> Pipeline<Arc<TempDatabase<DatabaseEnv>>> {
reth_tracing::init_test_tracing();

let executor_factory = TestExecutorFactory::new(chain_spec.clone());
let executor_factory = TestExecutorFactory::default();
executor_factory.extend(self.executor_results);

// Setup pipeline
Expand Down
10 changes: 1 addition & 9 deletions crates/consensus/beacon/src/engine/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,6 @@ where
A: ExecutorFactory,
B: ExecutorFactory,
{
fn chain_spec(&self) -> &ChainSpec {
match self {
EitherExecutorFactory::Left(a) => a.chain_spec(),
EitherExecutorFactory::Right(b) => b.chain_spec(),
}
}

fn with_state<'a, SP: reth_provider::StateProvider + 'a>(
&'a self,
sp: SP,
Expand Down Expand Up @@ -467,8 +460,7 @@ where
// use either test executor or real executor
let executor_factory = match self.base_config.executor_config {
TestExecutorConfig::Test(results) => {
let executor_factory =
TestExecutorFactory::new(self.base_config.chain_spec.clone());
let executor_factory = TestExecutorFactory::default();
executor_factory.extend(results);
EitherExecutorFactory::Left(executor_factory)
}
Expand Down
5 changes: 0 additions & 5 deletions crates/revm/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,4 @@ where
}
evm
}

/// Return internal chainspec
fn chain_spec(&self) -> &ChainSpec {
self.chain_spec.as_ref()
}
}
14 changes: 2 additions & 12 deletions crates/storage/provider/src/test_utils/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};
use parking_lot::Mutex;
use reth_interfaces::executor::BlockExecutionError;
use reth_primitives::{BlockNumber, BlockWithSenders, ChainSpec, PruneModes, Receipt, U256};
use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt, U256};
use std::sync::Arc;
/// Test executor with mocked result.
#[derive(Debug)]
Expand Down Expand Up @@ -61,18 +61,12 @@ impl PrunableBlockExecutor for TestExecutor {
}

/// Executor factory with pre-set execution results.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct TestExecutorFactory {
exec_results: Arc<Mutex<Vec<BundleStateWithReceipts>>>,
chain_spec: Arc<ChainSpec>,
}

impl TestExecutorFactory {
/// Create new instance of test factory.
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
Self { exec_results: Arc::new(Mutex::new(Vec::new())), chain_spec }
}

/// Extend the mocked execution results
pub fn extend(&self, results: Vec<BundleStateWithReceipts>) {
self.exec_results.lock().extend(results);
Expand All @@ -87,8 +81,4 @@ impl ExecutorFactory for TestExecutorFactory {
let exec_res = self.exec_results.lock().pop();
Box::new(TestExecutor(exec_res))
}

fn chain_spec(&self) -> &ChainSpec {
self.chain_spec.as_ref()
}
}
5 changes: 1 addition & 4 deletions crates/storage/provider/src/traits/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{bundle_state::BundleStateWithReceipts, StateProvider};
use reth_interfaces::executor::BlockExecutionError;
use reth_primitives::{BlockNumber, BlockWithSenders, ChainSpec, PruneModes, Receipt, U256};
use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt, U256};
use std::time::Duration;
use tracing::debug;

Expand All @@ -15,9 +15,6 @@ pub trait ExecutorFactory: Send + Sync + 'static {
&'a self,
_sp: SP,
) -> Box<dyn PrunableBlockExecutor + 'a>;

/// Return internal chainspec
fn chain_spec(&self) -> &ChainSpec;
}

/// An executor capable of executing a block.
Expand Down
Loading