@@ -1506,6 +1506,58 @@ impl_runtime_apis! {
15061506
15071507 #[ cfg( feature = "evm-tracing" ) ]
15081508 impl evm_debug_api:: EvmDebugApi <Block > for Runtime {
1509+ fn trace_block(
1510+ extrinsics: Vec <<Block as BlockT >:: Extrinsic >,
1511+ known_transactions: Vec <H256 >,
1512+ header: & <Block as BlockT >:: Header ,
1513+ ) -> Result <( ) , sp_runtime:: DispatchError > {
1514+ Executive :: initialize_block( header) ;
1515+
1516+ let mut config = <Runtime as pallet_evm:: Config >:: config( ) . clone( ) ;
1517+ config. estimate = true ;
1518+
1519+ // Apply all extrinsics. Ethereum extrinsics are traced.
1520+ for ext in extrinsics {
1521+ match & ext. 0 . function {
1522+ RuntimeCall :: Ethereum ( transact { transaction } ) => {
1523+ let tx_hash = & transaction. hash( ) ;
1524+ if known_transactions. contains( tx_hash) {
1525+ // Each known extrinsic is a new call stack.
1526+ evm_tracer:: EvmTracer :: emit_new( ) ;
1527+ evm_tracer:: EvmTracer :: new( ) . trace( || {
1528+ if let Err ( err) = Executive :: apply_extrinsic( ext) {
1529+ frame_support:: log:: debug!(
1530+ target: "tracing" ,
1531+ "Could not trace eth transaction (hash: {}): {:?}" ,
1532+ & tx_hash,
1533+ err
1534+ ) ;
1535+ }
1536+ } ) ;
1537+ } else if let Err ( err) = Executive :: apply_extrinsic( ext) {
1538+ frame_support:: log:: debug!(
1539+ target: "tracing" ,
1540+ "Failed to apply eth extrinsic (hash: {}): {:?}" ,
1541+ & tx_hash,
1542+ err
1543+ ) ;
1544+ }
1545+ } ,
1546+ _ => {
1547+ if let Err ( err) = Executive :: apply_extrinsic( ext) {
1548+ frame_support:: log:: debug!(
1549+ target: "tracing" ,
1550+ "Failed to apply non-eth extrinsic: {:?}" ,
1551+ err
1552+ ) ;
1553+ }
1554+ }
1555+ }
1556+ }
1557+
1558+ Ok ( ( ) )
1559+ }
1560+
15091561 fn trace_call(
15101562 header: & <Block as BlockT >:: Header ,
15111563 from: H160 ,
0 commit comments