From 47568e4f7fc5d7c747272d0537c2a58eda0db8ee Mon Sep 17 00:00:00 2001 From: Georg Wiese Date: Fri, 23 Feb 2024 17:22:51 +0100 Subject: [PATCH] Refactor --- executor/src/witgen/machines/block_machine.rs | 14 +++++----- executor/src/witgen/processor.rs | 26 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/executor/src/witgen/machines/block_machine.rs b/executor/src/witgen/machines/block_machine.rs index a4d9f6a283..d96b3c5814 100644 --- a/executor/src/witgen/machines/block_machine.rs +++ b/executor/src/witgen/machines/block_machine.rs @@ -331,12 +331,14 @@ impl<'a, T: FieldElement> Machine<'a, T> for BlockMachine<'a, T> { // Set all selectors to 0 for rhs in &self.connecting_rhs { - processor.set_value( - self.block_size, - rhs.selector.as_ref().unwrap(), - T::zero(), - || "Zero selectors".to_string(), - ); + processor + .set_value( + self.block_size, + rhs.selector.as_ref().unwrap(), + T::zero(), + || "Zero selectors".to_string(), + ) + .unwrap(); } // Run BlockProcessor (to potentially propagate selector values) diff --git a/executor/src/witgen/processor.rs b/executor/src/witgen/processor.rs index 00250bb9b9..f4569d36f8 100644 --- a/executor/src/witgen/processor.rs +++ b/executor/src/witgen/processor.rs @@ -13,7 +13,7 @@ use super::{ data_structures::{column_map::WitnessColumnMap, finalizable_data::FinalizableData}, identity_processor::IdentityProcessor, rows::{CellValue, Row, RowIndex, RowPair, RowUpdater, UnknownStrategy}, - Constraints, EvalError, EvalValue, FixedData, MutableState, QueryCallback, + Constraints, EvalError, EvalValue, FixedData, IncompleteCause, MutableState, QueryCallback, }; type Left<'a, T> = Vec>; @@ -222,9 +222,11 @@ Known values in current row (local: {row_index}, global {global_row_index}): ) -> Result<(bool, Constraints<&'a AlgebraicReference, T>), EvalError> { let mut progress = false; if let Some(selector) = self.outer_query.as_ref().unwrap().right.selector.as_ref() { - progress |= self.set_value(row_index, selector, T::one(), || { - "Set selector to 1".to_string() - }); + progress |= self + .set_value(row_index, selector, T::one(), || { + "Set selector to 1".to_string() + }) + .unwrap_or(false); } let OuterQuery { left, right } = self @@ -313,7 +315,7 @@ Known values in current row (local: {row_index}, global {global_row_index}): expression: &'a Expression, value: T, name: impl Fn() -> String, - ) -> bool { + ) -> Result> { let row_pair = RowPair::new( &self.data[row_index], &self.data[row_index + 1], @@ -321,15 +323,11 @@ Known values in current row (local: {row_index}, global {global_row_index}): self.fixed_data, UnknownStrategy::Unknown, ); - let mut updates = EvalValue::complete(vec![]); - if let Ok(selector) = row_pair.evaluate(expression) { - updates.combine( - (selector - value.into()) - .solve_with_range_constraints(&row_pair) - .unwrap(), - ) - } - self.apply_updates(row_index, &updates, name) + let affine_expression = row_pair.evaluate(expression)?; + let updates = (affine_expression - value.into()) + .solve_with_range_constraints(&row_pair) + .unwrap(); + Ok(self.apply_updates(row_index, &updates, name)) } fn apply_updates(