From 398b15c103e39b239527ed5de6172c38c1fa39dc Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Sun, 19 Nov 2023 15:11:03 +0300 Subject: [PATCH 1/3] wip --- plonky2/src/plonk/circuit_builder.rs | 38 +++++++++++++++++++++------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index 67db68649a..0aa438ae90 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -8,7 +8,7 @@ use std::time::Instant; use hashbrown::{HashMap, HashSet}; use itertools::Itertools; -use log::{debug, info, Level}; +use log::{debug, info, warn, Level}; use plonky2_util::ceil_div_usize; use crate::field::cosets::get_unique_coset_shifts; @@ -915,11 +915,22 @@ impl, const D: usize> CircuitBuilder { } } - /// Builds a "full circuit", with both prover and verifier data. pub fn build_with_options>( - mut self, + self, commit_to_sigma: bool, ) -> CircuitData { + let (circuit_data, success) = self.try_build_with_options(commit_to_sigma); + if !success { + panic!("Failed to build circuit"); + } + circuit_data + } + + /// Builds a "full circuit", with both prover and verifier data. + pub fn try_build_with_options>( + mut self, + commit_to_sigma: bool, + ) -> (CircuitData, bool) { let mut timing = TimingTree::new("preprocess", Level::Trace); #[cfg(feature = "std")] @@ -1125,8 +1136,14 @@ impl, const D: usize> CircuitBuilder { num_lookup_selectors, luts: self.luts, }; + + let mut success = true; + if let Some(goal_data) = self.goal_common_data { - assert_eq!(goal_data, common, "The expected circuit data passed to cyclic recursion method did not match the actual circuit"); + if goal_data != common { + warn!("The expected circuit data passed to cyclic recursion method did not match the actual circuit"); + success = false; + } } let prover_only = ProverOnlyCircuitData:: { @@ -1151,11 +1168,14 @@ impl, const D: usize> CircuitBuilder { timing.print(); #[cfg(feature = "std")] debug!("Building circuit took {}s", start.elapsed().as_secs_f32()); - CircuitData { - prover_only, - verifier_only, - common, - } + ( + CircuitData { + prover_only, + verifier_only, + common, + }, + success, + ) } pub fn build>(self) -> CircuitData { From 2a6065b42fba25b4a152604bb5fbc42cb7207ca1 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 27 Nov 2023 14:56:51 -0800 Subject: [PATCH 2/3] comment --- plonky2/src/plonk/circuit_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index 0aa438ae90..0da3ed60d6 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -915,6 +915,7 @@ impl, const D: usize> CircuitBuilder { } } + /// Builds a "full circuit", with both prover and verifier data. pub fn build_with_options>( self, commit_to_sigma: bool, @@ -926,7 +927,6 @@ impl, const D: usize> CircuitBuilder { circuit_data } - /// Builds a "full circuit", with both prover and verifier data. pub fn try_build_with_options>( mut self, commit_to_sigma: bool, From b598e6ff9f93d7ba548758aba561549f3e5767c9 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Tue, 28 Nov 2023 16:32:20 -0800 Subject: [PATCH 3/3] VerifierCircuitData Clone,PartialEq,Eq --- plonky2/src/plonk/circuit_data.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plonky2/src/plonk/circuit_data.rs b/plonky2/src/plonk/circuit_data.rs index c93de8cb98..e850cb4269 100644 --- a/plonky2/src/plonk/circuit_data.rs +++ b/plonky2/src/plonk/circuit_data.rs @@ -265,7 +265,7 @@ impl, C: GenericConfig, const D: usize> } /// Circuit data required by the prover. -#[derive(Debug)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct VerifierCircuitData< F: RichField + Extendable, C: GenericConfig,