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

Commit

Permalink
Add deprecation panics for imported halo2 columns in middleware compi…
Browse files Browse the repository at this point in the history
…lation
  • Loading branch information
alxkzmn committed Aug 5, 2024
1 parent 0ae531c commit 5d8eed0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ authors = ["Leo Lara <leo@leolara.me>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[patch.crates-io]
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", rev = "da4983e" }
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, rev = "da4983e" }

[patch."https://github.com/scroll-tech/halo2.git"]
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", rev = "da4983e" }
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, rev = "da4983e" }

[dependencies]
pyo3 = { version = "0.19.1", features = ["extension-module"] }

halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", features = [ "circuit-params", "derive_serde"], rev = "da4983e"}
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, features = [ "circuit-params", "derive_serde"], rev = "da4983e"}

halo2_middleware = { git = "https://github.com/privacy-scaling-explorations/halo2.git", rev = "da4983e" }
halo2_backend = { git = "https://github.com/privacy-scaling-explorations/halo2.git", features = ["derive_serde"], rev = "da4983e" }
Expand Down
50 changes: 19 additions & 31 deletions src/plonkish/backend/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,9 @@ impl<F: PrimeField + From<u64> + Hash> ChiquitoHalo2<F> {
let halo2_column = meta.fixed_column(column);
fixed_columns.insert(column.uuid(), halo2_column);
}
Halo2Advice => {
let halo2_column = meta.advice_from_halo2(column);
advice_columns.insert(column.uuid(), halo2_column);
}
Halo2Fixed => {
let halo2_column = meta.fixed_from_halo2(column);
fixed_columns.insert(column.uuid(), halo2_column);
}
Halo2Advice | Halo2Fixed => panic!(
"Use src/plonkish/backend/halo2_legacy.rs to compile a circuit with imported Halo2 columns"
),
});

if !self.plonkish_ir.exposed.is_empty() {
Expand Down Expand Up @@ -287,34 +282,40 @@ impl<F: PrimeField> ConstraintSystemBuilder<F> {
column_type: Any::Fixed,
rotation: Rotation(rotation),
})),
Halo2Advice | Halo2Fixed => {
unreachable!("Halo2 columns should be converted within Halo2Expr")
}
Halo2Advice | Halo2Fixed => panic!(
"Use src/plonkish/backend/halo2_legacy.rs to compile a circuit with imported Halo2 columns"
),
}
}

fn convert_advice_column(&self, column: &cColumn) -> ColumnMid {
match column.ctype {
cAdvice | Halo2Advice => ColumnMid {
cAdvice => ColumnMid {
column_type: Columns::Advice,
index: *self
.advice_idx_map
.get(&column.uuid())
.unwrap_or_else(|| panic!("column not found {}", column.annotation)),
},
Halo2Advice => panic!(
"Use src/plonkish/backend/halo2_legacy.rs to compile a circuit with imported Halo2 columns"
),
_ => panic!("wrong column type"),
}
}

fn convert_fixed_column(&self, column: &cColumn) -> ColumnMid {
match column.ctype {
cFixed | Halo2Fixed => ColumnMid {
cFixed => ColumnMid {
column_type: Columns::Fixed,
index: *self
.fixed_idx_map
.get(&column.uuid())
.unwrap_or_else(|| panic!("column not found {}", column.annotation)),
},
Halo2Fixed => panic!(
"Use src/plonkish/backend/halo2_legacy.rs to compile a circuit with imported Halo2 columns"
),
_ => panic!("wrong column type"),
}
}
Expand Down Expand Up @@ -366,8 +367,11 @@ impl<F: PrimeField> ConstraintSystemBuilder<F> {
.enumerate()
.for_each(|(row, (column, offset))| {
let col_type: Columns = match column.ctype {
cAdvice | Halo2Advice => Columns::Advice,
cFixed | Halo2Fixed => Columns::Fixed,
cAdvice => Columns::Advice,
cFixed => Columns::Fixed,
Halo2Advice | Halo2Fixed => panic!(
"Use src/plonkish/backend/halo2_legacy.rs to compile a circuit with imported Halo2 columns"
),
};

let index = if col_type == Columns::Advice {
Expand Down Expand Up @@ -428,14 +432,6 @@ impl<F: PrimeField> ConstraintSystemBuilder<F> {
self.allocate_advice(index, column)
}

fn advice_from_halo2(&mut self, column: &cColumn) -> ColumnMid {
let halo2_column = column
.halo2_advice
.unwrap_or_else(|| panic!("halo2 advice column not found {}", column.annotation))
.column;
self.allocate_advice(halo2_column.index, column)
}

fn fixed_column(&mut self, column: &cColumn) -> ColumnMid {
let index = self.num_fixed_columns;
self.allocate_fixed(index, column)
Expand All @@ -462,14 +458,6 @@ impl<F: PrimeField> ConstraintSystemBuilder<F> {
self.num_advice_columns += 1;
column_mid
}

fn fixed_from_halo2(&mut self, column: &cColumn) -> ColumnMid {
let halo2_column = column
.halo2_fixed
.unwrap_or_else(|| panic!("halo2 advice column not found {}", column.annotation))
.column;
self.allocate_fixed(halo2_column.index, column)
}
}

impl<F: PrimeField> Halo2WitnessGenerator<F, Assignments<F>> for ChiquitoHalo2<F> {
Expand Down

0 comments on commit 5d8eed0

Please sign in to comment.