From b6156225fadc1a851cb177c255c905f449a4822d Mon Sep 17 00:00:00 2001 From: Leo Lara Date: Fri, 16 Jun 2023 17:00:43 +0700 Subject: [PATCH] Integration tests compare permutations of proofs to check for variadic circuits (#1480) ### Description Integration tests compare permutations of proofs to check for variadic circuits ### Issue Link [[_link issue here_]](https://github.com/privacy-scaling-explorations/zkevm-circuits/issues/1220) ### Type of change - [X] New feature (non-breaking change which adds functionality) ### Contents - as said ### Rationale Trivial ### How Has This Been Tested? Run integration test in PR --- .../src/integration_test_circuits.rs | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/integration-tests/src/integration_test_circuits.rs b/integration-tests/src/integration_test_circuits.rs index 4771edd86e..c9bfd37a09 100644 --- a/integration-tests/src/integration_test_circuits.rs +++ b/integration-tests/src/integration_test_circuits.rs @@ -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::{ @@ -139,6 +142,7 @@ pub struct IntegrationTest + Circuit> { degree: u32, key: Option>, fixed: Option>>>, + permutation: Option, _marker: PhantomData, } @@ -149,6 +153,7 @@ impl + Circuit> IntegrationTest { degree, key: None, fixed: None, + permutation: None, _marker: PhantomData, } } @@ -266,20 +271,25 @@ impl + Circuit> IntegrationTest { fn test_variadic(&mut self, mock_prover: &MockProver) { 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(); - // 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.