Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
add error pruning on step_first/step_last to avoid use against lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Oct 23, 2023
1 parent 09651d4 commit 5ed683a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions zkevm-circuits/src/evm_circuit/util/constraint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,17 +1430,18 @@ impl<'a, F: Field> EVMConstraintBuilder<'a, F> {
self.constraints_location = ConstraintLocation::Step;
ret
}
/// TODO: Doc

/// register constraints to be applied `step_first` selector
pub(crate) fn step_first<R>(&mut self, constraint: impl FnOnce(&mut Self) -> R) -> R {
self.constraint_at_location(ConstraintLocation::StepFirst, constraint)
}

/// TODO: Doc
/// register constraints to be applied on step other than first step
pub(crate) fn not_step_last<R>(&mut self, constraint: impl FnOnce(&mut Self) -> R) -> R {
self.constraint_at_location(ConstraintLocation::NotStepLast, constraint)
}

/// TODO: Doc
/// register constraints to be applied on respective selector later
fn push_constraint(&mut self, name: &'static str, constraint: Expression<F>) {
match self.constraints_location {
ConstraintLocation::Step => self.constraints.step.push((name, constraint)),
Expand All @@ -1452,6 +1453,11 @@ impl<'a, F: Field> EVMConstraintBuilder<'a, F> {
}

pub(crate) fn add_lookup(&mut self, name: &str, lookup: Lookup<F>) {
debug_assert_eq!(
self.constraints_location,
ConstraintLocation::Step,
"lookup do not support conditional on constraint location other than `ConstraintLocation::Step`"
);
let lookup = match self.condition_expr_opt() {
Some(condition) => lookup.conditional(condition),
None => lookup,
Expand Down

0 comments on commit 5ed683a

Please sign in to comment.