From 197f274b31eeaa0fafa14d2aa5cff0ac2103cce2 Mon Sep 17 00:00:00 2001 From: Tomas Milukas Date: Fri, 13 Dec 2024 15:14:48 +0100 Subject: [PATCH] Propagating OpDAConfig to OpPayloadBuilder (#13375) --- crates/optimism/bin/src/main.rs | 6 ++-- crates/optimism/node/src/node.rs | 45 +++++++++++++++++------- crates/optimism/node/tests/it/builder.rs | 5 +-- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/crates/optimism/bin/src/main.rs b/crates/optimism/bin/src/main.rs index 82fb3c241..f19c38f92 100644 --- a/crates/optimism/bin/src/main.rs +++ b/crates/optimism/bin/src/main.rs @@ -32,10 +32,12 @@ fn main() { let engine_tree_config = TreeConfig::default() .with_persistence_threshold(rollup_args.persistence_threshold) .with_memory_block_buffer_target(rollup_args.memory_block_buffer_target); + + let op_node = OpNode::new(rollup_args.clone()); let handle = builder .with_types_and_provider::>() - .with_components(OpNode::components(rollup_args.clone())) - .with_add_ons(OpNode::new(rollup_args).add_ons()) + .with_components(op_node.components()) + .with_add_ons(op_node.add_ons()) .launch_with_fn(|builder| { let launcher = EngineNodeLauncher::new( builder.task_executor().clone(), diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index 4fe67b819..7d51c99b0 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -25,7 +25,10 @@ use reth_node_builder::{ use reth_optimism_chainspec::OpChainSpec; use reth_optimism_consensus::OpBeaconConsensus; use reth_optimism_evm::{OpEvmConfig, OpExecutionStrategyFactory}; -use reth_optimism_payload_builder::{builder::OpPayloadTransactions, config::OpDAConfig}; +use reth_optimism_payload_builder::{ + builder::OpPayloadTransactions, + config::{OpBuilderConfig, OpDAConfig}, +}; use reth_optimism_primitives::OpPrimitives; use reth_optimism_rpc::{ miner::{MinerApiExtServer, OpMinerExtApi}, @@ -136,7 +139,7 @@ impl OpNode { /// Returns the components for the given [`RollupArgs`]. pub fn components( - args: RollupArgs, + &self, ) -> ComponentsBuilder< Node, OpPoolBuilder, @@ -154,11 +157,14 @@ impl OpNode { >, >, { - let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = args; + let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = + self.args; ComponentsBuilder::default() .node_types::() .pool(OpPoolBuilder::default()) - .payload(OpPayloadBuilder::new(compute_pending_block)) + .payload( + OpPayloadBuilder::new(compute_pending_block).with_da_config(self.da_config.clone()), + ) .network(OpNetworkBuilder { disable_txpool_gossip, disable_discovery_v4: !discovery_v4, @@ -192,7 +198,7 @@ where OpAddOns>::Components>>; fn components_builder(&self) -> Self::ComponentsBuilder { - Self::components(self.args.clone()) + Self::components(self) } fn add_ons(&self) -> Self::AddOns { @@ -494,12 +500,22 @@ pub struct OpPayloadBuilder { /// The type responsible for yielding the best transactions for the payload if mempool /// transactions are allowed. pub best_transactions: Txs, + /// This data availability configuration specifies constraints for the payload builder + /// when assembling payloads + pub da_config: OpDAConfig, } impl OpPayloadBuilder { - /// Create a new instance with the given `compute_pending_block` flag. - pub const fn new(compute_pending_block: bool) -> Self { - Self { compute_pending_block, best_transactions: () } + /// Create a new instance with the given `compute_pending_block` flag and data availability + /// config. + pub fn new(compute_pending_block: bool) -> Self { + Self { compute_pending_block, best_transactions: (), da_config: OpDAConfig::default() } + } + + /// Configure the data availability configuration for the OP payload builder. + pub fn with_da_config(mut self, da_config: OpDAConfig) -> Self { + self.da_config = da_config; + self } } @@ -513,8 +529,8 @@ where self, best_transactions: T, ) -> OpPayloadBuilder { - let Self { compute_pending_block, .. } = self; - OpPayloadBuilder { compute_pending_block, best_transactions } + let Self { compute_pending_block, da_config, .. } = self; + OpPayloadBuilder { compute_pending_block, best_transactions, da_config } } /// A helper method to initialize [`PayloadBuilderService`] with the given EVM config. @@ -537,9 +553,12 @@ where + 'static, Evm: ConfigureEvm
, { - let payload_builder = reth_optimism_payload_builder::OpPayloadBuilder::new(evm_config) - .with_transactions(self.best_transactions) - .set_compute_pending_block(self.compute_pending_block); + let payload_builder = reth_optimism_payload_builder::OpPayloadBuilder::with_builder_config( + evm_config, + OpBuilderConfig { da_config: self.da_config }, + ) + .with_transactions(self.best_transactions) + .set_compute_pending_block(self.compute_pending_block); let conf = ctx.payload_builder_config(); let payload_job_config = BasicPayloadJobGeneratorConfig::default() diff --git a/crates/optimism/node/tests/it/builder.rs b/crates/optimism/node/tests/it/builder.rs index 875b282e0..d64868817 100644 --- a/crates/optimism/node/tests/it/builder.rs +++ b/crates/optimism/node/tests/it/builder.rs @@ -12,11 +12,12 @@ fn test_basic_setup() { let config = NodeConfig::new(BASE_MAINNET.clone()); let db = create_test_rw_db(); let args = RollupArgs::default(); + let op_node = OpNode::new(args); let _builder = NodeBuilder::new(config) .with_database(db) .with_types::() - .with_components(OpNode::components(args.clone())) - .with_add_ons(OpNode::new(args).add_ons()) + .with_components(op_node.components()) + .with_add_ons(op_node.add_ons()) .on_component_initialized(move |ctx| { let _provider = ctx.provider(); Ok(())