From 50c30b2b39d4d77d652042be69c53960cf02db63 Mon Sep 17 00:00:00 2001 From: dante <45801863+alexander-camuto@users.noreply.github.com> Date: Fri, 10 Nov 2023 21:56:00 +0300 Subject: [PATCH] fix: don't unwrap on OOR lookup (#4) --- halo2_proofs/src/plonk/mv_lookup/prover.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/halo2_proofs/src/plonk/mv_lookup/prover.rs b/halo2_proofs/src/plonk/mv_lookup/prover.rs index 18f0c18c7e..c750239ab6 100644 --- a/halo2_proofs/src/plonk/mv_lookup/prover.rs +++ b/halo2_proofs/src/plonk/mv_lookup/prover.rs @@ -117,19 +117,27 @@ impl> Argument { let m_values: Vec = { use std::sync::atomic::{AtomicU64, Ordering}; - use std::sync::RwLock; let m_values: Vec = (0..params.n()).map(|_| AtomicU64::new(0)).collect(); for compressed_input_expression in compressed_inputs_expressions.iter() { - compressed_input_expression + let res: Result<(), Error> = compressed_input_expression .par_iter() .take(params.n() as usize - blinding_factors - 1) - .for_each(|fi| { - let index = table_index_value_mapping + .map(|fi| { + let index = match table_index_value_mapping .get(&fi.to_repr().as_ref().to_owned()) - .unwrap(); + { + Some(value) => value, + None => { + log::error!("value is OOR of lookup"); + return Err(Error::Synthesis); + } + }; m_values[*index].fetch_add(1, Ordering::Relaxed); - }); + Ok(()) + }) + .collect(); + res? } m_values