-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug when changing from platform tools v1.37 to v1.39 #252
Comments
Anchor has a bunch of tests that fail after upgrading to The tests work as long as the program is built using an earlier version than v1.39, independent of |
As an update for this issue, the pyth tests failures mentioned in coral-xyz/anchor#2795 (comment) by @acheroncrypto are caused by the change in the minimum size for enums in Rust. I've fixed this bug in anza-xyz/rust#90. I ran the test with the fix and everything turned out green. The OpenBook-V2 failure has been consuming more time, as it is a large contract that also depends on Anchor's code generation. I discovered the I haven't yet pinpointed the problem, but I suspect something has changed in Rust's data structures that interferes with function calls and stack variables. |
I guess we can create a simpler example then if we could pinpoint where the issue comes from. |
Nice! Have you checked any of the other failures too?
Here is a much shorter example that is likely related: https://beta.solpg.io/65cbb30bcffcf4b13384cf5b (run locally)
I think we might be using more memory somehow. The behavior on the example I've shared is very weird too. |
I've found the cause for the problem in OpenBook. Your example @acheroncrypto is likely to be hitting the same problem, as I simplified the OpenBook contract so much that it looked like the code you showed. What is the problem? SBFv1 functions have a limited frame size of 4096 bytes (4 kb), so using too many stack variables risks overwriting the frame of the caller function. In the OpenBook example, the anchor-generated function In the example, SBFv2 introduces dynamic stack frames, so this problem won't exist anymore once we migrate to the new runtime. Why wasn't this a problem in v1.37? Algoside Rust updates, the LLVM backend is also updated. Although the SBF code generation hasn't had any modification, the LLVM target independent code generation is constantly updated. This time, the SROA (Scalar Replacement of Aggregates) pass, an optimization that breaks down structs in its individual values, had an update and is breaking down structs in different places in the code, using more stack space than before. In v1.37, Any solution? Although we can disable the SROA pass, such a measure won't make |
I had a look at |
Thanks for the explanation! I'll note that this looks like a major regression for our case because not only does the 10 account example I've given work on v1.37, but you can also add many more accounts to the instruction until you hit the transaction size limit (1232 bytes). It doesn't run into any stack issues even with many more accounts used compared to v1.39.
The issue is that we can fix these problems in our tests, but it's likely that many of the production programs will also hit this problem once they start using
Thanks, we'll first need a new release that has the fixes to get the PR merged. We also have some token 2022 tests failing, which I haven't yet debugged, but they are most likely not related to |
Those regressions are a concern, but I have good news. I've tested platform-tools version v1.41 in this Openbook-v2 issue, in Anchor's tests |
Thanks @LucasSte! The memory issues we had are fixed in the |
Thanks for the feedback. Can we close this issue? |
I think so, yes. |
Problem
When building Openbook-V2 with the tools version v1.37, the following steps work correctly, but fail in platform tools version v1.39.
Steps to reproduce:
git clone https://github.com/openbook-dex/openbook-v2
cargo build-sbf --features enable-gpl
solana program deploy ./target/deply/openbook_v2.so
yarn run ts-node test.ts
Error in v1.39:
Proposed Solution
Investigating the problem
The text was updated successfully, but these errors were encountered: