@@ -3707,26 +3707,50 @@ impl RpcMethod<1> for EthTraceBlock {
37073707 const PARAM_NAMES : [ & ' static str ; 1 ] = [ "blockParam" ] ;
37083708 const API_PATHS : BitFlags < ApiPaths > = ApiPaths :: all ( ) ;
37093709 const PERMISSION : Permission = Permission :: Read ;
3710+ const DESCRIPTION : Option < & ' static str > = Some ( "Returns traces created at given block." ) ;
3711+
37103712 type Params = ( ExtBlockNumberOrHash , ) ;
37113713 type Ok = Vec < EthBlockTrace > ;
37123714 async fn handle (
37133715 ctx : Ctx < impl Blockstore + Send + Sync + ' static > ,
37143716 ( block_param, ) : Self :: Params ,
37153717 ) -> Result < Self :: Ok , ServerError > {
3716- trace_block ( ctx, block_param) . await
3718+ let ts = tipset_by_ext_block_number_or_hash (
3719+ ctx. chain_store ( ) ,
3720+ block_param,
3721+ ResolveNullTipset :: TakeOlder ,
3722+ ) ?;
3723+ eth_trace_block ( & ctx, & ts) . await
37173724 }
37183725}
37193726
3720- async fn trace_block < B : Blockstore + Send + Sync + ' static > (
3721- ctx : Ctx < B > ,
3722- block_param : ExtBlockNumberOrHash ,
3723- ) -> Result < Vec < EthBlockTrace > , ServerError > {
3724- let ts = tipset_by_ext_block_number_or_hash (
3725- ctx. chain_store ( ) ,
3726- block_param,
3727- ResolveNullTipset :: TakeOlder ,
3728- ) ?;
3729- let ( state_root, trace) = ctx. state_manager . execution_trace ( & ts) ?;
3727+ pub enum EthTraceBlockV2 { }
3728+ impl RpcMethod < 1 > for EthTraceBlockV2 {
3729+ const NAME : & ' static str = "Filecoin.EthTraceBlock" ;
3730+ const NAME_ALIAS : Option < & ' static str > = Some ( "trace_block" ) ;
3731+ const N_REQUIRED_PARAMS : usize = 1 ;
3732+ const PARAM_NAMES : [ & ' static str ; 1 ] = [ "blockParam" ] ;
3733+ const API_PATHS : BitFlags < ApiPaths > = make_bitflags ! ( ApiPaths :: V2 ) ;
3734+ const PERMISSION : Permission = Permission :: Read ;
3735+ const DESCRIPTION : Option < & ' static str > = Some ( "Returns traces created at given block." ) ;
3736+
3737+ type Params = ( ExtBlockNumberOrHash , ) ;
3738+ type Ok = Vec < EthBlockTrace > ;
3739+ async fn handle (
3740+ ctx : Ctx < impl Blockstore + Send + Sync + ' static > ,
3741+ ( block_param, ) : Self :: Params ,
3742+ ) -> Result < Self :: Ok , ServerError > {
3743+ let ts = tipset_by_block_number_or_hash_v2 ( & ctx, block_param, ResolveNullTipset :: TakeOlder )
3744+ . await ?;
3745+ eth_trace_block ( & ctx, & ts) . await
3746+ }
3747+ }
3748+
3749+ async fn eth_trace_block < DB > ( ctx : & Ctx < DB > , ts : & Tipset ) -> Result < Vec < EthBlockTrace > , ServerError >
3750+ where
3751+ DB : Blockstore + Send + Sync + ' static ,
3752+ {
3753+ let ( state_root, trace) = ctx. state_manager . execution_trace ( ts) ?;
37303754 let state = StateTree :: new_from_root ( ctx. store_owned ( ) , & state_root) ?;
37313755 let cid = ts. key ( ) . cid ( ) ?;
37323756 let block_hash: EthHash = cid. into ( ) ;
@@ -3788,14 +3812,17 @@ impl RpcMethod<1> for EthTraceTransaction {
37883812 . await ?
37893813 . ok_or ( ServerError :: internal_error ( "transaction not found" , None ) ) ?;
37903814
3791- let traces = trace_block (
3792- ctx,
3815+ let ts = tipset_by_ext_block_number_or_hash (
3816+ ctx. chain_store ( ) ,
37933817 ExtBlockNumberOrHash :: from_block_number ( eth_txn. block_number . 0 as i64 ) ,
3794- )
3795- . await ?
3796- . into_iter ( )
3797- . filter ( |trace| trace. transaction_hash == eth_hash)
3798- . collect ( ) ;
3818+ ResolveNullTipset :: TakeOlder ,
3819+ ) ?;
3820+
3821+ let traces = eth_trace_block ( & ctx, & ts)
3822+ . await ?
3823+ . into_iter ( )
3824+ . filter ( |trace| trace. transaction_hash == eth_hash)
3825+ . collect ( ) ;
37993826 Ok ( traces)
38003827 }
38013828}
0 commit comments