I've been experimenting with the Compute Budget program to manage transaction costs and noticed something odd. When I invoke Compute Budget directly, everything works as expected. However, invoking it through CPI doesn't seem to apply the expected fees.


Is it known that Compute Budget behaves differently when called via CPI? Why might the fees not show up after a CPI invocation? Are specific adjustments required to ensure fees are assessed correctly with CPI calls?

1 Answer 1


The Compute Budget program does not work when invoked via CPI, and must be called at the top-level of a transaction.

The runtime scans through all instructions in a transaction prior to execution, looking for compute budget instructions, to setup the costs for the transaction. You can see that code at https://github.com/anza-xyz/agave/blob/f205d0e729e05f48ebba4e4bb47859714ff390f2/svm/src/transaction_processor.rs#L264

Also, the leader must know the fees that it can capture for a transaction, before choosing to include it in a block. If the Compute Budget program is invoked via CPI, then it must execute the transaction to figure out how much it can earn from the transaction, which is computationally redundant. You can see that code at https://github.com/anza-xyz/agave/blob/f205d0e729e05f48ebba4e4bb47859714ff390f2/runtime/src/bank.rs#L4021

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.