Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions zkevm-circuits/src/evm_circuit/execution/stop.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::{
evm_circuit::{
execution::ExecutionGadget,
param::N_BYTES_PROGRAM_COUNTER,
step::ExecutionState,
util::{
common_gadget::RestoreContextGadget,
constraint_builder::{
ConstraintBuilder, StepStateTransition,
Transition::{Delta, Same},
},
math_gadget::IsZeroGadget,
math_gadget::LtGadget,
CachedRegion, Cell,
},
witness::{Block, Call, ExecStep, Transaction},
Expand All @@ -23,7 +24,7 @@ use halo2_proofs::{circuit::Value, plonk::Error};
#[derive(Clone, Debug)]
pub(crate) struct StopGadget<F> {
code_length: Cell<F>,
is_out_of_range: IsZeroGadget<F>,
is_out_of_range: LtGadget<F, N_BYTES_PROGRAM_COUNTER>,
opcode: Cell<F>,
restore_context: RestoreContextGadget<F>,
}
Expand All @@ -36,14 +37,12 @@ impl<F: Field> ExecutionGadget<F> for StopGadget<F> {
fn configure(cb: &mut ConstraintBuilder<F>) -> 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`.
Expand Down Expand Up @@ -116,7 +115,8 @@ impl<F: Field> ExecutionGadget<F> for StopGadget<F> {
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();
Expand Down