From dd6960040a08d5220c16f1038cb63730aa383c5e Mon Sep 17 00:00:00 2001 From: Alex Kuzmin Date: Tue, 6 Aug 2024 12:33:16 +0800 Subject: [PATCH] Fix code style --- src/plonkish/backend/halo2.rs | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/plonkish/backend/halo2.rs b/src/plonkish/backend/halo2.rs index e73bccc8..50b934c6 100644 --- a/src/plonkish/backend/halo2.rs +++ b/src/plonkish/backend/halo2.rs @@ -191,7 +191,7 @@ impl + Hash> ChiquitoHalo2 { } } - fn configure_halo2_columns(&mut self, meta: &mut ConstraintSystemBuilder) { + fn configure_halo2_columns(&mut self, cs_builder: &mut ConstraintSystemBuilder) { let mut advice_columns: HashMap = HashMap::new(); let mut fixed_columns: HashMap = HashMap::new(); @@ -200,11 +200,11 @@ impl + Hash> ChiquitoHalo2 { .iter() .for_each(|column| match column.ctype { cAdvice => { - let halo2_column = meta.advice_column(column); + let halo2_column = cs_builder.advice_column(column); advice_columns.insert(column.uuid(), halo2_column); } cFixed => { - let halo2_column = meta.fixed_column(column); + let halo2_column = cs_builder.fixed_column(column); fixed_columns.insert(column.uuid(), halo2_column); } Halo2Advice | Halo2Fixed => panic!( @@ -213,13 +213,13 @@ impl + Hash> ChiquitoHalo2 { }); if !self.plonkish_ir.exposed.is_empty() { - meta.has_instance_column = true; + cs_builder.has_instance_column = true; } self.plonkish_ir.polys.iter().for_each(|poly| { - meta.gates.push(GateMid { + cs_builder.gates.push(GateMid { name: "main".to_string(), - poly: meta.convert_poly(&poly.expr), + poly: cs_builder.convert_poly(&poly.expr), }) }); @@ -227,9 +227,9 @@ impl + Hash> ChiquitoHalo2 { let annotation: &'static str = Box::leak(lookup.annotation.clone().into_boxed_str()); let mut exprs = Vec::new(); for (src, dest) in lookup.exprs.iter() { - exprs.push((meta.convert_poly(src), meta.convert_poly(dest))) + exprs.push((cs_builder.convert_poly(src), cs_builder.convert_poly(dest))) } - meta.lookups.push(lookup::ArgumentMid { + cs_builder.lookups.push(lookup::ArgumentMid { name: annotation.to_string(), input_expressions: exprs.iter().map(|(src, _)| src.clone()).collect(), table_expressions: exprs.iter().map(|(_, dest)| dest.clone()).collect(), @@ -241,6 +241,24 @@ impl + Hash> ChiquitoHalo2 { } } +#[derive(Default)] +struct ConstraintSystemBuilder { + num_fixed_columns: usize, + num_advice_columns: usize, + has_instance_column: bool, + gates: Vec>, + lookups: Vec>, + /// Map from advice column UUID to index + advice_idx_map: HashMap, + /// Map from fixed column UUID to index + fixed_idx_map: HashMap, + permutation: PermutationArgument, + advice_queries: HashMap, + fixed_queries: HashMap, + instance_queries: HashMap, + annotations: HashMap, +} + impl ConstraintSystemBuilder { fn convert_poly(&self, src: &PolyExpr) -> ExpressionMid { match src { @@ -599,24 +617,6 @@ pub struct PermutationArgument { pub columns: Vec, } -#[derive(Default)] -struct ConstraintSystemBuilder { - num_fixed_columns: usize, - num_advice_columns: usize, - has_instance_column: bool, - gates: Vec>, - lookups: Vec>, - /// Map from advice column UUID to index - advice_idx_map: HashMap, - /// Map from fixed column UUID to index - fixed_idx_map: HashMap, - permutation: PermutationArgument, - advice_queries: HashMap, - fixed_queries: HashMap, - instance_queries: HashMap, - annotations: HashMap, -} - impl From> for ConstraintSystemMid { fn from(val: ConstraintSystemBuilder) -> Self { ConstraintSystemMid {