Open MaksymZavershynskyi opened 5 years ago
That's strange. I can't see any f64
/f32
in generated code for second example:
https://webassembly.studio/?f=www28iehfj
I do not remember exactly which contract out of the two given generated floats.
The version of the compiler is currently tied to near-shell, so the dependency"near-shell": "github:nearprotocol/near-shell"
is the issue. Unlike the compiler near-shell is versioned and since it uses a lock file to determine which commit of the compiler to use it acts as a proxy for the version of the compiler. Not saying we shouldn't version the compiler, but just perhaps this is the reason for the breakage/instability.
Also I can't download the zip file as dropbox says it's too large and I can't open the .ts
file in the browser since dropbox thinks it a video file.
@willemneal Did you figure out how to download the dropbox file?
When we compile AssemblyScript that does not use floats it gets compiled into WebAssembly that uses float operations. Float operations are not allowed for smart contracts, since they introduce non-determinism, see relevant: https://github.com/AssemblyScript/assemblyscript/issues/732
To reproduce:
Start local node (you would need to install rust)
Copy smart contracts: https://www.dropbox.com/sh/yd1gi0a83robwvc/AACGJhts5TBr6OlOtWcZrg0sa?dl=0 https://www.dropbox.com/sh/5m4thls6bd3nwhw/AADa3CakXizUxfpA_d9Vwieta?dl=0
Do not rebuild them (since we have https://github.com/nearprotocol/near-runtime-ts/issues/85 and I cannot tell what AssemblyScript will be like at the moment of someone trying to reproduce this issue);
Launch contracts:
(Fix the path to nearcore)
Call the contract:
Observe the error message:
Expected: to get no error message.
To see that it is float-related comment out https://github.com/nearprotocol/nearcore/blob/2cb653181143cfe4a0c8b2eac5a9e7701e88d1ea/runtime/near-vm-runner/src/prepare.rs#L59 and try again, it will succeed this time.