Skip to content
Merged
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
394 changes: 1 addition & 393 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ edition = "2024"

[dependencies]
op-alloy-rpc-types-engine = "0.11.1"
op-alloy-rpc-types = "0.11.1"
op-alloy-rpc-jsonrpsee = { version = "0.11.1", features = ["client"] }
alloy-rpc-types-engine = "0.12.5"
alloy-rpc-types-eth = "0.12.5"
alloy-eips = { version = "0.12.5", features = ["serde"], optional = true }
alloy-primitives = { version = "0.8.10", features = ["rand"] }
alloy-eips = { version = "0.12.5", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
tracing = "0.1.4"
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
Expand All @@ -19,20 +16,17 @@ thiserror = "2.0.12"
clap = { version = "4", features = ["derive", "env"] }
jsonrpsee = { version = "0.24", features = ["server", "http-client", "macros"] }
moka = { version = "0.12.10", features = ["sync"] }
reqwest = "0.12.5"
http = "1.1.0"
dotenv = "0.15.0"
tower = "0.4.13"
tower-http = { version = "0.5.2", features = ["decompression-full"] }
http-body = "1.0.1"
http-body-util = "0.1.2"
hyper = { version = "1.4.1", features = ["full"] }
hyper-util = { version = "0.1", features = ["full"] }
hyper-rustls = { version = "0.27.0", features = ["ring"] }
rustls = { version = "0.23.23", features = ["ring"] }
serde_json = "1.0.96"
opentelemetry = { version = "0.28.0", features = ["trace"] }
opentelemetry-http = "0.28.0"
opentelemetry-otlp = { version = "0.28.0", features = [
"http-proto",
"http-json",
Expand All @@ -42,23 +36,20 @@ opentelemetry-otlp = { version = "0.28.0", features = [
] }
opentelemetry_sdk = { version = "0.28.0", features = ["rt-tokio"] }
tracing-opentelemetry = "0.29.0"
flate2 = "1.0.35"
futures = "0.3.31"
metrics-derive = "0.1"
metrics = "0.24.0"
metrics-exporter-prometheus = "0.16.0"
metrics-process = "2.3.1"
metrics-util = "0.19.0"
eyre = "0.6.12"
paste = "1.0.15"

# dev dependencies for integration tests
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
futures-util = "0.3.31"
lazy_static = "1.5.0"
parking_lot = "0.12.3"
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"], optional = true }
lazy_static = {version = "1.5.0", optional = true }

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

[features]
integration = []
integration = [
"dep:lazy_static",
"dep:time",
"dep:alloy-eips"
]

[[bin]]
name = "rollup-boost"
path = "src/bin/main.rs"

[lib]
path = "src/lib.rs"
126 changes: 6 additions & 120 deletions src/main.rs → src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,134 +1,20 @@
#![allow(clippy::complexity)]
use crate::client::rpc::{BuilderArgs, L2ClientArgs, RpcClient};
use ::tracing::{Level, info};
use clap::{Parser, Subcommand, arg};
use debug_api::DebugClient;
use health::HealthLayer;
use metrics::init_metrics;
use ::tracing::info;
use clap::Parser;
use rollup_boost::{
Args, Commands, DebugClient, DebugCommands, PayloadSource, ProxyLayer, RollupBoostServer,
RpcClient, init_metrics, init_tracing,
};
use std::net::SocketAddr;
use tracing::init_tracing;

use alloy_rpc_types_engine::JwtSecret;
use dotenv::dotenv;
use eyre::bail;
use jsonrpsee::RpcModule;
use jsonrpsee::server::Server;
use proxy::ProxyLayer;
use server::{ExecutionMode, PayloadSource, RollupBoostServer};

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

mod client;
mod debug_api;
mod health;
#[cfg(all(feature = "integration", test))]
mod integration;
mod metrics;
mod proxy;
mod server;
mod tracing;

#[derive(Parser, Debug)]
#[clap(author, version, about)]
struct Args {
#[command(subcommand)]
command: Option<Commands>,

#[clap(flatten)]
builder: BuilderArgs,

#[clap(flatten)]
l2_client: L2ClientArgs,

/// Disable using the proposer to sync the builder node
#[arg(long, env, default_value = "false")]
no_boost_sync: bool,

/// Host to run the server on
#[arg(long, env, default_value = "0.0.0.0")]
rpc_host: String,

/// Port to run the server on
#[arg(long, env, default_value = "8081")]
rpc_port: u16,

// Enable tracing
#[arg(long, env, default_value = "false")]
tracing: bool,

// Enable Prometheus metrics
#[arg(long, env, default_value = "false")]
metrics: bool,

/// Host to run the metrics server on
#[arg(long, env, default_value = "0.0.0.0")]
metrics_host: String,

/// Port to run the metrics server on
#[arg(long, env, default_value = "9090")]
metrics_port: u16,

/// OTLP endpoint
#[arg(long, env, default_value = "http://localhost:4317")]
otlp_endpoint: String,

/// Log level
#[arg(long, env, default_value = "info")]
log_level: Level,

/// Log format
#[arg(long, env, default_value = "text")]
log_format: LogFormat,

/// Host to run the debug server on
#[arg(long, env, default_value = "127.0.0.1")]
debug_host: String,

/// Debug server port
#[arg(long, env, default_value = "5555")]
debug_server_port: u16,

/// Execution mode to start rollup boost with
#[arg(long, env, default_value = "enabled")]
execution_mode: ExecutionMode,
}

#[derive(Clone, Debug)]
enum LogFormat {
Json,
Text,
}

impl std::str::FromStr for LogFormat {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"json" => Ok(LogFormat::Json),
"text" => Ok(LogFormat::Text),
_ => Err("Invalid log format".into()),
}
}
}

#[derive(Subcommand, Debug)]
enum Commands {
/// Debug commands
Debug {
#[command(subcommand)]
command: DebugCommands,
},
}

#[derive(Subcommand, Debug)]
enum DebugCommands {
/// Set the execution mode
SetExecutionMode { execution_mode: ExecutionMode },

/// Get the execution mode
ExecutionMode {},
}

#[tokio::main]
async fn main() -> eyre::Result<()> {
// Load .env file
Expand Down
108 changes: 108 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
use clap::{Parser, Subcommand};
use tracing::Level;

use crate::{
client::rpc::{BuilderArgs, L2ClientArgs},
server::ExecutionMode,
};

#[derive(Parser, Debug)]
#[clap(author, version, about)]
pub struct Args {
#[command(subcommand)]
pub command: Option<Commands>,

#[clap(flatten)]
pub builder: BuilderArgs,

#[clap(flatten)]
pub l2_client: L2ClientArgs,

/// Disable using the proposer to sync the builder node
#[arg(long, env, default_value = "false")]
pub no_boost_sync: bool,

/// Host to run the server on
#[arg(long, env, default_value = "0.0.0.0")]
pub rpc_host: String,

/// Port to run the server on
#[arg(long, env, default_value = "8081")]
pub rpc_port: u16,

// Enable tracing
#[arg(long, env, default_value = "false")]
pub tracing: bool,

// Enable Prometheus metrics
#[arg(long, env, default_value = "false")]
pub metrics: bool,

/// Host to run the metrics server on
#[arg(long, env, default_value = "0.0.0.0")]
pub metrics_host: String,

/// Port to run the metrics server on
#[arg(long, env, default_value = "9090")]
pub metrics_port: u16,

/// OTLP endpoint
#[arg(long, env, default_value = "http://localhost:4317")]
pub otlp_endpoint: String,

/// Log level
#[arg(long, env, default_value = "info")]
pub log_level: Level,

/// Log format
#[arg(long, env, default_value = "text")]
pub log_format: LogFormat,

/// Host to run the debug server on
#[arg(long, env, default_value = "127.0.0.1")]
pub debug_host: String,

/// Debug server port
#[arg(long, env, default_value = "5555")]
pub debug_server_port: u16,

/// Execution mode to start rollup boost with
#[arg(long, env, default_value = "enabled")]
pub execution_mode: ExecutionMode,
}

#[derive(Clone, Debug)]
pub enum LogFormat {
Json,
Text,
}

impl std::str::FromStr for LogFormat {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"json" => Ok(LogFormat::Json),
"text" => Ok(LogFormat::Text),
_ => Err("Invalid log format".into()),
}
}
}

#[derive(Subcommand, Debug)]
pub enum Commands {
/// Debug commands
Debug {
#[command(subcommand)]
command: DebugCommands,
},
}

#[derive(Subcommand, Debug)]
pub enum DebugCommands {
/// Set the execution mode
SetExecutionMode { execution_mode: ExecutionMode },

/// Get the execution mode
ExecutionMode {},
}
4 changes: 2 additions & 2 deletions src/client/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use tracing::{debug, error, instrument};
use super::auth::{AuthClientLayer, AuthClientService};

#[derive(Clone, Debug)]
pub(crate) struct HttpClient {
pub struct HttpClient {
client: Decompression<AuthClientService<Client<HttpsConnector<HttpConnector>, HttpBody>>>,
url: Uri,
target: PayloadSource,
}

impl HttpClient {
pub(crate) fn new(url: Uri, secret: JwtSecret, target: PayloadSource) -> Self {
pub fn new(url: Uri, secret: JwtSecret, target: PayloadSource) -> Self {
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.expect("no native root CA certificates found")
Expand Down
4 changes: 2 additions & 2 deletions src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const INTERNAL_ERROR: i32 = 13;
pub(crate) type ClientResult<T> = Result<T, RpcClientError>;

#[derive(Error, Debug)]
pub(crate) enum RpcClientError {
pub enum RpcClientError {
#[error(transparent)]
Jsonrpsee(#[from] jsonrpsee::core::client::Error),
#[error("Invalid payload: {0}")]
Expand Down Expand Up @@ -89,7 +89,7 @@ impl From<RpcClientError> for ErrorObjectOwned {
/// - **Engine API** calls are faciliated via the `auth_client` (requires JWT authentication).
///
#[derive(Clone)]
pub(crate) struct RpcClient {
pub struct RpcClient {
/// Handles requests to the authenticated Engine API (requires JWT authentication)
auth_client: HttpClient<AuthClientService<HttpBackend>>,
/// Uri of the RPC server for authenticated Engine API calls
Expand Down
2 changes: 1 addition & 1 deletion src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tower::{Layer, Service, util::Either};

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

impl<S> Layer<S> for HealthLayer {
type Service = HealthService<S>;
Expand Down
Loading
Loading