mirror of https://github.com/zcash/halo2.git
circuit::layouter::RegionLayouter: Introduce add_to_lookup() method
Co-authored-by: Avi Dessauer <avi.dessauer@platonic.systems>
This commit is contained in:
parent
fc71bba6ba
commit
07655b9e7b
|
@ -4,6 +4,8 @@ use std::{fmt, marker::PhantomData};
|
|||
|
||||
use ff::Field;
|
||||
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
use crate::plonk::TableTag;
|
||||
use crate::plonk::{Advice, Any, Assigned, Column, Error, Fixed, Instance, Selector, TableColumn};
|
||||
|
||||
mod value;
|
||||
|
@ -204,6 +206,12 @@ impl<'r, F: Field> Region<'r, F> {
|
|||
.enable_selector(&|| annotation().into(), selector, offset)
|
||||
}
|
||||
|
||||
/// Enables a dynamic table lookup at the given offset.
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
pub fn add_to_lookup(&mut self, table: TableTag, offset: usize) -> Result<(), Error> {
|
||||
self.region.add_to_lookup(table, offset)
|
||||
}
|
||||
|
||||
/// Assign an advice column value (witness).
|
||||
///
|
||||
/// Even though `to` has `FnMut` bounds, it is guaranteed to be called at most once.
|
||||
|
|
|
@ -5,6 +5,8 @@ use std::marker::PhantomData;
|
|||
|
||||
use ff::Field;
|
||||
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
use crate::plonk::TableTag;
|
||||
use crate::{
|
||||
circuit::{
|
||||
layouter::{RegionColumn, RegionLayouter, RegionShape},
|
||||
|
@ -259,6 +261,13 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> RegionLayouter<F>
|
|||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
fn add_to_lookup(&mut self, table: TableTag, offset: usize) -> Result<(), Error> {
|
||||
self.layouter
|
||||
.cs
|
||||
.add_to_lookup(table, *self.layouter.regions[*self.region_index] + offset)
|
||||
}
|
||||
|
||||
fn assign_advice<'v>(
|
||||
&'v mut self,
|
||||
annotation: &'v (dyn Fn() -> String + 'v),
|
||||
|
|
|
@ -374,6 +374,13 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> RegionLayouter<F> for V1Region<'r
|
|||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
fn add_to_lookup(&mut self, table: crate::plonk::TableTag, offset: usize) -> Result<(), Error> {
|
||||
self.plan
|
||||
.cs
|
||||
.add_to_lookup(table, *self.plan.regions[*self.region_index] + offset)
|
||||
}
|
||||
|
||||
fn assign_advice<'v>(
|
||||
&'v mut self,
|
||||
annotation: &'v (dyn Fn() -> String + 'v),
|
||||
|
|
|
@ -51,6 +51,10 @@ pub trait RegionLayouter<F: Field>: fmt::Debug {
|
|||
offset: usize,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
/// Enables a dynamic table lookup at the given offset.
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
fn add_to_lookup(&mut self, table: TableTag, offset: usize) -> Result<(), Error>;
|
||||
|
||||
/// Assign an advice column value (witness)
|
||||
fn assign_advice<'v>(
|
||||
&'v mut self,
|
||||
|
@ -215,6 +219,14 @@ impl<F: Field> RegionLayouter<F> for RegionShape {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
fn add_to_lookup(&mut self, table: TableTag, offset: usize) -> Result<(), Error> {
|
||||
// Track the tag's fixed column as part of the region's shape.
|
||||
self.columns.insert(table.into());
|
||||
self.row_count = cmp::max(self.row_count, offset + 1);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn assign_advice<'v>(
|
||||
&'v mut self,
|
||||
_: &'v (dyn Fn() -> String + 'v),
|
||||
|
|
|
@ -236,6 +236,12 @@ impl<'r, F: Field> RegionLayouter<F> for TracingRegion<'r, F> {
|
|||
self.0.enable_selector(annotation, selector, offset)
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-dynamic-lookups")]
|
||||
fn add_to_lookup(&mut self, table: TableTag, offset: usize) -> Result<(), Error> {
|
||||
debug!(target: "add_to_lookup", table = ?table, offset = ?offset);
|
||||
self.0.add_to_lookup(table, offset)
|
||||
}
|
||||
|
||||
fn assign_advice<'v>(
|
||||
&'v mut self,
|
||||
annotation: &'v (dyn Fn() -> String + 'v),
|
||||
|
|
Loading…
Reference in New Issue