From 727ff8ecea4195f76c9989a7f09d5ca4581cb32e Mon Sep 17 00:00:00 2001 From: Jan Ferdinand Sauer Date: Mon, 8 Apr 2024 09:45:34 +0200 Subject: [PATCH] perf(test): use minimal size for quotient domain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the quotient domain was artificially enlarged to pinpoint the exact AIR constraint in case of a proving failure. However, since then a lot more tests evaluating the constraints directly have been put in place. They are simpler to use and don't change the critical code path – i.e., proving – between test and release builds. Therefore, remove the quotient domain enlarging. --- triton-vm/src/arithmetic_domain.rs | 3 ++- triton-vm/src/stark.rs | 14 ++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/triton-vm/src/arithmetic_domain.rs b/triton-vm/src/arithmetic_domain.rs index 2156358d2..9e193aedc 100644 --- a/triton-vm/src/arithmetic_domain.rs +++ b/triton-vm/src/arithmetic_domain.rs @@ -1,6 +1,7 @@ use std::ops::MulAssign; use num_traits::One; +use rayon::prelude::*; use twenty_first::prelude::*; use twenty_first::shared_math::traits::FiniteField; use twenty_first::shared_math::traits::PrimitiveRootOfUnity; @@ -66,7 +67,7 @@ impl ArithmeticDomain { FF: FiniteField + MulAssign + From, { self.domain_values() - .iter() + .par_iter() .map(|&v| polynomial.evaluate(&v.into())) .collect() } diff --git a/triton-vm/src/stark.rs b/triton-vm/src/stark.rs index b1db18feb..894ec0230 100644 --- a/triton-vm/src/stark.rs +++ b/triton-vm/src/stark.rs @@ -522,22 +522,12 @@ impl Stark { /// polynomials. Concretely, the maximal degree of a polynomial over the quotient domain is at /// most only slightly larger than the maximal degree allowed in the STARK proof, and could be /// equal. This makes computation for the prover much faster. - /// - /// When debugging, it is useful to check the degree of some intermediate polynomials. - /// However, the quotient domain's minimal length can make it impossible to check if some - /// operation (e.g., dividing out the zerofier) has (erroneously) increased the polynomial's - /// degree beyond the allowed maximum. Hence, a larger quotient domain is chosen when debugging - /// and testing. pub(crate) fn quotient_domain( fri_domain: ArithmeticDomain, max_degree: Degree, ) -> Result { - let maybe_blowup_factor = match cfg!(debug_assertions) { - true => 2, - false => 1, - }; - let domain_length = (max_degree as u64).next_power_of_two() as usize; - let domain_length = maybe_blowup_factor * domain_length; + let max_degree = usize::try_from(max_degree).expect("AIR should constrain the VM"); + let domain_length = max_degree.next_power_of_two(); Ok(ArithmeticDomain::of_length(domain_length)?.with_offset(fri_domain.offset)) }