chore: remove BlockExecutorProvider trait (#15989)

Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
This commit is contained in:
Federico Gimenez
2025-05-06 13:34:37 +02:00
committed by GitHub
parent cbdb81069f
commit 699b3fde1b
56 changed files with 411 additions and 880 deletions

View File

@@ -12,6 +12,7 @@ use crate::{
rpc::{RethRpcAddOns, RethRpcServerHandles, RpcContext},
AddOns, FullNode,
};
use reth_exex::ExExContext;
use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes};
use reth_node_core::node_config::NodeConfig;
@@ -91,7 +92,6 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeTypes for NodeAdapter<T, C>
impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<T, C> {
type Pool = C::Pool;
type Evm = C::Evm;
type Executor = C::Executor;
type Consensus = C::Consensus;
type Network = C::Network;
@@ -103,10 +103,6 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
self.components.evm_config()
}
fn block_executor(&self) -> &Self::Executor {
self.components.block_executor()
}
fn consensus(&self) -> &Self::Consensus {
self.components.consensus()
}

View File

@@ -8,7 +8,6 @@ use crate::{
BuilderContext, ConfigureEvm, FullNodeTypes,
};
use reth_consensus::{ConsensusError, FullConsensus};
use reth_evm::execute::BlockExecutorProvider;
use reth_network::NetworkPrimitives;
use reth_node_api::{BlockTy, BodyTy, HeaderTy, PrimitivesTy, TxTy};
use reth_transaction_pool::{PoolTransaction, TransactionPool};
@@ -317,14 +316,8 @@ where
ExecB: ExecutorBuilder<Node>,
ConsB: ConsensusBuilder<Node>,
{
type Components = Components<
Node,
NetworkB::Primitives,
PoolB::Pool,
ExecB::EVM,
ExecB::Executor,
ConsB::Consensus,
>;
type Components =
Components<Node, NetworkB::Primitives, PoolB::Pool, ExecB::EVM, ConsB::Consensus>;
async fn build_components(
self,
@@ -339,7 +332,7 @@ where
_marker,
} = self;
let (evm_config, executor) = evm_builder.build_evm(context).await?;
let evm_config = evm_builder.build_evm(context).await?;
let pool = pool_builder.build_pool(context).await?;
let network = network_builder.build_network(context, pool.clone()).await?;
let payload_builder_handle = payload_builder
@@ -352,7 +345,6 @@ where
evm_config,
network,
payload_builder_handle,
executor,
consensus,
})
}
@@ -391,7 +383,7 @@ pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {
) -> impl Future<Output = eyre::Result<Self::Components>> + Send;
}
impl<Node, N, F, Fut, Pool, EVM, Executor, Cons> NodeComponentsBuilder<Node> for F
impl<Node, N, F, Fut, Pool, EVM, Cons> NodeComponentsBuilder<Node> for F
where
N: NetworkPrimitives<
BlockHeader = HeaderTy<Node::Types>,
@@ -400,16 +392,15 @@ where
>,
Node: FullNodeTypes,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Components<Node, N, Pool, EVM, Executor, Cons>>> + Send,
Fut: Future<Output = eyre::Result<Components<Node, N, Pool, EVM, Cons>>> + Send,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin
+ 'static,
EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static,
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
Cons:
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
{
type Components = Components<Node, N, Pool, EVM, Executor, Cons>;
type Components = Components<Node, N, Pool, EVM, Cons>;
fn build_components(
self,

View File

@@ -1,6 +1,5 @@
//! EVM component for the node builder.
use crate::{BuilderContext, ConfigureEvm, FullNodeTypes};
use reth_evm::execute::BlockExecutorProvider;
use reth_node_api::PrimitivesTy;
use std::future::Future;
@@ -11,31 +10,26 @@ pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
/// This provides the node with the necessary configuration to configure an EVM.
type EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static;
/// The type that knows how to execute blocks.
type Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>;
/// Creates the EVM config.
fn build_evm(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<(Self::EVM, Self::Executor)>> + Send;
) -> impl Future<Output = eyre::Result<Self::EVM>> + Send;
}
impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F
impl<Node, F, Fut, EVM> ExecutorBuilder<Node> for F
where
Node: FullNodeTypes,
EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static,
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<(EVM, Executor)>> + Send,
Fut: Future<Output = eyre::Result<EVM>> + Send,
{
type EVM = EVM;
type Executor = Executor;
fn build_evm(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<(Self::EVM, Self::Executor)>> {
) -> impl Future<Output = eyre::Result<Self::EVM>> {
self(ctx)
}
}

View File

@@ -20,13 +20,13 @@ pub use execute::*;
pub use network::*;
pub use payload::*;
pub use pool::*;
use reth_network_p2p::BlockClient;
use reth_payload_builder::PayloadBuilderHandle;
use std::fmt::Debug;
use crate::{ConfigureEvm, FullNodeTypes};
use reth_consensus::{ConsensusError, FullConsensus};
use reth_evm::execute::BlockExecutorProvider;
use reth_network::{NetworkHandle, NetworkPrimitives};
use reth_network_api::FullNetwork;
use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, PrimitivesTy, TxTy};
@@ -44,9 +44,6 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Debug + Unpin + Send + Sync
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
type Evm: ConfigureEvm<Primitives = <T::Types as NodeTypes>::Primitives>;
/// The type that knows how to execute blocks.
type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>;
/// The consensus type of the node.
type Consensus: FullConsensus<<T::Types as NodeTypes>::Primitives, Error = ConsensusError>
+ Clone
@@ -62,9 +59,6 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Debug + Unpin + Send + Sync
/// Returns the node's evm config.
fn evm_config(&self) -> &Self::Evm;
/// Returns the node's executor type.
fn block_executor(&self) -> &Self::Executor;
/// Returns the node's consensus type.
fn consensus(&self) -> &Self::Consensus;
@@ -80,13 +74,11 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Debug + Unpin + Send + Sync
///
/// This provides access to all the components of the node.
#[derive(Debug)]
pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Executor, Consensus> {
pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Consensus> {
/// The transaction pool of the node.
pub transaction_pool: Pool,
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
pub evm_config: EVM,
/// The node's executor type used to execute individual blocks and batches of blocks.
pub executor: Executor,
/// The consensus implementation of the node.
pub consensus: Consensus,
/// The network implementation of the node.
@@ -95,8 +87,7 @@ pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Exec
pub payload_builder_handle: PayloadBuilderHandle<<Node::Types as NodeTypes>::Payload>,
}
impl<Node, Pool, EVM, Executor, Cons, N> NodeComponents<Node>
for Components<Node, N, Pool, EVM, Executor, Cons>
impl<Node, Pool, EVM, Cons, N> NodeComponents<Node> for Components<Node, N, Pool, EVM, Cons>
where
Node: FullNodeTypes,
N: NetworkPrimitives<
@@ -108,13 +99,11 @@ where
+ Unpin
+ 'static,
EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static,
Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
Cons:
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
{
type Pool = Pool;
type Evm = EVM;
type Executor = Executor;
type Consensus = Cons;
type Network = NetworkHandle<N>;
@@ -126,10 +115,6 @@ where
&self.evm_config
}
fn block_executor(&self) -> &Self::Executor {
&self.executor
}
fn consensus(&self) -> &Self::Consensus {
&self.consensus
}
@@ -143,20 +128,18 @@ where
}
}
impl<Node, N, Pool, EVM, Executor, Cons> Clone for Components<Node, N, Pool, EVM, Executor, Cons>
impl<Node, N, Pool, EVM, Cons> Clone for Components<Node, N, Pool, EVM, Cons>
where
N: NetworkPrimitives,
Node: FullNodeTypes,
Pool: TransactionPool,
EVM: ConfigureEvm,
Executor: BlockExecutorProvider,
Cons: Clone,
{
fn clone(&self) -> Self {
Self {
transaction_pool: self.transaction_pool.clone(),
evm_config: self.evm_config.clone(),
executor: self.executor.clone(),
consensus: self.consensus.clone(),
network: self.network.clone(),
payload_builder_handle: self.payload_builder_handle.clone(),

View File

@@ -17,7 +17,7 @@ use reth_db_common::init::{init_genesis, InitStorageError};
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
use reth_engine_local::MiningMode;
use reth_engine_tree::tree::{InvalidBlockHook, InvalidBlockHooks, NoopInvalidBlockHook};
use reth_evm::{execute::BasicBlockExecutorProvider, noop::NoopEvmConfig, ConfigureEvm};
use reth_evm::{noop::NoopEvmConfig, ConfigureEvm};
use reth_fs_util as fs;
use reth_invalid_block_hooks::InvalidBlockWitnessHook;
use reth_network_p2p::headers::client::HeadersClient;
@@ -423,7 +423,7 @@ where
Arc::new(NoopConsensus::default()),
NoopHeaderDownloader::default(),
NoopBodiesDownloader::default(),
BasicBlockExecutorProvider::new(NoopEvmConfig::<Evm>::default()),
NoopEvmConfig::<Evm>::default(),
self.toml_config().stages.clone(),
self.prune_modes(),
))
@@ -905,7 +905,7 @@ where
Ok(match hook {
InvalidBlockHookType::Witness => Box::new(InvalidBlockWitnessHook::new(
self.blockchain_db().clone(),
self.components().block_executor().clone(),
self.components().evm_config().clone(),
output_directory,
healthy_node_rpc_client.clone(),
)),

View File

@@ -163,7 +163,7 @@ where
ctx.prune_config(),
max_block,
static_file_producer,
ctx.components().block_executor().clone(),
ctx.components().evm_config().clone(),
pipeline_exex_handle,
)?;
@@ -362,7 +362,6 @@ where
let full_node = FullNode {
evm_config: ctx.components().evm_config().clone(),
block_executor: ctx.components().block_executor().clone(),
pool: ctx.components().pool().clone(),
network: ctx.components().network().clone(),
provider: ctx.node_adapter().provider.clone(),

View File

@@ -69,7 +69,7 @@ impl<Node: FullNodeComponents + Clone> ExExLauncher<Node> {
id.clone(),
head,
components.provider().clone(),
components.block_executor().clone(),
components.evm_config().clone(),
exex_wal.handle(),
);
exex_handles.push(handle);

View File

@@ -1,12 +1,13 @@
// re-export the node api types
pub use reth_node_api::{FullNodeTypes, NodeTypes};
use reth_payload_builder::PayloadBuilderHandle;
use crate::{components::NodeComponentsBuilder, rpc::RethRpcAddOns, NodeAdapter, NodeAddOns};
use reth_node_api::{EngineTypes, FullNodeComponents, PayloadTypes};
use reth_node_core::{
dirs::{ChainPath, DataDirPath},
node_config::NodeConfig,
};
use reth_payload_builder::PayloadBuilderHandle;
use reth_provider::ChainSpecProvider;
use reth_rpc_api::EngineApiClient;
use reth_rpc_builder::{auth::AuthServerHandle, RpcServerHandle};
@@ -18,8 +19,6 @@ use std::{
sync::Arc,
};
use crate::{components::NodeComponentsBuilder, rpc::RethRpcAddOns, NodeAdapter, NodeAddOns};
/// A [`crate::Node`] is a [`NodeTypes`] that comes with preconfigured components.
///
/// This can be used to configure the builder with a preset of components.
@@ -102,8 +101,6 @@ where
pub struct FullNode<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> {
/// The evm configuration.
pub evm_config: Node::Evm,
/// The executor of the node.
pub block_executor: Node::Executor,
/// The node's transaction pool.
pub pool: Node::Pool,
/// Handle to the node's network.
@@ -126,7 +123,6 @@ impl<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> Clone for FullNode<Node
fn clone(&self) -> Self {
Self {
evm_config: self.evm_config.clone(),
block_executor: self.block_executor.clone(),
pool: self.pool.clone(),
network: self.network.clone(),
provider: self.provider.clone(),

View File

@@ -195,7 +195,7 @@ pub struct RpcRegistry<Node: FullNodeComponents, EthApi: EthApiTypes> {
Node::Network,
TaskExecutor,
EthApi,
Node::Executor,
Node::Evm,
Node::Consensus,
>,
}
@@ -211,7 +211,7 @@ where
Node::Network,
TaskExecutor,
EthApi,
Node::Executor,
Node::Evm,
Node::Consensus,
>;
@@ -497,7 +497,6 @@ where
.with_network(node.network().clone())
.with_executor(node.task_executor().clone())
.with_evm_config(node.evm_config().clone())
.with_block_executor(node.block_executor().clone())
.with_consensus(node.consensus().clone())
.build_with_auth_server(module_config, engine_api, eth_api);

View File

@@ -10,7 +10,7 @@ use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
headers::reverse_headers::ReverseHeadersDownloaderBuilder,
};
use reth_evm::execute::BlockExecutorProvider;
use reth_evm::ConfigureEvm;
use reth_exex::ExExManagerHandle;
use reth_network_p2p::{
bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader, BlockClient,
@@ -25,7 +25,7 @@ use tokio::sync::watch;
/// Constructs a [Pipeline] that's wired to the network
#[expect(clippy::too_many_arguments)]
pub fn build_networked_pipeline<N, Client, Executor>(
pub fn build_networked_pipeline<N, Client, Evm>(
config: &StageConfig,
client: Client,
consensus: Arc<dyn FullConsensus<N::Primitives, Error = ConsensusError>>,
@@ -35,13 +35,13 @@ pub fn build_networked_pipeline<N, Client, Executor>(
prune_config: Option<PruneConfig>,
max_block: Option<BlockNumber>,
static_file_producer: StaticFileProducer<ProviderFactory<N>>,
executor: Executor,
evm_config: Evm,
exex_manager_handle: ExExManagerHandle<N::Primitives>,
) -> eyre::Result<Pipeline<N>>
where
N: ProviderNodeTypes,
Client: BlockClient<Block = BlockTy<N>> + 'static,
Executor: BlockExecutorProvider<Primitives = N::Primitives>,
Evm: ConfigureEvm<Primitives = N::Primitives> + 'static,
{
// building network downloaders using the fetch client
let header_downloader = ReverseHeadersDownloaderBuilder::new(config.headers)
@@ -62,7 +62,7 @@ where
metrics_tx,
prune_config,
static_file_producer,
executor,
evm_config,
exex_manager_handle,
)?;
@@ -71,7 +71,7 @@ where
/// Builds the [Pipeline] with the given [`ProviderFactory`] and downloaders.
#[expect(clippy::too_many_arguments)]
pub fn build_pipeline<N, H, B, Executor>(
pub fn build_pipeline<N, H, B, Evm>(
provider_factory: ProviderFactory<N>,
stage_config: &StageConfig,
header_downloader: H,
@@ -81,14 +81,14 @@ pub fn build_pipeline<N, H, B, Executor>(
metrics_tx: reth_stages::MetricEventsSender,
prune_config: Option<PruneConfig>,
static_file_producer: StaticFileProducer<ProviderFactory<N>>,
executor: Executor,
evm_config: Evm,
exex_manager_handle: ExExManagerHandle<N::Primitives>,
) -> eyre::Result<Pipeline<N>>
where
N: ProviderNodeTypes,
H: HeaderDownloader<Header = HeaderTy<N>> + 'static,
B: BodyDownloader<Block = BlockTy<N>> + 'static,
Executor: BlockExecutorProvider<Primitives = N::Primitives>,
Evm: ConfigureEvm<Primitives = N::Primitives> + 'static,
{
let mut builder = Pipeline::<N>::builder();
@@ -111,12 +111,12 @@ where
Arc::clone(&consensus),
header_downloader,
body_downloader,
executor.clone(),
evm_config.clone(),
stage_config.clone(),
prune_modes,
)
.set(ExecutionStage::new(
executor,
evm_config,
consensus,
stage_config.execution.into(),
stage_config.execution_external_clean_threshold(),