reth_node_builder/components/
execute.rs

1//! EVM component for the node builder.
2use crate::{BuilderContext, ConfigureEvm, FullNodeTypes};
3use reth_evm::execute::BlockExecutorProvider;
4use reth_node_api::PrimitivesTy;
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<Primitives = PrimitivesTy<Node::Types>> + 'static;
13
14    /// The type that knows how to execute blocks.
15    type Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>;
16
17    /// Creates the EVM config.
18    fn build_evm(
19        self,
20        ctx: &BuilderContext<Node>,
21    ) -> impl Future<Output = eyre::Result<(Self::EVM, Self::Executor)>> + Send;
22}
23
24impl<Node, F, Fut, EVM, Executor> ExecutorBuilder<Node> for F
25where
26    Node: FullNodeTypes,
27    EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static,
28    Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
29    F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
30    Fut: Future<Output = eyre::Result<(EVM, Executor)>> + Send,
31{
32    type EVM = EVM;
33    type Executor = Executor;
34
35    fn build_evm(
36        self,
37        ctx: &BuilderContext<Node>,
38    ) -> impl Future<Output = eyre::Result<(Self::EVM, Self::Executor)>> {
39        self(ctx)
40    }
41}