mirror of https://github.com/zcash/halo2.git
circuit::layouter::RegionColumn: Introduce TableTag variant
Co-authored-by: Avi Dessauer <avi.dessauer@platonic.systems>
This commit is contained in:
parent
77b18df089
commit
78ea483f65
|
@ -8,6 +8,8 @@ use ff::Field;
|
||||||
|
|
||||||
pub use super::table_layouter::TableLayouter;
|
pub use super::table_layouter::TableLayouter;
|
||||||
use super::{Cell, RegionIndex, Value};
|
use super::{Cell, RegionIndex, Value};
|
||||||
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
use crate::plonk::TableTag;
|
||||||
use crate::plonk::{Advice, Any, Assigned, Column, Error, Fixed, Instance, Selector};
|
use crate::plonk::{Advice, Any, Assigned, Column, Error, Fixed, Instance, Selector};
|
||||||
|
|
||||||
/// Helper trait for implementing a custom [`Layouter`].
|
/// Helper trait for implementing a custom [`Layouter`].
|
||||||
|
@ -15,7 +17,7 @@ use crate::plonk::{Advice, Any, Assigned, Column, Error, Fixed, Instance, Select
|
||||||
/// This trait is used for implementing region assignments:
|
/// This trait is used for implementing region assignments:
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// impl<'a, F: FieldExt, C: Chip<F>, CS: Assignment<F> + 'a> Layouter<C> for MyLayouter<'a, C, CS> {
|
/// impl<'a, F: Field, C: Chip<F>, CS: Assignment<F> + 'a> Layouter<C> for MyLayouter<'a, C, CS> {
|
||||||
/// fn assign_region(
|
/// fn assign_region(
|
||||||
/// &mut self,
|
/// &mut self,
|
||||||
/// assignment: impl FnOnce(Region<'_, F, C>) -> Result<(), Error>,
|
/// assignment: impl FnOnce(Region<'_, F, C>) -> Result<(), Error>,
|
||||||
|
@ -127,6 +129,9 @@ pub enum RegionColumn {
|
||||||
Column(Column<Any>),
|
Column(Column<Any>),
|
||||||
/// Virtual column representing a (boolean) selector
|
/// Virtual column representing a (boolean) selector
|
||||||
Selector(Selector),
|
Selector(Selector),
|
||||||
|
/// Virtual column used for storing dynamic table tags
|
||||||
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
TableTag(TableTag),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Column<Any>> for RegionColumn {
|
impl From<Column<Any>> for RegionColumn {
|
||||||
|
@ -141,13 +146,26 @@ impl From<Selector> for RegionColumn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
impl From<TableTag> for RegionColumn {
|
||||||
|
fn from(table_tag: TableTag) -> RegionColumn {
|
||||||
|
RegionColumn::TableTag(table_tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Ord for RegionColumn {
|
impl Ord for RegionColumn {
|
||||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Self::Column(ref a), Self::Column(ref b)) => a.cmp(b),
|
(Self::Column(ref a), Self::Column(ref b)) => a.cmp(b),
|
||||||
(Self::Selector(ref a), Self::Selector(ref b)) => a.0.cmp(&b.0),
|
(Self::Selector(ref a), Self::Selector(ref b)) => a.0.cmp(&b.0),
|
||||||
(Self::Column(_), Self::Selector(_)) => cmp::Ordering::Less,
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
(Self::TableTag(ref a), Self::TableTag(ref b)) => a.0.cmp(&b.0),
|
||||||
|
(Self::Column(_), _) => cmp::Ordering::Less,
|
||||||
(Self::Selector(_), Self::Column(_)) => cmp::Ordering::Greater,
|
(Self::Selector(_), Self::Column(_)) => cmp::Ordering::Greater,
|
||||||
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
(Self::TableTag(_), _) => cmp::Ordering::Greater,
|
||||||
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
(_, Self::TableTag(_)) => cmp::Ordering::Less,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,8 @@ impl CircuitLayout {
|
||||||
let column: Column<Any> = match column {
|
let column: Column<Any> = match column {
|
||||||
RegionColumn::Column(col) => col,
|
RegionColumn::Column(col) => col,
|
||||||
RegionColumn::Selector(selector) => cs.selector_map[selector.0].into(),
|
RegionColumn::Selector(selector) => cs.selector_map[selector.0].into(),
|
||||||
|
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||||
|
RegionColumn::TableTag(tag_col) => cs.dynamic_table_tag_map[tag_col.0].into(),
|
||||||
};
|
};
|
||||||
column.index()
|
column.index()
|
||||||
+ match column.column_type() {
|
+ match column.column_type() {
|
||||||
|
|
Loading…
Reference in New Issue