pub(crate) struct MemoryOpSolver<F> {
pub(super) block_value: Vec<F>,
}
Expand description
Maintains the state for solving MemoryInit
and MemoryOp
opcodes.
Fields§
§block_value: Vec<F>
Known values of the memory block, based on the index This vec starts as big as it needs to, when initialized, then evolves as we process the opcodes.
Implementations§
Source§impl<F: AcirField> MemoryOpSolver<F>
impl<F: AcirField> MemoryOpSolver<F>
Sourcepub(crate) fn new(
init: &[Witness],
initial_witness: &WitnessMap<F>,
) -> Result<Self, OpcodeResolutionError<F>>
pub(crate) fn new( init: &[Witness], initial_witness: &WitnessMap<F>, ) -> Result<Self, OpcodeResolutionError<F>>
Creates a new MemoryOpSolver with the values given in init
.
fn len(&self) -> u32
Sourcefn index_from_field(&self, index: F) -> Result<u32, OpcodeResolutionError<F>>
fn index_from_field(&self, index: F) -> Result<u32, OpcodeResolutionError<F>>
Convert a field element into a memory index Only 32 bits values are valid memory indices
Sourcefn write_memory_index(
&mut self,
index: u32,
value: F,
) -> Result<(), OpcodeResolutionError<F>>
fn write_memory_index( &mut self, index: u32, value: F, ) -> Result<(), OpcodeResolutionError<F>>
Update the ‘block_value’ map with the provided index/value Returns an ‘IndexOutOfBounds’ error if the index is outside the block range.
Sourcefn read_memory_index(&self, index: u32) -> Result<F, OpcodeResolutionError<F>>
fn read_memory_index(&self, index: u32) -> Result<F, OpcodeResolutionError<F>>
Returns the value stored in the ‘block_value’ map for the provided index Returns an ‘IndexOutOfBounds’ error if the index is not in the map.
Sourcepub(crate) fn solve_memory_op(
&mut self,
op: &MemOp<F>,
initial_witness: &mut WitnessMap<F>,
pedantic_solving: bool,
) -> Result<(), OpcodeResolutionError<F>>
pub(crate) fn solve_memory_op( &mut self, op: &MemOp<F>, initial_witness: &mut WitnessMap<F>, pedantic_solving: bool, ) -> Result<(), OpcodeResolutionError<F>>
Update the ‘block_values’ by processing the provided Memory opcode The opcode ‘op’ contains the index and value of the operation and the type of the operation. They are all stored as an acir::native_types::Expression The type of ‘operation’ is ‘0’ for a read and ‘1’ for a write. It must be a constant expression. Index is not required to be constant but it must reduce to a known value for processing the opcode. This is done by doing the (partial) evaluation of its expression, using the provided witness map.
READ: read the block at index op.index and update op.value with the read value
- ‘op.value’ must reduce to a witness (after the evaluation of its expression)
- the value is updated in the provided witness map, for the ‘op.value’ witness
WRITE: update the block at index ‘op.index’ with ‘op.value’
- ‘op.value’ must reduce to a known value
If a requirement is not met, it returns an error.
Auto Trait Implementations§
impl<F> Freeze for MemoryOpSolver<F>
impl<F> RefUnwindSafe for MemoryOpSolver<F>where
F: RefUnwindSafe,
impl<F> Send for MemoryOpSolver<F>where
F: Send,
impl<F> Sync for MemoryOpSolver<F>where
F: Sync,
impl<F> Unpin for MemoryOpSolver<F>where
F: Unpin,
impl<F> UnwindSafe for MemoryOpSolver<F>where
F: UnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more