2

I'm trying to verify ZK proofs on solana, but running into compute limits. I was told I can break things into multiple instructions to get around compute limits but I'm not sure how to do that exactly.

3 Answers 3

3

That will very much depend on the code you want to run in the instruction, of course. Is it code you wrote yourself, or are you mostly calling function from some library? You would have to find ways to split the work to be done, then do only part of it, and save the intermediate result in a PDA, and pick up form there in the next instruction.

Please post the code (or something that gives us an idea of the nature of the code), so that we can give some further input.

1
3

To do compute over multiple instructions you can store intermediate calculations in variables on an account. That way when you start up the next transaction you can continue on from where you finished at the end of the last transaction.

0

This should not be an issue anymore since we have moved to Transaction-wide Compute Budget. This is already enabled in mainnet-beta.

Previously, there was a per-instruction limit but now the compute budget is calculated for the entire transaction. And you can request additional budget for a fee, e.g. here is a web3.js example:

transaction.add(
  ComputeBudgetProgram.requestUnits({
      units: 100_000,
      additionalFee: 100,
  })
);

This is the instruction it is calling. I highly recommend reading this part of Solana docs as well.

In short, you should be able to get away with a single instruction and not have to break it up anymore.

3
  • the additional compute units max out at 1 mil and the code still wasn't complete in that limit, so i think i'll have to still break it up
    – Dev Bharel
    Commented Jul 24, 2022 at 5:06
  • Do you into multiple transactions?
    – sohrab
    Commented Jul 24, 2022 at 9:39
  • Additional compute maxed out at 1.4m, not 1m
    – Jacob Creech
    Commented Jul 24, 2022 at 10:33

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.