Crate essential_constraint_vm

Source
Expand description

The essential constraint checking implementation.

§Checking Predicates

The primary entrypoint for this crate is the check_predicate function which allows for checking a contract of constraints associated with a single predicate against some provided solution data and state slot mutations in parallel.

§Checking Individual Constraints

Functions are also exposed for checking constraints individually.

  • The exec_bytecode, exec_bytecode_iter and exec_ops functions allow for executing the constraint and returning the resulting Stack.
  • The eval_bytecode, eval_bytecode_iter and eval_ops functions are similar to their exec_* counterparts, but expect the top of the Stack to contain a single boolean value indicating whether the constraint was satisfied (0 for false, 1 for true) and returns this value.

§Performing a Single Operation

The step_op function (and related step_op_* functions) are exposed to allow for applying a single operation to the given stack. This can be useful in the case of integrating constraint operations in a downstream VM (e.g. the essential state read VM).

§Understanding the Assembly

The essential-constraint-asm crate is re-exported as the asm module. See this module’s documentation for information about the expected behaviour of individual operations.

Re-exports§

pub use essential_types as types;

Modules§

asm
Assembly for checking constraints.
error
The types of errors that might occur throughout constraint checking.

Structs§

Access
All necessary solution data and state access required to check an individual predicate.
BytecodeMapped
A memory efficient representation of a sequence of operations parsed from bytecode.
BytecodeMappedLazy
A type wrapper around BytecodeMapped that lazily constructs the map from the given bytecode as operations are accessed.
BytecodeMappedSlice
A slice into a BytecodeMapped instance.
LazyCache
Lazily cache expensive to compute values.
Memory
Memory for temporary storage of words.
Repeat
A stack of repeat counters.
SolutionAccess
All necessary solution data access required to check an individual predicate.
Stack
The VM’s Stack, i.e. a Vec of Words updated during each step of execution.
StateSlots
The pre and post mutation state slot values for the predicate being solved.

Enums§

ProgramControlFlow
Update the program to a new position or halt it.

Traits§

OpAccess
Types that provide access to operations.

Functions§

check_predicate
Check whether the constraints of a single predicate are met for the given solution data and state slot mutations. All constraints are checked in parallel.
eval
Evaluate the operations of a single constraint and return its boolean result.
eval_bytecode
Evaluate the bytecode of a single constraint and return its boolean result.
eval_bytecode_iter
Evaluate the bytecode of a single constraint and return its boolean result.
eval_ops
Evaluate the operations of a single constraint and return its boolean result.
exec
Execute the operations of a constraint and return the resulting stack.
exec_bytecode
Execute the bytecode of a constraint and return the resulting stack.
exec_bytecode_iter
Execute the bytecode of a constraint and return the resulting stack.
exec_ops
Execute the operations of a constraint and return the resulting stack.
mut_keys
A helper for collecting all mutable keys that are proposed for mutation for the predicate at the given index.
mut_keys_set
Get the contract of mutable keys for this predicate.
mut_keys_slices
Get the mutable keys as slices
step_on_temporary
Step forward constraint checking by the given temporary operation.
step_on_total_control_flow
Step forward constraint checking by the given total control flow operation.
step_op
Step forward constraint checking by the given operation.
step_op_access
Step forward constraint checking by the given access operation.
step_op_alu
Step forward constraint checking by the given ALU operation.
step_op_crypto
Step forward constraint checking by the given crypto operation.
step_op_pred
Step forward constraint checking by the given predicate operation.
step_op_stack
Step forward constraint checking by the given stack operation.

Type Aliases§

CheckResult
Shorthand for a Result where the error type is a CheckError.
ConstraintResult
Shorthand for a Result where the error type is a ConstraintError.
OpResult
Shorthand for a Result where the error type is an OpError.
StackResult
Shorthand for a Result where the error type is a StackError.
StateSlotSlice
The state slots declared within the predicate.