Skip to content

Commit

Permalink
merge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-deng committed Oct 9, 2024
1 parent a4715b7 commit a260fba
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 83 deletions.
78 changes: 9 additions & 69 deletions evm_arithmetization/src/fixed_recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,6 @@ where
abort_signal: Option<Arc<AtomicBool>>,
) -> anyhow::Result<ProverOutputData<F, C, D>> {
features_check(&generation_inputs);

let all_proof = prove::<F, C, D>(
all_stark,
config,
Expand All @@ -1912,7 +1911,15 @@ where
timing,
abort_signal.clone(),
)?;
self.prove_segment_with_all_proofs(&all_proof, config, abort_signal.clone())
}

pub fn prove_segment_with_all_proofs(
&self,
all_proof: &AllProof<F, C, D>,
config: &StarkConfig,
abort_signal: Option<Arc<AtomicBool>>,
) -> anyhow::Result<ProverOutputData<F, C, D>> {
let mut root_inputs = PartialWitness::new();

for table in 0..NUM_TABLES {
Expand Down Expand Up @@ -1995,7 +2002,7 @@ where
is_agg: false,
is_dummy: false,
proof_with_pvs: ProofWithPublicValues {
public_values: all_proof.public_values,
public_values: all_proof.public_values.clone(),
intern: root_proof,
},
})
Expand Down Expand Up @@ -3135,70 +3142,3 @@ pub mod testing {
}
}
}

#[cfg(test)]
#[cfg(not(feature = "cdk_erigon"))]
mod tests {
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::plonk::config::PoseidonGoldilocksConfig;
use plonky2::timed;

use super::*;
use crate::testing_utils::{init_logger, segment_without_keccak};

type F = GoldilocksField;
const D: usize = 2;
type C = PoseidonGoldilocksConfig;

#[test]
fn test_segment_proof_generation_without_keccak() -> anyhow::Result<()> {
init_logger();

let all_stark = AllStark::<F, D>::default();
let config = StarkConfig::standard_fast_config();

let timing = &mut TimingTree::new(
"Segment Proof Generation Without Keccak Test",
log::Level::Info,
);
// Process and prove segment
let all_circuits = timed!(
timing,
log::Level::Info,
"Create all recursive circuits",
AllRecursiveCircuits::<F, C, D>::new(
&all_stark,
&[16..17, 8..9, 7..8, 4..9, 8..9, 4..7, 17..18, 17..18, 17..18],
&config,
)
);

let (payload, mut segment_data) = segment_without_keccak()?;
let segment_proof = timed!(
timing,
log::Level::Info,
"Prove segment",
all_circuits.prove_segment(
&all_stark,
&config,
payload,
&mut segment_data,
timing,
None,
)?
);

// Verify the generated segment proof
timed!(
timing,
log::Level::Info,
"Verify segment proof",
all_circuits.verify_root(segment_proof.proof_with_pvs.intern.clone())?
);

// Print timing details
timing.print();

Ok(())
}
}
69 changes: 55 additions & 14 deletions evm_arithmetization/tests/empty_tables.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![cfg(feature = "eth_mainnet")]

use std::time::Duration;

use evm_arithmetization::fixed_recursive_verifier::AllRecursiveCircuits;
use evm_arithmetization::prover::prove;
use evm_arithmetization::testing_utils::{init_logger, segment_without_keccak};
use evm_arithmetization::verifier::testing::verify_all_proofs;
use evm_arithmetization::AllStark;
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::plonk::config::PoseidonGoldilocksConfig;
use plonky2::timed;
use plonky2::util::timing::TimingTree;
use starky::config::StarkConfig;

Expand All @@ -22,21 +22,62 @@ fn empty_tables() -> anyhow::Result<()> {

Check warning on line 22 in evm_arithmetization/tests/empty_tables.rs

View workflow job for this annotation

GitHub Actions / cargo-fmt

Diff in /home/runner/work/zk_evm/zk_evm/evm_arithmetization/tests/empty_tables.rs
let all_stark = AllStark::<F, D>::default();
let config = StarkConfig::standard_fast_config();
let mut proofs = vec![];
let mut timing = TimingTree::new("prove", log::Level::Debug);
let mut timing = &mut TimingTree::new(
"Empty Table Test",
log::Level::Info,
);

// Generate segment data
let (payload, mut segment_data) = segment_without_keccak()?;
let proof = prove::<F, C, D>(
&all_stark,
&config,
payload,
&mut segment_data,
&mut timing,
None,
)?;

// Create all STARK proofs
let mut proofs = vec![];
let proof = timed!(
timing,
log::Level::Info,
"Create all STARK proofs",
prove::<F, C, D>(
&all_stark,
&config,
payload,
&mut segment_data,
&mut timing,

Check failure on line 44 in evm_arithmetization/tests/empty_tables.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler
None,
)?
);
proofs.push(proof);

timing.filter(Duration::from_millis(100)).print();
// Verify the generated STARK proofs
verify_all_proofs(&all_stark, &proofs, &config)?;

// Process and generate segment proof
let all_circuits = timed!(
timing,
log::Level::Info,
"Create all recursive circuits",
AllRecursiveCircuits::<F, C, D>::new(
&all_stark,
&[16..17, 8..9, 7..8, 4..9, 8..9, 4..7, 17..18, 17..18, 17..18],
&config,
)
);
let segment_proof = timed!(
timing,
log::Level::Info,
"Prove segment",
all_circuits.prove_segment_with_all_proofs(&proofs[0], &config, None)?
);

// Verify the generated segment proof
timed!(
timing,
log::Level::Info,
"Verify segment proof",
all_circuits.verify_root(segment_proof.proof_with_pvs.intern.clone())?
);

// Print timing details
timing.print();

verify_all_proofs(&all_stark, &proofs, &config)
Ok(())
}

0 comments on commit a260fba

Please sign in to comment.