Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Runtime Limits

This page summarises the fixed and configurable limits of the XQVM runtime.

Fixed Limits

LimitValueError
Stack depth8,192 itemsStackOverflow
Register count256 slots (r0–r255)– (statically allocated)
Jump label range0–65,535 (u16)InvalidLabel
Shift amount0–63 bitsInvalidShift
Grid dimensionsMust be > 0InvalidGridDimensions

Configurable Limits

LimitDefaultMethodError
Step count10,000,000Vm::set_step_limit(n)StepLimitExceeded
Calldata slots0Vm::set_calldata(vec)CallDataIndex
Output slots0Vm::set_output_slots(n)OutputIndex

Setting the step limit to 0 sets it to u64::MAX (effectively unlimited).

Pallet Limits

When running in the Substrate pallet, additional limits apply:

LimitConfigurationPurpose
Program sizeMaxProgramSizeMaximum bytecode bytes.
Calldata entriesMaxCallDataLenMaximum input integers.
Output slotsMaxOutputSlotsMaximum output slots.
Step limitMaxStepLimitCap on per-execution steps.

Error Types

All runtime errors include the byte offset (pos) of the faulting instruction for precise diagnostics. The full error enum is defined in crates/vm/src/error.rs.

ErrorCause
StackUnderflowPopping from an empty or too-shallow stack.
StackOverflowPushing when stack is at 8,192 items.
RegisterTypeInstruction expects a different RegVal variant.
DivisionByZeroDIV or MOD with divisor 0.
IndexOutOfBoundsVec access with invalid index.
NoActiveLoopNEXT or LVAL with no loop frame.
InvalidLabelJump to a non-existent label.
BadJumpTargetJump target is not a TARGET instruction.
BadOpcodeUnknown opcode byte.
TruncatedInstructionBytecode ends mid-instruction.
CallDataIndexINPUT index out of range.
OutputIndexOUTPUT index out of range.
SizeMismatchENERGY sample length ≠ model size.
StepLimitExceededExecution exceeded configured limit.
InvalidGridDimensionsRESIZE with rows or cols ≤ 0.
InvalidShiftSHL/SHR shift amount outside [0, 64).
InvalidDiscreteKXQMX/XSMX called with k < 2 (the signed [-k, k-1] domain requires at least two values).