Unable to do the CPI to Orca whirlpool program after obtaining its interface via solang
kupermind opened this issue · 1 comments
Describe the bug
We are unable to correctly finalize the call to the Orca whirlpool program fork after we have obtained the whirlpool interface via the solang idl whirlpool.json
command.
When doing the CPI, we have tried to analyze how the whirlpool SDK calls the needed function, and the assembled data seem to match with what we have passed into the function.
In brief, the CPI we are calling is this one:
https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/a1676ba93a7da2f0da44d32647752b76ac8ae1ae/solidity/nft_token.sol#L207-L224
The solana idl
-obtained whirlpool interface is located here:
https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/integration/solidity/interfaces/whirlpool.sol
The originating script code is located here:
https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/a1676ba93a7da2f0da44d32647752b76ac8ae1ae/tests/nft_token.ts#L328-L362
To Reproduce
Steps to reproduce the behavior:
- What ledger are you using: Solana
- Solidity source: https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/integration/solidity/nft_token.sol
- Client code: https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/integration/tests/nft_token.ts
- Solang version number: 0.3.3
- What behavior are you seeing? We are getting the
'Program GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb failed: Access violation in unknown section at address 0xa of size 32'
error - What behavior did you expect? The function to complete the CPI call correctly.
Please read the main README in order to reproduce the exact behavior:
https://github.com/valory-xyz/autonolas-tokenomics-solana/tree/integration
In order to see the expected behavior, the following lines can be uncommented:
https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/a1676ba93a7da2f0da44d32647752b76ac8ae1ae/tests/nft_token.ts#L227-L260
When calling the decreaseLiquidity() function via the whirlpool SDK, we are seeing the following data formed:
[
...
programId: PublicKey [PublicKey(whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc)] {
_bn: <BN: e03685f8e909053e458121c66f5a76aedc7706aa11c82f8aa952a8f2b7879a9>
},
data: <Buffer a0 26 d0 6f 68 5b 2c 01 ef f0 ae 00 00 00 00 00 00 00 00 00 00 00 00 00 aa f1 95 02 00 00 00 00 b8 52 2d 00 00 00 00 00>
}
]
We can then state that the decreaseLiquidity() selector is correctly created by the solang idl whirlpool.json
execution as it matches here:
https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/a1676ba93a7da2f0da44d32647752b76ac8ae1ae/solidity/interfaces/whirlpool.sol#L192-L193
We have also tried to just encode the data into the set of bytes to follow the SDK output, and those lines are listed here:
https://github.com/valory-xyz/autonolas-tokenomics-solana/blob/a1676ba93a7da2f0da44d32647752b76ac8ae1ae/solidity/nft_token.sol#L221-L223
However, we've got the same error result.
Expected behavior
We expected the decreaseLiquidity() function to complete and essentially decrease the liquidity of our LP token.
Hyperledger Solang version
Version of Solang (v0.3.3)
Version of Solana (solana-cli 1.17.7 (src:fca44b78; feat:3073089885, client:SolanaLabs))
Version of Anchor (anchor-cli 0.29.0)
Include the complete solidity source code
The code is located here: https://github.com/valory-xyz/autonolas-tokenomics-solana/tree/integration
Additional context
Add any other context about the problem here.
Notes:
anchor build
solang compile solidity/nft_token.sol -v --target solana
3f6c3ea21cf0a31d72064b8775ecefab nft_token.so
3f6c3ea21cf0a31d72064b8775ecefab target/deploy/nft_token.so
solang compile solidity/nft_token.sol -O none -v --target solana
cp nft_token.so target/deploy/
./validator.sh (in separate windows)
solana airdrop 10000 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h --url localhost && anchor test --skip-build --skip-local-validator
Deploying program "nft_token"...
Program path: /home/andrey/valory/autonolas-tokenomics-solana/target/deploy/nft_token.so...
Error: ELF error: ELF error: Found writable section (.bss) in ELF, read-write data not supported
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.
solang compile solidity/nft_token.sol -O less -v --target solana
cp nft_token.so target/deploy/
./validator.sh (in separate windows)
solana airdrop 10000 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h --url localhost && anchor test --skip-build --skip-local-validator
Deploying program "nft_token"...
Program path: /home/andrey/valory/autonolas-tokenomics-solana/target/deploy/nft_token.so...
Error: ELF error: ELF error: Found writable section (.bss) in ELF, read-write data not supported
There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.
solang compile solidity/nft_token.sol -O default -v --target solana
cp nft_token.so target/deploy/nft_token.so
solana airdrop 10000 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h --url localhost && anchor test --skip-build --skip-local-validator
Deploying program "nft_token"...
Program path: /home/andrey/valory/autonolas-tokenomics-solana/target/deploy/nft_token.so...
Program Id: GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb
Deploy success
Found a 'test' script in the Anchor.toml. Running it as a test suite!
Running test suite: "/home/andrey/valory/autonolas-tokenomics-solana/Anchor.toml"
yarn run v1.22.19
warning ../../package.json: No license field
$ /home/andrey/valory/autonolas-tokenomics-solana/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
Provider wallet: 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h
nft_token
User wallet: 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h
price: 68.469738
lower & upper tick_index: -443632 443632
lower & upper price: 0.000000 18438674135049479094762.080954
..
'Program GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb failed: Access violation in unknown section at address 0xa of size 32'
],
programErrorStack: ProgramErrorStack {
stack: [
[PublicKey [PublicKey(GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb)]]
]
}
}
solang compile solidity/nft_token.sol -O aggressive -v --target solana
cp nft_token.so target/deploy/nft_token.so
solana airdrop 10000 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h --url localhost && anchor test --skip-build --skip-local-validator
Deploying program "nft_token"...
Program path: /home/andrey/valory/autonolas-tokenomics-solana/target/deploy/nft_token.so...
Program Id: GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb
Deploy success
Found a 'test' script in the Anchor.toml. Running it as a test suite!
Running test suite: "/home/andrey/valory/autonolas-tokenomics-solana/Anchor.toml"
yarn run v1.22.19
warning ../../package.json: No license field
$ /home/andrey/valory/autonolas-tokenomics-solana/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
Provider wallet: 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h
nft_token
User wallet: 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h
price: 68.469738
lower & upper tick_index: -443632 443632
lower & upper price: 0.000000 18438674135049479094762.080954
..
'Program GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb failed: Access violation in unknown section at address 0xa of size 32'
],
programErrorStack: ProgramErrorStack {
stack: [
[PublicKey [PublicKey(GUGGHzwC8wEKY3g7QS38YmoS8t5Q2faWAGAfxDK2bXbb)]]
]
}
}