mirror of
https://github.com/logos-storage/proof-aggregation.git
synced 2026-01-03 22:33:08 +00:00
improve recursion bench.
This commit is contained in:
parent
47f831c727
commit
bfed76e46f
@ -1,9 +1,6 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{Criterion, criterion_group, criterion_main};
|
||||||
use plonky2::iop::witness::PartialWitness;
|
|
||||||
use plonky2::plonk::circuit_builder::CircuitBuilder;
|
|
||||||
use plonky2::plonk::circuit_data::{CircuitConfig};
|
|
||||||
use plonky2::plonk::config::GenericConfig;
|
|
||||||
use plonky2::plonk::proof::ProofWithPublicInputs;
|
use plonky2::plonk::proof::ProofWithPublicInputs;
|
||||||
|
use codex_plonky2_circuits::circuit_helper::Plonky2Circuit;
|
||||||
use codex_plonky2_circuits::circuits::sample_cells::{SampleCircuit};
|
use codex_plonky2_circuits::circuits::sample_cells::{SampleCircuit};
|
||||||
use codex_plonky2_circuits::recursion::uniform::tree::TreeRecursion;
|
use codex_plonky2_circuits::recursion::uniform::tree::TreeRecursion;
|
||||||
use proof_input::params::{C, D, F,HF};
|
use proof_input::params::{C, D, F,HF};
|
||||||
@ -17,21 +14,17 @@ fn bench_uniform_recursion<const K: usize,const N: usize,const M: usize,>(c: &mu
|
|||||||
|
|
||||||
//------------ sampling inner circuit ----------------------
|
//------------ sampling inner circuit ----------------------
|
||||||
// Circuit that does the sampling - 100 samples
|
// Circuit that does the sampling - 100 samples
|
||||||
let config = CircuitConfig::standard_recursion_config();
|
|
||||||
let mut sampling_builder = CircuitBuilder::<F, D>::new(config);
|
|
||||||
let mut params = Params::default();
|
let mut params = Params::default();
|
||||||
params.input_params.n_samples = 100;
|
params.set_n_samples(100);
|
||||||
params.circuit_params.n_samples = 100;
|
|
||||||
let one_circ_input = gen_testing_circuit_input::<F,D>(¶ms.input_params);
|
let one_circ_input = gen_testing_circuit_input::<F,D>(¶ms.input_params);
|
||||||
let samp_circ = SampleCircuit::<F,D,HF>::new(params.circuit_params);
|
let samp_circ = SampleCircuit::<F,D,HF>::new(params.circuit_params);
|
||||||
let inner_tar = samp_circ.sample_slot_circuit_with_public_input(&mut sampling_builder)?;
|
let (inner_tar, inner_data) = samp_circ.build_with_standard_config()?;
|
||||||
// get generate a sampling proof
|
// get generate a sampling proof
|
||||||
let mut pw = PartialWitness::<F>::new();
|
let inner_verifier_data = inner_data.verifier_data();
|
||||||
samp_circ.sample_slot_assign_witness(&mut pw,&inner_tar,&one_circ_input)?;
|
let inner_prover_data = inner_data.prover_data();
|
||||||
let inner_data = sampling_builder.build::<C>();
|
let inner_proof = samp_circ.prove(&inner_tar, &one_circ_input, &inner_prover_data)?;
|
||||||
let inner_proof = inner_data.prove(pw.clone())?;
|
// clone the proof to get K proofs
|
||||||
|
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..K).map(|_i| inner_proof.clone()).collect();
|
||||||
let proofs: Vec<ProofWithPublicInputs<F, C, D>> = (0..K).map(|i| inner_proof.clone()).collect();
|
|
||||||
|
|
||||||
// ------------------- tree --------------------
|
// ------------------- tree --------------------
|
||||||
|
|
||||||
@ -40,7 +33,7 @@ fn bench_uniform_recursion<const K: usize,const N: usize,const M: usize,>(c: &mu
|
|||||||
// Building phase
|
// Building phase
|
||||||
group.bench_function("build tree", |b| {
|
group.bench_function("build tree", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
tree = Some(TreeRecursion::<F,D,C,HF, N, M>::build(inner_data.common.clone()).unwrap());
|
tree = Some(TreeRecursion::<F,D,C,HF, N, M>::build_with_standard_config(inner_verifier_data.common.clone(), inner_verifier_data.verifier_only.clone()).unwrap());
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,7 +44,7 @@ fn bench_uniform_recursion<const K: usize,const N: usize,const M: usize,>(c: &mu
|
|||||||
// Proving Phase
|
// Proving Phase
|
||||||
group.bench_function("prove tree", |b| {
|
group.bench_function("prove tree", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
proof = Some(tree.prove_tree(&proofs, &inner_data.verifier_only).unwrap());
|
proof = Some(tree.prove_tree(&proofs).unwrap());
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -62,7 +55,7 @@ fn bench_uniform_recursion<const K: usize,const N: usize,const M: usize,>(c: &mu
|
|||||||
// Verifying Phase
|
// Verifying Phase
|
||||||
group.bench_function("verify root proof", |b| {
|
group.bench_function("verify root proof", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
tree.verify_proof_and_public_input(proof.clone(),inner_pi.clone(),&inner_data.verifier_data())
|
tree.verify_proof_and_public_input(proof.clone(),inner_pi.clone(), false)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,7 +64,7 @@ fn bench_uniform_recursion<const K: usize,const N: usize,const M: usize,>(c: &mu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn bench_uniform_tree_recursion(c: &mut Criterion){
|
fn bench_uniform_tree_recursion(c: &mut Criterion){
|
||||||
const K: usize = 32; // number of inner proofs to aggregate
|
// const K: usize = 4; // number of inner proofs to aggregate
|
||||||
const N: usize = 1; // number of inner proofs in the leaf
|
const N: usize = 1; // number of inner proofs in the leaf
|
||||||
const M: usize = 2; // number of leaf proofs in the node
|
const M: usize = 2; // number of leaf proofs in the node
|
||||||
bench_uniform_recursion::<2, N, M>(c).expect("bench failed");
|
bench_uniform_recursion::<2, N, M>(c).expect("bench failed");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user