mirror of https://github.com/zcash/halo2.git
Simplify Backend gate type
This commit is contained in:
parent
d350e727f1
commit
2c50b39812
|
@ -1623,12 +1623,11 @@ impl<F: Field, C: Into<Constraint<F>>, Iter: IntoIterator<Item = C>> IntoIterato
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GateV2Backend
|
/// A Gate contains a single polynomial identity with a name as metadata.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GateV2Backend<F: Field> {
|
pub struct GateV2Backend<F: Field> {
|
||||||
name: String,
|
name: String,
|
||||||
constraint_names: Vec<String>,
|
poly: ExpressionMid<F>,
|
||||||
polys: Vec<ExpressionMid<F>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F: Field> GateV2Backend<F> {
|
impl<F: Field> GateV2Backend<F> {
|
||||||
|
@ -1637,14 +1636,9 @@ impl<F: Field> GateV2Backend<F> {
|
||||||
self.name.as_str()
|
self.name.as_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the name of the constraint at index `constraint_index`.
|
/// Returns the polynomial identity of this gate
|
||||||
pub fn constraint_name(&self, constraint_index: usize) -> &str {
|
pub fn polynomial(&self) -> &ExpressionMid<F> {
|
||||||
self.constraint_names[constraint_index].as_str()
|
&self.poly
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns constraints of this gate
|
|
||||||
pub fn polynomials(&self) -> &[ExpressionMid<F>] {
|
|
||||||
&self.polys
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1988,11 +1982,19 @@ pub fn compile_circuit<F: Field, ConcreteCircuit: Circuit<F>>(
|
||||||
gates: cs
|
gates: cs
|
||||||
.gates
|
.gates
|
||||||
.iter()
|
.iter()
|
||||||
.map(|g| GateV2Backend {
|
.map(|g| {
|
||||||
name: g.name.clone(),
|
g.polys.clone().into_iter().enumerate().map(|(i, e)| {
|
||||||
constraint_names: g.constraint_names.clone(),
|
let name = match g.constraint_name(i) {
|
||||||
polys: g.polys.clone().into_iter().map(|e| e.into()).collect(),
|
"" => g.name.clone(),
|
||||||
|
constraint_name => format!("{}:{}", g.name, constraint_name),
|
||||||
|
};
|
||||||
|
GateV2Backend {
|
||||||
|
name,
|
||||||
|
poly: e.into(),
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
.flatten()
|
||||||
.collect(),
|
.collect(),
|
||||||
permutation: cs.permutation.clone(),
|
permutation: cs.permutation.clone(),
|
||||||
lookups: cs
|
lookups: cs
|
||||||
|
@ -2073,12 +2075,8 @@ impl<F: Field> ConstraintSystemV2Backend<F> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|gate| Gate {
|
.map(|gate| Gate {
|
||||||
name: gate.name.clone(),
|
name: gate.name.clone(),
|
||||||
constraint_names: gate.constraint_names.clone(),
|
constraint_names: Vec::new(),
|
||||||
polys: gate
|
polys: vec![queries.as_expression(gate.polynomial())],
|
||||||
.polynomials()
|
|
||||||
.iter()
|
|
||||||
.map(|e| queries.as_expression(e))
|
|
||||||
.collect(),
|
|
||||||
queried_selectors: Vec::new(), // Unused?
|
queried_selectors: Vec::new(), // Unused?
|
||||||
queried_cells: Vec::new(), // Unused?
|
queried_cells: Vec::new(), // Unused?
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue