RPC error InstructionError: Computational budget exceeded
Last updated:
At a glance
| Property | Value |
|---|---|
| Applies to | Solana JSON-RPC |
| Display strings | Computational budget exceeded; exceeded CUs meter at BPF instruction |
| Default limit | 200,000 per non-builtin instruction, 3,000 per builtin |
| Maximum | 1,400,000 per transaction |
| Set with | ComputeBudget SetComputeUnitLimit |
| Fee charged | Yes, if it failed on chain |
Cause
Every transaction has a compute unit limit. Without an explicit instruction the default is 200,000 per non-builtin instruction and 3,000 per builtin, up to a maximum of 1,400,000. The VM reports the moment it runs out as exceeded CUs meter at BPF instruction, and the runtime reports the result as Computational budget exceeded. Both are the same event. A limit that was fine yesterday can fail today if the path through a program changes, for example a swap routed through more pools.
Solution
- Find the instruction in the logs: the last
Program ... invokebefore the failure names the program that ran out. - Run a simulation and read
unitsConsumed. - Add a
SetComputeUnitLimitinstruction with that number plus a margin of about 10%. - Do not set the limit far above what you use: your priority fee is the price multiplied by the limit you request, not by what you consume.
Example
{
"err": {
"InstructionError": [
1,
"ComputationalBudgetExceeded"
]
},
"logs": [
"Program ... failed: exceeded CUs meter at BPF instruction"
]
}FAQ
- Why not always request 1,400,000 compute units?
- Because the priority fee is computed from the limit you request. A generous limit makes the same price cost more, and large requests are harder for a leader to fit.
- What margin should I add?
- Around 10% above the simulated figure is a common choice. Use more if the path changes between simulation and landing, such as a swap against moving pools.