diff --git a/crates/rollup-boost/src/cli.rs b/crates/rollup-boost/src/cli.rs index 3eb4d3d6..1d5f3566 100644 --- a/crates/rollup-boost/src/cli.rs +++ b/crates/rollup-boost/src/cli.rs @@ -17,7 +17,7 @@ use crate::{ client::rpc::{BuilderArgs, L2ClientArgs}, debug_api::ExecutionMode, get_version, init_metrics, - payload::PayloadSource, + payload::ExecutionClient, probe::ProbeLayer, }; @@ -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; @@ -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(); diff --git a/crates/rollup-boost/src/client/http.rs b/crates/rollup-boost/src/client/http.rs index 5e18edd7..9063c014 100644 --- a/crates/rollup-boost/src/client/http.rs +++ b/crates/rollup-boost/src/client/http.rs @@ -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; @@ -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, execution_client: ExecutionClient, timeout: u64) -> Self { let connector = hyper_rustls::HttpsConnectorBuilder::new() .with_native_roots() .expect("no native root CA certificates found") @@ -54,17 +54,18 @@ impl HttpClient { Self { client, url, - target, + execution_client, } } /// Forwards an HTTP request to the `authrpc`, attaching the provided JWT authorization. #[instrument( - skip(self, req), + skip_all, fields( otel.kind = ?SpanKind::Client, + execution_client = %self.execution_client, url = %self.url, - method, + %method, code, ), err(Debug) @@ -79,7 +80,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(); diff --git a/crates/rollup-boost/src/client/rpc.rs b/crates/rollup-boost/src/client/rpc.rs index 6633e643..53418916 100644 --- a/crates/rollup-boost/src/client/rpc.rs +++ b/crates/rollup-boost/src/client/rpc.rs @@ -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}; @@ -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 { @@ -117,7 +117,7 @@ impl RpcClient { auth_rpc: Uri, auth_rpc_jwt_secret: JwtSecret, timeout: u64, - payload_source: PayloadSource, + execution_client: ExecutionClient, ) -> Result { let version = format!("{CARGO_PKG_VERSION}-{VERGEN_GIT_SHA}"); let mut headers = HeaderMap::new(); @@ -133,17 +133,18 @@ impl RpcClient { Ok(Self { auth_client, auth_rpc, - payload_source, + execution_client, }) } #[instrument( 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 @@ -154,7 +155,7 @@ impl RpcClient { fork_choice_state: ForkchoiceState, payload_attributes: Option, ) -> ClientResult { - 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()) @@ -171,30 +172,26 @@ impl RpcClient { )) .set_code(); } - info!( - "Successfully sent fork_choice_updated_v3 to {}", - self.payload_source - ); Ok(res) } #[instrument( - skip(self), + 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 { - 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) @@ -207,7 +204,7 @@ impl RpcClient { 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, @@ -219,8 +216,7 @@ impl RpcClient { versioned_hashes: Vec, parent_beacon_block_root: B256, ) -> ClientResult { - 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) @@ -235,11 +231,11 @@ impl RpcClient { } #[instrument( - skip(self), + 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, ) @@ -248,7 +244,7 @@ impl RpcClient { &self, payload_id: PayloadId, ) -> ClientResult { - info!("Sending get_payload_v4 to {}", self.payload_source); + info!("Sending get_payload_v4"); Ok(self .auth_client .get_payload_v4(payload_id) @@ -276,7 +272,7 @@ impl RpcClient { 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, @@ -289,7 +285,7 @@ impl RpcClient { parent_beacon_block_root: B256, execution_requests: Vec, ) -> ClientResult { - info!("Sending new_payload_v4 to {}", self.payload_source); + info!("Sending new_payload_v4"); let res = self .auth_client @@ -413,7 +409,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}; @@ -457,7 +453,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"); diff --git a/crates/rollup-boost/src/flashblocks/service.rs b/crates/rollup-boost/src/flashblocks/service.rs index 6c95eef9..077d8074 100644 --- a/crates/rollup-boost/src/flashblocks/service.rs +++ b/crates/rollup-boost/src/flashblocks/service.rs @@ -380,7 +380,7 @@ impl EngineApiExt for FlashblocksService { mod tests { use super::*; use crate::{ - PayloadSource, + ExecutionClient, server::tests::{MockEngineServer, spawn_server}, }; use http::Uri; @@ -399,7 +399,7 @@ mod tests { builder_auth_rpc.clone(), jwt_secret, 2000, - PayloadSource::Builder, + ExecutionClient::Builder, )?; let service = @@ -428,7 +428,7 @@ mod tests { builder_auth_rpc.clone(), jwt_secret, 2000, - PayloadSource::Builder, + ExecutionClient::Builder, )?; let service = diff --git a/crates/rollup-boost/src/health.rs b/crates/rollup-boost/src/health.rs index fed2e27c..2d6582f4 100644 --- a/crates/rollup-boost/src/health.rs +++ b/crates/rollup-boost/src/health.rs @@ -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, @@ -272,7 +272,7 @@ mod tests { format!("http://{}", builder.addr).parse::()?, JwtSecret::random(), 100, - PayloadSource::Builder, + ExecutionClient::Builder, )?); let health_handle = HealthHandle { @@ -303,7 +303,7 @@ mod tests { format!("http://{}", builder.addr).parse::()?, JwtSecret::random(), 100, - PayloadSource::Builder, + ExecutionClient::Builder, )?); let health_handle = HealthHandle { @@ -335,7 +335,7 @@ mod tests { format!("http://{}", builder.addr).parse::()?, JwtSecret::random(), 100, - PayloadSource::Builder, + ExecutionClient::Builder, )?); let health_handle = HealthHandle { @@ -367,7 +367,7 @@ mod tests { format!("http://{}", builder.addr).parse::()?, JwtSecret::random(), 100, - PayloadSource::Builder, + ExecutionClient::Builder, )?); let health_handle = HealthHandle { @@ -392,7 +392,7 @@ mod tests { "http://127.0.0.1:6000".parse::()?, JwtSecret::random(), 100, - PayloadSource::Builder, + ExecutionClient::Builder, )?); let health_handle = HealthHandle { diff --git a/crates/rollup-boost/src/payload.rs b/crates/rollup-boost/src/payload.rs index 1ed6707e..da00b9fc 100644 --- a/crates/rollup-boost/src/payload.rs +++ b/crates/rollup-boost/src/payload.rs @@ -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) } } diff --git a/crates/rollup-boost/src/proxy.rs b/crates/rollup-boost/src/proxy.rs index 4853907f..1590f5d1 100644 --- a/crates/rollup-boost/src/proxy.rs +++ b/crates/rollup-boost/src/proxy.rs @@ -1,5 +1,5 @@ use crate::client::http::HttpClient; -use crate::payload::PayloadSource; +use crate::payload::ExecutionClient; use crate::{Request, Response, from_buffered_request, into_buffered_request}; use alloy_rpc_types_engine::JwtSecret; use http::Uri; @@ -60,14 +60,14 @@ impl Layer for ProxyLayer { let l2_client = HttpClient::new( self.l2_auth_rpc.clone(), self.l2_auth_secret, - PayloadSource::L2, + ExecutionClient::Sequencer, self.l2_timeout, ); let builder_client = HttpClient::new( self.builder_auth_rpc.clone(), self.builder_auth_secret, - PayloadSource::Builder, + ExecutionClient::Builder, self.builder_timeout, ); diff --git a/crates/rollup-boost/src/selection.rs b/crates/rollup-boost/src/selection.rs index d6ef583d..f379632a 100644 --- a/crates/rollup-boost/src/selection.rs +++ b/crates/rollup-boost/src/selection.rs @@ -1,4 +1,4 @@ -use crate::{OpExecutionPayloadEnvelope, PayloadSource}; +use crate::{ExecutionClient, OpExecutionPayloadEnvelope}; use serde::{Deserialize, Serialize}; /// Defines the strategy for choosing between the builder block and the L2 client block @@ -19,7 +19,7 @@ impl BlockSelectionPolicy { &self, builder_payload: OpExecutionPayloadEnvelope, l2_payload: OpExecutionPayloadEnvelope, - ) -> (OpExecutionPayloadEnvelope, PayloadSource) { + ) -> (OpExecutionPayloadEnvelope, ExecutionClient) { match self { BlockSelectionPolicy::GasUsed => { let builder_gas = builder_payload.gas_used() as f64; @@ -28,9 +28,9 @@ impl BlockSelectionPolicy { // Select the L2 block if the builder block uses less than 10% of the gas. // This avoids selecting empty or severely underfilled blocks, if builder_gas < l2_gas * 0.1 { - (l2_payload, PayloadSource::L2) + (l2_payload, ExecutionClient::Sequencer) } else { - (builder_payload, PayloadSource::Builder) + (builder_payload, ExecutionClient::Builder) } } } @@ -71,7 +71,7 @@ mod tests { let selected_payload = BlockSelectionPolicy::GasUsed.select_block(builder_payload, l2_payload); - assert_eq!(selected_payload.1, PayloadSource::L2); + assert_eq!(selected_payload.1, ExecutionClient::Sequencer); Ok(()) } @@ -103,7 +103,7 @@ mod tests { let selected_payload = BlockSelectionPolicy::GasUsed.select_block(builder_payload, l2_payload); - assert_eq!(selected_payload.1, PayloadSource::Builder); + assert_eq!(selected_payload.1, ExecutionClient::Builder); Ok(()) } } diff --git a/crates/rollup-boost/src/server.rs b/crates/rollup-boost/src/server.rs index d6f315a2..4afc0118 100644 --- a/crates/rollup-boost/src/server.rs +++ b/crates/rollup-boost/src/server.rs @@ -5,7 +5,7 @@ use crate::{ debug_api::DebugServer, health::HealthHandle, payload::{ - NewPayload, NewPayloadV3, NewPayloadV4, OpExecutionPayloadEnvelope, PayloadSource, + ExecutionClient, NewPayload, NewPayloadV3, NewPayloadV4, OpExecutionPayloadEnvelope, PayloadTraceContext, PayloadVersion, }, probe::{Health, Probes}, @@ -104,7 +104,7 @@ where let execution_payload = ExecutionPayload::from(new_payload.clone()); let block_hash = execution_payload.block_hash(); let parent_hash = execution_payload.parent_hash(); - info!(message = "received new_payload", "block_hash" = %block_hash, "version" = new_payload.version().as_str()); + info!(%block_hash, "version" = new_payload.version().as_str(), "received new_payload"); if let Some(causes) = self .payload_trace_context @@ -142,19 +142,21 @@ where return match l2_fut.await { Ok(payload) => { self.probes.set_health(Health::Healthy); - let context = PayloadSource::L2; - tracing::Span::current().record("payload_source", context.to_string()); - counter!("rpc.blocks_created", "source" => context.to_string()).increment(1); + let execution_client = ExecutionClient::Sequencer; + tracing::Span::current() + .record("execution_client", execution_client.to_string()); + counter!("rpc.blocks_created", "source" => execution_client.to_string()) + .increment(1); let execution_payload = ExecutionPayload::from(payload.clone()); info!( - message = "returning block", "hash" = %execution_payload.block_hash(), "number" = %execution_payload.block_number(), - %context, + %execution_client, %payload_id, // Add an extra label to know that this is the disabled execution mode path "execution_mode" = "disabled", + "returning block" ); Ok(payload) @@ -177,14 +179,14 @@ where .has_builder_payload(&payload_id) .await { - info!(message = "builder has no payload, skipping get_payload call to builder"); + info!("builder has no payload, skipping get_payload call to builder"); tracing::Span::current().record("builder_has_payload", false); return RpcResult::Ok(None); } // Get payload and validate with the local l2 client tracing::Span::current().record("builder_has_payload", true); - info!(message = "builder has payload, calling get_payload on builder"); + info!("builder has payload, calling get_payload on builder"); let payload = self.builder_client.get_payload(payload_id, version).await?; let _ = self @@ -198,7 +200,7 @@ where let (l2_payload, builder_payload) = tokio::join!(l2_fut, builder_fut); // Evaluate the builder and l2 response and select the final payload - let (payload, context) = { + let (payload, execution_client) = { let l2_payload = l2_payload.inspect_err(|_| self.probes.set_health(Health::ServiceUnavailable))?; self.probes.set_health(Health::Healthy); @@ -206,9 +208,9 @@ where // Convert Result> to Option by extracting the inner Option. // If there's an error, log it and return None instead. let builder_payload = builder_payload - .map_err(|e| { - error!(message = "error getting payload from builder", error = %e); - e + .map_err(|error| { + error!(%error, "error getting payload from builder"); + error }) .unwrap_or(None); @@ -228,11 +230,11 @@ where // If execution mode is set to DryRun, fallback to the l2_payload, // otherwise prefer the builder payload if self.execution_mode().is_dry_run() { - (l2_payload, PayloadSource::L2) + (l2_payload, ExecutionClient::Sequencer) } else if let Some(selection_policy) = &self.block_selection_policy { selection_policy.select_block(builder_payload, l2_payload) } else { - (builder_payload, PayloadSource::Builder) + (builder_payload, ExecutionClient::Builder) } } else { // Only update the health status if the builder payload fails @@ -240,14 +242,14 @@ where if !self.execution_mode().is_dry_run() { self.probes.set_health(Health::PartialContent); } - (l2_payload, PayloadSource::L2) + (l2_payload, ExecutionClient::Sequencer) } }; - tracing::Span::current().record("payload_source", context.to_string()); + tracing::Span::current().record("execution_client", execution_client.to_string()); // To maintain backwards compatibility with old metrics, we need to record blocks built // This is temporary until we migrate to the new metrics - counter!("rpc.blocks_created", "source" => context.to_string()).increment(1); + counter!("rpc.blocks_created", "source" => execution_client.to_string()).increment(1); let inner_payload = ExecutionPayload::from(payload.clone()); let block_hash = inner_payload.block_hash(); @@ -260,7 +262,7 @@ where message = "returning block", "hash" = %block_hash, "number" = %block_number, - %context, + %execution_client, %payload_id, ); Ok(payload) @@ -364,10 +366,10 @@ where if attrs.no_tx_pool.unwrap_or_default() { let l2_response = l2_fut.await?; if let Some(payload_id) = l2_response.payload_id { + tracing::Span::current().record("payload_id", payload_id.to_string()); info!( - message = "block building started", - "payload_id" = %payload_id, - "builder_building" = false, + "block_builder" = %ExecutionClient::Sequencer, + "block building started", ); self.payload_trace_context @@ -393,10 +395,14 @@ where let l2_response = l2_result?; if let Some(payload_id) = l2_response.payload_id { + let block_builder = if builder_result.is_ok() { + ExecutionClient::Builder + } else { + ExecutionClient::Sequencer + }; info!( - message = "block building started", - "payload_id" = %payload_id, - "builder_building" = builder_result.is_ok(), + %block_builder, + "block building started", ); self.payload_trace_context @@ -431,15 +437,7 @@ where #[instrument( skip_all, err, - fields( - otel.kind = ?SpanKind::Server, - %payload_id, - payload_source, - gas_delta, - tx_count_delta, - builder_has_payload, - flashblocks_count, - ) + fields(otel.kind = ?SpanKind::Server, %payload_id) )] async fn get_payload_v3( &self, @@ -460,9 +458,7 @@ where #[instrument( skip_all, err, - fields( - otel.kind = ?SpanKind::Server, - ) + fields(otel.kind = ?SpanKind::Server, %parent_beacon_block_root) )] async fn new_payload_v3( &self, @@ -483,13 +479,7 @@ where #[instrument( skip_all, err, - fields( - otel.kind = ?SpanKind::Server, - %payload_id, - payload_source, - gas_delta, - tx_count_delta, - ) + fields(otel.kind = ?SpanKind::Server, %payload_id) )] async fn get_payload_v4( &self, @@ -512,6 +502,7 @@ where err, fields( otel.kind = ?SpanKind::Server, + %parent_beacon_block_root, ) )] async fn new_payload_v4( @@ -652,8 +643,13 @@ pub mod tests { let (builder_server, builder_server_addr) = spawn_server(builder_mock.clone()).await; let l2_auth_rpc = Uri::from_str(&format!("http://{l2_server_addr}")).unwrap(); - let l2_client = - RpcClient::new(l2_auth_rpc.clone(), jwt_secret, 2000, PayloadSource::L2).unwrap(); + let l2_client = RpcClient::new( + l2_auth_rpc.clone(), + jwt_secret, + 2000, + ExecutionClient::Sequencer, + ) + .unwrap(); let builder_auth_rpc = Uri::from_str(&format!("http://{builder_server_addr}")).unwrap(); let builder_client = Arc::new( @@ -661,7 +657,7 @@ pub mod tests { builder_auth_rpc.clone(), jwt_secret, 2000, - PayloadSource::Builder, + ExecutionClient::Builder, ) .unwrap(), ); diff --git a/crates/rollup-boost/src/tests/common/mod.rs b/crates/rollup-boost/src/tests/common/mod.rs index 7d6f2a13..8676f38f 100644 --- a/crates/rollup-boost/src/tests/common/mod.rs +++ b/crates/rollup-boost/src/tests/common/mod.rs @@ -2,7 +2,7 @@ use crate::DebugClient; use crate::{AuthLayer, AuthService}; use crate::{EngineApiClient, OpExecutionPayloadEnvelope, PayloadVersion}; -use crate::{NewPayload, PayloadSource}; +use crate::{ExecutionClient, NewPayload}; use alloy_eips::Encodable2718; use alloy_primitives::{B256, Bytes, TxKind, U256, address, hex}; use alloy_rpc_types_engine::{ExecutionPayload, JwtSecret}; @@ -292,7 +292,7 @@ impl RollupBoostTestHarnessBuilder { pub async fn build(self) -> eyre::Result { let network = rand::random::().to_string(); - let l2_log_consumer = self.log_consumer("l2").await?; + let l2_log_consumer = self.log_consumer("sequencer").await?; let builder_log_consumer = self.log_consumer("builder").await?; let rollup_boost_log_file_path = self.file_path("rollup_boost")?; @@ -442,7 +442,7 @@ impl SimpleBlockGenerator { pub async fn generate_block( &mut self, empty_blocks: bool, - ) -> eyre::Result<(B256, PayloadSource)> { + ) -> eyre::Result<(B256, ExecutionClient)> { let timestamp = self.timestamp + self.genesis.block_time; self.current_block_number += 1; @@ -553,31 +553,38 @@ impl BlockBuilderCreatorValidator { } impl BlockBuilderCreatorValidator { - pub async fn get_block_creator(&self, block_hash: B256) -> eyre::Result> { + pub async fn get_block_creator( + &self, + block_hash: B256, + ) -> eyre::Result> { let contents = std::fs::read_to_string(&self.file)?; - let search_query = format!("returning block hash={:#x}", block_hash); + let search_query = format!("returning block hash={block_hash:#x}"); // Find the log line containing the block hash for line in contents.lines() { if line.contains(&search_query) { // Extract the context=X part - if let Some(context_start) = line.find("context=") { - let context = line[context_start..] + println!("Found line: {line}"); + if let Some(context_start) = line.find("execution_client=") { + let execution_client = line[context_start..] .split_whitespace() .next() - .ok_or(eyre::eyre!("no context found"))? + .ok_or(eyre::eyre!("execution_client not found"))? + .split("}") + .next() + .ok_or(eyre::eyre!("execution_client not found"))? .split('=') .nth(1) - .ok_or(eyre::eyre!("no context found"))?; + .ok_or(eyre::eyre!("execution_client not found"))?; - match context { - "builder" => return Ok(Some(PayloadSource::Builder)), - "l2" => return Ok(Some(PayloadSource::L2)), - _ => panic!("Unknown context: {}", context), + match execution_client { + "builder" => return Ok(Some(ExecutionClient::Builder)), + "sequencer" => return Ok(Some(ExecutionClient::Sequencer)), + _ => panic!("Unknown execution_client: {execution_client}"), } } else { - panic!("no context found"); + panic!("execution_client not found"); } } } diff --git a/crates/rollup-boost/src/tracing.rs b/crates/rollup-boost/src/tracing.rs index a0e06076..2a0a8581 100644 --- a/crates/rollup-boost/src/tracing.rs +++ b/crates/rollup-boost/src/tracing.rs @@ -20,7 +20,7 @@ use crate::cli::{LogFormat, RollupBoostArgs}; /// label cardinality in mind. Not all span attributes make /// appropriate labels. pub const SPAN_ATTRIBUTE_LABELS: [&str; 4] = - ["code", "payload_source", "method", "builder_has_payload"]; + ["code", "execution_client", "method", "builder_has_payload"]; /// Custom span processor that records span durations as histograms #[derive(Debug)] @@ -124,82 +124,61 @@ pub fn init_tracing(args: &RollupBoostArgs) -> eyre::Result<()> { BoxMakeWriter::new(std::io::stdout) }; - // Weird control flow here is required because of type system + global::set_text_map_propagator(TraceContextPropagator::new()); + + let mut provider_builder = opentelemetry_sdk::trace::SdkTracerProvider::builder() + .with_resource( + Resource::builder_empty() + .with_attributes([ + KeyValue::new("service.name", env!("CARGO_PKG_NAME")), + KeyValue::new("service.version", env!("CARGO_PKG_VERSION")), + ]) + .build(), + ); + if args.tracing { - global::set_text_map_propagator(TraceContextPropagator::new()); let otlp_exporter = opentelemetry_otlp::SpanExporter::builder() .with_tonic() .with_endpoint(&args.otlp_endpoint) .build() .context("Failed to create OTLP exporter")?; - let mut provider_builder = opentelemetry_sdk::trace::SdkTracerProvider::builder() - .with_batch_exporter(otlp_exporter) - .with_resource( - Resource::builder_empty() - .with_attributes([ - KeyValue::new("service.name", env!("CARGO_PKG_NAME")), - KeyValue::new("service.version", env!("CARGO_PKG_VERSION")), - ]) - .build(), - ); - if args.metrics { - provider_builder = provider_builder.with_span_processor(MetricsSpanProcessor); - } - let provider = provider_builder.build(); - let tracer = provider.tracer(env!("CARGO_PKG_NAME")); - - let trace_filter = Targets::new() - .with_default(LevelFilter::OFF) - .with_target(&filter_name, LevelFilter::TRACE); - - let registry = registry.with(OpenTelemetryLayer::new(tracer).with_filter(trace_filter)); - - match args.log_format { - LogFormat::Json => { - tracing::subscriber::set_global_default( - registry.with( - tracing_subscriber::fmt::layer() - .json() - .with_ansi(false) - .with_writer(writer) - .with_filter(log_filter.clone()), - ), - )?; - } - LogFormat::Text => { - tracing::subscriber::set_global_default( - registry.with( - tracing_subscriber::fmt::layer() - .with_ansi(false) - .with_writer(writer) - .with_filter(log_filter.clone()), - ), - )?; - } + provider_builder = provider_builder.with_batch_exporter(otlp_exporter); + } + + if args.metrics { + provider_builder = provider_builder.with_span_processor(MetricsSpanProcessor); + } + + let provider = provider_builder.build(); + let tracer = provider.tracer(env!("CARGO_PKG_NAME")); + + let trace_filter = Targets::new() + .with_default(LevelFilter::OFF) + .with_target(&filter_name, LevelFilter::TRACE); + + let registry = registry.with(OpenTelemetryLayer::new(tracer).with_filter(trace_filter)); + + match args.log_format { + LogFormat::Json => { + tracing::subscriber::set_global_default( + registry.with( + tracing_subscriber::fmt::layer() + .json() + .with_ansi(false) + .with_writer(writer) + .with_filter(log_filter.clone()), + ), + )?; } - } else { - match args.log_format { - LogFormat::Json => { - tracing::subscriber::set_global_default( - registry.with( - tracing_subscriber::fmt::layer() - .json() - .with_ansi(false) - .with_writer(writer) - .with_filter(log_filter.clone()), - ), - )?; - } - LogFormat::Text => { - tracing::subscriber::set_global_default( - registry.with( - tracing_subscriber::fmt::layer() - .with_ansi(false) - .with_writer(writer) - .with_filter(log_filter.clone()), - ), - )?; - } + LogFormat::Text => { + tracing::subscriber::set_global_default( + registry.with( + tracing_subscriber::fmt::layer() + .with_ansi(false) + .with_writer(writer) + .with_filter(log_filter.clone()), + ), + )?; } }