I am currently trying to increase the Compute-Budget on my Solana Program on devnet. I am using solana version 1.9.9.
I have checked the anchor discord, and found this implementation to request a larger compute-budget. however, when I run this code-snippet
const data = Buffer.from(
Uint8Array.of(0, ...new BN(256000).toArray("le", 4))
);
const additionalComputeIx: TransactionInstruction = new TransactionInstruction({
keys: [],
programId: new PublicKey("ComputeBudget111111111111111111111111111111"),
data,
});
...
I get invalid instruction data
. any idea why this could be?
I was getting Compute Budget Exceeded
before adding this instruction to the transaction.
You're very close! The instruction definition for requesting an increase from the compute budget program contains a little-endian
u32
for the units, but then also a little-endianu32
for the additional fee to add, which you must include, even if it's 0. So instead, you should try:More information about the instruction at https://github.com/solana-labs/solana/blob/a6742b5838ffe6f37afcb24ab32ad2287a1514cf/sdk/src/compute_budget.rs#L10