You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that it's same issue but with another use case, in the pox-4 contract we use an expression to define the STACKING_THRESHOLD constant, it evaluates to 0 in WASM
it leads to a division by zero when we call get-stacking-minimum or get-pox-info (which the new boot contract signers-voting.clar does, so it can't be deployed in clar2wasm)
So, after a little bit of investigation, the bug is caused by the fact that a constant which is not a literal value is not evaluated if it's called from inside a function. This is because in this case, .top-level is not evaluated.
We have to make sure that an accessed constant has been evaluated first.
Here is a simple way to reproduce the bug in the clar2wasm-tests package:
Add the contract constant-expr.clar with this content:
Our traverse function for define-constant should also handle other cases than literal values at compile time, like atoms for reserved variables (e.g. tx-sender).
The signers.clar boot contracts has this function
When calling this method with clarinet console with --enable-clarity-wasm, it returns a chunk-size of 0.
I tried it with my local build of clarinet that has the latest clar2wasm version (from the
main
branch).The text was updated successfully, but these errors were encountered: