@@ -27,10 +27,10 @@ pub use call::{Call, CallContext, CallKind};
27
27
use core:: fmt:: Debug ;
28
28
use eth_types:: {
29
29
self ,
30
- evm_types:: { GasCost , OpcodeId } ,
30
+ evm_types:: GasCost ,
31
31
geth_types,
32
32
sign_types:: { pk_bytes_le, pk_bytes_swap_endianness, SignData } ,
33
- Address , GethExecStep , GethExecTrace , ToBigEndian , ToWord , Word , H256 ,
33
+ Address , GethExecTrace , ToBigEndian , ToWord , Word , H256 ,
34
34
} ;
35
35
use ethers_providers:: JsonRpcClient ;
36
36
pub use execution:: {
@@ -55,6 +55,9 @@ pub use transaction::{
55
55
Transaction , TransactionContext , TxL1Fee , TX_L1_COMMIT_EXTRA_COST , TX_L1_FEE_PRECISION ,
56
56
} ;
57
57
58
+ #[ cfg( feature = "enable-stack" ) ]
59
+ use eth_types:: evm_types:: OpcodeId ;
60
+
58
61
/// Setup parameters for ECC-related precompile calls.
59
62
#[ derive( Debug , Clone , Copy ) ]
60
63
pub struct PrecompileEcParams {
@@ -616,53 +619,58 @@ impl<'a> CircuitInputBuilder {
616
619
state_ref. call( ) . map( |c| c. call_id) . unwrap_or( 0 ) ,
617
620
state_ref. call_ctx( ) ?. memory. len( ) ,
618
621
geth_step. refund. 0 ,
619
- if geth_step. op. is_push_with_data( ) {
620
- format!( "{:?}" , geth_trace. struct_logs. get( index + 1 ) . map( |step| step. stack. last( ) ) )
621
- } else if geth_step. op. is_call_without_value( ) {
622
- format!(
623
- "{:?} {:40x} {:?} {:?} {:?} {:?}" ,
624
- geth_step. stack. last( ) ,
625
- geth_step. stack. nth_last( 1 ) . unwrap_or_default( ) ,
626
- geth_step. stack. nth_last( 2 ) ,
627
- geth_step. stack. nth_last( 3 ) ,
628
- geth_step. stack. nth_last( 4 ) ,
629
- geth_step. stack. nth_last( 5 )
630
- )
631
- } else if geth_step. op. is_call_with_value( ) {
632
- format!(
633
- "{:?} {:40x} {:?} {:?} {:?} {:?} {:?}" ,
634
- geth_step. stack. last( ) ,
635
- geth_step. stack. nth_last( 1 ) . unwrap_or_default( ) ,
636
- geth_step. stack. nth_last( 2 ) ,
637
- geth_step. stack. nth_last( 3 ) ,
638
- geth_step. stack. nth_last( 4 ) ,
639
- geth_step. stack. nth_last( 5 ) ,
640
- geth_step. stack. nth_last( 6 ) ,
641
- )
642
- } else if geth_step. op. is_create( ) {
643
- format!(
644
- "value {:?} offset {:?} size {:?} {}" ,
645
- geth_step. stack. last( ) ,
646
- geth_step. stack. nth_last( 1 ) ,
647
- geth_step. stack. nth_last( 2 ) ,
648
- if geth_step. op == OpcodeId :: CREATE2 {
649
- format!( "salt {:?}" , geth_step. stack. nth_last( 3 ) )
650
- } else {
651
- "" . to_string( )
652
- }
653
- )
654
- } else if matches!( geth_step. op, OpcodeId :: SSTORE ) {
655
- format!(
656
- "{:?} {:?} {:?}" ,
657
- state_ref. call( ) . map( |c| c. address) ,
658
- geth_step. stack. last( ) ,
659
- geth_step. stack. nth_last( 1 ) ,
660
- )
661
- } else {
662
- let stack_input_num = 1024 - geth_step. op. valid_stack_ptr_range( ) . 1 as usize ;
663
- ( 0 ..stack_input_num) . map( |i|
664
- format!( "{:?}" , geth_step. stack. nth_last( i) )
665
- ) . collect_vec( ) . join( " " )
622
+ {
623
+ #[ cfg( feature = "enable-stack" ) ]
624
+ if geth_step. op. is_push_with_data( ) {
625
+ format!( "{:?}" , geth_trace. struct_logs. get( index + 1 ) . map( |step| step. stack. last( ) ) )
626
+ } else if geth_step. op. is_call_without_value( ) {
627
+ format!(
628
+ "{:?} {:40x} {:?} {:?} {:?} {:?}" ,
629
+ geth_step. stack. last( ) ,
630
+ geth_step. stack. nth_last( 1 ) . unwrap_or_default( ) ,
631
+ geth_step. stack. nth_last( 2 ) ,
632
+ geth_step. stack. nth_last( 3 ) ,
633
+ geth_step. stack. nth_last( 4 ) ,
634
+ geth_step. stack. nth_last( 5 )
635
+ )
636
+ } else if geth_step. op. is_call_with_value( ) {
637
+ format!(
638
+ "{:?} {:40x} {:?} {:?} {:?} {:?} {:?}" ,
639
+ geth_step. stack. last( ) ,
640
+ geth_step. stack. nth_last( 1 ) . unwrap_or_default( ) ,
641
+ geth_step. stack. nth_last( 2 ) ,
642
+ geth_step. stack. nth_last( 3 ) ,
643
+ geth_step. stack. nth_last( 4 ) ,
644
+ geth_step. stack. nth_last( 5 ) ,
645
+ geth_step. stack. nth_last( 6 ) ,
646
+ )
647
+ } else if geth_step. op. is_create( ) {
648
+ format!(
649
+ "value {:?} offset {:?} size {:?} {}" ,
650
+ geth_step. stack. last( ) ,
651
+ geth_step. stack. nth_last( 1 ) ,
652
+ geth_step. stack. nth_last( 2 ) ,
653
+ if geth_step. op == OpcodeId :: CREATE2 {
654
+ format!( "salt {:?}" , geth_step. stack. nth_last( 3 ) )
655
+ } else {
656
+ "" . to_string( )
657
+ }
658
+ )
659
+ } else if matches!( geth_step. op, OpcodeId :: SSTORE ) {
660
+ format!(
661
+ "{:?} {:?} {:?}" ,
662
+ state_ref. call( ) . map( |c| c. address) ,
663
+ geth_step. stack. last( ) ,
664
+ geth_step. stack. nth_last( 1 ) ,
665
+ )
666
+ } else {
667
+ let stack_input_num = 1024 - geth_step. op. valid_stack_ptr_range( ) . 1 as usize ;
668
+ ( 0 ..stack_input_num) . map( |i|
669
+ format!( "{:?}" , geth_step. stack. nth_last( i) )
670
+ ) . collect_vec( ) . join( " " )
671
+ }
672
+ #[ cfg( not( feature = "enable-stack" ) ) ]
673
+ "N/A" . to_string( )
666
674
}
667
675
) ;
668
676
debug_assert_eq ! (
@@ -910,9 +918,9 @@ pub fn keccak_inputs_tx_circuit(txs: &[geth_types::Transaction]) -> Result<Vec<V
910
918
}
911
919
912
920
/// Retrieve the init_code from memory for {CREATE, CREATE2}
913
- pub fn get_create_init_code ( call_ctx : & CallContext , step : & GethExecStep ) -> Result < Vec < u8 > , Error > {
914
- let offset = step . stack . nth_last ( 1 ) ?. low_u64 ( ) as usize ;
915
- let length = step . stack . nth_last ( 2 ) ?. as_usize ( ) ;
921
+ pub fn get_create_init_code ( call_ctx : & CallContext ) -> Result < Vec < u8 > , Error > {
922
+ let offset = call_ctx . stack . nth_last ( 1 ) ?. low_u64 ( ) as usize ;
923
+ let length = call_ctx . stack . nth_last ( 2 ) ?. as_usize ( ) ;
916
924
917
925
let mem_len = call_ctx. memory . 0 . len ( ) ;
918
926
let mut result = vec ! [ 0u8 ; length] ;
@@ -925,9 +933,12 @@ pub fn get_create_init_code(call_ctx: &CallContext, step: &GethExecStep) -> Resu
925
933
}
926
934
927
935
/// Retrieve the memory offset and length of call.
928
- pub fn get_call_memory_offset_length ( step : & GethExecStep , nth : usize ) -> Result < ( u64 , u64 ) , Error > {
929
- let offset = step. stack . nth_last ( nth) ?;
930
- let length = step. stack . nth_last ( nth + 1 ) ?;
936
+ pub fn get_call_memory_offset_length (
937
+ call_ctx : & CallContext ,
938
+ nth : usize ,
939
+ ) -> Result < ( u64 , u64 ) , Error > {
940
+ let offset = call_ctx. stack . nth_last ( nth) ?;
941
+ let length = call_ctx. stack . nth_last ( nth + 1 ) ?;
931
942
if length. is_zero ( ) {
932
943
Ok ( ( 0 , 0 ) )
933
944
} else {
0 commit comments