1- use super :: { EthereumRPC , DebugRPC , Either , RPCTransaction , RPCTrace , RPCStep , RPCBlock , RPCLog , RPCReceipt , RPCLogFilter , RPCBlockTrace , RPCDump , RPCDumpAccount } ;
1+ use super :: { EthereumRPC , DebugRPC , Either , RPCTransaction , RPCTrace , RPCStep , RPCBlock , RPCLog , RPCReceipt , RPCLogFilter , RPCBlockTrace , RPCDump , RPCDumpAccount , RPCTraceConfig } ;
22use super :: util:: * ;
33use super :: filter:: * ;
44use super :: serialize:: * ;
@@ -574,7 +574,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
574574 Ok ( Bytes ( rlp:: encode ( & block) . to_vec ( ) ) )
575575 }
576576
577- fn trace_transaction ( & self , hash : Hex < H256 > ) -> Result < RPCTrace , Error > {
577+ fn trace_transaction ( & self , hash : Hex < H256 > , config : Trailing < RPCTraceConfig > ) -> Result < RPCTrace , Error > {
578+ let config = config. unwrap_or ( RPCTraceConfig :: default ( ) ) ;
578579 let state = self . state . lock ( ) . unwrap ( ) ;
579580
580581 let transaction = state. get_transaction_by_hash ( hash. 0 ) ?;
@@ -592,7 +593,7 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
592593 }
593594 }
594595
595- let ( steps, vm) = replay_transaction :: < P > ( & stateful, transaction, & block, & last_hashes) ?;
596+ let ( steps, vm) = replay_transaction :: < P > ( & stateful, transaction, & block, & last_hashes, & config ) ?;
596597
597598 let gas = Hex ( vm. real_used_gas ( ) ) ;
598599 let return_value = Bytes ( vm. out ( ) . into ( ) ) ;
@@ -603,7 +604,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
603604 } )
604605 }
605606
606- fn trace_block ( & self , block_rlp : Bytes ) -> Result < RPCBlockTrace , Error > {
607+ fn trace_block ( & self , block_rlp : Bytes , config : Trailing < RPCTraceConfig > ) -> Result < RPCBlockTrace , Error > {
608+ let config = config. unwrap_or ( RPCTraceConfig :: default ( ) ) ;
607609 let state = self . state . lock ( ) . unwrap ( ) ;
608610 let block: Block = UntrustedRlp :: new ( & block_rlp. 0 ) . as_val ( ) ?;
609611 let last_hashes = state. get_last_256_block_hashes_by_number ( block. header . number . as_usize ( ) ) ;
@@ -612,7 +614,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
612614 let mut steps = Vec :: new ( ) ;
613615 for transaction in block. transactions . clone ( ) {
614616 let ( mut local_steps, vm) = replay_transaction :: < P > ( & stateful, transaction,
615- & block, & last_hashes) ?;
617+ & block, & last_hashes,
618+ & config) ?;
616619 steps. append ( & mut local_steps) ;
617620 let mut accounts = Vec :: new ( ) ;
618621 for account in vm. accounts ( ) {
@@ -626,7 +629,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
626629 } )
627630 }
628631
629- fn trace_block_by_number ( & self , number : usize ) -> Result < RPCBlockTrace , Error > {
632+ fn trace_block_by_number ( & self , number : usize , config : Trailing < RPCTraceConfig > ) -> Result < RPCBlockTrace , Error > {
633+ let config = config. unwrap_or ( RPCTraceConfig :: default ( ) ) ;
630634 let state = self . state . lock ( ) . unwrap ( ) ;
631635 if number > state. block_height ( ) {
632636 return Err ( Error :: NotFound ) ;
@@ -638,7 +642,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
638642 let mut steps = Vec :: new ( ) ;
639643 for transaction in block. transactions . clone ( ) {
640644 let ( mut local_steps, vm) = replay_transaction :: < P > ( & stateful, transaction,
641- & block, & last_hashes) ?;
645+ & block, & last_hashes,
646+ & config) ?;
642647 steps. append ( & mut local_steps) ;
643648 let mut accounts = Vec :: new ( ) ;
644649 for account in vm. accounts ( ) {
@@ -652,7 +657,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
652657 } )
653658 }
654659
655- fn trace_block_by_hash ( & self , hash : Hex < H256 > ) -> Result < RPCBlockTrace , Error > {
660+ fn trace_block_by_hash ( & self , hash : Hex < H256 > , config : Trailing < RPCTraceConfig > ) -> Result < RPCBlockTrace , Error > {
661+ let config = config. unwrap_or ( RPCTraceConfig :: default ( ) ) ;
656662 let state = self . state . lock ( ) . unwrap ( ) ;
657663 let block: Block = state. get_block_by_hash ( hash. 0 ) ?;
658664 let last_hashes = state. get_last_256_block_hashes_by_number ( block. header . number . as_usize ( ) ) ;
@@ -661,7 +667,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
661667 let mut steps = Vec :: new ( ) ;
662668 for transaction in block. transactions . clone ( ) {
663669 let ( mut local_steps, vm) = replay_transaction :: < P > ( & stateful, transaction,
664- & block, & last_hashes) ?;
670+ & block, & last_hashes,
671+ & config) ?;
665672 steps. append ( & mut local_steps) ;
666673 let mut accounts = Vec :: new ( ) ;
667674 for account in vm. accounts ( ) {
@@ -675,10 +682,11 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
675682 } )
676683 }
677684
678- fn trace_block_from_file ( & self , path : String ) -> Result < RPCBlockTrace , Error > {
685+ fn trace_block_from_file ( & self , path : String , config : Trailing < RPCTraceConfig > ) -> Result < RPCBlockTrace , Error > {
679686 use std:: fs:: File ;
680687 use std:: io:: Read ;
681688
689+ let config = config. unwrap_or ( RPCTraceConfig :: default ( ) ) ;
682690 let mut file = File :: open ( path) . unwrap ( ) ;
683691 let mut buffer = Vec :: new ( ) ;
684692 file. read_to_end ( & mut buffer) . unwrap ( ) ;
@@ -691,7 +699,8 @@ impl<P: 'static + Patch + Send> DebugRPC for MinerDebugRPC<P> {
691699 let mut steps = Vec :: new ( ) ;
692700 for transaction in block. transactions . clone ( ) {
693701 let ( mut local_steps, vm) = replay_transaction :: < P > ( & stateful, transaction,
694- & block, & last_hashes) ?;
702+ & block, & last_hashes,
703+ & config) ?;
695704 steps. append ( & mut local_steps) ;
696705 let mut accounts = Vec :: new ( ) ;
697706 for account in vm. accounts ( ) {
0 commit comments