reth_node_builder/components/
execute.rs

1//! EVM component for the node builder.
2use crate::{BuilderContext, FullNodeTypes};
3use reth_evm::execute::BlockExecutorProvider;
4use reth_node_api::{ConfigureEvm, HeaderTy, TxTy};
5use std::future::Future;
6
7/// A type that knows how to build the executor types.
8pub trait ExecutorBuilder<Node: FullNodeTypes>: Send {
9    /// The EVM config to use.
10    ///
11    /// This provides the node with the necessary configuration to configure an EVM.
12    type EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>;
13
14    /// The type that knows how to execute blocks.
15    type Executor: BlockExecutorProvider<
16        Primitives = <Node::Types as reth_node_api::NodeTypes>::Primitives,
17    >;
18
19    /// Creates the EVM config.
20    fn build_evm(
21        self,
22        ctx: &BuilderContext<Node>,
23    ) -> impl Future<Output = eyre::Result<(Self::EVM, Self::Executor)>> + Send;
24}
25
26impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F
27where
28    Node: FullNodeTypes,
29    EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
30    Executor:
31        BlockExecutorProvider<Primitives = <Node::Types as reth_node_api::NodeTypes>::Primitives>,
32    F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
33    Fut: Future<Output = eyre::Result<(EVM, Executor)>> + Send,
34{
35    type EVM = EVM;
36    type Executor = Executor;
37
38    fn build_evm(
39        self,
40        ctx: &BuilderContext<Node>,
41    ) -> impl Future<Output = eyre::Result<(Self::EVM, Self::Executor)>> {
42        self(ctx)
43    }
44}