From 027ac6cd960c21e04516bb2cb79836cd4b0f88a8 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Tue, 6 Aug 2024 10:05:15 +0800 Subject: [PATCH 1/2] Support custom EvmConfig for ethereumpayload builder --- crates/ethereum/node/src/node.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/ethereum/node/src/node.rs b/crates/ethereum/node/src/node.rs index 264297bc406a..319fd2cf0fb9 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 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 +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() From e11f3feb41a049d06d8228c01bd53b705501afbc Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Tue, 6 Aug 2024 10:19:48 +0800 Subject: [PATCH 2/2] update example custom_evm --- examples/custom-evm/src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index f10f0c3c73ea..c8b8a20f7a4c 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