From e93d36a35e41873050d5259f1c5a7406dcdeb099 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Tue, 6 Aug 2024 17:39:53 +0800 Subject: [PATCH] feat: Support custom EvmConfig for ethereumpayload builder (#10117) --- crates/ethereum/node/src/node.rs | 24 ++++++++++++++++++------ examples/custom-evm/src/main.rs | 11 +++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/crates/ethereum/node/src/node.rs b/crates/ethereum/node/src/node.rs index 264297bc4..319fd2cf0 100644 --- a/crates/ethereum/node/src/node.rs +++ b/crates/ethereum/node/src/node.rs @@ -17,7 +17,7 @@ use reth_node_builder::{ PayloadServiceBuilder, PoolBuilder, }, node::{FullNodeTypes, NodeTypes}, - BuilderContext, Node, PayloadBuilderConfig, PayloadTypes, + BuilderContext, ConfigureEvm, Node, PayloadBuilderConfig, PayloadTypes, }; use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService}; use reth_provider::CanonStateSubscriptions; @@ -56,7 +56,7 @@ impl EthereumNode { ComponentsBuilder::default() .node_types::() .pool(EthereumPoolBuilder::default()) - .payload(EthereumPayloadBuilder::default()) + .payload(EthereumPayloadBuilder::new(EthEvmConfig::default())) .network(EthereumNetworkBuilder::default()) .executor(EthereumExecutorBuilder::default()) .consensus(EthereumConsensusBuilder::default()) @@ -196,12 +196,23 @@ where /// A basic ethereum payload service. #[derive(Debug, Default, Clone)] #[non_exhaustive] -pub struct EthereumPayloadBuilder; +pub struct EthereumPayloadBuilder { + /// The EVM configuration to use for the payload builder. + pub evm_config: Evm, +} -impl PayloadServiceBuilder for EthereumPayloadBuilder +impl EthereumPayloadBuilder { + /// Create a new instance with the given evm config. + pub const fn new(evm_config: EVM) -> Self { + Self { evm_config } + } +} + +impl PayloadServiceBuilder for EthereumPayloadBuilder where - Pool: TransactionPool + Unpin + 'static, Node: FullNodeTypes, + Evm: ConfigureEvm, + Pool: TransactionPool + Unpin + 'static, ::Engine: PayloadTypes< BuiltPayload = EthBuiltPayload, PayloadAttributes = EthPayloadAttributes, @@ -213,7 +224,8 @@ where ctx: &BuilderContext, pool: Pool, ) -> eyre::Result> { - let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::default(); + let payload_builder = + reth_ethereum_payload_builder::EthereumPayloadBuilder::new(self.evm_config); let conf = ctx.payload_builder_config(); let payload_job_config = BasicPayloadJobGeneratorConfig::default() diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index f10f0c3c7..c8b8a20f7 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -22,7 +22,10 @@ use reth_chainspec::{Chain, ChainSpec, Head}; use reth_evm_ethereum::EthEvmConfig; use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes}; use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig}; -use reth_node_ethereum::{node::EthereumAddOns, EthExecutorProvider, EthereumNode}; +use reth_node_ethereum::{ + node::{EthereumAddOns, EthereumPayloadBuilder}, + EthExecutorProvider, EthereumNode, +}; use reth_primitives::{ revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv}, Address, Header, TransactionSigned, U256, @@ -181,7 +184,11 @@ async fn main() -> eyre::Result<()> { // configure the node with regular ethereum types .with_types::() // use default ethereum components but with our executor - .with_components(EthereumNode::components().executor(MyExecutorBuilder::default())) + .with_components( + EthereumNode::components() + .executor(MyExecutorBuilder::default()) + .payload(EthereumPayloadBuilder::new(MyEvmConfig::default())), + ) .with_add_ons::() .launch() .await