Skip to content
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
10 changes: 6 additions & 4 deletions bin/node/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ use clap::Args;
use std::time::Duration;
use url::Url;

use xlayer_builder::args::BuilderArgs;
use xlayer_monitor::FullLinkMonitorArgs;

/// X Layer specific configuration flags
#[derive(Debug, Clone, Args, PartialEq, Eq, Default)]
#[command(next_help_heading = "X Layer")]
pub struct XLayerArgs {
/// Flashblock builder configuration
#[command(flatten)]
pub builder: BuilderArgs,

/// Enable legacy rpc routing
#[command(flatten)]
pub legacy: LegacyRpcArgs,
Expand Down Expand Up @@ -291,10 +296,7 @@ mod tests {
legacy_rpc_url: Some("invalid-url".to_string()),
legacy_rpc_timeout: Duration::from_secs(30),
},
monitor: FullLinkMonitorArgs::default(),
enable_flashblocks_subscription: false,
flashblocks_subscription_max_addresses: 1000,
sequencer_mode: false,
..Default::default()
};

let result = args.validate();
Expand Down
21 changes: 12 additions & 9 deletions bin/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ use reth::{
};
use reth_node_api::FullNodeComponents;
use reth_optimism_cli::Cli;
use reth_optimism_node::OpNode;
use reth_optimism_node::{args::RollupArgs, OpNode};
use reth_rpc_server_types::RethRpcModule;
use xlayer_builder::args::OpRbuilderArgs;

use xlayer_chainspec::XLayerChainSpecParser;
use xlayer_flashblocks::handler::FlashblocksService;
Expand All @@ -36,9 +35,9 @@ static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::ne
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
#[command(next_help_heading = "Rollup")]
struct Args {
/// Upstream rollup args + flashblock specific args
/// Upstream rollup args
#[command(flatten)]
pub node_args: OpRbuilderArgs,
pub rollup_args: RollupArgs,

#[command(flatten)]
pub xlayer_args: XLayerArgs,
Expand Down Expand Up @@ -77,7 +76,7 @@ fn main() {
info!(target: "xlayer::monitor", "Global tracer initialized with output path: {}", args.xlayer_args.monitor.output_path);
}

let op_node = OpNode::new(args.node_args.rollup_args.clone());
let op_node = OpNode::new(args.rollup_args.clone());

let genesis_block = builder.config().chain.genesis().number.unwrap_or_default();
info!("X Layer genesis block = {}", genesis_block);
Expand All @@ -95,7 +94,7 @@ fn main() {
// For X Layer full link monitor
let monitor = XLayerMonitor::new(
xlayer_args.monitor,
args.node_args.flashblocks.enabled,
xlayer_args.builder.flashblocks.enabled,
xlayer_args.sequencer_mode,
);

Expand All @@ -106,7 +105,10 @@ fn main() {

// Create the X Layer payload service builder
// It handles both flashblocks and default modes internally
let payload_builder = XLayerPayloadServiceBuilder::new(args.node_args.clone())?;
let payload_builder = XLayerPayloadServiceBuilder::new(
args.xlayer_args.builder.clone(),
args.rollup_args.compute_pending_block,
)?;

let NodeHandle { node, node_exit_future } = builder
.with_types_and_provider::<OpNode, BlockchainProvider<_>>()
Expand All @@ -120,13 +122,14 @@ fn main() {
let new_op_eth_api = Arc::new(ctx.registry.eth_api().clone());

// Initialize flashblocks RPC service if not in flashblocks sequencer mode
if !args.node_args.flashblocks.enabled {
if !args.xlayer_args.builder.flashblocks.enabled {
if let Some(flashblock_rx) = new_op_eth_api.subscribe_received_flashblocks()
{
let service = FlashblocksService::new(
ctx.node().clone(),
flashblock_rx,
args.node_args.clone(),
args.xlayer_args.builder.flashblocks,
args.rollup_args.flashblocks_url.is_some(),
)?;
service.spawn();
info!(target: "reth::cli", "xlayer flashblocks service initialized");
Expand Down
24 changes: 16 additions & 8 deletions bin/node/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use reth_optimism_evm::OpEvmConfig;
use reth_optimism_node::node::OpPayloadBuilder;
use reth_optimism_payload_builder::config::{OpDAConfig, OpGasLimitConfig};
use xlayer_builder::{
args::OpRbuilderArgs,
args::BuilderArgs,
payload::{BuilderConfig, FlashblocksServiceBuilder},
traits::{NodeBounds, PoolBounds},
};
Expand All @@ -25,12 +25,21 @@ pub struct XLayerPayloadServiceBuilder {
}

impl XLayerPayloadServiceBuilder {
pub fn new(xlayer_builder_args: OpRbuilderArgs) -> eyre::Result<Self> {
Self::with_config(xlayer_builder_args, OpDAConfig::default(), OpGasLimitConfig::default())
pub fn new(
xlayer_builder_args: BuilderArgs,
compute_pending_block: bool,
) -> eyre::Result<Self> {
Self::with_config(
xlayer_builder_args,
compute_pending_block,
OpDAConfig::default(),
OpGasLimitConfig::default(),
)
}

pub fn with_config(
xlayer_builder_args: OpRbuilderArgs,
xlayer_builder_args: BuilderArgs,
compute_pending_block: bool,
da_config: OpDAConfig,
gas_limit_config: OpGasLimitConfig,
) -> eyre::Result<Self> {
Expand All @@ -40,10 +49,9 @@ impl XLayerPayloadServiceBuilder {
builder_config,
)))
} else {
let payload_builder =
OpPayloadBuilder::new(xlayer_builder_args.rollup_args.compute_pending_block)
.with_da_config(da_config)
.with_gas_limit_config(gas_limit_config);
let payload_builder = OpPayloadBuilder::new(compute_pending_block)
.with_da_config(da_config)
.with_gas_limit_config(gas_limit_config);
XLayerPayloadServiceBuilderInner::Default(BasicPayloadServiceBuilder::new(
payload_builder,
))
Expand Down
4 changes: 2 additions & 2 deletions crates/builder/src/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub use op::{FlashblocksArgs, OpRbuilderArgs};
pub use op::{BuilderArgs, FlashblocksArgs};
use reth_optimism_cli::chainspec::OpChainSpecParser;
pub type Cli = reth_optimism_cli::Cli<OpChainSpecParser, OpRbuilderArgs>;
pub type Cli = reth_optimism_cli::Cli<OpChainSpecParser, BuilderArgs>;

mod op;
27 changes: 6 additions & 21 deletions crates/builder/src/args/op.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
//! Additional Node command arguments.
//! Flashblock builder command arguments.
//!
//! Copied from OptimismNode to allow easy extension.

//! clap [Args](clap::Args) for optimism rollup configuration
//! Builder-specific configuration for the flashblock payload builder.

use crate::tx::signer::Signer;
use alloy_primitives::Address;
use anyhow::{anyhow, Result};
use clap::Parser;
use reth_optimism_cli::commands::Commands;
use reth_optimism_node::args::RollupArgs;
use std::path::PathBuf;

/// Parameters for rollup configuration
/// Parameters for the flashblock builder configuration.
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
#[command(next_help_heading = "Rollup")]
pub struct OpRbuilderArgs {
/// Rollup configuration
#[command(flatten)]
pub rollup_args: RollupArgs,
pub struct BuilderArgs {
/// Builder secret key for signing last transaction in block
#[arg(long = "rollup.builder-secret-key", env = "BUILDER_SECRET_KEY")]
pub builder_signer: Option<Signer>,
Expand Down Expand Up @@ -52,7 +45,7 @@ pub struct OpRbuilderArgs {
pub flashblocks: FlashblocksArgs,
}

impl Default for OpRbuilderArgs {
impl Default for BuilderArgs {
fn default() -> Self {
let args = crate::args::Cli::parse_from(["dummy", "node"]);
let Commands::Node(node_command) = args.command else { unreachable!() };
Expand All @@ -71,7 +64,7 @@ fn expand_path(s: &str) -> Result<PathBuf> {
/// Parameters for Flashblocks configuration
/// The names in the struct are prefixed with `flashblocks` to avoid conflicts
/// with the standard block building configuration since these args are flattened
/// into the main `OpRbuilderArgs` struct with the other rollup/node args.
/// into the main `BuilderArgs` struct with the other rollup/node args.
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
pub struct FlashblocksArgs {
/// When set to true, the builder will build flashblocks
Expand Down Expand Up @@ -108,14 +101,6 @@ pub struct FlashblocksArgs {
)]
pub flashblocks_disable_state_root: bool,

/// Whether to builder running with rollup boost
#[arg(
long = "flashblocks.disable-rollup-boost",
default_value = "false",
env = "FLASHBLOCK_DISABLE_ROLLUP_BOOST"
)]
pub flashblocks_disable_rollup_boost: bool,

/// Whether to disable async state root calculation on full payload resolution
#[arg(
long = "flashblocks.disable-async-calculate-state-root",
Expand Down
4 changes: 2 additions & 2 deletions crates/builder/src/metrics/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio_metrics::{RuntimeMetrics, RuntimeMonitor, TaskMetrics, TaskMonitor};

/// Metrics for a single monitored tokio task.
#[derive(Metrics, Clone)]
#[metrics(scope = "op_rbuilder.tokio_task")]
#[metrics(scope = "flashblock_builder.tokio_task")]
pub struct TokioTaskMetricsRecorder {
/// Total number of times the task has been instrumented (spawned)
pub instrumented_count: Counter,
Expand Down Expand Up @@ -52,7 +52,7 @@ pub struct TokioTaskMetricsRecorder {
/// Note: Only stable tokio metrics are exposed here. Additional metrics like
/// steal counts, schedule counts, and overflow counts require the `tokio_unstable` flag.
#[derive(Metrics, Clone)]
#[metrics(scope = "op_rbuilder.tokio_runtime")]
#[metrics(scope = "flashblock_builder.tokio_runtime")]
pub struct TokioRuntimeMetricsRecorder {
/// Number of worker threads in the runtime
pub workers_count: Gauge,
Expand Down
Loading