diff --git a/executor/src/witgen/jit/witgen_inference.rs b/executor/src/witgen/jit/witgen_inference.rs index b6ef24142e..977b45a18a 100644 --- a/executor/src/witgen/jit/witgen_inference.rs +++ b/executor/src/witgen/jit/witgen_inference.rs @@ -1,5 +1,5 @@ use std::{ - collections::{HashMap, HashSet}, + collections::{BTreeSet, HashMap, HashSet}, fmt::{Display, Formatter}, }; @@ -37,7 +37,7 @@ pub struct WitgenInference<'a, T: FieldElement, FixedEval> { /// connection on the same row. complete_identities: HashSet<(u64, i32)>, /// Internal equality constraints that are not identities from the constraint set. - assignments: Vec>, + assignments: BTreeSet>, code: Vec>, } @@ -181,7 +181,7 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator> WitgenInference<'a, T, F /// This does not have to be solvable right away, but is always processed as soon as we have progress. /// Note that all variables in the expression can be unknown and their status can also change over time. pub fn assign_constant(&mut self, expression: &'a Expression, row_offset: i32, value: T) { - self.assignments.push(Assignment { + self.assignments.insert(Assignment { lhs: expression, row_offset, rhs: VariableOrValue::Value(value), @@ -198,7 +198,7 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator> WitgenInference<'a, T, F row_offset: i32, variable: Variable, ) { - self.assignments.push(Assignment { + self.assignments.insert(Assignment { lhs: expression, row_offset, rhs: VariableOrValue::Variable(variable), @@ -568,14 +568,14 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator> Evaluator<'a, T, FixedEv /// An equality constraint between an algebraic expression evaluated /// on a certain row offset and a variable or fixed constant value. -#[derive(Clone)] +#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug)] struct Assignment<'a, T: FieldElement> { lhs: &'a Expression, row_offset: i32, rhs: VariableOrValue, } -#[derive(Clone, derive_more::Display)] +#[derive(Clone, derive_more::Display, Ord, PartialOrd, Eq, PartialEq, Debug)] enum VariableOrValue { Variable(V), Value(T),