Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-deng committed Oct 11, 2024
1 parent 9f2283e commit a7be2b9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 56 deletions.
9 changes: 5 additions & 4 deletions evm_arithmetization/src/fixed_recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ where
pub fn prove_segment_after_initial_stark(
&self,
all_proof: AllProof<F, C, D>,
table_circuits: &[(RecursiveCircuitsForTableSize<F, C, D>, u8); NUM_TABLES],
table_circuits: &[Option<(RecursiveCircuitsForTableSize<F, C, D>, u8)>; NUM_TABLES],
abort_signal: Option<Arc<AtomicBool>>,
) -> anyhow::Result<ProofWithPublicValues<F, C, D>> {
let mut root_inputs = PartialWitness::new();
Expand All @@ -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),
Expand Down Expand Up @@ -2880,7 +2882,6 @@ where
stark_config: &StarkConfig,
) -> Self {
let by_stark_size = degree_bits_range
.clone()
.map(|degree_bits| {
(
degree_bits,
Expand All @@ -2893,7 +2894,7 @@ where
),
)
})
.collect::<BTreeMap<_, _>>();
.collect();

Self { by_stark_size }
}
Expand Down
2 changes: 0 additions & 2 deletions evm_arithmetization/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();

Expand Down
2 changes: 2 additions & 0 deletions zero/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(array_try_from_fn)]

zk_evm_common::check_chain_features!();

pub mod block_interval;
Expand Down
77 changes: 27 additions & 50 deletions zero/src/prover_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();

/// 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<Option<(RecursiveCircuitsForTableSize, u8)>> {
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
Expand Down

0 comments on commit a7be2b9

Please sign in to comment.