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§
- deferral
- Streams-like deferral state
- 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.
- 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
AdapterCoreMetadataNOTE:ASis the adapter type that implementsAdapterTraceExecutorWARNING:AS::WIDTHis 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_READSbatch reads of sizeREAD_SIZEandNUM_WRITESbatch 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
MultiRowMetadatawithget_num_rowsalways 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.
- VecHeap
Adapter Interface - VecHeap
Branch Adapter Interface - Adapter interface for branch operations that read from heap via vec-style blocks.
Similar to
VecHeapAdapterInterfacebut without writes (branch operations only compare values). - 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
MEMand 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 index of the boundary AIR in the VM circuit.
- CONNECTOR_
AIR_ ID - DEFAULT_
BLOCK_ SIZE - Default block size for memory bus interactions. RISC-V byte/halfword loads (
lb/lh) need fewer bytes, but the adapter always reads a full 4-byte block from memory. - DEFAULT_
DEFERRAL_ ADDR_ SPACE_ CELLS - Max number of deferral address space cells
- DEFAULT_
MAX_ NUM_ PUBLIC_ VALUES - MEMORY_
AIRS_ START_ IDX - Starting AIR index of memory AIRs in the VM circuit.
- 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.
Traits§
- Adapter
Core Metadata Metadatatypes need to implement this trait to be used withAdapterCoreLayoutNOTE: get_adapter_width returns the size in bytes- Adapter
Trace Executor - A helper trait for expressing generic state accesses within the implementation of PreflightExecutor. 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 PreflightExecutor 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
Tto represent a memory cell in the address space. On host, the address space will be mapped to linear host memory in bytes. The typeTmust be plain old data (POD) and be safely transmutable from a fixed size array of bytes. Moreover, each typeTmust be convertible to a field elementF. - AnyAir
With Columns - AIR trait object combining [
AnyAir] (used by stark-backend for proving) with [ColumnsAir] (OpenVM-internal column-name introspection used by external tooling). The blanket impl below makes every type satisfying both traits also satisfy this one, so existing concrete AIRs need no changes. - AnyEnum
- A helper trait for downcasting types that may be enums.
- Arena
- Custom
Borrow - A trait that allows for custom implementation of
borrowgiven 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 Metadatatypes need to implement this trait to be used withMultiRowLayout- Record
Arena - Given some minimum layout of type
Layout, theRecordArenashould 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 SizedRecordis 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
VmConfigis 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
Efor [StarkEngine],RAfor record arena, andEXTfor 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 theCustomBorrowtrait to transmute to the desired record typeT. - vm_
poseidon2_ config - Returns a Poseidon2 config for the VM.
Type Aliases§
- AirRef
With Columns - Reference-counted dyn pointer to an AIR with column-name introspection.
- Empty
Adapter Core Layout - AdapterCoreLayout with empty metadata that can be used by chips that have record type
(&mut A, &mut C) where
AandCareSized - Empty
Multi RowLayout - Empty metadata that implements
MultiRowMetadata - Executor
Id
Attribute Macros§
- create_
handler - An attribute procedural macro for creating TCO (Tail Call Optimization) handlers.