Summary
Default 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.
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 explicit SetComputeUnitLimit instruction is present, the
default is calculated
based on instruction type:
default_cu_limit = (num_non_migratable_builtin_instructions * 3,000)+ (num_not_migrated_builtin_instructions * 3,000)+ (num_non_builtin_instructions * 200,000)+ (num_migrated_builtin_instructions * 200,000)
- Builtin instructions (System Program, Stake, Vote, etc. 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).
The result is clamped to 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 |
Source: 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):
total_cost = signature_cost+ write_lock_cost+ data_bytes_cost+ programs_execution_cost+ loaded_accounts_data_size_cost
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 |
All values are in compute units.
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 |
Vote transaction cost
Vote transactions use a static cost of 3,428 CUs regardless of their actual content.
Block limits
The scheduler enforces per-block limits. If adding a transaction would exceed any limit, it is not included in the block.
| Limit | Value |
|---|---|
MAX_BLOCK_UNITS | 60,000,000 |
MAX_WRITABLE_ACCOUNT_UNITS | 12,000,000 |
MAX_VOTE_UNITS | 36,000,000 |
MAX_BLOCK_ACCOUNTS_DATA_SIZE_DELTA | 100 MB |
SIMD-0286
proposes increasing MAX_BLOCK_UNITS to 100,000,000.
Execution budget constants
The following constants from
execution_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 |
DEFAULT_INVOCATION_COST | 1,000 CUs | Cost of one CPI invocation |
INVOKE_UNITS_COST_SIMD_0339 | 946 CUs | CPI invocation cost with 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 |
Is this page helpful?