Skip to content
Open
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
33 changes: 31 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tokio = { version = "1", features = ["full"] }
eyre = "0.6.12"
url = "2.2.0"
sha2 = { version = "0.10", default-features = false }
backoff = "0.4.0"

# Reth deps
reth-optimism-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
Expand Down
4 changes: 4 additions & 0 deletions crates/rollup-boost/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ paste = "1.0.15"
parking_lot = "0.12.3"
tokio-util = { version = "0.7.13" }
dashmap = "6.1.0"
backoff.workspace = true
uuid = { version = "1.17.0", features = ["v4", "v7"] }
bytes = "1.10.1"
lru = "0.16"

[dev-dependencies]
rand = "0.9.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/rollup-boost/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl RollupBoostArgs {
builder_client.clone(),
inbound_url,
outbound_addr,
flashblocks_args.flashblock_builder_ws_reconnect_ms,
flashblocks_args.flashblocks_ws_config,
)?);

let rollup_boost = RollupBoostServer::new(
Expand Down
57 changes: 55 additions & 2 deletions crates/rollup-boost/src/flashblocks/args.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use backoff::{ExponentialBackoff, ExponentialBackoffBuilder};
use clap::Parser;
use std::time::Duration;
use url::Url;

#[derive(Parser, Clone, Debug)]
Expand All @@ -19,7 +21,58 @@ pub struct FlashblocksArgs {
#[arg(long, env, default_value = "1112")]
pub flashblocks_port: u16,

/// Time used for timeout if builder disconnected
/// Websocket connection configuration
#[command(flatten)]
pub flashblocks_ws_config: FlashblocksWebsocketConfig,
}

#[derive(Parser, Debug, Clone, Copy)]
pub struct FlashblocksWebsocketConfig {
/// Minimum time for exponential backoff for timeout if builder disconnected
#[arg(long, env, default_value = "10")]
pub flashblock_builder_ws_initial_reconnect_ms: u64,

/// Maximum time for exponential backoff for timeout if builder disconnected
#[arg(long, env, default_value = "5000")]
pub flashblock_builder_ws_reconnect_ms: u64,
pub flashblock_builder_ws_max_reconnect_ms: u64,

/// Interval in milliseconds between ping messages sent to upstream servers to detect unresponsive connections
#[arg(long, env, default_value = "500")]
pub flashblock_builder_ws_ping_interval_ms: u64,

/// Timeout in milliseconds to wait for pong responses from upstream servers before considering the connection dead
#[arg(long, env, default_value = "1500")]
pub flashblock_builder_ws_pong_timeout_ms: u64,
}

impl FlashblocksWebsocketConfig {
/// Creates `ExponentialBackoff` use to control builder websocket reconnection time
pub fn backoff(&self) -> ExponentialBackoff {
ExponentialBackoffBuilder::default()
.with_initial_interval(self.initial_interval())
.with_max_interval(self.max_interval())
.with_randomization_factor(0 as f64)
.with_max_elapsed_time(None)
.build()
}

/// Returns initial time for exponential backoff
pub fn initial_interval(&self) -> Duration {
Duration::from_millis(self.flashblock_builder_ws_initial_reconnect_ms)
}

/// Returns maximal time for exponential backoff
pub fn max_interval(&self) -> Duration {
Duration::from_millis(self.flashblock_builder_ws_max_reconnect_ms)
}

/// Returns ping interval
pub fn ping_interval(&self) -> Duration {
Duration::from_millis(self.flashblock_builder_ws_ping_interval_ms)
}

/// Returns pong interval
pub fn pong_interval(&self) -> Duration {
Duration::from_millis(self.flashblock_builder_ws_pong_timeout_ms)
}
}
Loading
Loading