@@ -33,8 +33,8 @@ use xcm_runtime_apis::{
3333// Local module imports
3434use super :: {
3535 config:: { monetary:: fee:: WeightToFee , system:: RuntimeBlockWeights , xcm as xcm_config} ,
36- AccountId , Balance , Balances , Block , BlockNumber , BlockWeights , EthExtraImpl , EventRecord ,
37- Executive , ExtrinsicInclusionMode , InherentDataExt , Nfts , Nonce , OriginCaller , ParachainSystem ,
36+ AccountId , Balance , Balances , Block , BlockNumber , BlockWeights , Executive ,
37+ ExtrinsicInclusionMode , InherentDataExt , Nfts , Nonce , OriginCaller , ParachainSystem ,
3838 PolkadotXcm , Revive , Runtime , RuntimeCall , RuntimeEvent , RuntimeGenesisConfig , RuntimeOrigin ,
3939 SessionKeys , System , TransactionPayment , UncheckedExtrinsic , VERSION ,
4040} ;
@@ -395,7 +395,7 @@ impl_runtime_apis! {
395395 }
396396 }
397397
398- impl pallet_revive:: ReviveApi <Block , AccountId , Balance , Nonce , BlockNumber , EventRecord > for Runtime
398+ impl pallet_revive:: ReviveApi <Block , AccountId , Balance , Nonce , BlockNumber > for Runtime
399399 {
400400 fn balance( address: H160 ) -> Balance {
401401 use frame_support:: traits:: fungible:: Inspect ;
@@ -438,16 +438,14 @@ impl_runtime_apis! {
438438 gas_limit: Option <Weight >,
439439 storage_deposit_limit: Option <Balance >,
440440 input_data: Vec <u8 >,
441- ) -> pallet_revive:: ContractResult <pallet_revive:: ExecReturnValue , Balance , EventRecord > {
441+ ) -> pallet_revive:: ContractResult <pallet_revive:: ExecReturnValue , Balance > {
442442 Revive :: bare_call(
443443 RuntimeOrigin :: signed( origin) ,
444444 dest,
445445 value,
446446 gas_limit. unwrap_or( RuntimeBlockWeights :: get( ) . max_block) ,
447447 pallet_revive:: DepositLimit :: Balance ( storage_deposit_limit. unwrap_or( u128 :: MAX ) ) ,
448448 input_data,
449- pallet_revive:: DebugInfo :: UnsafeDebug ,
450- pallet_revive:: CollectEvents :: UnsafeCollect ,
451449 )
452450 }
453451
@@ -459,7 +457,7 @@ impl_runtime_apis! {
459457 code: pallet_revive:: Code ,
460458 data: Vec <u8 >,
461459 salt: Option <[ u8 ; 32 ] >,
462- ) -> pallet_revive:: ContractResult <pallet_revive:: InstantiateReturnValue , Balance , EventRecord >
460+ ) -> pallet_revive:: ContractResult <pallet_revive:: InstantiateReturnValue , Balance >
463461 {
464462 Revive :: bare_instantiate(
465463 RuntimeOrigin :: signed( origin) ,
@@ -469,8 +467,6 @@ impl_runtime_apis! {
469467 code,
470468 data,
471469 salt,
472- pallet_revive:: DebugInfo :: UnsafeDebug ,
473- pallet_revive:: CollectEvents :: UnsafeCollect ,
474470 )
475471 }
476472
@@ -496,6 +492,67 @@ impl_runtime_apis! {
496492 key
497493 )
498494 }
495+
496+ fn trace_block(
497+ block: Block ,
498+ config: pallet_revive:: evm:: TracerConfig
499+ ) -> Vec <( u32 , pallet_revive:: evm:: CallTrace ) > {
500+ use pallet_revive:: tracing:: trace;
501+ let mut tracer = config. build( Revive :: evm_gas_from_weight) ;
502+ let mut traces = vec![ ] ;
503+ let ( header, extrinsics) = block. deconstruct( ) ;
504+
505+ Executive :: initialize_block( & header) ;
506+ for ( index, ext) in extrinsics. into_iter( ) . enumerate( ) {
507+ trace( & mut tracer, || {
508+ let _ = Executive :: apply_extrinsic( ext) ;
509+ } ) ;
510+
511+ if let Some ( tx_trace) = tracer. collect_traces( ) . pop( ) {
512+ traces. push( ( index as u32 , tx_trace) ) ;
513+ }
514+ }
515+
516+ traces
517+ }
518+
519+ fn trace_tx(
520+ block: Block ,
521+ tx_index: u32 ,
522+ config: pallet_revive:: evm:: TracerConfig
523+ ) -> Option <pallet_revive:: evm:: CallTrace > {
524+ use pallet_revive:: tracing:: trace;
525+ let mut tracer = config. build( Revive :: evm_gas_from_weight) ;
526+ let ( header, extrinsics) = block. deconstruct( ) ;
527+
528+ Executive :: initialize_block( & header) ;
529+ for ( index, ext) in extrinsics. into_iter( ) . enumerate( ) {
530+ if index as u32 == tx_index {
531+ trace( & mut tracer, || {
532+ let _ = Executive :: apply_extrinsic( ext) ;
533+ } ) ;
534+ break ;
535+ } else {
536+ let _ = Executive :: apply_extrinsic( ext) ;
537+ }
538+ }
539+
540+ tracer. collect_traces( ) . pop( )
541+ }
542+
543+ fn trace_call(
544+ tx: pallet_revive:: evm:: GenericTransaction ,
545+ config: pallet_revive:: evm:: TracerConfig )
546+ -> Result <pallet_revive:: evm:: CallTrace , pallet_revive:: EthTransactError >
547+ {
548+ use pallet_revive:: tracing:: trace;
549+ let mut tracer = config. build( Revive :: evm_gas_from_weight) ;
550+ trace( & mut tracer, || {
551+ Self :: eth_transact( tx)
552+ } ) ?;
553+
554+ Ok ( tracer. collect_traces( ) . pop( ) . expect( "eth_transact succeeded, trace must exist, qed" ) )
555+ }
499556 }
500557}
501558
0 commit comments