diff --git a/evm_arithmetization/src/fixed_recursive_verifier.rs b/evm_arithmetization/src/fixed_recursive_verifier.rs index 99657dcbd..dd63387bd 100644 --- a/evm_arithmetization/src/fixed_recursive_verifier.rs +++ b/evm_arithmetization/src/fixed_recursive_verifier.rs @@ -2137,7 +2137,7 @@ where pub fn prove_segment_after_initial_stark( &self, all_proof: AllProof, - table_circuits: &[(RecursiveCircuitsForTableSize, u8); NUM_TABLES], + table_circuits: &[Option<(RecursiveCircuitsForTableSize, u8)>; NUM_TABLES], abort_signal: Option>, ) -> anyhow::Result> { let mut root_inputs = PartialWitness::new(); @@ -2156,7 +2156,9 @@ where &dummy_proof.proof, ); } else { - let (table_circuit, index_verifier_data) = &table_circuits[table]; + let (table_circuit, index_verifier_data) = &table_circuits[table] + .as_ref() + .ok_or_else(|| anyhow::format_err!("Unable to get circuits"))?; root_inputs.set_target( self.root.index_verifier_data[table], F::from_canonical_u8(*index_verifier_data), @@ -2880,7 +2882,6 @@ where stark_config: &StarkConfig, ) -> Self { let by_stark_size = degree_bits_range - .clone() .map(|degree_bits| { ( degree_bits, @@ -2893,7 +2894,7 @@ where ), ) }) - .collect::>(); + .collect(); Self { by_stark_size } } diff --git a/evm_arithmetization/src/lib.rs b/evm_arithmetization/src/lib.rs index 26b030429..41b7f093a 100644 --- a/evm_arithmetization/src/lib.rs +++ b/evm_arithmetization/src/lib.rs @@ -252,8 +252,6 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::field_reassign_with_default)] #![feature(let_chains)] -#![feature(maybe_uninit_uninit_array)] -#![feature(maybe_uninit_array_assume_init)] zk_evm_common::check_chain_features!(); diff --git a/zero/src/lib.rs b/zero/src/lib.rs index c2ca63f6a..6de5dee98 100644 --- a/zero/src/lib.rs +++ b/zero/src/lib.rs @@ -1,3 +1,5 @@ +#![feature(array_try_from_fn)] + zk_evm_common::check_chain_features!(); pub mod block_interval; diff --git a/zero/src/prover_state/mod.rs b/zero/src/prover_state/mod.rs index a46373bdd..d5bf2c741 100644 --- a/zero/src/prover_state/mod.rs +++ b/zero/src/prover_state/mod.rs @@ -174,57 +174,34 @@ impl ProverStateManager { &self, config: &StarkConfig, all_proof: &AllProof, - ) -> anyhow::Result<[(RecursiveCircuitsForTableSize, u8); NUM_TABLES]> { - let degrees = all_proof - .degree_bits(config) - .iter() - .enumerate() - .map(|(i, opt)| { - opt.unwrap_or_else(|| { - p_state().state.table_dummy_proofs[i] - .as_ref() - .expect("Unable to get table dummy proof data") - .init_degree - }) - }) - .collect::>(); - - /// Given a recursive circuit index (e.g., Arithmetic / 0), return a - /// tuple containing the loaded table at the specified size and - /// its offset relative to the configured range used to pre-process the - /// circuits. - macro_rules! circuit { - ($circuit_index:expr) => { - ( - RecursiveCircuitResource::get(&( - $circuit_index.into(), - degrees[$circuit_index], - )) - .map_err(|e| { - let circuit: $crate::prover_state::circuit::Circuit = $circuit_index.into(); - let size = degrees[$circuit_index]; - anyhow::Error::from(e).context(format!( - "Attempting to load circuit: {circuit:?} at size: {size}" - )) - })?, - (degrees[$circuit_index] - self.circuit_config[$circuit_index].start) as u8, - ) - }; - } + ) -> anyhow::Result<[Option<(RecursiveCircuitsForTableSize, u8)>; NUM_TABLES]> { + let degrees = all_proof.degree_bits(config); + + // Given a recursive circuit index (e.g., Arithmetic / 0), return a + // tuple containing the loaded table at the specified size and + // its offset relative to the configured range used to pre-process the + // circuits. + let circuits = std::array::try_from_fn( + |i| -> anyhow::Result> { + match degrees[i] { + Some(size) => { + let circuit_resource = RecursiveCircuitResource::get(&(i.into(), size)) + .map_err(|e| { + anyhow::Error::from(e).context(format!( + "Attempting to load circuit: {i} at size: {size}" + )) + })?; + Ok(Some(( + circuit_resource, + (size - self.circuit_config[i].start) as u8, + ))) + } + None => Ok(None), + } + }, + )?; - Ok([ - circuit!(0), - circuit!(1), - circuit!(2), - circuit!(3), - circuit!(4), - circuit!(5), - circuit!(6), - circuit!(7), - circuit!(8), - #[cfg(feature = "cdk_erigon")] - circuit!(9), - ]) + Ok(circuits) } /// Generate a segment proof using the specified input, loading