Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support custom EvmConfig for ethereumpayload builder #10117

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions crates/ethereum/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,7 +56,7 @@ impl EthereumNode {
ComponentsBuilder::default()
.node_types::<Node>()
.pool(EthereumPoolBuilder::default())
.payload(EthereumPayloadBuilder::default())
.payload(EthereumPayloadBuilder::new(EthEvmConfig::default()))
.network(EthereumNetworkBuilder::default())
.executor(EthereumExecutorBuilder::default())
.consensus(EthereumConsensusBuilder::default())
Expand Down Expand Up @@ -196,12 +196,23 @@ where
/// A basic ethereum payload service.
#[derive(Debug, Default, Clone)]
#[non_exhaustive]
pub struct EthereumPayloadBuilder;
pub struct EthereumPayloadBuilder<Evm = EthEvmConfig> {
/// The EVM configuration to use for the payload builder.
pub evm_config: Evm,
}

impl<EVM> EthereumPayloadBuilder<EVM> {
/// Create a new instance with the given evm config.
pub const fn new(evm_config: EVM) -> Self {
Self { evm_config }
}
}

impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for EthereumPayloadBuilder
impl<Node, Evm, Pool> PayloadServiceBuilder<Node, Pool> for EthereumPayloadBuilder<Evm>
where
Pool: TransactionPool + Unpin + 'static,
Node: FullNodeTypes,
Evm: ConfigureEvm,
Pool: TransactionPool + Unpin + 'static,
<Node as NodeTypes>::Engine: PayloadTypes<
BuiltPayload = EthBuiltPayload,
PayloadAttributes = EthPayloadAttributes,
Expand All @@ -213,7 +224,8 @@ where
ctx: &BuilderContext<Node>,
pool: Pool,
) -> eyre::Result<PayloadBuilderHandle<Node::Engine>> {
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()
Expand Down
11 changes: 9 additions & 2 deletions examples/custom-evm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -181,7 +184,11 @@ async fn main() -> eyre::Result<()> {
// configure the node with regular ethereum types
.with_types::<EthereumNode>()
// 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::<EthereumAddOns>()
.launch()
.await
Expand Down
Loading