Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7914369
initial p2p node impl in p2p crate
noot Sep 18, 2025
a082367
update args and add p2p node to flashblocks service
noot Sep 19, 2025
960ecf7
send built flashblocks to p2p layer
noot Sep 22, 2025
c03416d
implement generic message in p2p crate, concrete message in builder
noot Sep 22, 2025
5428121
implement incoming streams handler
noot Sep 24, 2025
847180e
implement PayloadHandler for handling incoming p2p payloads
noot Sep 24, 2025
fa98c77
support multiple stream protocols
noot Sep 24, 2025
590927c
make agent version configurable
noot Sep 24, 2025
192340d
merge w main
noot Sep 24, 2025
7ae5778
fmt
noot Sep 25, 2025
5b77ff1
clippy
noot Sep 25, 2025
3b66510
add known peers flag
noot Sep 25, 2025
380a5c1
update error handling for better logging in payload builder
noot Sep 25, 2025
f522f4f
merge w main
noot Oct 5, 2025
2ee1855
change p2p hex string to file path; add documentation for p2p crate
noot Oct 6, 2025
b20f773
fix optional flags
noot Oct 6, 2025
35715c7
update Message trait to have custom to/from string
noot Oct 14, 2025
1b1f345
cargo update
noot Oct 14, 2025
2b0e5cd
fix copilot issues
noot Oct 14, 2025
696030a
fix copilot issues
noot Oct 14, 2025
9fd7548
fix derive_more
noot Oct 14, 2025
3237890
fix copilot issues
noot Oct 14, 2025
1badb92
regenerate Cargo.lock
noot Oct 14, 2025
1a8fd45
merge w main
noot Oct 14, 2025
6e6d9de
merge: wip
noot Oct 20, 2025
2525f48
Merge branch 'main' of https://github.com/flashbots/op-rbuilder into …
noot Oct 20, 2025
3e9ea53
merge
noot Oct 20, 2025
0d30052
update p2p args
noot Oct 20, 2025
9a9b31d
add max peer arg
noot Oct 21, 2025
9ebf706
lint
noot Oct 21, 2025
31c527c
merge wip
noot Oct 27, 2025
7bb5c80
temp fix
noot Oct 27, 2025
5313e7d
rename metrics with payload_tx_ to payload_transaction_
noot Oct 27, 2025
0311b4d
address comments
noot Oct 27, 2025
669507a
revert builder_tx to see if it compiles on ci
noot Oct 27, 2025
061067c
re-add builder_tx changes
noot Oct 27, 2025
6c28ec4
fix formatting
noot Oct 27, 2025
9bbc4a4
use alloy_primitives::map::HashMap
noot Oct 27, 2025
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
3,047 changes: 2,058 additions & 989 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/flashbots/op-rbuilder"
exclude = [".github/"]

[workspace]
members = [ "crates/op-rbuilder", "crates/tdx-quote-provider"]
members = [ "crates/op-rbuilder", "crates/p2p", "crates/tdx-quote-provider"]
default-members = ["crates/op-rbuilder"]
resolver = "2"

Expand Down Expand Up @@ -179,6 +179,9 @@ flate2 = "1.0.35"
prometheus = "0.13.4"
ctor = "0.2"
dashmap = "6.1"
hex = "0.4"
futures = "0.3"
futures-util = "0.3.31"

lazy_static = "1.4.0"
tikv-jemallocator = { version = "0.6" }
Expand Down
9 changes: 6 additions & 3 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ default-run = "op-rbuilder"
workspace = true

[dependencies]
p2p = { path = "../p2p" }

reth.workspace = true
reth-optimism-node.workspace = true
reth-optimism-cli.workspace = true
Expand Down Expand Up @@ -109,10 +111,11 @@ url.workspace = true
anyhow = "1"
opentelemetry = { workspace = true, optional = true }
dashmap.workspace = true
hex = { workspace = true }
futures = { workspace = true }
futures-util = { workspace = true }

tower = "0.5"
futures = "0.3"
futures-util = "0.3.31"
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
chrono = "0.4"
uuid = { version = "1.6.1", features = ["serde", "v5", "v4"] }
Expand All @@ -124,7 +127,7 @@ serde_yaml = { version = "0.9" }
moka = "0.12"
http = "1.0"
sha3 = "0.10"
hex = "0.4"
ureq = "2.10"
reqwest = "0.12.23"
k256 = "0.13.4"

Expand Down
32 changes: 32 additions & 0 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,38 @@ pub struct FlashblocksArgs {
)]
pub flashblocks_calculate_state_root: bool,

/// Enable libp2p networking for flashblock propagation
#[arg(
long = "flashblocks.p2p_enabled",
env = "FLASHBLOCK_P2P_ENABLED",
default_value = "false"
)]
pub flashblocks_p2p_enabled: bool,

/// Port for the flashblocks p2p node
#[arg(
long = "flashblocks.p2p_port",
env = "FLASHBLOCK_P2P_PORT",
default_value = "9009"
)]
pub flashblocks_p2p_port: u16,

/// Path to the file containing a hex-encoded libp2p private key.
/// If the file does not exist, a new key will be generated.
#[arg(
long = "flashblocks.p2p_private_key_file",
env = "FLASHBLOCK_P2P_PRIVATE_KEY_FILE"
)]
pub flashblocks_p2p_private_key_file: Option<String>,

/// Comma-separated list of multiaddrs of known Flashblocks peers
/// Example: "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ,/ip4/104.131.131.82/udp/4001/quic-v1/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
#[arg(
long = "flashblocks.p2p_known_peers",
env = "FLASHBLOCK_P2P_KNOWN_PEERS"
)]
pub flashblocks_known_peers: Option<String>,

/// Flashblocks number contract address
///
/// This is the address of the contract that will be used to increment the flashblock number.
Expand Down
2 changes: 2 additions & 0 deletions crates/op-rbuilder/src/builders/flashblocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use service::FlashblocksServiceBuilder;
mod best_txs;
mod builder_tx;
mod config;
mod p2p;
mod payload;
mod payload_handler;
mod service;
mod wspub;

Expand Down
60 changes: 60 additions & 0 deletions crates/op-rbuilder/src/builders/flashblocks/p2p.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use alloy_primitives::U256;
use reth::{core::primitives::SealedBlock, payload::PayloadId};
use reth_optimism_payload_builder::OpBuiltPayload as RethOpBuiltPayload;
use reth_optimism_primitives::OpBlock;
use serde::{Deserialize, Serialize};

pub(super) const AGENT_VERSION: &str = "op-rbuilder/1.0.0";
pub(super) const FLASHBLOCKS_STREAM_PROTOCOL: p2p::StreamProtocol =
p2p::StreamProtocol::new("/flashblocks/1.0.0");
Comment on lines +7 to +9
Copy link
Collaborator

Choose a reason for hiding this comment

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

are the versions meant to be updated manually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes they are, if a breaking change was to be made to the stream protocol, this would be updated. that also allows for nodes to potentially support multiple versions of the protocol for backwards-compatibility


#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub(super) enum Message {
OpBuiltPayload(OpBuiltPayload),
}

impl p2p::Message for Message {
fn protocol(&self) -> p2p::StreamProtocol {
FLASHBLOCKS_STREAM_PROTOCOL
}
}

/// Internal type analogous to [`reth_optimism_payload_builder::OpBuiltPayload`]
/// which additionally implements `Serialize` and `Deserialize` for p2p transmission.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub(crate) struct OpBuiltPayload {
/// Identifier of the payload
pub(crate) id: PayloadId,
/// Sealed block
pub(crate) block: SealedBlock<OpBlock>,
/// The fees of the block
pub(crate) fees: U256,
}

impl From<RethOpBuiltPayload> for Message {
fn from(value: RethOpBuiltPayload) -> Self {
Message::OpBuiltPayload(value.into())
}
}

impl From<OpBuiltPayload> for Message {
fn from(value: OpBuiltPayload) -> Self {
Message::OpBuiltPayload(value)
}
}

impl From<OpBuiltPayload> for RethOpBuiltPayload {
fn from(value: OpBuiltPayload) -> Self {
RethOpBuiltPayload::new(value.id, value.block.into(), value.fees, None)
}
}

impl From<RethOpBuiltPayload> for OpBuiltPayload {
fn from(value: RethOpBuiltPayload) -> Self {
OpBuiltPayload {
id: value.id(),
block: value.block().clone(),
fees: value.fees(),
}
}
}
Loading