pub struct LookupAnyManager<F: Field + Ord, const ADVICE_COLS: usize> {
pub cells_to_lookup: Arc<Mutex<BTreeMap<ContextTag, Vec<[AssignedValue<F>; ADVICE_COLS]>>>>,
/* private fields */
}
Expand description
A manager that can be used for any lookup argument. This manager automates the process of copying cells to designed advice columns with lookup enabled. It also manages how many such advice columns are necessary.
§Detailed explanation
If we have a lookup argument that uses ADVICE_COLS
advice columns and TABLE_COLS
table columns, where
the table is either fixed or dynamic (advice), then we want to dynamically allocate chunks of ADVICE_COLS
columns
that have the lookup into the table always on so that:
- every time we want to lookup [_; ADVICE_COLS] values, we copy them over to a row in the special lookup-enabled advice columns.
- note that just for assignment, we don’t need to know anything about the table itself.
Note: the manager does not need to know the value of
TABLE_COLS
.
We want this manager to be CPU thread safe, while ensuring that the resulting circuit is
deterministic – the order in which the cells to lookup are added matters.
The current solution is to tag the cells to lookup with the context id from the Context
in which
it was called, and add virtual cells sequentially to buckets labelled by id.
The virtual cells will be assigned to physical cells sequentially by id.
We use a BTreeMap
for the buckets instead of sorting to cells, to ensure that the order of the cells
within a bucket is deterministic.
The assumption is that the Context
is thread-local.
Cheap to clone across threads because everything is in Arc.
Fields§
§cells_to_lookup: Arc<Mutex<BTreeMap<ContextTag, Vec<[AssignedValue<F>; ADVICE_COLS]>>>>
Shared cells to lookup, tagged by (type id, context id).
Implementations§
Source§impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
Sourcepub fn copy_manager(&self) -> &SharedCopyConstraintManager<F>
pub fn copy_manager(&self) -> &SharedCopyConstraintManager<F>
Global shared copy manager
Source§impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
Sourcepub fn witness_gen_only(&self) -> bool
pub fn witness_gen_only(&self) -> bool
Specify whether constraints should be imposed for additional safety.
Source§impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
Sourcepub fn set_copy_manager(
&mut self,
val: SharedCopyConstraintManager<F>,
) -> &mut Self
pub fn set_copy_manager( &mut self, val: SharedCopyConstraintManager<F>, ) -> &mut Self
Global shared copy manager
Source§impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
impl<F: Field + Ord, const ADVICE_COLS: usize> LookupAnyManager<F, ADVICE_COLS>
Sourcepub fn new(
witness_gen_only: bool,
copy_manager: SharedCopyConstraintManager<F>,
) -> Self
pub fn new( witness_gen_only: bool, copy_manager: SharedCopyConstraintManager<F>, ) -> Self
Creates a new LookupAnyManager with a given copy manager.
Sourcepub fn add_lookup(
&self,
tag: ContextTag,
cells: [AssignedValue<F>; ADVICE_COLS],
)
pub fn add_lookup( &self, tag: ContextTag, cells: [AssignedValue<F>; ADVICE_COLS], )
Add a lookup argument to the manager.
Sourcepub fn total_rows(&self) -> usize
pub fn total_rows(&self) -> usize
The total number of virtual rows needed to special lookups
Sourcepub fn num_advice_chunks(&self, usable_rows: usize) -> usize
pub fn num_advice_chunks(&self, usable_rows: usize) -> usize
The optimal number of ADVICE_COLS
chunks of advice columns with lookup enabled for this
particular lookup argument that we should allocate.
Sourcepub fn deep_clone(&self, copy_manager: SharedCopyConstraintManager<F>) -> Self
pub fn deep_clone(&self, copy_manager: SharedCopyConstraintManager<F>) -> Self
Deep clone with the specified copy manager. Unsets assigned
.
Trait Implementations§
Source§impl<F: Clone + Field + Ord, const ADVICE_COLS: usize> Clone for LookupAnyManager<F, ADVICE_COLS>
impl<F: Clone + Field + Ord, const ADVICE_COLS: usize> Clone for LookupAnyManager<F, ADVICE_COLS>
Source§fn clone(&self) -> LookupAnyManager<F, ADVICE_COLS>
fn clone(&self) -> LookupAnyManager<F, ADVICE_COLS>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<F: Debug + Field + Ord, const ADVICE_COLS: usize> Debug for LookupAnyManager<F, ADVICE_COLS>
impl<F: Debug + Field + Ord, const ADVICE_COLS: usize> Debug for LookupAnyManager<F, ADVICE_COLS>
Source§impl<F: Field + Ord, const ADVICE_COLS: usize> VirtualRegionManager<F> for LookupAnyManager<F, ADVICE_COLS>
impl<F: Field + Ord, const ADVICE_COLS: usize> VirtualRegionManager<F> for LookupAnyManager<F, ADVICE_COLS>
Source§type Config = Vec<[Column<Advice>; ADVICE_COLS]>
type Config = Vec<[Column<Advice>; ADVICE_COLS]>
Source§fn assign_raw(&self, config: &Self::Config, region: &mut Region<'_, F>)
fn assign_raw(&self, config: &Self::Config, region: &mut Region<'_, F>)
config
.Source§type Assignment = ()
type Assignment = ()
assign_raw
method. Default is ()
.Auto Trait Implementations§
impl<F, const ADVICE_COLS: usize> Freeze for LookupAnyManager<F, ADVICE_COLS>
impl<F, const ADVICE_COLS: usize> RefUnwindSafe for LookupAnyManager<F, ADVICE_COLS>
impl<F, const ADVICE_COLS: usize> Send for LookupAnyManager<F, ADVICE_COLS>
impl<F, const ADVICE_COLS: usize> Sync for LookupAnyManager<F, ADVICE_COLS>
impl<F, const ADVICE_COLS: usize> Unpin for LookupAnyManager<F, ADVICE_COLS>
impl<F, const ADVICE_COLS: usize> UnwindSafe for LookupAnyManager<F, ADVICE_COLS>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.