reth_node_builder/components/
execute.rs

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