1

I want to deploy my own instance of the Raydium cp-swap program on Solana's devnet. After cloning the repo and building clean with anchor and no trouble, followed by a successful deployment and running of the initialize.test.ts script, i end up with an access violation.

Steps:

  1. I clone this repo: https://github.com/raydium-io/raydium-cp-swap/
  2. I run anchor build it
  3. I deploy the program using anchor deploy
  4. I run: yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/initialize.test.ts
  5. The initialize test script calls the createAmmConfig function successfully, the ammConfig PDA gets created (i verified this)
  6. But then the initialize test script fails to create the pool in the first test

Error messages:

Message: Transaction simulation failed: Error processing Instruction 0: Program failed to complete. 
Logs: 
[
  "Program AywUGda6ZMcRHMt9XqEdvZ1L8eY3zFfsKGLv7xG57WSq invoke [1]",
  "Program log: Instruction: Initialize",
  "Program AywUGda6ZMcRHMt9XqEdvZ1L8eY3zFfsKGLv7xG57WSq consumed 6029 of 200000 compute units",
  "Program AywUGda6ZMcRHMt9XqEdvZ1L8eY3zFfsKGLv7xG57WSq failed: Access violation in stack frame 5 at address 0x200005ff8 of size 8"
]. 
Catch the `SendTransactionError` and call `getLogs()` on it for full details.

Under this program id (HPUJeMcNgwNjrnNpGBpMXZjQpMpBdJ1viFd7PgVdjkbC) you can find my program deployed on the Devnet

Interestingly, when compiling the program straight from the repo, i get this error:

# anchor build
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /dev/raydium-cp-swap/programs/cp-swap/Cargo.toml
workspace: /dev/raydium-cp-swap/Cargo.toml
Error: Function _ZN112_$LT$solana_program..instruction..InstructionError$u20$as$u20$solana_frozen_abi..abi_example..AbiEnumVisitor$GT$13visit_for_abi17h43ecb57923db73a1E Stack offset of 4608 exceeded max offset of 4096 by 512 bytes, please minimize large stack variables
   Compiling raydium-cp-swap v0.1.0 (/dev/raydium-cp-swap/programs/cp-swap)
    Finished release [optimized] target(s) in 3.28s

Are the two errors related?

If yes, how can the problem be fixed in the program? And if not, what am i doing wrong, what am i missing? Shouldn't the test scripts work with the repo as is?

I lack the necessary rust skills to start debugging this. Also it should work out of the box, or something else is wrong.

Please Note: The program id is correctly set everywhere and i changed the admin id declarations to match my deployment wallet's public key.

1 Answer 1

2

It's extremely likely that the two errors are related. There have been some reported increases of stack usage with newer versions of the Solana compiler: https://github.com/anza-xyz/agave/issues/1186

You might need to use an earlier version of the platform tools, like v1.41 or v1.40. Anchor doesn't seem to have a --tools-version argument, so you'll need to run:

cargo build-sbf --tools-version v1.40

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.