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

Propagating OpDAConfig to OpPayloadBuilder #13375

Merged
merged 4 commits into from
Dec 13, 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
6 changes: 4 additions & 2 deletions crates/optimism/bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<OpNode, BlockchainProvider2<_>>()
.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(),
Expand Down
45 changes: 32 additions & 13 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -136,7 +139,7 @@ impl OpNode {

/// Returns the components for the given [`RollupArgs`].
pub fn components<Node>(
args: RollupArgs,
&self,
) -> ComponentsBuilder<
Node,
OpPoolBuilder,
Expand All @@ -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::<Node>()
.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,
Expand Down Expand Up @@ -192,7 +198,7 @@ where
OpAddOns<NodeAdapter<N, <Self::ComponentsBuilder as NodeComponentsBuilder<N>>::Components>>;

fn components_builder(&self) -> Self::ComponentsBuilder {
Self::components(self.args.clone())
Self::components(self)
}

fn add_ons(&self) -> Self::AddOns {
Expand Down Expand Up @@ -494,12 +500,22 @@ pub struct OpPayloadBuilder<Txs = ()> {
/// 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
}
}

Expand All @@ -513,8 +529,8 @@ where
self,
best_transactions: T,
) -> OpPayloadBuilder<T> {
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.
Expand All @@ -537,9 +553,12 @@ where
+ 'static,
Evm: ConfigureEvm<Header = Header, Transaction = TransactionSigned>,
{
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()
Expand Down
5 changes: 3 additions & 2 deletions crates/optimism/node/tests/it/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<OpNode>()
.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(())
Expand Down
Loading