Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Integration tests compare permutations of proofs to check for variadic circuits #1480

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions integration-tests/src/integration_test_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use eth_types::geth_types::GethData;
use halo2_proofs::{
dev::{CellValue, MockProver},
halo2curves::bn256::{Bn256, Fr, G1Affine},
plonk::{create_proof, keygen_pk, keygen_vk, verify_proof, Circuit, ProvingKey, VerifyingKey},
plonk::{
create_proof, keygen_pk, keygen_vk, permutation::Assembly, verify_proof, Circuit,
ProvingKey, VerifyingKey,
},
poly::{
commitment::ParamsProver,
kzg::{
Expand Down Expand Up @@ -139,6 +142,7 @@ pub struct IntegrationTest<C: SubCircuit<Fr> + Circuit<Fr>> {
degree: u32,
key: Option<ProvingKey<G1Affine>>,
fixed: Option<Vec<Vec<CellValue<Fr>>>>,
permutation: Option<Assembly>,
_marker: PhantomData<C>,
}

Expand All @@ -149,6 +153,7 @@ impl<C: SubCircuit<Fr> + Circuit<Fr>> IntegrationTest<C> {
degree,
key: None,
fixed: None,
permutation: None,
_marker: PhantomData,
}
}
Expand Down Expand Up @@ -266,20 +271,25 @@ impl<C: SubCircuit<Fr> + Circuit<Fr>> IntegrationTest<C> {
fn test_variadic(&mut self, mock_prover: &MockProver<Fr>) {
let fixed = mock_prover.fixed();

match self.fixed.clone() {
Some(prev_fixed) => {
assert!(
fixed.eq(&prev_fixed),
"circuit fixed columns are not constant for different witnesses"
);
}
None => {
self.fixed = Some(fixed.clone());
}
};
if let Some(prev_fixed) = self.fixed.clone() {
assert!(
fixed.eq(&prev_fixed),
"circuit fixed columns are not constant for different witnesses"
);
} else {
self.fixed = Some(fixed.clone());
}

let permutation = mock_prover.permutation();
leolara marked this conversation as resolved.
Show resolved Hide resolved

// TODO: check mock_prover.permutation(), currently the returning type
// is private so cannot store.
if let Some(prev_permutation) = self.permutation.clone() {
assert!(
permutation.eq(&prev_permutation),
"circuit permutations are not constant for different witnesses"
);
} else {
self.permutation = Some(permutation.clone());
}
}

/// Run integration test at a block identified by a tag.
Expand Down