Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions crates/rollup-boost/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
client::rpc::{BuilderArgs, L2ClientArgs},
debug_api::ExecutionMode,
get_version, init_metrics,
payload::PayloadSource,
payload::ExecutionClient,
probe::ProbeLayer,
};

Expand Down Expand Up @@ -117,7 +117,7 @@ impl RollupBoostArgs {
l2_client_args.l2_url.clone(),
l2_auth_jwt,
l2_client_args.l2_timeout,
PayloadSource::L2,
ExecutionClient::Sequencer,
)?;

let builder_args = self.builder;
Expand All @@ -133,7 +133,7 @@ impl RollupBoostArgs {
builder_args.builder_url.clone(),
builder_auth_jwt,
builder_args.builder_timeout,
PayloadSource::Builder,
ExecutionClient::Builder,
)?;

let (probe_layer, probes) = ProbeLayer::new();
Expand Down
16 changes: 9 additions & 7 deletions crates/rollup-boost/src/client/http.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use crate::client::auth::AuthLayer;
use crate::payload::PayloadSource;
use crate::payload::ExecutionClient;
use alloy_primitives::bytes::Bytes;
use alloy_rpc_types_engine::JwtSecret;
use http::Uri;
Expand Down Expand Up @@ -30,11 +30,11 @@ pub type HttpClientService =
pub struct HttpClient {
client: HttpClientService,
url: Uri,
target: PayloadSource,
execution_client: ExecutionClient,
}

impl HttpClient {
pub fn new(url: Uri, secret: JwtSecret, target: PayloadSource, timeout: u64) -> Self {
pub fn new(url: Uri, secret: JwtSecret, target: ExecutionClient, timeout: u64) -> Self {
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.expect("no native root CA certificates found")
Expand All @@ -54,17 +54,19 @@ impl HttpClient {
Self {
client,
url,
target,
execution_client: target,
}
}

/// Forwards an HTTP request to the `authrpc`, attaching the provided JWT authorization.
#[instrument(
skip(self, req),
level = "info",
skip_all,
fields(
otel.kind = ?SpanKind::Client,
execution_client = %self.execution_client,
url = %self.url,
method,
%method,
code,
),
err(Debug)
Expand All @@ -79,7 +81,7 @@ impl HttpClient {
+ Send
+ 'static,
{
debug!("forwarding {} to {}", method, self.target);
debug!("forwarding request");
tracing::Span::current().record("method", method);
*req.uri_mut() = self.url.clone();

Expand Down
55 changes: 28 additions & 27 deletions crates/rollup-boost/src/client/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::EngineApiExt;
use crate::client::auth::AuthLayer;
use crate::payload::{NewPayload, OpExecutionPayloadEnvelope, PayloadSource, PayloadVersion};
use crate::payload::{ExecutionClient, NewPayload, OpExecutionPayloadEnvelope, PayloadVersion};
use crate::server::EngineApiClient;
use crate::version::{CARGO_PKG_VERSION, VERGEN_GIT_SHA};
use alloy_primitives::{B256, Bytes};
Expand Down Expand Up @@ -107,8 +107,8 @@ pub struct RpcClient {
auth_client: RpcClientService,
/// Uri of the RPC server for authenticated Engine API calls
auth_rpc: Uri,
/// The source of the payload
payload_source: PayloadSource,
/// Which execution client this client is pointed to.
execution_client: ExecutionClient,
}

impl RpcClient {
Expand All @@ -117,7 +117,7 @@ impl RpcClient {
auth_rpc: Uri,
auth_rpc_jwt_secret: JwtSecret,
timeout: u64,
payload_source: PayloadSource,
execution_client: ExecutionClient,
) -> Result<Self, RpcClientError> {
let version = format!("{CARGO_PKG_VERSION}-{VERGEN_GIT_SHA}");
let mut headers = HeaderMap::new();
Expand All @@ -133,17 +133,19 @@ impl RpcClient {
Ok(Self {
auth_client,
auth_rpc,
payload_source,
execution_client,
})
}

#[instrument(
level = "info",
skip_all,
err,
fields(
otel.kind = ?SpanKind::Client,
target = self.payload_source.to_string(),
?fork_choice_state,
payload_attributes = %(payload_attributes.is_some()),
head_block_hash = %fork_choice_state.head_block_hash,
execution_client = %self.execution_client,
url = %self.auth_rpc,
code,
payload_id
Expand All @@ -154,7 +156,7 @@ impl RpcClient {
fork_choice_state: ForkchoiceState,
payload_attributes: Option<OpPayloadAttributes>,
) -> ClientResult<ForkchoiceUpdated> {
info!("Sending fork_choice_updated_v3 to {}", self.payload_source);
info!("Sending fork_choice_updated_v3");
let res = self
.auth_client
.fork_choice_updated_v3(fork_choice_state, payload_attributes.clone())
Expand All @@ -171,30 +173,27 @@ impl RpcClient {
))
.set_code();
}
info!(
"Successfully sent fork_choice_updated_v3 to {}",
self.payload_source
);

Ok(res)
}

#[instrument(
skip(self),
level = "info",
skip_all,
err,
fields(
otel.kind = ?SpanKind::Client,
target = self.payload_source.to_string(),
url = %self.auth_rpc,
%payload_id,
execution_client = self.execution_client.to_string(),
url = %self.auth_rpc,
code,
)
)]
pub async fn get_payload_v3(
&self,
payload_id: PayloadId,
) -> ClientResult<OpExecutionPayloadEnvelopeV3> {
tracing::Span::current().record("payload_id", payload_id.to_string());
info!("Sending get_payload_v3 to {}", self.payload_source);
info!("sending get_payload_v3");
Ok(self
.auth_client
.get_payload_v3(payload_id)
Expand All @@ -203,11 +202,12 @@ impl RpcClient {
}

#[instrument(
level = "info",
skip_all,
err,
fields(
otel.kind = ?SpanKind::Client,
target = self.payload_source.to_string(),
execution_client = self.execution_client.to_string(),
url = %self.auth_rpc,
block_hash = %payload.payload_inner.payload_inner.block_hash,
code,
Expand All @@ -219,8 +219,7 @@ impl RpcClient {
versioned_hashes: Vec<B256>,
parent_beacon_block_root: B256,
) -> ClientResult<PayloadStatus> {
info!("Sending new_payload_v3 to {}", self.payload_source);

info!("Sending new_payload_v3");
let res = self
.auth_client
.new_payload_v3(payload, versioned_hashes, parent_beacon_block_root)
Expand All @@ -235,11 +234,12 @@ impl RpcClient {
}

#[instrument(
skip(self),
level = "info",
skip_all,
err,
fields(
otel.kind = ?SpanKind::Client,
target = self.payload_source.to_string(),
execution_client = %self.execution_client,
url = %self.auth_rpc,
%payload_id,
)
Expand All @@ -248,7 +248,7 @@ impl RpcClient {
&self,
payload_id: PayloadId,
) -> ClientResult<OpExecutionPayloadEnvelopeV4> {
info!("Sending get_payload_v4 to {}", self.payload_source);
info!("Sending get_payload_v4");
Ok(self
.auth_client
.get_payload_v4(payload_id)
Expand All @@ -272,11 +272,12 @@ impl RpcClient {
}

#[instrument(
level = "info",
skip_all,
err,
fields(
otel.kind = ?SpanKind::Client,
target = self.payload_source.to_string(),
execution_client = %self.execution_client,
url = %self.auth_rpc,
block_hash = %payload.payload_inner.payload_inner.payload_inner.block_hash,
code,
Expand All @@ -289,7 +290,7 @@ impl RpcClient {
parent_beacon_block_root: B256,
execution_requests: Vec<Bytes>,
) -> ClientResult<PayloadStatus> {
info!("Sending new_payload_v4 to {}", self.payload_source);
info!("Sending new_payload_v4");

let res = self
.auth_client
Expand Down Expand Up @@ -413,7 +414,7 @@ pub mod tests {
use jsonrpsee::core::client::ClientT;
use parking_lot::Mutex;

use crate::payload::PayloadSource;
use crate::payload::ExecutionClient;
use alloy_rpc_types_engine::JwtSecret;
use jsonrpsee::core::client::Error as ClientError;
use jsonrpsee::server::{ServerBuilder, ServerHandle};
Expand Down Expand Up @@ -457,7 +458,7 @@ pub mod tests {
let port = get_available_port();
let secret = JwtSecret::from_hex(SECRET).unwrap();
let auth_rpc = Uri::from_str(&format!("http://{}:{}", AUTH_ADDR, port)).unwrap();
let client = RpcClient::new(auth_rpc, secret, 1000, PayloadSource::L2).unwrap();
let client = RpcClient::new(auth_rpc, secret, 1000, ExecutionClient::Sequencer).unwrap();
let response = send_request(client.auth_client, port).await;
assert!(response.is_ok());
assert_eq!(response.unwrap(), "You are the dark lord");
Expand Down
6 changes: 3 additions & 3 deletions crates/rollup-boost/src/flashblocks/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl EngineApiExt for FlashblocksService {
mod tests {
use super::*;
use crate::{
PayloadSource,
ExecutionClient,
server::tests::{MockEngineServer, spawn_server},
};
use http::Uri;
Expand All @@ -399,7 +399,7 @@ mod tests {
builder_auth_rpc.clone(),
jwt_secret,
2000,
PayloadSource::Builder,
ExecutionClient::Builder,
)?;

let service =
Expand Down Expand Up @@ -428,7 +428,7 @@ mod tests {
builder_auth_rpc.clone(),
jwt_secret,
2000,
PayloadSource::Builder,
ExecutionClient::Builder,
)?;

let service =
Expand Down
12 changes: 6 additions & 6 deletions crates/rollup-boost/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod tests {
use tokio::net::TcpListener;

use super::*;
use crate::{Probes, payload::PayloadSource};
use crate::{Probes, payload::ExecutionClient};

pub struct MockHttpServer {
addr: SocketAddr,
Expand Down Expand Up @@ -272,7 +272,7 @@ mod tests {
format!("http://{}", builder.addr).parse::<Uri>()?,
JwtSecret::random(),
100,
PayloadSource::Builder,
ExecutionClient::Builder,
)?);

let health_handle = HealthHandle {
Expand Down Expand Up @@ -303,7 +303,7 @@ mod tests {
format!("http://{}", builder.addr).parse::<Uri>()?,
JwtSecret::random(),
100,
PayloadSource::Builder,
ExecutionClient::Builder,
)?);

let health_handle = HealthHandle {
Expand Down Expand Up @@ -335,7 +335,7 @@ mod tests {
format!("http://{}", builder.addr).parse::<Uri>()?,
JwtSecret::random(),
100,
PayloadSource::Builder,
ExecutionClient::Builder,
)?);

let health_handle = HealthHandle {
Expand Down Expand Up @@ -367,7 +367,7 @@ mod tests {
format!("http://{}", builder.addr).parse::<Uri>()?,
JwtSecret::random(),
100,
PayloadSource::Builder,
ExecutionClient::Builder,
)?);

let health_handle = HealthHandle {
Expand All @@ -392,7 +392,7 @@ mod tests {
"http://127.0.0.1:6000".parse::<Uri>()?,
JwtSecret::random(),
100,
PayloadSource::Builder,
ExecutionClient::Builder,
)?);

let health_handle = HealthHandle {
Expand Down
16 changes: 8 additions & 8 deletions crates/rollup-boost/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,28 @@ impl PayloadVersion {
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PayloadSource {
L2,
pub enum ExecutionClient {
Sequencer,
Builder,
}

impl std::fmt::Display for PayloadSource {
impl std::fmt::Display for ExecutionClient {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PayloadSource::L2 => write!(f, "l2"),
PayloadSource::Builder => write!(f, "builder"),
ExecutionClient::Sequencer => write!(f, "sequencer"),
ExecutionClient::Builder => write!(f, "builder"),
}
}
}

#[allow(dead_code)]
impl PayloadSource {
impl ExecutionClient {
pub fn is_builder(&self) -> bool {
matches!(self, PayloadSource::Builder)
matches!(self, ExecutionClient::Builder)
}

pub fn is_l2(&self) -> bool {
matches!(self, PayloadSource::L2)
matches!(self, ExecutionClient::Sequencer)
}
}

Expand Down
Loading
Loading