@@ -12,7 +12,7 @@ use crate::{
12
12
use core:: fmt:: Debug ;
13
13
use eth_types:: { evm_unimplemented, GethExecStep , ToAddress , ToWord , Word } ;
14
14
15
- use crate :: util:: CHECK_MEM_STRICT ;
15
+ use crate :: util:: CHECK_MEM_STACK_STRICT ;
16
16
17
17
#[ cfg( any( feature = "test" , test) ) ]
18
18
pub use self :: sha3:: sha3_tests:: { gen_sha3_code, MemoryKind } ;
@@ -401,7 +401,7 @@ pub fn gen_associated_ops(
401
401
state : & mut CircuitInputStateRef ,
402
402
geth_steps : & [ GethExecStep ] ,
403
403
) -> Result < Vec < ExecStep > , Error > {
404
- let check_level = if * CHECK_MEM_STRICT { 2 } else { 0 } ; // 0: no check, 1: check and log error and fix, 2: check and assert_eq
404
+ let check_level = if * CHECK_MEM_STACK_STRICT { 2 } else { 0 } ; // 0: no check, 1: check and log error and fix, 2: check and assert_eq
405
405
if check_level >= 1 {
406
406
let memory_enabled = !geth_steps. iter ( ) . all ( |s| s. memory . is_empty ( ) ) ;
407
407
if memory_enabled {
@@ -437,6 +437,38 @@ pub fn gen_associated_ops(
437
437
state. call_ctx_mut ( ) ?. memory = geth_steps[ 0 ] . memory . clone ( ) ;
438
438
}
439
439
}
440
+ let stack_enabled = !geth_steps. iter ( ) . all ( |s| s. stack . is_empty ( ) ) ;
441
+ if stack_enabled {
442
+ if state. call_ctx ( ) ?. stack != geth_steps[ 0 ] . stack {
443
+ log:: error!(
444
+ "wrong stack before {:?}. len in state {}, len in step {}" ,
445
+ opcode_id,
446
+ & state. call_ctx( ) ?. stack. len( ) ,
447
+ & geth_steps[ 0 ] . stack. len( ) ,
448
+ ) ;
449
+ log:: error!( "state stack {:?}" , & state. call_ctx( ) ?. stack) ;
450
+ log:: error!( "step stack {:?}" , & geth_steps[ 0 ] . stack) ;
451
+
452
+ for i in
453
+ 0 ..std:: cmp:: min ( state. call_ctx ( ) ?. stack . 0 . len ( ) , geth_steps[ 0 ] . stack . 0 . len ( ) )
454
+ {
455
+ let state_stack = state. call_ctx ( ) ?. stack . 0 [ i] ;
456
+ let step_stack = geth_steps[ 0 ] . stack . 0 [ i] ;
457
+ if state_stack != step_stack {
458
+ log:: error!(
459
+ "diff at {}: state {:?} != step {:?}" ,
460
+ i,
461
+ state_stack,
462
+ step_stack
463
+ ) ;
464
+ }
465
+ }
466
+ if check_level >= 2 {
467
+ panic ! ( "stack wrong" ) ;
468
+ }
469
+ state. call_ctx_mut ( ) ?. stack = geth_steps[ 0 ] . stack . clone ( ) ;
470
+ }
471
+ }
440
472
}
441
473
442
474
// check if have error
0 commit comments