pub struct BrilligSolver<'b, F, B: BlackBoxFunctionSolver<F>> {
vm: VM<'b, F, B>,
acir_index: usize,
pub function_id: BrilligFunctionId,
}
Expand description
Specific solver for Brillig opcodes It maintains a Brillig VM that can execute the bytecode of the called brillig function
Fields§
§vm: VM<'b, F, B>
§acir_index: usize
§function_id: BrilligFunctionId
This id references which Brillig function within the main ACIR program we are solving. This is used for appropriately resolving errors as the ACIR program artifacts set up their Brillig debug metadata by function id.
Implementations§
Source§impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B>
impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B>
Sourcepub(super) fn zero_out_brillig_outputs(
initial_witness: &mut WitnessMap<F>,
outputs: &[BrilligOutputs],
) -> Result<(), OpcodeResolutionError<F>>
pub(super) fn zero_out_brillig_outputs( initial_witness: &mut WitnessMap<F>, outputs: &[BrilligOutputs], ) -> Result<(), OpcodeResolutionError<F>>
Assigns the zero value to all outputs of a given brillig call.
Sourcepub(crate) fn new_call(
initial_witness: &WitnessMap<F>,
memory: &HashMap<BlockId, MemoryOpSolver<F>>,
inputs: &'b [BrilligInputs<F>],
brillig_bytecode: &'b [BrilligOpcode<F>],
bb_solver: &'b B,
acir_index: usize,
brillig_function_id: BrilligFunctionId,
profiling_active: bool,
with_branch_to_feature_map: Option<&BranchToFeatureMap>,
) -> Result<Self, OpcodeResolutionError<F>>
pub(crate) fn new_call( initial_witness: &WitnessMap<F>, memory: &HashMap<BlockId, MemoryOpSolver<F>>, inputs: &'b [BrilligInputs<F>], brillig_bytecode: &'b [BrilligOpcode<F>], bb_solver: &'b B, acir_index: usize, brillig_function_id: BrilligFunctionId, profiling_active: bool, with_branch_to_feature_map: Option<&BranchToFeatureMap>, ) -> Result<Self, OpcodeResolutionError<F>>
Constructs a solver for a Brillig block given the bytecode and initial witness.
Sourcefn setup_brillig_vm(
initial_witness: &WitnessMap<F>,
memory: &HashMap<BlockId, MemoryOpSolver<F>>,
inputs: &[BrilligInputs<F>],
brillig_bytecode: &'b [BrilligOpcode<F>],
bb_solver: &'b B,
profiling_active: bool,
with_branch_to_feature_map: Option<&BranchToFeatureMap>,
) -> Result<VM<'b, F, B>, OpcodeResolutionError<F>>
fn setup_brillig_vm( initial_witness: &WitnessMap<F>, memory: &HashMap<BlockId, MemoryOpSolver<F>>, inputs: &[BrilligInputs<F>], brillig_bytecode: &'b [BrilligOpcode<F>], bb_solver: &'b B, profiling_active: bool, with_branch_to_feature_map: Option<&BranchToFeatureMap>, ) -> Result<VM<'b, F, B>, OpcodeResolutionError<F>>
Get a BrilligVM for executing the provided bytecode
- Reduce the input expressions into a known value, or error if they do not reduce to a value.
- Instantiate the Brillig VM with the bytecode and the reduced inputs.
pub fn get_memory(&self) -> &[MemoryValue<F>]
pub fn write_memory_at(&mut self, ptr: usize, value: MemoryValue<F>)
pub fn get_call_stack(&self) -> Vec<usize>
pub fn get_fuzzing_trace(&self) -> Vec<u32>
pub(crate) fn solve( &mut self, ) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>>
pub fn step( &mut self, ) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>>
pub fn program_counter(&self) -> usize
Sourcefn handle_vm_status(
&self,
vm_status: VMStatus<F>,
) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>>
fn handle_vm_status( &self, vm_status: VMStatus<F>, ) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>>
Returns the status of the Brillig VM as a ‘BrilligSolverStatus’ resolution. It may be finished, in-progress, failed, or may be waiting for results of a foreign call. Return the “resolution” to the caller who may choose to make subsequent calls (when it gets foreign call results for example).
pub(crate) fn finalize( self, witness: &mut WitnessMap<F>, outputs: &[BrilligOutputs], ) -> Result<(), OpcodeResolutionError<F>>
Sourcepub(crate) fn finalize_with_profiling(
self,
witness: &mut WitnessMap<F>,
outputs: &[BrilligOutputs],
) -> Result<BrilligProfilingSamples, OpcodeResolutionError<F>>
pub(crate) fn finalize_with_profiling( self, witness: &mut WitnessMap<F>, outputs: &[BrilligOutputs], ) -> Result<BrilligProfilingSamples, OpcodeResolutionError<F>>
Finalize the VM and return the profiling samples.
Sourcefn finalize_inner(
&self,
witness: &mut WitnessMap<F>,
outputs: &[BrilligOutputs],
) -> Result<(), OpcodeResolutionError<F>>
fn finalize_inner( &self, witness: &mut WitnessMap<F>, outputs: &[BrilligOutputs], ) -> Result<(), OpcodeResolutionError<F>>
Finalize the VM execution and write the outputs to the provided witness map.
Sourcefn write_brillig_outputs(
&self,
witness_map: &mut WitnessMap<F>,
return_data_offset: usize,
return_data_size: usize,
outputs: &[BrilligOutputs],
) -> Result<(), OpcodeResolutionError<F>>
fn write_brillig_outputs( &self, witness_map: &mut WitnessMap<F>, return_data_offset: usize, return_data_size: usize, outputs: &[BrilligOutputs], ) -> Result<(), OpcodeResolutionError<F>>
Write VM execution results into the witness map
pub fn resolve_pending_foreign_call( &mut self, foreign_call_result: ForeignCallResult<F>, )
Auto Trait Implementations§
impl<'b, F, B> Freeze for BrilligSolver<'b, F, B>
impl<'b, F, B> RefUnwindSafe for BrilligSolver<'b, F, B>where
B: RefUnwindSafe,
F: RefUnwindSafe,
impl<'b, F, B> Send for BrilligSolver<'b, F, B>
impl<'b, F, B> Sync for BrilligSolver<'b, F, B>
impl<'b, F, B> Unpin for BrilligSolver<'b, F, B>where
F: Unpin,
impl<'b, F, B> UnwindSafe for BrilligSolver<'b, F, B>
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