Skip to content

Commit eca9266

Browse files
authored
feat: expose rollup-boost library (#160)
* feat: expose rollup-boost library * fix: dependency tree * chore: clp
1 parent 06a9d9b commit eca9266

File tree

12 files changed

+183
-548
lines changed

12 files changed

+183
-548
lines changed

Cargo.lock

Lines changed: 1 addition & 393 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ edition = "2024"
55

66
[dependencies]
77
op-alloy-rpc-types-engine = "0.11.1"
8-
op-alloy-rpc-types = "0.11.1"
9-
op-alloy-rpc-jsonrpsee = { version = "0.11.1", features = ["client"] }
108
alloy-rpc-types-engine = "0.12.5"
11-
alloy-rpc-types-eth = "0.12.5"
9+
alloy-eips = { version = "0.12.5", features = ["serde"], optional = true }
1210
alloy-primitives = { version = "0.8.10", features = ["rand"] }
13-
alloy-eips = { version = "0.12.5", features = ["serde"] }
1411
tokio = { version = "1", features = ["full"] }
1512
tracing = "0.1.4"
1613
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
@@ -19,20 +16,17 @@ thiserror = "2.0.12"
1916
clap = { version = "4", features = ["derive", "env"] }
2017
jsonrpsee = { version = "0.24", features = ["server", "http-client", "macros"] }
2118
moka = { version = "0.12.10", features = ["sync"] }
22-
reqwest = "0.12.5"
2319
http = "1.1.0"
2420
dotenv = "0.15.0"
2521
tower = "0.4.13"
2622
tower-http = { version = "0.5.2", features = ["decompression-full"] }
27-
http-body = "1.0.1"
2823
http-body-util = "0.1.2"
2924
hyper = { version = "1.4.1", features = ["full"] }
3025
hyper-util = { version = "0.1", features = ["full"] }
3126
hyper-rustls = { version = "0.27.0", features = ["ring"] }
3227
rustls = { version = "0.23.23", features = ["ring"] }
3328
serde_json = "1.0.96"
3429
opentelemetry = { version = "0.28.0", features = ["trace"] }
35-
opentelemetry-http = "0.28.0"
3630
opentelemetry-otlp = { version = "0.28.0", features = [
3731
"http-proto",
3832
"http-json",
@@ -42,23 +36,20 @@ opentelemetry-otlp = { version = "0.28.0", features = [
4236
] }
4337
opentelemetry_sdk = { version = "0.28.0", features = ["rt-tokio"] }
4438
tracing-opentelemetry = "0.29.0"
45-
flate2 = "1.0.35"
4639
futures = "0.3.31"
47-
metrics-derive = "0.1"
4840
metrics = "0.24.0"
4941
metrics-exporter-prometheus = "0.16.0"
50-
metrics-process = "2.3.1"
5142
metrics-util = "0.19.0"
5243
eyre = "0.6.12"
5344
paste = "1.0.15"
5445

5546
# dev dependencies for integration tests
56-
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
57-
futures-util = "0.3.31"
58-
lazy_static = "1.5.0"
5947
parking_lot = "0.12.3"
48+
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"], optional = true }
49+
lazy_static = {version = "1.5.0", optional = true }
6050

6151
[dev-dependencies]
52+
alloy-rpc-types-eth = "0.12.5"
6253
anyhow = "1.0"
6354
assert_cmd = "2.0.10"
6455
predicates = "3.1.2"
@@ -69,4 +60,15 @@ reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.3.
6960
ctor = "0.4.1"
7061

7162
[features]
72-
integration = []
63+
integration = [
64+
"dep:lazy_static",
65+
"dep:time",
66+
"dep:alloy-eips"
67+
]
68+
69+
[[bin]]
70+
name = "rollup-boost"
71+
path = "src/bin/main.rs"
72+
73+
[lib]
74+
path = "src/lib.rs"

src/main.rs renamed to src/bin/main.rs

Lines changed: 6 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,20 @@
11
#![allow(clippy::complexity)]
2-
use crate::client::rpc::{BuilderArgs, L2ClientArgs, RpcClient};
3-
use ::tracing::{Level, info};
4-
use clap::{Parser, Subcommand, arg};
5-
use debug_api::DebugClient;
6-
use health::HealthLayer;
7-
use metrics::init_metrics;
2+
use ::tracing::info;
3+
use clap::Parser;
4+
use rollup_boost::{
5+
Args, Commands, DebugClient, DebugCommands, PayloadSource, ProxyLayer, RollupBoostServer,
6+
RpcClient, init_metrics, init_tracing,
7+
};
88
use std::net::SocketAddr;
9-
use tracing::init_tracing;
109

1110
use alloy_rpc_types_engine::JwtSecret;
1211
use dotenv::dotenv;
1312
use eyre::bail;
1413
use jsonrpsee::RpcModule;
1514
use jsonrpsee::server::Server;
16-
use proxy::ProxyLayer;
17-
use server::{ExecutionMode, PayloadSource, RollupBoostServer};
1815

1916
use tokio::signal::unix::{SignalKind, signal as unix_signal};
2017

21-
mod client;
22-
mod debug_api;
23-
mod health;
24-
#[cfg(all(feature = "integration", test))]
25-
mod integration;
26-
mod metrics;
27-
mod proxy;
28-
mod server;
29-
mod tracing;
30-
31-
#[derive(Parser, Debug)]
32-
#[clap(author, version, about)]
33-
struct Args {
34-
#[command(subcommand)]
35-
command: Option<Commands>,
36-
37-
#[clap(flatten)]
38-
builder: BuilderArgs,
39-
40-
#[clap(flatten)]
41-
l2_client: L2ClientArgs,
42-
43-
/// Disable using the proposer to sync the builder node
44-
#[arg(long, env, default_value = "false")]
45-
no_boost_sync: bool,
46-
47-
/// Host to run the server on
48-
#[arg(long, env, default_value = "0.0.0.0")]
49-
rpc_host: String,
50-
51-
/// Port to run the server on
52-
#[arg(long, env, default_value = "8081")]
53-
rpc_port: u16,
54-
55-
// Enable tracing
56-
#[arg(long, env, default_value = "false")]
57-
tracing: bool,
58-
59-
// Enable Prometheus metrics
60-
#[arg(long, env, default_value = "false")]
61-
metrics: bool,
62-
63-
/// Host to run the metrics server on
64-
#[arg(long, env, default_value = "0.0.0.0")]
65-
metrics_host: String,
66-
67-
/// Port to run the metrics server on
68-
#[arg(long, env, default_value = "9090")]
69-
metrics_port: u16,
70-
71-
/// OTLP endpoint
72-
#[arg(long, env, default_value = "http://localhost:4317")]
73-
otlp_endpoint: String,
74-
75-
/// Log level
76-
#[arg(long, env, default_value = "info")]
77-
log_level: Level,
78-
79-
/// Log format
80-
#[arg(long, env, default_value = "text")]
81-
log_format: LogFormat,
82-
83-
/// Host to run the debug server on
84-
#[arg(long, env, default_value = "127.0.0.1")]
85-
debug_host: String,
86-
87-
/// Debug server port
88-
#[arg(long, env, default_value = "5555")]
89-
debug_server_port: u16,
90-
91-
/// Execution mode to start rollup boost with
92-
#[arg(long, env, default_value = "enabled")]
93-
execution_mode: ExecutionMode,
94-
}
95-
96-
#[derive(Clone, Debug)]
97-
enum LogFormat {
98-
Json,
99-
Text,
100-
}
101-
102-
impl std::str::FromStr for LogFormat {
103-
type Err = String;
104-
105-
fn from_str(s: &str) -> Result<Self, Self::Err> {
106-
match s.to_lowercase().as_str() {
107-
"json" => Ok(LogFormat::Json),
108-
"text" => Ok(LogFormat::Text),
109-
_ => Err("Invalid log format".into()),
110-
}
111-
}
112-
}
113-
114-
#[derive(Subcommand, Debug)]
115-
enum Commands {
116-
/// Debug commands
117-
Debug {
118-
#[command(subcommand)]
119-
command: DebugCommands,
120-
},
121-
}
122-
123-
#[derive(Subcommand, Debug)]
124-
enum DebugCommands {
125-
/// Set the execution mode
126-
SetExecutionMode { execution_mode: ExecutionMode },
127-
128-
/// Get the execution mode
129-
ExecutionMode {},
130-
}
131-
13218
#[tokio::main]
13319
async fn main() -> eyre::Result<()> {
13420
// Load .env file

src/cli.rs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
use clap::{Parser, Subcommand};
2+
use tracing::Level;
3+
4+
use crate::{
5+
client::rpc::{BuilderArgs, L2ClientArgs},
6+
server::ExecutionMode,
7+
};
8+
9+
#[derive(Parser, Debug)]
10+
#[clap(author, version, about)]
11+
pub struct Args {
12+
#[command(subcommand)]
13+
pub command: Option<Commands>,
14+
15+
#[clap(flatten)]
16+
pub builder: BuilderArgs,
17+
18+
#[clap(flatten)]
19+
pub l2_client: L2ClientArgs,
20+
21+
/// Disable using the proposer to sync the builder node
22+
#[arg(long, env, default_value = "false")]
23+
pub no_boost_sync: bool,
24+
25+
/// Host to run the server on
26+
#[arg(long, env, default_value = "0.0.0.0")]
27+
pub rpc_host: String,
28+
29+
/// Port to run the server on
30+
#[arg(long, env, default_value = "8081")]
31+
pub rpc_port: u16,
32+
33+
// Enable tracing
34+
#[arg(long, env, default_value = "false")]
35+
pub tracing: bool,
36+
37+
// Enable Prometheus metrics
38+
#[arg(long, env, default_value = "false")]
39+
pub metrics: bool,
40+
41+
/// Host to run the metrics server on
42+
#[arg(long, env, default_value = "0.0.0.0")]
43+
pub metrics_host: String,
44+
45+
/// Port to run the metrics server on
46+
#[arg(long, env, default_value = "9090")]
47+
pub metrics_port: u16,
48+
49+
/// OTLP endpoint
50+
#[arg(long, env, default_value = "http://localhost:4317")]
51+
pub otlp_endpoint: String,
52+
53+
/// Log level
54+
#[arg(long, env, default_value = "info")]
55+
pub log_level: Level,
56+
57+
/// Log format
58+
#[arg(long, env, default_value = "text")]
59+
pub log_format: LogFormat,
60+
61+
/// Host to run the debug server on
62+
#[arg(long, env, default_value = "127.0.0.1")]
63+
pub debug_host: String,
64+
65+
/// Debug server port
66+
#[arg(long, env, default_value = "5555")]
67+
pub debug_server_port: u16,
68+
69+
/// Execution mode to start rollup boost with
70+
#[arg(long, env, default_value = "enabled")]
71+
pub execution_mode: ExecutionMode,
72+
}
73+
74+
#[derive(Clone, Debug)]
75+
pub enum LogFormat {
76+
Json,
77+
Text,
78+
}
79+
80+
impl std::str::FromStr for LogFormat {
81+
type Err = String;
82+
83+
fn from_str(s: &str) -> Result<Self, Self::Err> {
84+
match s.to_lowercase().as_str() {
85+
"json" => Ok(LogFormat::Json),
86+
"text" => Ok(LogFormat::Text),
87+
_ => Err("Invalid log format".into()),
88+
}
89+
}
90+
}
91+
92+
#[derive(Subcommand, Debug)]
93+
pub enum Commands {
94+
/// Debug commands
95+
Debug {
96+
#[command(subcommand)]
97+
command: DebugCommands,
98+
},
99+
}
100+
101+
#[derive(Subcommand, Debug)]
102+
pub enum DebugCommands {
103+
/// Set the execution mode
104+
SetExecutionMode { execution_mode: ExecutionMode },
105+
106+
/// Get the execution mode
107+
ExecutionMode {},
108+
}

src/client/http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ use tracing::{debug, error, instrument};
1616
use super::auth::{AuthClientLayer, AuthClientService};
1717

1818
#[derive(Clone, Debug)]
19-
pub(crate) struct HttpClient {
19+
pub struct HttpClient {
2020
client: Decompression<AuthClientService<Client<HttpsConnector<HttpConnector>, HttpBody>>>,
2121
url: Uri,
2222
target: PayloadSource,
2323
}
2424

2525
impl HttpClient {
26-
pub(crate) fn new(url: Uri, secret: JwtSecret, target: PayloadSource) -> Self {
26+
pub fn new(url: Uri, secret: JwtSecret, target: PayloadSource) -> Self {
2727
let connector = hyper_rustls::HttpsConnectorBuilder::new()
2828
.with_native_roots()
2929
.expect("no native root CA certificates found")

src/client/rpc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const INTERNAL_ERROR: i32 = 13;
2323
pub(crate) type ClientResult<T> = Result<T, RpcClientError>;
2424

2525
#[derive(Error, Debug)]
26-
pub(crate) enum RpcClientError {
26+
pub enum RpcClientError {
2727
#[error(transparent)]
2828
Jsonrpsee(#[from] jsonrpsee::core::client::Error),
2929
#[error("Invalid payload: {0}")]
@@ -89,7 +89,7 @@ impl From<RpcClientError> for ErrorObjectOwned {
8989
/// - **Engine API** calls are faciliated via the `auth_client` (requires JWT authentication).
9090
///
9191
#[derive(Clone)]
92-
pub(crate) struct RpcClient {
92+
pub struct RpcClient {
9393
/// Handles requests to the authenticated Engine API (requires JWT authentication)
9494
auth_client: HttpClient<AuthClientService<HttpBackend>>,
9595
/// Uri of the RPC server for authenticated Engine API calls

src/health.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tower::{Layer, Service, util::Either};
1212

1313
/// A [`Layer`] that filters out /healthz requests and responds with a 200 OK.
1414
#[derive(Clone, Debug)]
15-
pub(crate) struct HealthLayer;
15+
pub struct HealthLayer;
1616

1717
impl<S> Layer<S> for HealthLayer {
1818
type Service = HealthService<S>;

0 commit comments

Comments
 (0)