Unpredictable behaviour when using the `elrond-wasm-rs` framework
Closed this issue · 6 comments
Copy of #916, since it is a serious issue and it was not even being investigated.
updates on this?
Please note that this is high priority and your mx-sdk-rs
is acting really weird... it's basically unusable for any real world application. Could jump on a call with one of your devs to explain the situation better.
This is out of our control. It's an issue with the Rust compiler, not with the framework. It happens sometimes when you have functions with too many arguments. We don't have the time nor the manpower to investigate and fix compiler issues.
In your case, to me it seems like the compute_claimable_rewards
function is causing the problem. Try grouping the arguments in a struct, for example, giving references to the whole staker_info
and package_info
instead of selecting specific fields.
Indeed, the problem seems to show up on functions with more than 5-6 parameters. If I'm using the #[inline(always)]
, the issue seems to go away.
However, I did not manage to isolate this on rust only code...
We are still investigating this issue, which is related to the compiler and to Wasmer.
A workaround that sometimes works is setting opt-level = 3
instead of opt-level = "z"
under [profile.release]
in the Cargo.toml
file of the wasm crate.
This issue was reproduced by us and the community several times.
It was caused by Wasmer 1. Now, after the latest mainnet release, Wasmer 1 is no longer in use, and this issue does not reroduce anymore.