Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
alxkzmn committed Aug 6, 2024
1 parent 5d8eed0 commit dd69600
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/plonkish/backend/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<F: PrimeField + From<u64> + Hash> ChiquitoHalo2<F> {
}
}

fn configure_halo2_columns(&mut self, meta: &mut ConstraintSystemBuilder<F>) {
fn configure_halo2_columns(&mut self, cs_builder: &mut ConstraintSystemBuilder<F>) {
let mut advice_columns: HashMap<UUID, ColumnMid> = HashMap::new();
let mut fixed_columns: HashMap<UUID, ColumnMid> = HashMap::new();

Expand All @@ -200,11 +200,11 @@ impl<F: PrimeField + From<u64> + Hash> ChiquitoHalo2<F> {
.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!(
Expand All @@ -213,23 +213,23 @@ impl<F: PrimeField + From<u64> + Hash> ChiquitoHalo2<F> {
});

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),
})
});

for lookup in self.plonkish_ir.lookups.iter() {
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(),
Expand All @@ -241,6 +241,24 @@ impl<F: PrimeField + From<u64> + Hash> ChiquitoHalo2<F> {
}
}

#[derive(Default)]
struct ConstraintSystemBuilder<F: PrimeField> {
num_fixed_columns: usize,
num_advice_columns: usize,
has_instance_column: bool,
gates: Vec<GateMid<F>>,
lookups: Vec<lookup::ArgumentMid<F>>,
/// Map from advice column UUID to index
advice_idx_map: HashMap<UUID, usize>,
/// Map from fixed column UUID to index
fixed_idx_map: HashMap<UUID, usize>,
permutation: PermutationArgument,
advice_queries: HashMap<usize, usize>,
fixed_queries: HashMap<usize, usize>,
instance_queries: HashMap<usize, usize>,
annotations: HashMap<ColumnMid, String>,
}

impl<F: PrimeField> ConstraintSystemBuilder<F> {
fn convert_poly(&self, src: &PolyExpr<F>) -> ExpressionMid<F> {
match src {
Expand Down Expand Up @@ -599,24 +617,6 @@ pub struct PermutationArgument {
pub columns: Vec<ColumnMid>,
}

#[derive(Default)]
struct ConstraintSystemBuilder<F: PrimeField> {
num_fixed_columns: usize,
num_advice_columns: usize,
has_instance_column: bool,
gates: Vec<GateMid<F>>,
lookups: Vec<lookup::ArgumentMid<F>>,
/// Map from advice column UUID to index
advice_idx_map: HashMap<UUID, usize>,
/// Map from fixed column UUID to index
fixed_idx_map: HashMap<UUID, usize>,
permutation: PermutationArgument,
advice_queries: HashMap<usize, usize>,
fixed_queries: HashMap<usize, usize>,
instance_queries: HashMap<usize, usize>,
annotations: HashMap<ColumnMid, String>,
}

impl<F: PrimeField> From<ConstraintSystemBuilder<F>> for ConstraintSystemMid<F> {
fn from(val: ConstraintSystemBuilder<F>) -> Self {
ConstraintSystemMid {
Expand Down

0 comments on commit dd69600

Please sign in to comment.