Struct BrilligSolver

Source
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>

Source

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][acir::circuit::opcodes::Opcode::BrilligCall].

Source

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.

Source

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

  1. Reduce the input expressions into a known value, or error if they do not reduce to a value.
  2. Instantiate the Brillig VM with the bytecode and the reduced inputs.
Source

pub fn get_memory(&self) -> &[MemoryValue<F>]

Source

pub fn write_memory_at(&mut self, ptr: u32, value: MemoryValue<F>)

Source

pub fn get_call_stack(&self) -> Vec<usize>

Source

pub fn get_fuzzing_trace(&self) -> Vec<u32>

Source

pub(crate) fn solve( &mut self, ) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>>

Source

pub fn step( &mut self, ) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>>

Source

pub fn program_counter(&self) -> usize

Source

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).

Source

pub(crate) fn finalize( self, witness: &mut WitnessMap<F>, outputs: &[BrilligOutputs], ) -> Result<(), OpcodeResolutionError<F>>

Source

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.

Source

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.

Source

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

Source

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>

§

impl<'b, F, B> Send for BrilligSolver<'b, F, B>
where B: Sync, F: Send + Sync,

§

impl<'b, F, B> Sync for BrilligSolver<'b, F, B>
where B: Sync, F: Sync,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more