SummaryDefault 200K CUs per instruction, 1.4M max per transaction. Use
SetComputeUnitLimit and SetComputeUnitPrice instructions to optimize.
Priority fee is based on requested CUs, not actual usage.ComputeBudget instructions do not apply to v1 transactionsThis page describes legacy and v0 transactions. In the v1
format,
ComputeBudget instructions are ignored for configuration (they execute as
no-ops that still cost 150 CUs and an instruction slot) — the limits and
priority fee are set directly in the message config, and unset limits default
to zero, not the values below.
Compute unit limit
Each instruction is allocated a default of 200,000 CUs, and each transaction is capped at 1,400,000 CUs. When no explicitSetComputeUnitLimit instruction is present, the
default is calculated
based on instruction type:
Default CU limit calculation
- Builtin instructions (System Program, Vote, Compute Budget, and other
builtins that have not been migrated to SBF): each allocated
MAX_BUILTIN_ALLOCATION_COMPUTE_UNIT_LIMIT= 3,000 CUs (per SIMD-0170). - Non-builtin instructions (user-deployed SBF programs): each allocated
DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT= 200,000 CUs. - Migrating builtins that have completed migration to SBF (feature-gated): treated as non-builtin (200,000 CUs each). Stake, Config, and Address Lookup Table are now Core BPF programs owned by loader-v3, so their instructions get the 200,000 CU default.
MAX_COMPUTE_UNIT_LIMIT (1,400,000).
You can override this default by including a
SetComputeUnitLimit
instruction in your transaction.
To determine the appropriate CU limit:
- Simulate the transaction to measure CU consumption.
- Add a 10% safety margin to the simulated value.
The priority fee is determined by the requested compute unit limit on the
transaction, not the actual number of compute units used. If you set a
compute unit limit that is too high or use the default amount, you pay for
unused compute units.
Compute budget instructions
The Compute Budget Program (ComputeBudget111111111111111111111111111111) has four instructions.
| Variant | Discriminator | Parameter | Type | Description |
|---|---|---|---|---|
RequestHeapFrame | 1 | bytes | u32 | Requested heap size in bytes for each program in the transaction |
SetComputeUnitLimit | 2 | units | u32 | Max CUs the transaction may consume |
SetComputeUnitPrice | 3 | micro_lamports | u64 | CU price in micro-lamports |
SetLoadedAccountsDataSizeLimit | 4 | bytes | u32 | Max total bytes of account data the transaction may load |
ComputeBudgetInstruction enum
Constraints and error conditions
The following rules apply when processing compute budget instructions:- One per type: only one of each instruction variant is allowed per
transaction. Including duplicates causes a
DuplicateInstructionerror (the entire transaction fails). RequestHeapFrame: the value must be betweenMIN_HEAP_FRAME_BYTES(32 KiB) andMAX_HEAP_FRAME_BYTES(256 KiB), and must be a multiple of 1,024. Otherwise the transaction fails withInvalidInstructionData. The heap size applies to every program invoked in the transaction (including CPIs).SetComputeUnitLimit: anyu32value is accepted. The effective limit is clamped toMAX_COMPUTE_UNIT_LIMIT(1,400,000).SetComputeUnitPrice: anyu64value is accepted (0 tou64::MAX).SetLoadedAccountsDataSizeLimit: the value must be greater than 0 (NonZeroU32). A value of 0 causesInvalidLoadedAccountsDataSizeLimit. The effective limit is clamped toMAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES(64 MiB).- Unrecognized data: any instruction sent to the Compute Budget Program that
does not deserialize to a known variant fails with
InvalidInstructionData.
The scheduler cost model below describes validator-internal pre-execution cost
estimation. Most developers only need the compute budget instructions above.
Scheduler cost model
The validator’s scheduler uses a cost model to estimate transaction resource usage before execution. These pre-execution cost estimates determine whether a transaction fits within the block’s remaining capacity. They are separate from the CU metering that happens during execution. The total scheduler cost is the sum of five components (UsageCostDetails::sum):
Scheduler cost formula
Cost components
| Component | Description |
|---|---|
| Signature cost | Per-signature cost for each signature type |
| Write lock cost | Per writable account |
| Instruction data cost | Based on total instruction data bytes |
| Programs execution cost | CU limit from compute budget or default |
| Loaded accounts data cost | Based on total loaded account data size |
Scheduler cost constants
| Constant | Value |
|---|---|
COMPUTE_UNIT_TO_US_RATIO | 30 |
SIGNATURE_COST | 720 CUs |
SECP256K1_VERIFY_COST | 6,690 CUs |
ED25519_VERIFY_COST | 2,280 CUs |
ED25519_VERIFY_STRICT_COST | 2,400 CUs |
SECP256R1_VERIFY_COST | 4,800 CUs |
WRITE_LOCK_UNITS | 300 CUs |
INSTRUCTION_DATA_BYTES_COST | 4 |
Block limits
The scheduler enforces per-block limits. If adding a transaction would exceed any limit, it is not included in the block. Block limits scale with slot time (SIMD-0525). Mainnet runs 200ms slots with SIMD-0286 active, so the limits are:| Limit | Value |
|---|---|
| Compute units per block | 50,000,000 |
| Compute units per writable account per block | 20,000,000 |
| Accounts data size growth per block | 50 MB |
Execution budget constants
The following constants fromexecution_budget.rs
define runtime limits during transaction execution:
| Constant | Value | Description |
|---|---|---|
MAX_COMPUTE_UNIT_LIMIT | 1,400,000 | Maximum CU limit per transaction |
DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT | 200,000 | Default CUs per non-builtin instruction |
MAX_BUILTIN_ALLOCATION_COMPUTE_UNIT_LIMIT | 3,000 | Default CUs per builtin instruction (SIMD-0170) |
DEFAULT_HEAP_COST | 8 CUs | Cost per 32 KiB heap page |
INVOKE_UNITS_COST_SIMD_0339 | 946 CUs | Cost of one CPI invocation (SIMD-0339 is active on Mainnet, Devnet, and Testnet) |
DEFAULT_INVOCATION_COST | 1,000 CUs | CPI invocation cost before SIMD-0339 |
MIN_HEAP_FRAME_BYTES | 32,768 | Minimum heap size (32 KiB) |
MAX_HEAP_FRAME_BYTES | 262,144 | Maximum heap size (256 KiB) |
MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES | 67,108,864 | Maximum loaded account data per transaction (64 MiB) |
MAX_INSTRUCTION_STACK_DEPTH | 5 | Maximum instruction stack depth (top-level + CPIs) |
MAX_INSTRUCTION_STACK_DEPTH_SIMD_0268 | 9 | Maximum instruction stack depth (top-level + CPIs) with SIMD-0268 |
MAX_CALL_DEPTH | 64 | Maximum SBF-to-SBF call depth within a program |
STACK_FRAME_SIZE | 4,096 bytes | Size of one SBF stack frame |