Skip to content

Commit 2c09693

Browse files
committed
chore: basic tracing
1 parent f002cfd commit 2c09693

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

crates/rpc/src/debug/endpoints.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use reth_node_api::FullNodeComponents;
1616
use signet_evm::EvmErrored;
1717
use signet_node_types::Pnt;
1818
use signet_types::MagicSig;
19+
use tracing::Instrument;
1920

2021
/// Params for the `debug_traceBlockByNumber` and `debug_traceBlockByHash`
2122
/// endpoints.
@@ -38,6 +39,8 @@ where
3839
Signet: Pnt,
3940
{
4041
let id = id.into();
42+
let span = tracing::debug_span!("traceBlock", ?id, tracer = ?opts.as_ref().and_then(|o| o.tracer.as_ref()));
43+
4144
let fut = async move {
4245
// Fetch the block by ID
4346
let Some((hash, block)) = response_tri!(ctx.signet().raw_block(id).await) else {
@@ -46,13 +49,19 @@ where
4649
);
4750
};
4851

52+
tracing::debug!(number = block.number(), "Loaded block");
53+
4954
// Allocate space for the frames
5055
let mut frames = Vec::with_capacity(block.transaction_count());
56+
5157
// Instantiate the EVM with the block
5258
let mut trevm = response_tri!(ctx.trevm(crate::LoadState::Before, block.header()));
5359

5460
// Apply all transactions in the block up, tracing each one
5561
let opts = opts.unwrap_or_default();
62+
63+
tracing::trace!(?opts, "Tracing block transactions");
64+
5665
let mut txns = block.body().transactions().enumerate().peekable();
5766
for (idx, tx) in txns
5867
.by_ref()
@@ -71,10 +80,13 @@ where
7180
let frame;
7281
(frame, trevm) = response_tri!(crate::debug::tracer::trace(t, &opts, tx_info));
7382
frames.push(TraceResult::Success { result: frame, tx_hash: Some(*tx.hash()) });
83+
84+
tracing::debug!(tx_index = idx, tx_hash = ?tx.hash(), "Traced transaction");
7485
}
7586

7687
ResponsePayload::Success(frames)
77-
};
88+
}
89+
.instrument(span);
7890

7991
await_handler!(@response_option hctx.spawn_blocking(fut))
8092
}
@@ -89,18 +101,24 @@ where
89101
Host: FullNodeComponents,
90102
Signet: Pnt,
91103
{
104+
let span = tracing::debug_span!("traceTransaction", %tx_hash, tracer = ?opts.as_ref().and_then(|o| o.tracer.as_ref()));
105+
92106
let fut = async move {
93107
// Load the transaction by hash
94108
let (tx, meta) = response_tri!(
95109
response_tri!(ctx.signet().raw_transaction_by_hash(tx_hash))
96110
.ok_or(EthApiError::TransactionNotFound)
97111
);
98112

113+
tracing::debug!("Loaded transaction metadata");
114+
99115
// Load the block containing the transaction
100116
let res = response_tri!(ctx.signet().raw_block(meta.block_hash).await);
101117
let (_, block) =
102118
response_tri!(res.ok_or_else(|| EthApiError::HeaderNotFound(meta.block_hash.into())));
103119

120+
tracing::debug!(number = block.number(), "Loaded containing block");
121+
104122
// Load trevm at the start of the block (i.e. before any transactions are applied)
105123
let mut trevm = response_tri!(ctx.trevm(crate::LoadState::Before, block.header()));
106124

@@ -133,7 +151,8 @@ where
133151
response_tri!(crate::debug::tracer::trace(trevm, &opts.unwrap_or_default(), tx_info)).0;
134152

135153
ResponsePayload::Success(res)
136-
};
154+
}
155+
.instrument(span);
137156

138157
await_handler!(@response_option hctx.spawn_blocking(fut))
139158
}

crates/rpc/src/debug/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub use error::DebugError;
77
mod tracer;
88

99
use crate::ctx::RpcCtx;
10-
use alloy::primitives::{B256, U64};
10+
use alloy::{eips::BlockNumberOrTag, primitives::B256};
1111
use reth_node_api::FullNodeComponents;
1212
use signet_node_types::Pnt;
1313

@@ -18,7 +18,7 @@ where
1818
Signet: Pnt,
1919
{
2020
ajj::Router::new()
21-
.route("traceBlockByNumber", trace_block::<U64, _, _>)
21+
.route("traceBlockByNumber", trace_block::<BlockNumberOrTag, _, _>)
2222
.route("traceBlockByHash", trace_block::<B256, _, _>)
2323
.route("traceTransaction", trace_transaction)
2424
}

crates/rpc/src/debug/tracer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ use revm_inspectors::tracing::{
2020
FourByteInspector, MuxInspector, TracingInspector, TracingInspectorConfig,
2121
};
2222
use signet_evm::{EvmNeedsTx, EvmReady};
23+
use tracing::instrument;
2324
use trevm::{
2425
helpers::Ctx,
2526
revm::{Database, DatabaseCommit, Inspector},
2627
};
2728

2829
/// Trace a transaction using the provided EVM and tracing options.
30+
#[instrument(skip(trevm, config, tx_info), fields(tx_hash = ?tx_info.hash))]
2931
pub(super) fn trace<Db, Insp>(
3032
trevm: EvmReady<Db, Insp>,
3133
config: &GethDebugTracingOptions,

0 commit comments

Comments
 (0)