diff --git a/evm_arithmetization/src/fixed_recursive_verifier.rs b/evm_arithmetization/src/fixed_recursive_verifier.rs index 1e68bc7b8..54b47a8f2 100644 --- a/evm_arithmetization/src/fixed_recursive_verifier.rs +++ b/evm_arithmetization/src/fixed_recursive_verifier.rs @@ -57,7 +57,10 @@ use crate::recursive_verifier::{ recursive_stark_circuit, set_final_public_value_targets, set_public_value_targets, PlonkWrapperCircuit, PublicInputs, StarkWrapperCircuit, }; -use crate::testing_utils::TWO_TO_ONE_BLOCK_CIRCUIT_TEST_THRESHOLD_DEGREE_BITS; +use crate::testing_utils::{ + TEST_RECURSION_CONFIG, TEST_STARK_CONFIG, TEST_THRESHOLD_DEGREE_BITS, + TWO_TO_ONE_BLOCK_CIRCUIT_TEST_THRESHOLD_DEGREE_BITS, +}; use crate::util::h256_limbs; use crate::verifier::initial_memory_merkle_cap; @@ -615,6 +618,42 @@ impl, C: GenericConfig, const D: usize> } } +/// A struct containing the parameters for configuration of +/// `AllRecursiveCircuits`. +pub struct RecursionConfig { + /// The configuration to be used for the STARK table prover. + pub stark_config: StarkConfig, + /// The configuration for the shrinking circuit. + pub shrinking_circuit_config: CircuitConfig, + /// The configuration for the recursion circuits. + pub recursion_circuit_config: CircuitConfig, + /// The recursion threshold in degree bits. + pub threshold_degree_bits: usize, +} + +impl Default for RecursionConfig { + fn default() -> Self { + RecursionConfig { + stark_config: StarkConfig::standard_fast_config(), + shrinking_circuit_config: shrinking_config(), + recursion_circuit_config: CircuitConfig::standard_recursion_config(), + threshold_degree_bits: THRESHOLD_DEGREE_BITS, + } + } +} + +impl RecursionConfig { + /// Returns a test configuration for `RecursionConfig`. + pub fn test_config() -> Self { + RecursionConfig { + stark_config: TEST_STARK_CONFIG, + shrinking_circuit_config: TEST_RECURSION_CONFIG, + recursion_circuit_config: TEST_RECURSION_CONFIG, + threshold_degree_bits: TEST_THRESHOLD_DEGREE_BITS, + } + } +} + impl AllRecursiveCircuits where F: RichField + Extendable, @@ -781,25 +820,19 @@ where /// starting from that length, for each `degree_bits` in the range specified /// for this STARK module. Specifying a wide enough range allows a /// prover to cover all possible scenarios. - /// - `stark_config`: the configuration to be used for the STARK prover. It - /// will usually be a fast one yielding large proofs. + /// - `config`: the set of configurations to be used for the different proof + /// layers. It will usually be a fast one yielding large proofs for the + /// base STARK prover, and a more flexible one for the recursive layers. pub fn new( all_stark: &AllStark, degree_bits_ranges: &[Range; NUM_TABLES], - stark_config: &StarkConfig, - shrinking_circuit_config: Option<&CircuitConfig>, - recursion_circuit_config: Option<&CircuitConfig>, - threshold_degree_bits: Option, + config: RecursionConfig, ) -> Self { + let stark_config = &config.stark_config; + // Sanity check on the provided config assert_eq!(DEFAULT_CAP_LEN, 1 << stark_config.fri_config.cap_height); - let shrinking_config = shrinking_config(); - let shrinking_circuit_config = shrinking_circuit_config.unwrap_or(&shrinking_config); - let circuit_config = CircuitConfig::standard_recursion_config(); - let recursion_circuit_config = recursion_circuit_config.unwrap_or(&circuit_config); - let threshold_degree_bits = threshold_degree_bits.unwrap_or(THRESHOLD_DEGREE_BITS); - macro_rules! create_recursive_circuit { ($table_enum:expr, $stark_field:ident) => { RecursiveCircuitsForTable::new( @@ -808,8 +841,8 @@ where degree_bits_ranges[*$table_enum].clone(), &all_stark.cross_table_lookups, stark_config, - shrinking_circuit_config, - threshold_degree_bits, + &config.shrinking_circuit_config, + config.threshold_degree_bits, ) }; } @@ -841,7 +874,8 @@ where poseidon, ]; - let root = Self::create_segment_circuit(&by_table, stark_config, recursion_circuit_config); + let root = + Self::create_segment_circuit(&by_table, stark_config, &config.recursion_circuit_config); let segment_aggregation = Self::create_segment_aggregation_circuit(&root); let batch_aggregation = Self::create_batch_aggregation_circuit(&segment_aggregation, stark_config); diff --git a/evm_arithmetization/tests/empty_tables.rs b/evm_arithmetization/tests/empty_tables.rs index 235bbb715..ab37e4798 100644 --- a/evm_arithmetization/tests/empty_tables.rs +++ b/evm_arithmetization/tests/empty_tables.rs @@ -2,11 +2,10 @@ use std::time::Duration; -use evm_arithmetization::fixed_recursive_verifier::AllRecursiveCircuits; +use evm_arithmetization::fixed_recursive_verifier::{AllRecursiveCircuits, RecursionConfig}; use evm_arithmetization::prover::prove; use evm_arithmetization::testing_utils::{ - init_logger, segment_with_empty_tables, TEST_RECURSION_CONFIG, TEST_STARK_CONFIG, - TEST_THRESHOLD_DEGREE_BITS, + init_logger, segment_with_empty_tables, TEST_STARK_CONFIG, }; use evm_arithmetization::verifier::testing::verify_all_proofs; use evm_arithmetization::AllStark; @@ -60,10 +59,7 @@ fn empty_tables() -> anyhow::Result<()> { AllRecursiveCircuits::::new( &all_stark, &[16..17, 8..9, 7..8, 4..6, 8..9, 4..5, 16..17, 16..17, 16..17], - &config, - Some(&TEST_RECURSION_CONFIG), - Some(&TEST_RECURSION_CONFIG), - Some(TEST_THRESHOLD_DEGREE_BITS), + RecursionConfig::test_config(), ) ); diff --git a/evm_arithmetization/tests/two_to_one_block.rs b/evm_arithmetization/tests/two_to_one_block.rs index 93e26f211..dd109967b 100644 --- a/evm_arithmetization/tests/two_to_one_block.rs +++ b/evm_arithmetization/tests/two_to_one_block.rs @@ -2,7 +2,7 @@ use ethereum_types::{Address, BigEndianHash, H256}; use evm_arithmetization::fixed_recursive_verifier::{ - extract_block_final_public_values, extract_two_to_one_block_hash, + extract_block_final_public_values, extract_two_to_one_block_hash, RecursionConfig, }; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; use evm_arithmetization::proof::{ @@ -10,8 +10,7 @@ use evm_arithmetization::proof::{ }; use evm_arithmetization::testing_utils::{ beacon_roots_account_nibbles, beacon_roots_contract_from_storage, init_logger, - preinitialized_state_and_storage_tries, update_beacon_roots_account_storage, - TEST_RECURSION_CONFIG, TEST_STARK_CONFIG, TEST_THRESHOLD_DEGREE_BITS, + preinitialized_state_and_storage_tries, update_beacon_roots_account_storage, TEST_STARK_CONFIG, }; use evm_arithmetization::{AllRecursiveCircuits, AllStark, Node, StarkConfig}; use hex_literal::hex; @@ -173,10 +172,7 @@ fn test_two_to_one_block_aggregation() -> anyhow::Result<()> { let all_circuits = AllRecursiveCircuits::new( &all_stark, &[16..17, 8..9, 12..13, 8..9, 8..9, 6..7, 17..18, 16..17, 7..8], - &config, - Some(&TEST_RECURSION_CONFIG), - Some(&TEST_RECURSION_CONFIG), - Some(TEST_THRESHOLD_DEGREE_BITS), + RecursionConfig::test_config(), ); let bp = some_timestamps diff --git a/zero/src/prover_state/circuit.rs b/zero/src/prover_state/circuit.rs index 44bbeeeef..9c12738f0 100644 --- a/zero/src/prover_state/circuit.rs +++ b/zero/src/prover_state/circuit.rs @@ -5,11 +5,9 @@ use std::{ str::FromStr, }; -use evm_arithmetization::testing_utils::{ - TEST_RECURSION_CONFIG, TEST_STARK_CONFIG, TEST_THRESHOLD_DEGREE_BITS, -}; +use evm_arithmetization::fixed_recursive_verifier::RecursionConfig; pub use evm_arithmetization::NUM_TABLES; -use evm_arithmetization::{AllRecursiveCircuits, AllStark, StarkConfig}; +use evm_arithmetization::{AllRecursiveCircuits, AllStark}; use crate::parsing::{parse_range_exclusive, RangeParseError}; @@ -253,19 +251,13 @@ impl CircuitConfig { AllRecursiveCircuits::new( &AllStark::default(), self.as_degree_bits_ranges(), - &TEST_STARK_CONFIG, - Some(&TEST_RECURSION_CONFIG), - Some(&TEST_RECURSION_CONFIG), - Some(TEST_THRESHOLD_DEGREE_BITS), + RecursionConfig::test_config(), ) } else { AllRecursiveCircuits::new( &AllStark::default(), self.as_degree_bits_ranges(), - &StarkConfig::standard_fast_config(), - None, - None, - None, + RecursionConfig::default(), ) } }