diff --git a/executor/src/witgen/generator.rs b/executor/src/witgen/generator.rs index 8a48941f8..ad29ac0ce 100644 --- a/executor/src/witgen/generator.rs +++ b/executor/src/witgen/generator.rs @@ -333,7 +333,7 @@ where fn process_polynomial_identity(&self, identity: &Expression) -> EvalResult { // If there is no "next" reference in the expression, // we just evaluate it directly on the "next" row. - let row = if contains_next_witness_ref(identity, self.fixed_data) { + let row = if contains_next_witness_ref(identity) { // TODO this is the only situation where we use "current" // TODO this is the only that actually uses a window. EvaluationRow::Current diff --git a/executor/src/witgen/machines/fixed_lookup_machine.rs b/executor/src/witgen/machines/fixed_lookup_machine.rs index 254a184e7..374326ab2 100644 --- a/executor/src/witgen/machines/fixed_lookup_machine.rs +++ b/executor/src/witgen/machines/fixed_lookup_machine.rs @@ -178,10 +178,7 @@ impl FixedLookup { // This is a matching machine if it is a plookup and the RHS is fully constant. if kind != IdentityKind::Plookup || right.selector.is_some() - || right - .expressions - .iter() - .any(|e| contains_witness_ref(e, fixed_data)) + || right.expressions.iter().any(contains_witness_ref) { return None; } diff --git a/executor/src/witgen/util.rs b/executor/src/witgen/util.rs index 6654590c2..635eec622 100644 --- a/executor/src/witgen/util.rs +++ b/executor/src/witgen/util.rs @@ -1,7 +1,5 @@ use pil_analyzer::{util::expr_any, Expression, PolynomialReference}; -use super::FixedData; - pub trait WitnessColumnNamer { fn name(&self, i: usize) -> String; } @@ -16,21 +14,17 @@ pub fn contains_next_ref(expr: &Expression) -> bool { } /// @returns true if the expression contains a reference to a next value of a witness column. -pub fn contains_next_witness_ref(expr: &Expression, fixed_data: &FixedData) -> bool { +pub fn contains_next_witness_ref(expr: &Expression) -> bool { expr_any(expr, |e| match e { - Expression::PolynomialReference(poly) => { - poly.next && fixed_data.witness_ids.contains_key(poly.name.as_str()) - } + Expression::PolynomialReference(poly) => poly.next && poly.is_witness(), _ => false, }) } /// @returns true if the expression contains a reference to a witness column. -pub fn contains_witness_ref(expr: &Expression, fixed_data: &FixedData) -> bool { +pub fn contains_witness_ref(expr: &Expression) -> bool { expr_any(expr, |e| match e { - Expression::PolynomialReference(poly) => { - fixed_data.witness_ids.contains_key(poly.name.as_str()) - } + Expression::PolynomialReference(poly) => poly.is_witness(), _ => false, }) } diff --git a/pil_analyzer/src/lib.rs b/pil_analyzer/src/lib.rs index a75921c23..42cc47696 100644 --- a/pil_analyzer/src/lib.rs +++ b/pil_analyzer/src/lib.rs @@ -197,6 +197,21 @@ pub struct PolynomialReference { pub next: bool, } +impl PolynomialReference { + #[inline] + pub fn poly_id(&self) -> u64 { + self.poly_id.unwrap().0 + } + #[inline] + pub fn is_witness(&self) -> bool { + self.poly_id.unwrap().1 == PolynomialType::Committed + } + #[inline] + pub fn is_fixed(&self) -> bool { + self.poly_id.unwrap().1 == PolynomialType::Constant + } +} + impl PartialOrd for PolynomialReference { fn partial_cmp(&self, other: &Self) -> Option { // TODO for efficiency reasons, we should avoid the unwrap check here somehow.