pub struct ACVM<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> {Show 16 fields
status: ACVMStatus<F>,
backend: &'a B,
block_solvers: HashMap<BlockId, MemoryOpSolver<F>>,
opcodes: &'a [Opcode<F>],
instruction_pointer: usize,
witness_map: WitnessMap<F>,
brillig_solver: Option<BrilligSolver<'a, F, B>>,
acir_call_counter: usize,
acir_call_results: Vec<Vec<F>>,
unconstrained_functions: &'a [BrilligBytecode<F>],
assertion_payloads: &'a [(OpcodeLocation, AssertionPayload<F>)],
profiling_active: bool,
profiling_samples: ProfilingSamples,
brillig_fuzzing_active: bool,
brillig_branch_to_feature_map: Option<&'a BranchToFeatureMap>,
brillig_fuzzing_trace: Option<Vec<u32>>,
}
Fields§
§status: ACVMStatus<F>
§backend: &'a B
§block_solvers: HashMap<BlockId, MemoryOpSolver<F>>
Stores the solver for memory operations acting on blocks of memory disambiguated by block.
opcodes: &'a [Opcode<F>]
A list of opcodes which are to be executed by the ACVM.
instruction_pointer: usize
Index of the next opcode to be executed.
witness_map: WitnessMap<F>
A mapping of witnesses to their solved values The map is updated as the ACVM executes.
brillig_solver: Option<BrilligSolver<'a, F, B>>
§acir_call_counter: usize
A counter maintained throughout an ACVM process that determines whether the caller has resolved the results of an ACIR call.
acir_call_results: Vec<Vec<F>>
Represents the outputs of all ACIR calls during an ACVM process List is appended onto by the caller upon reaching a ACVMStatus::RequiresAcirCall
unconstrained_functions: &'a [BrilligBytecode<F>]
§assertion_payloads: &'a [(OpcodeLocation, AssertionPayload<F>)]
§profiling_active: bool
§profiling_samples: ProfilingSamples
§brillig_fuzzing_active: bool
§brillig_branch_to_feature_map: Option<&'a BranchToFeatureMap>
§brillig_fuzzing_trace: Option<Vec<u32>>
Implementations§
Source§impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B>
impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B>
pub fn new( backend: &'a B, opcodes: &'a [Opcode<F>], initial_witness: WitnessMap<F>, unconstrained_functions: &'a [BrilligBytecode<F>], assertion_payloads: &'a [(OpcodeLocation, AssertionPayload<F>)], ) -> Self
pub fn with_profiler(&mut self, profiling_active: bool)
pub fn with_brillig_fuzzing( &mut self, brillig_branch_to_feature_map: Option<&'a BranchToFeatureMap>, )
pub fn get_brillig_fuzzing_trace(&self) -> Option<Vec<u32>>
Sourcepub fn witness_map(&self) -> &WitnessMap<F>
pub fn witness_map(&self) -> &WitnessMap<F>
Returns a reference to the current state of the ACVM’s WitnessMap
.
Once execution has completed, the witness map can be extracted using ACVM::finalize
pub fn overwrite_witness(&mut self, witness: Witness, value: F) -> Option<F>
Sourcepub fn opcodes(&self) -> &[Opcode<F>]
pub fn opcodes(&self) -> &[Opcode<F>]
Returns a slice containing the opcodes of the circuit being executed.
Sourcepub fn instruction_pointer(&self) -> usize
pub fn instruction_pointer(&self) -> usize
Returns the index of the current opcode to be executed.
pub fn take_profiling_samples(&mut self) -> ProfilingSamples
Sourcepub fn finalize(self) -> WitnessMap<F>
pub fn finalize(self) -> WitnessMap<F>
Finalize the ACVM execution, returning the resulting WitnessMap
.
Sourcefn status(&mut self, status: ACVMStatus<F>) -> ACVMStatus<F>
fn status(&mut self, status: ACVMStatus<F>) -> ACVMStatus<F>
Updates the current status of the VM. Returns the given status.
pub fn get_status(&self) -> &ACVMStatus<F>
Sourcefn fail(&mut self, error: OpcodeResolutionError<F>) -> ACVMStatus<F>
fn fail(&mut self, error: OpcodeResolutionError<F>) -> ACVMStatus<F>
Sets the VM status to ACVMStatus::Failure using the provided error
.
Returns the new status.
Sourcefn wait_for_foreign_call(
&mut self,
foreign_call: ForeignCallWaitInfo<F>,
) -> ACVMStatus<F>
fn wait_for_foreign_call( &mut self, foreign_call: ForeignCallWaitInfo<F>, ) -> ACVMStatus<F>
Sets the status of the VM to RequiresForeignCall
.
Indicating that the VM is now waiting for a foreign call to be resolved.
Sourcepub fn get_pending_foreign_call(&self) -> Option<&ForeignCallWaitInfo<F>>
pub fn get_pending_foreign_call(&self) -> Option<&ForeignCallWaitInfo<F>>
Return a reference to the arguments for the next pending foreign call, if one exists.
Sourcepub fn resolve_pending_foreign_call(
&mut self,
foreign_call_result: ForeignCallResult<F>,
)
pub fn resolve_pending_foreign_call( &mut self, foreign_call_result: ForeignCallResult<F>, )
Resolves a foreign call’s result using a result calculated outside of the ACVM.
The ACVM can then be restarted to solve the remaining Brillig VM process as well as the remaining ACIR opcodes.
Sourcefn wait_for_acir_call(
&mut self,
acir_call: AcirCallWaitInfo<F>,
) -> ACVMStatus<F>
fn wait_for_acir_call( &mut self, acir_call: AcirCallWaitInfo<F>, ) -> ACVMStatus<F>
Sets the status of the VM to RequiresAcirCall
Indicating that the VM is now waiting for an ACIR call to be resolved
Sourcepub fn resolve_pending_acir_call(&mut self, call_result: Vec<F>)
pub fn resolve_pending_acir_call(&mut self, call_result: Vec<F>)
Resolves an ACIR call’s result (simply a list of fields) using a result calculated by a separate ACVM instance.
The current ACVM instance can then be restarted to solve the remaining ACIR opcodes.
Sourcepub fn solve(&mut self) -> ACVMStatus<F>
pub fn solve(&mut self) -> ACVMStatus<F>
Executes the ACVM’s circuit until execution halts.
Execution can halt due to three reasons:
- All opcodes have been executed successfully.
- The circuit has been found to be unsatisfiable.
- A Brillig foreign call has been encountered and must be resolved.
fn current_opcode(&self) -> &'a Opcode<F>
Sourcepub fn solve_opcode(&mut self) -> ACVMStatus<F>
pub fn solve_opcode(&mut self) -> ACVMStatus<F>
Executes a single opcode using the dedicated solver.
Foreign or ACIR Calls are deferred to the caller, which will either instantiate a new ACVM to execute the called ACIR function or a custom implementation to execute the foreign call. Then it will resume execution of the current ACVM with the results of the call.
Sourcefn handle_opcode_resolution(
&mut self,
resolution: Result<(), OpcodeResolutionError<F>>,
) -> ACVMStatus<F>
fn handle_opcode_resolution( &mut self, resolution: Result<(), OpcodeResolutionError<F>>, ) -> ACVMStatus<F>
Returns the status of the ACVM If the status is an error, it converts the error into OpcodeResolutionError
fn extract_assertion_payload( &self, location: OpcodeLocation, ) -> Option<ResolvedAssertionPayload<F>>
Sourcefn solve_brillig_call_opcode(
&mut self,
id: &BrilligFunctionId,
inputs: &'a [BrilligInputs<F>],
outputs: &[BrilligOutputs],
predicate: &Option<Expression<F>>,
) -> Result<Option<ForeignCallWaitInfo<F>>, OpcodeResolutionError<F>>
fn solve_brillig_call_opcode( &mut self, id: &BrilligFunctionId, inputs: &'a [BrilligInputs<F>], outputs: &[BrilligOutputs], predicate: &Option<Expression<F>>, ) -> Result<Option<ForeignCallWaitInfo<F>>, OpcodeResolutionError<F>>
Solves a Brillig Call opcode, which represents a call to an unconstrained function. It first handles the predicate and returns zero values if the predicate is false. Then it executes (or resumes execution) the Brillig function using a Brillig VM.
pub fn step_into_brillig(&mut self) -> StepResult<'a, F, B>
pub fn finish_brillig_with_solver( &mut self, solver: BrilligSolver<'a, F, B>, ) -> ACVMStatus<F>
Sourcepub fn solve_call_opcode(
&mut self,
id: &AcirFunctionId,
inputs: &[Witness],
outputs: &[Witness],
predicate: &Option<Expression<F>>,
) -> Result<Option<AcirCallWaitInfo<F>>, OpcodeResolutionError<F>>
pub fn solve_call_opcode( &mut self, id: &AcirFunctionId, inputs: &[Witness], outputs: &[Witness], predicate: &Option<Expression<F>>, ) -> Result<Option<AcirCallWaitInfo<F>>, OpcodeResolutionError<F>>
Defer execution of the ACIR call opcode to the caller, or finalize the execution.
- It first handles the predicate and return zero values if the predicate is false.
- If the results of the execution are not available, it issues a ‘AcirCallWaitInfo’ to notify the caller that it (the caller) needs to execute the ACIR function.
- If the results are available, it updates the witness map and indicates that the opcode is solved.
Auto Trait Implementations§
impl<'a, F, B> Freeze for ACVM<'a, F, B>where
F: Freeze,
impl<'a, F, B> RefUnwindSafe for ACVM<'a, F, B>where
B: RefUnwindSafe,
F: RefUnwindSafe,
impl<'a, F, B> Send for ACVM<'a, F, B>
impl<'a, F, B> Sync for ACVM<'a, F, B>
impl<'a, F, B> Unpin for ACVM<'a, F, B>where
F: Unpin,
impl<'a, F, B> UnwindSafe for ACVM<'a, 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