Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl CliExt for Cli {
/// Currently supports `Standard` and `Flashblocks` modes.
fn builder_mode(&self) -> BuilderMode {
if let Commands::Node(ref node_command) = self.command {
if node_command.ext.enable_flashblocks {
if node_command.ext.flashblocks.enable_flashblocks {
return BuilderMode::Flashblocks;
}
}
Expand Down
71 changes: 45 additions & 26 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,14 @@ pub struct OpRbuilderArgs {
#[arg(long = "rollup.builder-secret-key", env = "BUILDER_SECRET_KEY")]
pub builder_signer: Option<Signer>,

/// 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 = "rollup.enable-flashblocks",
default_value = "false",
env = "ENABLE_FLASHBLOCKS"
)]
pub enable_flashblocks: bool,

/// Websocket port for flashblock payload builder
#[arg(
long = "rollup.flashblocks-ws-url",
env = "FLASHBLOCKS_WS_URL",
default_value = "127.0.0.1:1111"
)]
pub flashblocks_ws_url: String,
/// chain block time in milliseconds
#[arg(
long = "rollup.chain-block-time",
default_value = "1000",
env = "CHAIN_BLOCK_TIME"
)]
pub chain_block_time: u64,
/// flashblock block time in milliseconds
#[arg(
long = "rollup.flashblock-block-time",
default_value = "250",
env = "FLASHBLOCK_BLOCK_TIME"
)]
pub flashblock_block_time: u64,

/// Signals whether to log pool transaction events
#[arg(long = "builder.log-pool-transactions", default_value = "false")]
pub log_pool_transactions: bool,
Expand All @@ -71,6 +46,9 @@ pub struct OpRbuilderArgs {
env = "PLAYGROUND_DIR",
)]
pub playground: Option<PathBuf>,

#[command(flatten)]
pub flashblocks: FlashblocksArgs,
}

fn expand_path(s: &str) -> Result<PathBuf, String> {
Expand All @@ -80,3 +58,44 @@ fn expand_path(s: &str) -> Result<PathBuf, String> {
.parse()
.map_err(|e| format!("invalid path after expansion: {e}"))
}

/// Parameters for Flashblocks configuration
#[derive(Debug, Clone, Default, 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 = "rollup.enable-flashblocks",
default_value = "false",
env = "ENABLE_FLASHBLOCKS"
)]
pub enable_flashblocks: bool,

/// 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 port: u16,

/// The address that we bind to for the websocket server that provides flashblocks
#[arg(long = "flashblocks.addr", env = "FLASHBLOCKS_WS_ADDR")]
pub addr: String,

/// flashblock block time in milliseconds
#[arg(
long = "rollup.flashblock-block-time",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can have a followup issue to deprecate this flags.

default_value = "250",
env = "FLASHBLOCK_BLOCK_TIME"
)]
pub block_time: u64,

/// Websocket port for flashblock payload builder
#[arg(long = "rollup.flashblocks-ws-url", env = "FLASHBLOCKS_WS_URL")]
#[deprecated = "Use --flashblocks.port and --flashblocks.addr instead"]
pub url_deprecated: Option<String>,
}
11 changes: 6 additions & 5 deletions crates/op-rbuilder/src/builders/flashblocks/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ impl TryFrom<OpRbuilderArgs> for FlashblocksConfig {
type Error = eyre::Report;

fn try_from(args: OpRbuilderArgs) -> Result<Self, Self::Error> {
let ws_addr = args
.flashblocks_ws_url
.parse()
.map_err(|_| eyre::eyre!("Invalid flashblocks websocket address"))?;
let interval = Duration::from_millis(args.flashblocks.block_time);

let interval = Duration::from_millis(args.flashblock_block_time);
#[allow(deprecated)]
let ws_addr = match args.flashblocks.url_deprecated {
Some(url) => url.parse()?,
None => SocketAddr::new(args.flashblocks.addr.parse()?, args.flashblocks.port),
};

Ok(Self { ws_addr, interval })
}
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/tests/flashblocks/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::tests::TestHarnessBuilder;
#[ignore = "Flashblocks tests need more work"]
async fn chain_produces_blocks() -> eyre::Result<()> {
let harness = TestHarnessBuilder::new("flashbots_chain_produces_blocks")
.with_flashblocks_ws_url("ws://localhost:1239")
.with_flashblocks_port(1239)
.with_chain_block_time(2000)
.with_flashbots_block_time(200)
.build()
Expand Down
12 changes: 6 additions & 6 deletions crates/op-rbuilder/src/tests/framework/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use uuid::Uuid;
pub struct TestHarnessBuilder {
name: String,
use_revert_protection: bool,
flashblocks_ws_url: Option<String>,
flashblocks_port: Option<u16>,
chain_block_time: Option<u64>,
flashbots_block_time: Option<u64>,
namespaces: Option<String>,
Expand All @@ -34,7 +34,7 @@ impl TestHarnessBuilder {
Self {
name: name.to_string(),
use_revert_protection: false,
flashblocks_ws_url: None,
flashblocks_port: None,
chain_block_time: None,
flashbots_block_time: None,
namespaces: None,
Expand All @@ -47,8 +47,8 @@ impl TestHarnessBuilder {
self
}

pub fn with_flashblocks_ws_url(mut self, url: &str) -> Self {
self.flashblocks_ws_url = Some(url.to_string());
pub fn with_flashblocks_port(mut self, port: u16) -> Self {
self.flashblocks_port = Some(port);
self
}

Expand Down Expand Up @@ -96,8 +96,8 @@ impl TestHarnessBuilder {
.with_revert_protection(self.use_revert_protection)
.with_namespaces(self.namespaces)
.with_extra_params(self.extra_params);
if let Some(flashblocks_ws_url) = self.flashblocks_ws_url {
op_rbuilder_config = op_rbuilder_config.with_flashblocks_ws_url(&flashblocks_ws_url);
if let Some(flashblocks_port) = self.flashblocks_port {
op_rbuilder_config = op_rbuilder_config.with_flashblocks_port(flashblocks_port);
}

if let Some(chain_block_time) = self.chain_block_time {
Expand Down
14 changes: 7 additions & 7 deletions crates/op-rbuilder/src/tests/framework/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct OpRbuilderConfig {
http_port: Option<u16>,
network_port: Option<u16>,
builder_private_key: Option<String>,
flashblocks_ws_url: Option<String>,
flashblocks_port: Option<u16>,
Copy link
Contributor Author

@ferranbt ferranbt May 27, 2025

Choose a reason for hiding this comment

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

Using port here since we do not really have any utility to change the bind address during tests.

chain_block_time: Option<u64>,
flashbots_block_time: Option<u64>,
with_revert_protection: Option<bool>,
Expand Down Expand Up @@ -71,8 +71,8 @@ impl OpRbuilderConfig {
self
}

pub fn with_flashblocks_ws_url(mut self, url: &str) -> Self {
self.flashblocks_ws_url = Some(url.to_string());
pub fn with_flashblocks_port(mut self, port: u16) -> Self {
self.flashblocks_port = Some(port);
self
}

Expand Down Expand Up @@ -152,11 +152,11 @@ impl Service for OpRbuilderConfig {
.arg(http_port.to_string());
}

if let Some(flashblocks_ws_url) = &self.flashblocks_ws_url {
if let Some(flashblocks_port) = &self.flashblocks_port {
cmd.arg("--rollup.enable-flashblocks").arg("true");
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should also rename rollup.enable-flashblocks to flashblocks.enabled to be more consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was worried since Base is already using this code. But I think it should be fine. We do not provide yet any API guarantees. I am going to change the one about the flashblocks block time too.


cmd.arg("--rollup.flashblocks-ws-url")
.arg(flashblocks_ws_url);
cmd.arg("--flashblocks.addr").arg("127.0.0.1");
cmd.arg("--flashblocks.port")
.arg(flashblocks_port.to_string());
}

if let Some(chain_block_time) = self.chain_block_time {
Expand Down
Loading