Skip to content
Closed
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
1,606 changes: 907 additions & 699 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ reth-chain-state = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1"
reth-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
Expand All @@ -56,9 +57,7 @@ reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag
reth-node-core = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1", features = [
"test-utils",
] }
reth-provider = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
Expand All @@ -77,9 +76,10 @@ reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.
reth-testing-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-ipc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }

# reth optimism
reth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
# compatible with reth "v1.4.1 dependenciesreth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-consensus = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-forks = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
Expand All @@ -88,11 +88,10 @@ reth-optimism-node = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.
reth-optimism-payload-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-txpool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1" }
reth-optimism-rpc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.1", features = [
"client",
] }

# compatible with reth "v1.4.1 dependencies
revm = { version = "23.1.0", features = [
"std",
"secp256k1",
Expand Down
38 changes: 31 additions & 7 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ reth-optimism-evm.workspace = true
reth-optimism-consensus.workspace = true
reth-optimism-primitives.workspace = true
reth-optimism-txpool.workspace = true
reth-optimism-rpc.workspace = true
reth-cli.workspace = true
reth-cli-util.workspace = true
reth-payload-primitives.workspace = true
Expand Down Expand Up @@ -44,21 +45,21 @@ reth-testing-utils.workspace = true
reth-optimism-forks.workspace = true
reth-node-builder.workspace = true
reth-rpc-eth-types.workspace = true
reth-optimism-rpc.workspace = true

alloy-primitives.workspace = true
reth-db-api.workspace = true
alloy-consensus.workspace = true
alloy-eips.workspace = true
alloy-rpc-types-beacon.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-transport-http.workspace = true
alloy-rpc-types-eth.workspace = true
alloy-rpc-client.workspace = true
reth-ipc = { workspace = true, optional = true }
alloy-transport.workspace = true
alloy-network.workspace = true
alloy-provider.workspace = true
alloy-serde.workspace = true
alloy-json-rpc.workspace = true
alloy-primitives.workspace = true

# op
alloy-op-evm.workspace = true
Expand All @@ -68,6 +69,7 @@ op-alloy-rpc-types.workspace = true
op-alloy-network.workspace = true
op-alloy-flz.workspace = true


revm.workspace = true
op-revm.workspace = true

Expand All @@ -89,8 +91,11 @@ tokio-util.workspace = true
thiserror.workspace = true
parking_lot.workspace = true
url.workspace = true
nanoid = { version = "0.4", optional = true }
tower = { version = "0.5", optional = true }

tower = "0.5"

# `msozin/flashblocks-v1.4.1` branch based on `flashblocks-rebase`tower = "0.5"
futures = "0.3"
futures-util = "0.3.31"
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
Expand All @@ -101,9 +106,9 @@ rand = "0.9.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
shellexpand = "3.1"
serde_yaml = { version = "0.9" }
dashmap = { version = "6.1", optional = true }
macros = { path = "src/tests/macros", optional = true }
moka = "0.12"

# `msozin/flashblocks-v1.4.1` branch based on `flashblocks-rebase`
rollup-boost = { git = "http://github.com/flashbots/rollup-boost", rev = "8506dfb7d84c65746f7c88d250983658438f59e8" }

[target.'cfg(unix)'.dependencies]
Expand All @@ -118,6 +123,17 @@ alloy-provider = { workspace = true, default-features = true, features = [
"txpool-api",
] }

#reth-provider = { workspace = true, features = ["test-utils"] }

tower = "0.5"
nanoid = "0.4"
reth-node-builder = { workspace = true, features = ["test-utils"] }
reth-ipc.workspace = true
reth-rpc-eth-types.workspace = true
ctor = "0.4.2"
dashmap = "6.1"
macros = { path = "src/tests/macros" }

[features]
default = ["jemalloc"]

Expand All @@ -139,7 +155,15 @@ min-info-logs = ["tracing/release_max_level_info"]
min-debug-logs = ["tracing/release_max_level_debug"]
min-trace-logs = ["tracing/release_max_level_trace"]

testing = []
testing = [
"nanoid",
"reth-node-builder/test-utils",
"reth-ipc",
"dashmap",
"tower",
"macros",
#"reth-provider/test-utils",
]

interop = []

Expand Down
3 changes: 2 additions & 1 deletion crates/op-rbuilder/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ use crate::{
metrics::{CARGO_PKG_VERSION, VERGEN_GIT_SHA},
};
use clap_builder::{CommandFactory, FromArgMatches};
pub use op::OpRbuilderArgs;
use playground::PlaygroundOptions;
use reth_optimism_cli::{chainspec::OpChainSpecParser, commands::Commands};

mod op;
mod playground;

pub use op::{FlashblocksArgs, OpRbuilderArgs};

/// 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.
Expand Down
29 changes: 25 additions & 4 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
//! Copied from OptimismNode to allow easy extension.

//! clap [Args](clap::Args) for optimism rollup configuration
use std::path::PathBuf;

use crate::tx_signer::Signer;
use clap::Parser;
use reth_optimism_cli::commands::Commands;
use reth_optimism_node::args::RollupArgs;
use std::path::PathBuf;

/// Parameters for rollup configuration
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
#[command(next_help_heading = "Rollup")]
pub struct OpRbuilderArgs {
/// Rollup configuration
Expand Down Expand Up @@ -51,6 +52,16 @@ pub struct OpRbuilderArgs {
pub flashblocks: FlashblocksArgs,
}

impl Default for OpRbuilderArgs {
fn default() -> Self {
let args = crate::args::Cli::parse_from(["dummy", "node"]);
let Commands::Node(node_command) = args.command else {
unreachable!()
};
node_command.ext
}
}

fn expand_path(s: &str) -> Result<PathBuf, String> {
shellexpand::full(s)
.map_err(|e| format!("expansion error for `{s}`: {e}"))?
Expand All @@ -63,7 +74,7 @@ fn expand_path(s: &str) -> Result<PathBuf, String> {
/// 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.
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::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.
Expand Down Expand Up @@ -101,3 +112,13 @@ pub struct FlashblocksArgs {
)]
pub flashblocks_block_time: u64,
}

impl Default for FlashblocksArgs {
fn default() -> Self {
let args = crate::args::Cli::parse_from(["dummy", "node"]);
let Commands::Node(node_command) = args.command else {
unreachable!()
};
node_command.ext.flashblocks
}
}
14 changes: 1 addition & 13 deletions crates/op-rbuilder/src/builders/flashblocks/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::{args::OpRbuilderArgs, builders::BuilderConfig};
use core::{
net::{Ipv4Addr, SocketAddr},
time::Duration,
};
use core::{net::SocketAddr, time::Duration};

/// Configuration values that are specific to the flashblocks builder.
#[derive(Debug, Clone)]
Expand All @@ -17,15 +14,6 @@ pub struct FlashblocksConfig {
pub interval: Duration,
}

impl Default for FlashblocksConfig {
fn default() -> Self {
Self {
ws_addr: SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 1111),
interval: Duration::from_millis(250),
}
}
}

impl TryFrom<OpRbuilderArgs> for FlashblocksConfig {
type Error = eyre::Report;

Expand Down
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ where
// Spawn the timer task that signals when to build a new flashblock
let cancel_clone = ctx.cancel.clone();
let interval = self.config.specific.interval;

tokio::spawn(async move {
let mut interval = tokio::time::interval(interval);
loop {
Expand Down
2 changes: 0 additions & 2 deletions crates/op-rbuilder/src/builders/flashblocks/wspub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ async fn broadcast_loop(
// Receive payloads from the broadcast channel
payload = blocks.recv() => match payload {
Ok(payload) => {
// Here you would typically send the payload to the WebSocket clients.
// For this example, we just increment the sent counter.
sent.fetch_add(1, Ordering::Relaxed);
metrics.messages_sent_count.increment(1);

Expand Down
25 changes: 16 additions & 9 deletions crates/op-rbuilder/src/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,23 @@ impl<S: Debug + Clone> core::fmt::Debug for BuilderConfig<S> {
}
}

impl<S: Default + Clone> Default for BuilderConfig<S> {
impl<S: Default + Clone + TryFrom<OpRbuilderArgs>> Default for BuilderConfig<S>
where
S: TryFrom<OpRbuilderArgs, Error: Debug> + Clone,
{
fn default() -> Self {
Self {
builder_signer: None,
revert_protection: false,
block_time: Duration::from_secs(2),
block_time_leeway: Duration::from_millis(500),
da_config: OpDAConfig::default(),
specific: S::default(),
}
use clap::Parser;
use reth_optimism_cli::commands::Commands;

let args = crate::args::Cli::parse_from(["dummy", "node"]);
let Commands::Node(node_command) = args.command else {
unreachable!()
};

node_command
.ext
.try_into()
.expect("default cli args should always be valid")
}
}

Expand Down
9 changes: 9 additions & 0 deletions crates/op-rbuilder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
pub mod args;
pub mod builders;
pub mod primitives;
pub mod tx_signer;

mod metrics;
mod traits;
mod tx;

#[cfg(any(test, feature = "testing"))]
pub mod tests;

#[cfg(any(test, feature = "testing"))]
mod revert_protection;
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ where

ctx.modules
.merge_configured(revert_protection_ext.bundle_api().into_rpc())?;

ctx.modules.replace_configured(
revert_protection_ext.eth_api(reverted_cache).into_rpc(),
)?;
Expand Down
2 changes: 2 additions & 0 deletions crates/op-rbuilder/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]

use reth_metrics::{
metrics::{gauge, Counter, Gauge, Histogram},
Metrics,
Expand Down
Loading
Loading