mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 08:43:06 +00:00
Merge pull request #685 from mir-protocol/deterministic_iteration_order
Enumerate `constants_to_targets` in a deterministic order
This commit is contained in:
commit
c3c213350f
@ -2,6 +2,7 @@ use std::cmp::max;
|
|||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
use log::{debug, info, Level};
|
use log::{debug, info, Level};
|
||||||
use plonky2_field::cosets::get_unique_coset_shifts;
|
use plonky2_field::cosets::get_unique_coset_shifts;
|
||||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||||
@ -95,9 +96,9 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
|||||||
context_log: ContextTree::new(),
|
context_log: ContextTree::new(),
|
||||||
generators: Vec::new(),
|
generators: Vec::new(),
|
||||||
constants_to_targets: HashMap::new(),
|
constants_to_targets: HashMap::new(),
|
||||||
|
targets_to_constants: HashMap::new(),
|
||||||
base_arithmetic_results: HashMap::new(),
|
base_arithmetic_results: HashMap::new(),
|
||||||
arithmetic_results: HashMap::new(),
|
arithmetic_results: HashMap::new(),
|
||||||
targets_to_constants: HashMap::new(),
|
|
||||||
current_slots: HashMap::new(),
|
current_slots: HashMap::new(),
|
||||||
constant_generators: Vec::new(),
|
constant_generators: Vec::new(),
|
||||||
};
|
};
|
||||||
@ -665,6 +666,9 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
|||||||
.constants_to_targets
|
.constants_to_targets
|
||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
// We need to enumerate constants_to_targets in some deterministic order to ensure that
|
||||||
|
// building a circuit is deterministic.
|
||||||
|
.sorted_by_key(|(c, _t)| c.to_canonical_u64())
|
||||||
.zip(self.constant_generators.clone())
|
.zip(self.constant_generators.clone())
|
||||||
{
|
{
|
||||||
// Set the constant in the constant polynomial.
|
// Set the constant in the constant polynomial.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user