feat: integrate ExecutorProvider (#7798)

This commit is contained in:
Matthias Seitz
2024-05-03 13:39:46 +02:00
committed by GitHub
parent ec45ae679f
commit 067b0ff420
74 changed files with 1087 additions and 2027 deletions

View File

@ -51,6 +51,7 @@ reth-stages = { workspace = true, features = ["test-utils"] }
reth-blockchain-tree = { workspace = true, features = ["test-utils"] }
reth-db = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
reth-evm = { workspace = true, features = ["test-utils"] }
reth-rpc-types-compat.workspace = true
reth-rpc.workspace = true
reth-tracing.workspace = true

View File

@ -14,9 +14,9 @@ use reth_downloaders::{
headers::reverse_headers::ReverseHeadersDownloaderBuilder,
};
use reth_ethereum_engine_primitives::EthEngineTypes;
use reth_evm_ethereum::EthEvmConfig;
use reth_evm::{either::Either, test_utils::MockExecutorProvider};
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_interfaces::{
executor::BlockExecutionError,
p2p::{bodies::client::BodiesClient, either::EitherDownloader, headers::client::HeadersClient},
sync::NoopSyncStateUpdater,
test_utils::NoopFullBlockClient,
@ -24,13 +24,10 @@ use reth_interfaces::{
use reth_payload_builder::test_utils::spawn_test_payload_service;
use reth_primitives::{BlockNumber, ChainSpec, FinishedExExHeight, PruneModes, B256};
use reth_provider::{
providers::BlockchainProvider,
test_utils::{create_test_provider_factory_with_chain_spec, TestExecutorFactory},
BundleStateWithReceipts, ExecutorFactory, HeaderSyncMode, PrunableBlockExecutor,
StaticFileProviderFactory,
providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec,
BundleStateWithReceipts, HeaderSyncMode, StaticFileProviderFactory,
};
use reth_prune::Pruner;
use reth_revm::EvmProcessorFactory;
use reth_rpc_types::engine::{
CancunPayloadFields, ExecutionPayload, ForkchoiceState, ForkchoiceUpdated, PayloadStatus,
};
@ -155,31 +152,6 @@ impl Default for TestExecutorConfig {
}
}
/// A type that represents one of two possible executor factories.
#[derive(Debug, Clone)]
pub enum EitherExecutorFactory<A: ExecutorFactory, B: ExecutorFactory> {
/// The first factory variant
Left(A),
/// The second factory variant
Right(B),
}
impl<A, B> ExecutorFactory for EitherExecutorFactory<A, B>
where
A: ExecutorFactory,
B: ExecutorFactory,
{
fn with_state<'a, SP: reth_provider::StateProvider + 'a>(
&'a self,
sp: SP,
) -> Box<dyn PrunableBlockExecutor<Error = BlockExecutionError> + 'a> {
match self {
EitherExecutorFactory::Left(a) => a.with_state::<'a, SP>(sp),
EitherExecutorFactory::Right(b) => b.with_state::<'a, SP>(sp),
}
}
}
/// The basic configuration for a `TestConsensusEngine`, without generics for the client or
/// consensus engine.
#[derive(Debug)]
@ -366,14 +338,13 @@ where
// use either test executor or real executor
let executor_factory = match self.base_config.executor_config {
TestExecutorConfig::Test(results) => {
let executor_factory = TestExecutorFactory::default();
let executor_factory = MockExecutorProvider::default();
executor_factory.extend(results);
EitherExecutorFactory::Left(executor_factory)
Either::Left(executor_factory)
}
TestExecutorConfig::Real => {
Either::Right(EthExecutorProvider::ethereum(self.base_config.chain_spec.clone()))
}
TestExecutorConfig::Real => EitherExecutorFactory::Right(EvmProcessorFactory::new(
self.base_config.chain_spec.clone(),
EthEvmConfig::default(),
)),
};
let static_file_producer = StaticFileProducer::new(