From c2853684f77d2d5f53e60ab8b66ea1fd14f55057 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Thu, 2 Feb 2023 11:50:39 +0100 Subject: [PATCH] feat: Add `assert_satisfied_at_rows_par` variant Resolves: #133 --- halo2_proofs/src/dev.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/halo2_proofs/src/dev.rs b/halo2_proofs/src/dev.rs index 35fce1daf6..4e2b843827 100644 --- a/halo2_proofs/src/dev.rs +++ b/halo2_proofs/src/dev.rs @@ -962,8 +962,7 @@ impl MockProver { /// Returns `Ok(())` if this `MockProver` is satisfied, or a list of errors indicating /// the reasons that the circuit is not satisfied. - /// Constraints are only checked at `gate_row_ids`, - /// and lookup inputs are only checked at `lookup_input_row_ids`, parallelly. + /// Constraints are only checked at `gate_row_ids`, and lookup inputs are only checked at `lookup_input_row_ids`, parallelly. pub fn verify_at_rows_par>( &self, gate_row_ids: I, @@ -1354,6 +1353,31 @@ impl MockProver { } } + /// Panics if the circuit being checked by this `MockProver` is not satisfied. + /// + /// Any verification failures will be pretty-printed to stderr before the function + /// panics. + /// + /// Constraints are only checked at `gate_row_ids`, and lookup inputs are only checked at `lookup_input_row_ids`, parallelly. + /// + /// Apart from the stderr output, this method is equivalent to: + /// ```ignore + /// assert_eq!(prover.verify_at_rows_par(), Ok(())); + /// ``` + pub fn assert_satisfied_at_rows_par>( + &self, + gate_row_ids: I, + lookup_input_row_ids: I, + ) { + if let Err(errs) = self.verify_at_rows_par(gate_row_ids, lookup_input_row_ids) { + for err in errs { + err.emit(self); + eprintln!(); + } + panic!("circuit was not satisfied"); + } + } + /// Returns the list of Fixed Columns used within a MockProver instance and the associated values contained on each Cell. pub fn fixed(&self) -> &Vec>> { &self.fixed