diff --git a/halo2_proofs/src/plonk.rs b/halo2_proofs/src/plonk.rs index 85a544d585..9c1bc6eaa6 100644 --- a/halo2_proofs/src/plonk.rs +++ b/halo2_proofs/src/plonk.rs @@ -108,7 +108,8 @@ pub struct VerifyingKey { domain: EvaluationDomain, fixed_commitments: Vec, permutation: permutation::VerifyingKey, - cs: ConstraintSystem, + /// TODO: Remove pub + pub cs: ConstraintSystem, /// Cached maximum degree of `cs` (which doesn't change after construction). cs_degree: usize, /// The representative of this `VerifyingKey` in transcripts. diff --git a/halo2_proofs/src/plonk/keygen.rs b/halo2_proofs/src/plonk/keygen.rs index 6014ac55d8..eb47d26887 100644 --- a/halo2_proofs/src/plonk/keygen.rs +++ b/halo2_proofs/src/plonk/keygen.rs @@ -275,7 +275,9 @@ where C::Scalar: FromUniformBytes<64>, { let (compiled_circuit, _, _) = compile_circuit(params.k(), circuit, compress_selectors)?; - keygen_vk_v2(params, &compiled_circuit) + let mut vk = keygen_vk_v2(params, &compiled_circuit)?; + vk.compress_selectors = compress_selectors; + Ok(vk) } // TODO: Remove diff --git a/halo2_proofs/src/plonk/prover.rs b/halo2_proofs/src/plonk/prover.rs index e694e4427f..62f45e85c3 100644 --- a/halo2_proofs/src/plonk/prover.rs +++ b/halo2_proofs/src/plonk/prover.rs @@ -283,6 +283,8 @@ impl< let params = self.params; let meta = &self.pk.vk.cs; // let queries = &self.pk.vk.queries; + // println!("DBG commit_phase gate {:?}", meta.gates()[0]); + // println!("DBG commit_phase queries {:?}", meta.advice_queries()); let mut rng = &mut self.rng; @@ -888,7 +890,7 @@ pub fn create_proof_legacy< pk: &ProvingKey, circuits: &[ConcreteCircuit], instances: &[&[&[Scheme::Scalar]]], - mut rng: R, + rng: R, transcript: &mut T, ) -> Result<(), Error> where diff --git a/halo2_proofs/tests/frontend_backend_split.rs b/halo2_proofs/tests/frontend_backend_split.rs index 7f6558bf49..34a71ff59b 100644 --- a/halo2_proofs/tests/frontend_backend_split.rs +++ b/halo2_proofs/tests/frontend_backend_split.rs @@ -11,11 +11,10 @@ use halo2_proofs::arithmetic::Field; use halo2_proofs::circuit::{AssignedCell, Cell, Layouter, Region, SimpleFloorPlanner, Value}; use halo2_proofs::dev::MockProver; use halo2_proofs::plonk::{ - compile_circuit, create_proof, keygen_pk, keygen_pk_v2, keygen_vk, keygen_vk_v2, verify_proof, - verify_proof_single, Advice, Assigned, Challenge, Circuit, Column, CompiledCircuitV2, - ConstraintSystem, ConstraintSystemV2Backend, Error, Expression, FirstPhase, Fixed, Instance, - ProverV2Single, ProvingKey, SecondPhase, Selector, TableColumn, VerifyingKey, - WitnessCalculator, + compile_circuit, keygen_pk_v2, keygen_vk_v2, verify_proof, verify_proof_single, Advice, + Assigned, Challenge, Circuit, Column, CompiledCircuitV2, ConstraintSystem, + ConstraintSystemV2Backend, Error, Expression, FirstPhase, Fixed, Instance, ProverV2Single, + ProvingKey, SecondPhase, Selector, TableColumn, VerifyingKey, WitnessCalculator, }; use halo2_proofs::poly::commitment::{CommitmentScheme, ParamsProver, Prover, Verifier}; use halo2_proofs::poly::Rotation; @@ -161,9 +160,9 @@ impl, const WIDTH_FACTOR: usize> MyCircuit meta.create_gate("gate_a", |meta| { let s_gate = meta.query_selector(s_gate); + let b = meta.query_advice(b, Rotation::cur()); let a1 = meta.query_advice(a, Rotation::next()); let a0 = meta.query_advice(a, Rotation::cur()); - let b = meta.query_advice(b, Rotation::cur()); let c = meta.query_advice(c, Rotation::cur()); let d = meta.query_fixed(d, Rotation::cur()); @@ -488,6 +487,7 @@ fn test_mycircuit_full_legacy() { create_proof_legacy as create_proof, keygen_pk_legacy as keygen_pk, keygen_vk_legacy as keygen_vk, }; + // use halo2_proofs::plonk::{create_proof, keygen_pk, keygen_vk}; let k = K; let circuit: MyCircuit = MyCircuit::new(k, 42); @@ -498,6 +498,8 @@ fn test_mycircuit_full_legacy() { let verifier_params = params.verifier_params(); let start = Instant::now(); let vk = keygen_vk(¶ms, &circuit).expect("keygen_vk should not fail"); + // println!("DBG gate {:?}", vk.cs.gates()[0]); + // println!("DBG queries {:?}", vk.cs.advice_queries()); let pk = keygen_pk(¶ms, vk.clone(), &circuit).expect("keygen_pk should not fail"); println!("Keygen: {:?}", start.elapsed()); diff --git a/rust-toolchain b/rust-toolchain index b6148bc0a7..7c7053aa23 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.66.0 +1.75.0 diff --git a/scratch b/scratch new file mode 100644 index 0000000000..ab22c18135 --- /dev/null +++ b/scratch @@ -0,0 +1,137 @@ +DBG collected queries +Queries { + advice: [ + ( + Column { + index: 0, + column_type: Advice, + }, + Rotation( + 0, + ), + ), + ( + Column { + index: 0, + column_type: Advice, + }, + Rotation( + 1, + ), + ), + ( + Column { + index: 1, + column_type: Advice, + }, + Rotation( + 0, + ), + ), + ( + Column { + index: 2, + column_type: Advice, + }, + Rotation( + 0, + ), + ), + ], + instance: [], + fixed: [ + ( + Column { + index: 0, + column_type: Fixed, + }, + Rotation( + 0, + ), + ), + ( + Column { + index: 5, + column_type: Fixed, + }, + Rotation( + 0, + ), + ), + ], + num_advice_queries: [ + 2, + 1, + 1, + 0, + ], +} +DBG collected queries +Queries { + advice: [ + ( + Column { + index: 0, + column_type: Advice, + }, + Rotation( + 0, + ), + ), + ( + Column { + index: 0, + column_type: Advice, + }, + Rotation( + 1, + ), + ), + ( + Column { + index: 1, + column_type: Advice, + }, + Rotation( + 0, + ), + ), + ( + Column { + index: 2, + column_type: Advice, + }, + Rotation( + 0, + ), + ), + ], + instance: [], + fixed: [ + ( + Column { + index: 0, + column_type: Fixed, + }, + Rotation( + 0, + ), + ), + ( # EXTRA + Column { + index: 5, + column_type: Fixed, + }, + Rotation( + 0, + ), + ), + ], + num_advice_queries: [ + 2, + 1, + 1, + 0, + ], +} +