From 5f7764317be6940e5cfb1b6804b0f48db5a9e995 Mon Sep 17 00:00:00 2001 From: Anna Carroll Date: Wed, 18 Jun 2025 14:37:26 +0200 Subject: [PATCH 1/4] fix: span record fields --- crates/rpc/src/eth/endpoints.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/rpc/src/eth/endpoints.rs b/crates/rpc/src/eth/endpoints.rs index e5ad459b..0020276a 100644 --- a/crates/rpc/src/eth/endpoints.rs +++ b/crates/rpc/src/eth/endpoints.rs @@ -29,7 +29,7 @@ use reth_rpc_eth_api::{RpcBlock, RpcHeader, RpcReceipt, RpcTransaction}; use serde::Deserialize; use signet_evm::EvmErrored; use std::borrow::Cow; -use tracing::{trace_span, Instrument}; +use tracing::{field::Empty, span::Span, trace_span, Instrument}; use trevm::revm::context::result::ExecutionResult; /// Args for `eth_estimateGas` and `eth_call`. @@ -433,7 +433,7 @@ where block_id = %id, state_overrides = ?state_overrides.as_ref().map(StateOverride::len).unwrap_or_default(), block_overrides = ?block_overrides.is_some(), - block_cfg = tracing::field::Empty, + block_cfg = Empty, ); let task = async move { @@ -447,7 +447,7 @@ where } }; - tracing::span::Span::current().record("block_cfg", format!("{:?}", &block_cfg)); + Span::current().record("block_cfg", format!("{:?}", &block_cfg)); // Set up trevm @@ -461,7 +461,7 @@ where // modify the gas cap. let new_gas = response_tri!(trevm.cap_tx_gas()); if Some(new_gas) != request.gas { - tracing::span::Span::current().record("request", format!("{:?}", &request)); + Span::current().record("request", format!("{:?}", &request)); } let execution_result = response_tri!(trevm.call().map_err(EvmErrored::into_error)).0; @@ -534,14 +534,16 @@ where block_id = %id, state_overrides = ?state_overrides.as_ref().map(StateOverride::len).unwrap_or_default(), block_overrides = ?block_overrides.is_some(), - block_cfg = tracing::field::Empty, + block_cfg = Empty, + normalized_gas = Empty, + estimate = Empty, ); // Stateless gas normalization. let max_gas = ctx.signet().config().rpc_gas_cap; normalize_gas_stateless(&mut request, max_gas); - tracing::span::Span::current().record("normalized_gas", format!("{:?}", request.gas)); + Span::current().record("normalized_gas", format!("{:?}", request.gas)); let task = async move { // Get the block cfg from backend, erroring if it fails @@ -555,7 +557,7 @@ where } }; - tracing::span::Span::current().record("block_cfg", format!("{:?}", &block_cfg)); + Span::current().record("block_cfg", format!("{:?}", &block_cfg)); let trevm = response_tri!(ctx.trevm(id, &block_cfg)); @@ -570,7 +572,7 @@ where let (estimate, _) = response_tri!(trevm.estimate_gas().map_err(EvmErrored::into_error)); - tracing::span::Span::current().record("estimate", format!("{:?}", &estimate)); + Span::current().record("estimate", format!("{:?}", &estimate)); match estimate { trevm::EstimationResult::Success { estimation, .. } => { From af6665a8d45f2b8099c83b748008e3b87da025e6 Mon Sep 17 00:00:00 2001 From: Anna Carroll Date: Wed, 18 Jun 2025 15:12:45 +0200 Subject: [PATCH 2/4] add tracing logs --- crates/rpc/src/eth/endpoints.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/rpc/src/eth/endpoints.rs b/crates/rpc/src/eth/endpoints.rs index 0020276a..bd9f81f2 100644 --- a/crates/rpc/src/eth/endpoints.rs +++ b/crates/rpc/src/eth/endpoints.rs @@ -29,7 +29,7 @@ use reth_rpc_eth_api::{RpcBlock, RpcHeader, RpcReceipt, RpcTransaction}; use serde::Deserialize; use signet_evm::EvmErrored; use std::borrow::Cow; -use tracing::{field::Empty, span::Span, trace_span, Instrument}; +use tracing::{field::Empty, span::Span, trace, trace_span, Instrument}; use trevm::revm::context::result::ExecutionResult; /// Args for `eth_estimateGas` and `eth_call`. @@ -527,6 +527,7 @@ where { let id = block.unwrap_or(BlockId::pending()); + trace!(initial_gas = request.gas, "request received for estimate_gas"); // this span is verbose yo. let span = trace_span!( "estimate_gas", @@ -543,6 +544,7 @@ where let max_gas = ctx.signet().config().rpc_gas_cap; normalize_gas_stateless(&mut request, max_gas); + trace!(normalized_gas = request.gas, "gas normalized for estimate_gas"); Span::current().record("normalized_gas", format!("{:?}", request.gas)); let task = async move { @@ -572,6 +574,7 @@ where let (estimate, _) = response_tri!(trevm.estimate_gas().map_err(EvmErrored::into_error)); + trace!(?estimate, "estimate done for estimate_gas"); Span::current().record("estimate", format!("{:?}", &estimate)); match estimate { From 1d4a92c84756c313208fc1ffe5fb82e9f974a1fe Mon Sep 17 00:00:00 2001 From: Anna Carroll Date: Wed, 18 Jun 2025 15:20:17 +0200 Subject: [PATCH 3/4] fix span actually --- crates/rpc/src/eth/endpoints.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/rpc/src/eth/endpoints.rs b/crates/rpc/src/eth/endpoints.rs index bd9f81f2..e70c97ed 100644 --- a/crates/rpc/src/eth/endpoints.rs +++ b/crates/rpc/src/eth/endpoints.rs @@ -29,7 +29,7 @@ use reth_rpc_eth_api::{RpcBlock, RpcHeader, RpcReceipt, RpcTransaction}; use serde::Deserialize; use signet_evm::EvmErrored; use std::borrow::Cow; -use tracing::{field::Empty, span::Span, trace, trace_span, Instrument}; +use tracing::{field::Empty, span::Span, trace_span, Instrument}; use trevm::revm::context::result::ExecutionResult; /// Args for `eth_estimateGas` and `eth_call`. @@ -527,7 +527,6 @@ where { let id = block.unwrap_or(BlockId::pending()); - trace!(initial_gas = request.gas, "request received for estimate_gas"); // this span is verbose yo. let span = trace_span!( "estimate_gas", @@ -544,9 +543,9 @@ where let max_gas = ctx.signet().config().rpc_gas_cap; normalize_gas_stateless(&mut request, max_gas); - trace!(normalized_gas = request.gas, "gas normalized for estimate_gas"); - Span::current().record("normalized_gas", format!("{:?}", request.gas)); + span.record("normalized_gas", format!("{:?}", request.gas)); + let span_for_task = span.clone(); let task = async move { // Get the block cfg from backend, erroring if it fails let block_cfg = match ctx.signet().block_cfg(id).await { @@ -559,7 +558,7 @@ where } }; - Span::current().record("block_cfg", format!("{:?}", &block_cfg)); + span.record("block_cfg", format!("{:?}", &block_cfg)); let trevm = response_tri!(ctx.trevm(id, &block_cfg)); @@ -574,8 +573,7 @@ where let (estimate, _) = response_tri!(trevm.estimate_gas().map_err(EvmErrored::into_error)); - trace!(?estimate, "estimate done for estimate_gas"); - Span::current().record("estimate", format!("{:?}", &estimate)); + span.record("estimate", format!("{:?}", &estimate)); match estimate { trevm::EstimationResult::Success { estimation, .. } => { @@ -595,7 +593,7 @@ where } } } - .instrument(span); + .instrument(span_for_task); await_jh_option_response!(hctx.spawn_blocking(task)) } From 0baeaf2232848b626fa71693d76b517ce290392b Mon Sep 17 00:00:00 2001 From: Anna Carroll Date: Wed, 18 Jun 2025 15:21:59 +0200 Subject: [PATCH 4/4] also fix in other endpoint --- crates/rpc/src/eth/endpoints.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/rpc/src/eth/endpoints.rs b/crates/rpc/src/eth/endpoints.rs index e70c97ed..24cedc2d 100644 --- a/crates/rpc/src/eth/endpoints.rs +++ b/crates/rpc/src/eth/endpoints.rs @@ -29,7 +29,7 @@ use reth_rpc_eth_api::{RpcBlock, RpcHeader, RpcReceipt, RpcTransaction}; use serde::Deserialize; use signet_evm::EvmErrored; use std::borrow::Cow; -use tracing::{field::Empty, span::Span, trace_span, Instrument}; +use tracing::{field::Empty, trace_span, Instrument}; use trevm::revm::context::result::ExecutionResult; /// Args for `eth_estimateGas` and `eth_call`. @@ -436,6 +436,7 @@ where block_cfg = Empty, ); + let span_for_instr = span.clone(); let task = async move { let block_cfg = match ctx.signet().block_cfg(id).await { Ok(block_cfg) => block_cfg, @@ -447,7 +448,7 @@ where } }; - Span::current().record("block_cfg", format!("{:?}", &block_cfg)); + span.record("block_cfg", format!("{:?}", &block_cfg)); // Set up trevm @@ -461,14 +462,14 @@ where // modify the gas cap. let new_gas = response_tri!(trevm.cap_tx_gas()); if Some(new_gas) != request.gas { - Span::current().record("request", format!("{:?}", &request)); + span.record("request", format!("{:?}", &request)); } let execution_result = response_tri!(trevm.call().map_err(EvmErrored::into_error)).0; ResponsePayload::Success(execution_result) } - .instrument(span); + .instrument(span_for_instr); await_jh_option_response!(hctx.spawn_blocking(task)) } @@ -545,7 +546,7 @@ where span.record("normalized_gas", format!("{:?}", request.gas)); - let span_for_task = span.clone(); + let span_for_instr = span.clone(); let task = async move { // Get the block cfg from backend, erroring if it fails let block_cfg = match ctx.signet().block_cfg(id).await { @@ -593,7 +594,7 @@ where } } } - .instrument(span_for_task); + .instrument(span_for_instr); await_jh_option_response!(hctx.spawn_blocking(task)) }