@@ -16,6 +16,7 @@ use reth_node_api::FullNodeComponents;
1616use signet_evm:: EvmErrored ;
1717use signet_node_types:: Pnt ;
1818use signet_types:: MagicSig ;
19+ use tracing:: Instrument ;
1920
2021/// Params for the `debug_traceBlockByNumber` and `debug_traceBlockByHash`
2122/// endpoints.
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}
0 commit comments