diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index a7f384283..acd158997 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -11,6 +11,7 @@ on: env: CARGO_TERM_COLOR: always POWDR_GENERATE_PROOFS: "true" + MAX_DEGREE_LOG: "10" jobs: build: diff --git a/backend/src/composite/split.rs b/backend/src/composite/split.rs index ccfd343dc..d5488197c 100644 --- a/backend/src/composite/split.rs +++ b/backend/src/composite/split.rs @@ -99,7 +99,7 @@ pub(crate) fn machine_fixed_columns( ); match machine_degrees.iter().next() { Some(°ree) => iter::once(degree as usize).collect(), - None => (MIN_DEGREE_LOG..=MAX_DEGREE_LOG) + None => (MIN_DEGREE_LOG..=*MAX_DEGREE_LOG) .map(|log_size| 1 << log_size) .collect(), } diff --git a/executor/src/constant_evaluator/mod.rs b/executor/src/constant_evaluator/mod.rs index dd056e0ac..30f0a5b2f 100644 --- a/executor/src/constant_evaluator/mod.rs +++ b/executor/src/constant_evaluator/mod.rs @@ -1,10 +1,12 @@ use std::{ collections::{BTreeMap, HashMap}, + env, sync::{Arc, RwLock}, }; pub use data_structures::{get_uniquely_sized, get_uniquely_sized_cloned, VariablySizedColumn}; use itertools::Itertools; +use lazy_static::lazy_static; use powdr_ast::{ analyzed::{Analyzed, FunctionValueDefinition, Symbol, TypedExpression}, parsed::{ @@ -19,7 +21,22 @@ use rayon::prelude::{IntoParallelIterator, ParallelIterator}; mod data_structures; pub const MIN_DEGREE_LOG: usize = 5; -pub const MAX_DEGREE_LOG: usize = 22; +lazy_static! { + // The maximum degree can add a significant cost during setup, because + // the fixed columns need to be committed to in all sizes up to the max degree. + // This gives the user the possibility to overwrite the default value. + pub static ref MAX_DEGREE_LOG: usize = { + let default_max_degree_log = 22; + + let max_degree_log = match env::var("MAX_DEGREE_LOG") { + Ok(val) => val.parse::().unwrap(), + Err(_) => default_max_degree_log, + }; + log::info!("For variably-sized machine, the maximum degree is 2^{max_degree_log}. \ + You can set the environment variable MAX_DEGREE_LOG to change this value."); + max_degree_log + }; +} /// Generates the fixed column values for all fixed columns that are defined /// (and not just declared). @@ -37,7 +54,7 @@ pub fn generate(analyzed: &Analyzed) -> Vec<(String, Variabl let values = if let Some(degree) = poly.degree { generate_values(analyzed, degree, &name, value, index).into() } else { - (MIN_DEGREE_LOG..=MAX_DEGREE_LOG) + (MIN_DEGREE_LOG..=*MAX_DEGREE_LOG) .map(|degree_log| { let degree = 1 << degree_log; generate_values(analyzed, degree, &name, value, index) diff --git a/executor/src/witgen/mod.rs b/executor/src/witgen/mod.rs index e87322ad7..b6ba3d791 100644 --- a/executor/src/witgen/mod.rs +++ b/executor/src/witgen/mod.rs @@ -350,7 +350,7 @@ impl<'a, T: FieldElement> FixedData<'a, T> { } fn common_degree<'b>(&self, ids: impl IntoIterator) -> DegreeType { - self.common_set_degree(ids).unwrap_or(1 << MAX_DEGREE_LOG) + self.common_set_degree(ids).unwrap_or(1 << *MAX_DEGREE_LOG) } fn is_variable_size<'b>(&self, ids: impl IntoIterator) -> bool {