Skip to content

Commit 586a2b2

Browse files
authored
Interop support (#462)
Implement SupervisorValidator to be used in rbuilder Add additional primitives crate, that is used for storing external ## 📝 Summary <!--- A general summary of your changes --> ## 💡 Motivation and Context <!--- (Optional) Why is this change required? What problem does it solve? Remove this section if not applicable. --> --- ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [x] Added tests (if applicable)
1 parent f4fe57c commit 586a2b2

13 files changed

+923
-370
lines changed

Cargo.lock

+648-348
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ethereum_ssz_derive = "0.8"
110110
ethereum_ssz = "0.8"
111111

112112
alloy-primitives = { version = "0.8.15", default-features = false }
113-
alloy-rlp = "0.3.10"
113+
alloy-rlp = "0.3.11"
114114
alloy-chains = "0.1.33"
115115
alloy-provider = { version = "0.11.1", features = ["ipc", "pubsub"] }
116116
alloy-pubsub = { version = "0.11.1" }
@@ -137,6 +137,10 @@ op-alloy-rpc-jsonrpsee = { version = "0.10.3", default-features = false }
137137
op-alloy-network = { version = "0.10.3", default-features = false }
138138
op-alloy-consensus = { version = "0.10.3", default-features = false }
139139

140+
# kona
141+
kona-rpc = { git="https://github.com/op-rs/kona", rev="0493d8479e2ca9f0eb6d5c6154e2bedc61de7217", features = ["client", "interop", "jsonrpsee"]}
142+
kona-interop = { git="https://github.com/op-rs/kona", rev="0493d8479e2ca9f0eb6d5c6154e2bedc61de7217"}
143+
140144
async-trait = { version = "0.1.83" }
141145
clap = { version = "4.4.3", features = ["derive", "env"] }
142146
clap_builder = { version = "4.5.19" }

Dockerfile.op-rbuilder

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
ARG FEATURES
1010
ARG RBUILDER_BIN="op-rbuilder"
1111

12-
FROM rust:1.82 AS base
12+
FROM rust:1.85 AS base
1313
ARG TARGETPLATFORM
1414

1515
RUN apt-get update \

crates/op-rbuilder/Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ op-alloy-consensus.workspace = true
5656
op-alloy-rpc-types-engine.workspace = true
5757
op-alloy-network.workspace = true
5858

59+
# kona
60+
kona-rpc = {workspace = true, optional = true}
61+
kona-interop = {workspace = true, optional = true}
62+
5963
revm.workspace = true
6064

6165
tracing.workspace = true
@@ -85,6 +89,7 @@ alloy-serde = "0.7"
8589
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
8690

8791
rollup-boost = { git = "http://github.com/flashbots/rollup-boost", rev = "e74a1fd01366e4ddd13515da4efda59cdc8fbce0" }
92+
url = "2.5.3"
8893

8994
[target.'cfg(unix)'.dependencies]
9095
tikv-jemallocator = { version = "0.6", optional = true }
@@ -113,7 +118,7 @@ min-info-logs = ["tracing/release_max_level_info"]
113118
min-debug-logs = ["tracing/release_max_level_debug"]
114119
min-trace-logs = ["tracing/release_max_level_trace"]
115120

116-
optimism = ["reth-optimism-node/optimism", "reth-optimism-cli/optimism"]
121+
optimism = ["reth-optimism-node/optimism", "reth-optimism-cli/optimism", "kona-rpc", "kona-interop"]
117122

118123
integration = []
119124
flashblocks = []

crates/op-rbuilder/src/args.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use reth_optimism_node::args::RollupArgs;
77

88
use crate::tx_signer::Signer;
9+
use alloy_transport_http::reqwest::Url;
910

1011
/// Parameters for rollup configuration
1112
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
@@ -38,7 +39,16 @@ pub struct OpRbuilderArgs {
3839
env = "FLASHBLOCK_BLOCK_TIME"
3940
)]
4041
pub flashblock_block_time: u64,
41-
42+
/// URL of the supervisor service for transaction validation
43+
#[arg(long = "rollup.supervisor-url", env = "SUPERVISOR_URL")]
44+
pub supervisor_url: Option<Url>,
45+
/// URL of the supervisor service for transaction validation
46+
#[arg(
47+
long = "rollup.supervisor_safety_level",
48+
env = "SUPERVISOR_SAFETY_LEVEL",
49+
help = "Safety level to pass to supervisor, values: finalized, safe, local-safe, cross-unsafe, unsafe, invalid"
50+
)]
51+
pub supervisor_safety_level: Option<String>,
4252
/// Signals whether to log pool transactions events
4353
#[arg(long = "builder.log-pool-transactions", default_value = "false")]
4454
pub log_pool_transactions: bool,

crates/op-rbuilder/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod integration;
2+
pub mod primitives;
23
pub mod tester;
34
pub mod tx_signer;

crates/op-rbuilder/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ fn main() {
4242
builder_args.flashblocks_ws_url,
4343
builder_args.chain_block_time,
4444
builder_args.flashblock_block_time,
45+
builder_args.supervisor_url,
46+
builder_args.supervisor_safety_level,
4547
)))
4648
.with_add_ons(
4749
OpAddOnsBuilder::default()

crates/op-rbuilder/src/metrics.rs

+24
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ pub struct OpRBuilderMetrics {
4444
pub tx_byte_size: Histogram,
4545
/// Number of reverted transactions
4646
pub num_reverted_tx: Counter,
47+
/// Number of cross-chain transactions
48+
pub num_cross_chain_tx: Counter,
49+
/// Number of cross-chain transactions that didn't pass supervisor validation
50+
pub num_cross_chain_tx_fail: Counter,
51+
/// Number of cross-chain transactions that weren't verified because of the timeout
52+
pub num_cross_chain_tx_timeout: Counter,
53+
/// Number of cross-chain transactions that weren't verified because of the server error
54+
pub num_cross_chain_tx_server_error: Counter,
4755
}
4856

4957
impl OpRBuilderMetrics {
@@ -70,4 +78,20 @@ impl OpRBuilderMetrics {
7078
pub fn set_builder_balance(&self, balance: f64) {
7179
self.builder_balance.set(balance);
7280
}
81+
82+
pub fn inc_num_cross_chain_tx_fail(&self) {
83+
self.num_cross_chain_tx_fail.increment(1);
84+
}
85+
86+
pub fn inc_num_cross_chain_tx(&self) {
87+
self.num_cross_chain_tx.increment(1);
88+
}
89+
90+
pub fn inc_num_cross_chain_tx_timeout(&self) {
91+
self.num_cross_chain_tx_timeout.increment(1);
92+
}
93+
94+
pub fn inc_num_cross_chain_tx_server_error(&self) {
95+
self.num_cross_chain_tx_server_error.increment(1);
96+
}
7397
}

crates/op-rbuilder/src/payload_builder.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use tokio::net::{TcpListener, TcpStream};
7575
use tokio::sync::mpsc;
7676
use tokio_tungstenite::accept_async;
7777
use tokio_tungstenite::WebSocketStream;
78+
use url::Url;
7879

7980
use serde::{Deserialize, Serialize};
8081

@@ -88,11 +89,15 @@ struct FlashblocksMetadata<N: NodePrimitives> {
8889
#[derive(Debug, Clone, Default)]
8990
#[non_exhaustive]
9091
pub struct CustomOpPayloadBuilder {
91-
#[allow(dead_code)]
92+
#[expect(dead_code)]
9293
builder_signer: Option<Signer>,
9394
flashblocks_ws_url: String,
9495
chain_block_time: u64,
9596
flashblock_block_time: u64,
97+
#[expect(dead_code)]
98+
supervisor_url: Option<Url>,
99+
#[expect(dead_code)]
100+
supervisor_safety_level: Option<String>,
96101
}
97102

98103
impl CustomOpPayloadBuilder {
@@ -101,12 +106,16 @@ impl CustomOpPayloadBuilder {
101106
flashblocks_ws_url: String,
102107
chain_block_time: u64,
103108
flashblock_block_time: u64,
109+
supervisor_url: Option<Url>,
110+
supervisor_safety_level: Option<String>,
104111
) -> Self {
105112
Self {
106113
builder_signer,
107114
flashblocks_ws_url,
108115
chain_block_time,
109116
flashblock_block_time,
117+
supervisor_url,
118+
supervisor_safety_level,
110119
}
111120
}
112121
}

0 commit comments

Comments
 (0)