Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
georgwiese committed Feb 23, 2024
1 parent 2cd2828 commit 47568e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
14 changes: 8 additions & 6 deletions executor/src/witgen/machines/block_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 12 additions & 14 deletions executor/src/witgen/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AffineExpression<&'a AlgebraicReference, T>>;
Expand Down Expand Up @@ -222,9 +222,11 @@ Known values in current row (local: {row_index}, global {global_row_index}):
) -> Result<(bool, Constraints<&'a AlgebraicReference, T>), EvalError<T>> {
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
Expand Down Expand Up @@ -313,23 +315,19 @@ Known values in current row (local: {row_index}, global {global_row_index}):
expression: &'a Expression<T>,
value: T,
name: impl Fn() -> String,
) -> bool {
) -> Result<bool, IncompleteCause<&'a AlgebraicReference>> {
let row_pair = RowPair::new(
&self.data[row_index],
&self.data[row_index + 1],
self.row_offset + row_index as u64,
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(
Expand Down

0 comments on commit 47568e4

Please sign in to comment.