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_iterandexec_opsfunctions allow for executing the constraint and returning the resultingStack. - The
eval_bytecode,eval_bytecode_iterandeval_opsfunctions are similar to theirexec_*counterparts, but expect the top of theStackto contain a single boolean value indicating whether the constraint was satisfied (0forfalse,1fortrue) 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.
- Bytecode
Mapped - A memory efficient representation of a sequence of operations parsed from bytecode.
- Bytecode
Mapped Lazy - A type wrapper around
BytecodeMappedthat lazily constructs the map from the given bytecode as operations are accessed. - Bytecode
Mapped Slice - A slice into a
BytecodeMappedinstance. - Lazy
Cache - Lazily cache expensive to compute values.
- Memory
- Memory for temporary storage of words.
- Repeat
- A stack of repeat counters.
- Solution
Access - All necessary solution data access required to check an individual predicate.
- Stack
- The VM’s
Stack, i.e. aVecofWords updated during each step of execution. - State
Slots - The pre and post mutation state slot values for the predicate being solved.
Enums§
- Program
Control Flow - 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§
- Check
Result - Shorthand for a
Resultwhere the error type is aCheckError. - Constraint
Result - Shorthand for a
Resultwhere the error type is aConstraintError. - OpResult
- Shorthand for a
Resultwhere the error type is anOpError. - Stack
Result - Shorthand for a
Resultwhere the error type is aStackError. - State
Slot Slice - The state slots declared within the predicate.