Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
48 changes: 2 additions & 46 deletions bin/builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,11 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use eyre::Result;
use op_rbuilder::{
args::CliExt,
builders::{BuilderMode, FlashblocksBuilder, StandardBuilder},
launcher::BuilderLauncher,
};
use op_rbuilder::launcher::launch;

#[global_allocator]
static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::new_allocator();

fn main() -> Result<()> {
// Parse CLI arguments with builder-specific configuration
let cli = op_rbuilder::args::Cli::parsed();
let mode = cli.builder_mode();

// Extract telemetry args before configuring CLI (if telemetry feature enabled)
#[cfg(feature = "telemetry")]
let telemetry_args = match &cli.command {
reth_optimism_cli::commands::Commands::Node(node_command) => {
node_command.ext.telemetry.clone()
}
_ => Default::default(),
};

// Configure CLI application
#[cfg(not(feature = "telemetry"))]
let cli_app = cli.configure();

#[cfg(feature = "telemetry")]
let mut cli_app = cli.configure();
#[cfg(feature = "telemetry")]
{
use op_rbuilder::primitives::telemetry::setup_telemetry_layer;
let telemetry_layer = setup_telemetry_layer(&telemetry_args)?;
cli_app.access_tracing_layers()?.add_layer(telemetry_layer);
}

// Launch the builder with the appropriate mode
match mode {
BuilderMode::Standard => {
tracing::info!("Starting OP builder in standard mode");
let launcher = BuilderLauncher::<StandardBuilder>::new();
cli_app.run(launcher)?;
}
BuilderMode::Flashblocks => {
tracing::info!("Starting OP builder in flashblocks mode");
let launcher = BuilderLauncher::<FlashblocksBuilder>::new();
cli_app.run(launcher)?;
}
}

Ok(())
launch()
}
21 changes: 2 additions & 19 deletions crates/builder/op-rbuilder/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@ pub use op::{FlashblocksArgs, OpRbuilderArgs, TelemetryArgs};
use playground::PlaygroundOptions;
use reth_optimism_cli::{chainspec::OpChainSpecParser, commands::Commands};

use crate::{
builders::BuilderMode,
metrics::{LONG_VERSION, SHORT_VERSION},
};
use crate::metrics::{LONG_VERSION, SHORT_VERSION};

mod op;
mod playground;

/// This trait is used to extend Reth's CLI with additional functionality that
/// are specific to the OP builder, such as populating default values for CLI arguments
/// when running in the playground mode or checking the builder mode.
/// when running in the playground mode.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

///
pub trait CliExt {
/// Populates the default values for the CLI arguments when the user specifies
/// the `--builder.playground` flag.
fn populate_defaults(self) -> Self;

/// Returns the builder mode that the node is started with.
fn builder_mode(&self) -> BuilderMode;

/// Returns the Cli instance with the parsed command line arguments
/// and defaults populated if applicable.
fn parsed() -> Self;
Expand Down Expand Up @@ -66,17 +60,6 @@ impl CliExt for Cli {
Self::set_version().populate_defaults()
}

/// Returns the type of builder implementation that the node is started with.
/// Currently supports `Standard` and `Flashblocks` modes.
fn builder_mode(&self) -> BuilderMode {
if let Commands::Node(ref node_command) = self.command
&& node_command.ext.flashblocks.enabled
{
return BuilderMode::Flashblocks;
}
BuilderMode::Standard
}

/// Parses commands and overrides versions
fn set_version() -> Self {
let logs_dir = dirs_next::cache_dir()
Expand Down
13 changes: 3 additions & 10 deletions crates/builder/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,11 @@ 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.
/// with the legacy standard builder configuration (now removed) since these args are
/// flattened into the main `OpRbuilderArgs` 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
/// and will build standard blocks at the chain block time.
///
/// The default value will change in the future once the flashblocks
/// feature is stable.
#[arg(long = "flashblocks.enabled", default_value = "false", env = "ENABLE_FLASHBLOCKS")]
pub enabled: bool,

/// Flashblocks is always enabled; these options tune its behavior.
/// The port that we bind to for the websocket server that provides flashblocks
#[arg(long = "flashblocks.port", env = "FLASHBLOCKS_WS_PORT", default_value = "1111")]
pub flashblocks_port: u16,
Expand Down
197 changes: 0 additions & 197 deletions crates/builder/op-rbuilder/src/builders/flashblocks/builder_tx.rs

This file was deleted.

39 changes: 0 additions & 39 deletions crates/builder/op-rbuilder/src/builders/flashblocks/mod.rs

This file was deleted.

Loading
Loading