diff --git a/zkevm-circuits/src/evm_circuit/execution/stop.rs b/zkevm-circuits/src/evm_circuit/execution/stop.rs index f4bcd954cc..3c13d032ff 100644 --- a/zkevm-circuits/src/evm_circuit/execution/stop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/stop.rs @@ -1,6 +1,7 @@ use crate::{ evm_circuit::{ execution::ExecutionGadget, + param::N_BYTES_PROGRAM_COUNTER, step::ExecutionState, util::{ common_gadget::RestoreContextGadget, @@ -8,7 +9,7 @@ use crate::{ ConstraintBuilder, StepStateTransition, Transition::{Delta, Same}, }, - math_gadget::IsZeroGadget, + math_gadget::LtGadget, CachedRegion, Cell, }, witness::{Block, Call, ExecStep, Transaction}, @@ -23,7 +24,7 @@ use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] pub(crate) struct StopGadget { code_length: Cell, - is_out_of_range: IsZeroGadget, + is_out_of_range: LtGadget, opcode: Cell, restore_context: RestoreContextGadget, } @@ -36,14 +37,12 @@ impl ExecutionGadget for StopGadget { fn configure(cb: &mut ConstraintBuilder) -> Self { let code_length = cb.query_cell(); cb.bytecode_length(cb.curr.state.code_hash.expr(), code_length.expr()); - let is_out_of_range = IsZeroGadget::construct( - cb, - code_length.expr() - cb.curr.state.program_counter.expr(), - ); + let is_out_of_range = + LtGadget::construct(cb, cb.curr.state.program_counter.expr(), code_length.expr()); let opcode = cb.query_cell(); - // cb.condition(1.expr() - is_out_of_range.expr(), |cb| { - // cb.opcode_lookup(opcode.expr(), 1.expr()); - // }); + cb.condition(1.expr() - is_out_of_range.expr(), |cb| { + cb.opcode_lookup(opcode.expr(), 1.expr()); + }); // We do the responsible opcode check explicitly here because we're not using // the `SameContextGadget` for `STOP`. @@ -116,7 +115,8 @@ impl ExecutionGadget for StopGadget { self.is_out_of_range.assign( region, offset, - F::from(code.bytes.len() as u64) - F::from(step.program_counter), + F::from(step.program_counter), + F::from(code.bytes.len() as u64), )?; let opcode = step.opcode.unwrap();