Expand description
Traits and constructs for the OpenVM architecture.
Re-exports§
pub use execution_mode::ExecutionCtxTrait;
pub use execution_mode::MeteredExecutionCtxTrait;
pub use interpreter::InterpretedInstance;
pub use openvm_instructions as instructions;
pub use execution::*;
pub use vm::*;
Modules§
- execution
- Instruction execution traits and types. Execution bus and interface.
- execution_
mode - Execution context types for different execution modes.
- hasher
- interpreter
- Interpreter for pure and metered VM execution
- interpreter_
preflight - Interpreter for preflight VM execution, for trace generation purposes.
- testing
- Testing framework
- vm
- Top level VmExecutor and VirtualMachine constructor and API. VmExecutor is the struct that can execute an arbitrary program, provided in the form of a [VmExe], for a fixed set of OpenVM instructions corresponding to a VmExecutionConfig. Internally once it is given a program, it will preprocess the program to rewrite it into a more optimized format for runtime execution. This instance of the executor will be a separate struct specialized to running a fixed program on different program inputs.
Structs§
- Adapter
AirContext - Adapter
Core Empty Metadata - Empty metadata that implements
AdapterCoreMetadata
NOTE:AS
is the adapter type that implementsAdapterTraceExecutor
WARNING:AS::WIDTH
is the number of field elements, not the size in bytes - Adapter
Core Layout - Minimal layout information that RecordArena requires for record allocation in scenarios involving chips that:
- Address
Space Host Config - AirInventory
- Basic
Adapter Interface - The most common adapter interface.
Performs
NUM_READS
batch reads of sizeREAD_SIZE
andNUM_WRITES
batch writes of sizeWRITE_SIZE
. - BusIndex
Manager - Chip
Inventory - Dense
Record Arena - DynAdapter
Interface - An interface that is fully determined during runtime. This should only be used as a last resort when static compile-time guarantees cannot be made.
- DynArray
- Newtype to implement
From
. - Empty
Multi RowMetadata - Empty metadata that implements
MultiRowMetadata
withget_num_rows
always returning 1 - Executor
Inventory - Executor
Inventory Builder - Flat
Interface - Similar to
BasicAdapterInterface
, but it flattens the reads and writes into a single flat array for each - ImmInstruction
- Matrix
Record Arena - Memory
Config - Minimal
Instruction - Multi
RowLayout - Minimal layout information that RecordArena requires for record allocation in scenarios involving chips that:
- Record
Seeker - Signed
ImmInstruction - System
Config - System-level configuration for the virtual machine. Contains all configuration parameters that are managed by the architecture, including configuration for continuations support.
- VecHeap
Adapter Interface - VmAir
Wrapper - VmChip
Complex - The collection of all chips in the VM. The chips should correspond 1-to-1 with the associated AirInventory. The VmChipComplex coordinates the trace generation for all chips in the VM after construction.
- VmChip
Wrapper - We want a blanket implementation of
Chip<MatrixRecordArena, CpuBackend>
on any struct that implements TraceFiller but due to Rust orphan rules, we need a wrapper struct. - VmExec
State - Represents the full execution state of a VM during execution.
The global state is generic in guest memory
MEM
and additional contextCTX
. The host state is execution context specific. - VmState
- Represents the core state of a VM.
Enums§
Constants§
- ADDR_
SPACE_ OFFSET - Offset for address space indices. This is used to distinguish between different memory spaces.
- BOUNDARY_
AIR_ ID - AIR ID of the Memory Boundary AIR.
- CONNECTOR_
AIR_ ID - DEFAULT_
MAX_ NUM_ PUBLIC_ VALUES - MERKLE_
AIR_ ID - If VM has continuations enabled, all AIRs of MemoryController are added after ConnectorChip. Merkle AIR commits start/final memory states.
- OPENVM_
DEFAULT_ INIT_ FILE_ BASENAME - OPENVM_
DEFAULT_ INIT_ FILE_ NAME - POSEIDO
N2_ WIDTH - Width of Poseidon2 VM uses.
- PROGRAM_
AIR_ ID - Global AIR ID in the VM circuit verifying key.
- PROGRAM_
CACHED_ TRACE_ INDEX - ProgramAir is the first AIR so its cached trace should be the first main trace.
- PUBLIC_
VALUES_ AIR_ ID - If PublicValuesAir is enabled, its AIR ID is 2. PublicValuesAir is always disabled when continuations is enabled.
Traits§
- Adapter
Core Metadata Metadata
types need to implement this trait to be used withAdapterCoreLayout
NOTE: get_adapter_width returns the size in bytes- Adapter
Trace Executor - A helper trait for expressing generic state accesses within the implementation of [TraceExecutor]. Note that this is only a helper trait when the same interface of state access is reused or shared by multiple implementations. It is not required to implement this trait if it is easier to implement the [TraceExecutor] trait directly without this trait.
- Adapter
Trace Filler - Address
Space Host Layout - Each address space in guest memory may be configured with a different type
T
to represent a memory cell in the address space. On host, the address space will be mapped to linear host memory in bytes. The typeT
must be plain old data (POD) and be safely transmutable from a fixed size array of bytes. Moreover, each typeT
must be convertible to a field elementF
. - AnyEnum
- A helper trait for downcasting types that may be enums.
- Arena
- Custom
Borrow - A trait that allows for custom implementation of
borrow
given the necessary information This is useful for record structs that have dynamic size - Init
File Generator - Trait for generating a init.rs file that contains a call to moduli_init!, complex_init!, sw_init! with the supported moduli and curves. Should be implemented by all VM config structs.
- Multi
RowMetadata Metadata
types need to implement this trait to be used withMultiRowLayout
- Record
Arena - Given some minimum layout of type
Layout
, theRecordArena
should allocate a buffer, of size possibly larger than the record, and then return mutable pointers to the record within the buffer. - RowMajor
Matrix Arena - Helper trait for arenas backed by row-major matrices.
- Sized
Record SizedRecord
is a trait that provides additional information about the size and alignment requirements of a record. Should be implemented on RecordMut types- Trace
Filler - Helper trait for CPU tracegen.
- VmAdapter
Air - VmAdapter
Interface - The interface between primitive AIR and machine adapter AIR.
- VmBuilder
- This trait is intended to be implemented on a new type wrapper of the VmConfig struct to get around Rust orphan rules.
- VmCircuit
Config - VmCircuit
Extension - Extension of the VM circuit. Allows in-order addition of new AIRs with interactions.
- VmConfig
- A VM configuration is the minimum serializable format to be able to create the execution
environment and circuit for a zkVM supporting a fixed set of instructions.
This trait contains the sub-traits VmExecutionConfig and VmCircuitConfig.
The InitFileGenerator sub-trait provides custom build hooks to generate code for initializing
some VM extensions. The
VmConfig
is expected to contain the SystemConfig internally. - VmCore
Air - VmExecution
Config - VmExecution
Extension - Extension of VM execution. Allows registration of custom execution of new instructions by opcode.
- VmProver
Extension - Extension of VM trace generation. The generics are
E
for StarkEngine,RA
for record arena, andEXT
for execution and circuit extension.
Functions§
- get_
record_ ⚠from_ slice - Converts a field element slice into a record type.
This function transmutes the
&mut [F]
to raw bytes, then uses theCustomBorrow
trait to transmute to the desired record typeT
. - vm_
poseidon2_ config - Returns a Poseidon2 config for the VM.
Type Aliases§
- Empty
Adapter Core Layout - AdapterCoreLayout with empty metadata that can be used by chips that have record type
(&mut A, &mut C) where
A
andC
areSized
- Empty
Multi RowLayout - Empty metadata that implements
MultiRowMetadata
- Executor
Id
Attribute Macros§
- create_
tco_ handler - An attribute procedural macro for creating TCO (Tail Call Optimization) handlers.