From 5f4a2442409eb4770052931a1a0ddf17ba7c364a Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Mon, 18 Oct 2021 21:38:57 +0200 Subject: [PATCH] PR feedback --- src/fri/recursive_verifier.rs | 15 ++++++++------- src/gates/random_access.rs | 4 ++-- src/plonk/circuit_builder.rs | 7 +------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/fri/recursive_verifier.rs b/src/fri/recursive_verifier.rs index 0115277e..b268e831 100644 --- a/src/fri/recursive_verifier.rs +++ b/src/fri/recursive_verifier.rs @@ -59,11 +59,12 @@ impl, const D: usize> CircuitBuilder { /// Make sure we have enough wires and routed wires to do the FRI checks efficiently. This check /// isn't required -- without it we'd get errors elsewhere in the stack -- but just gives more /// helpful errors. - fn check_config(&self, arity: usize) { - // TODO: It would be nice to remove the hardcoded 8 here and replace it with the maximum arity bits - // used in FRI. - let random_access = RandomAccessGate::::new_from_config(&self.config, 8); - let interpolation_gate = InterpolationGate::::new(arity); + fn check_config(&self, max_fri_arity: usize) { + let random_access = RandomAccessGate::::new_from_config( + &self.config, + max_fri_arity.max(1 << self.config.cap_height), + ); + let interpolation_gate = InterpolationGate::::new(max_fri_arity); let min_wires = random_access .num_wires() @@ -75,14 +76,14 @@ impl, const D: usize> CircuitBuilder { assert!( self.config.num_wires >= min_wires, "To efficiently perform FRI checks with an arity of {}, at least {} wires are needed. Consider reducing arity.", - arity, + max_fri_arity, min_wires ); assert!( self.config.num_routed_wires >= min_routed_wires, "To efficiently perform FRI checks with an arity of {}, at least {} routed wires are needed. Consider reducing arity.", - arity, + max_fri_arity, min_routed_wires ); } diff --git a/src/gates/random_access.rs b/src/gates/random_access.rs index 9cc283de..ea4aff97 100644 --- a/src/gates/random_access.rs +++ b/src/gates/random_access.rs @@ -37,8 +37,8 @@ impl, const D: usize> RandomAccessGate { pub fn max_num_copies(num_routed_wires: usize, num_wires: usize, vec_size: usize) -> usize { // Need `(2 + vec_size) * num_copies` routed wires (num_routed_wires / (2 + vec_size)).min( - // Need `(2 + 4*vec_size) * num_copies` wires - num_wires / (2 + 4 * vec_size), + // Need `(2 + 3*vec_size) * num_copies` wires + num_wires / (2 + 3 * vec_size), ) } diff --git a/src/plonk/circuit_builder.rs b/src/plonk/circuit_builder.rs index 4b392be9..ac8f01f1 100644 --- a/src/plonk/circuit_builder.rs +++ b/src/plonk/circuit_builder.rs @@ -540,12 +540,7 @@ impl, const D: usize> CircuitBuilder { /// `RandomAccessGenerator`s are run. fn fill_random_access_gates(&mut self) { let zero = self.zero(); - let remaining_random_access_gates = self - .free_random_access - .clone() - .into_iter() - .collect::>(); - for (vec_size, (_, i)) in remaining_random_access_gates { + for (vec_size, (_, i)) in self.free_random_access.clone() { let max_copies = RandomAccessGate::::max_num_copies( self.config.num_routed_wires, self.config.num_wires,