nearprotocol / assemblyscript

A TypeScript to WebAssembly compiler 🚀
https://assemblyscript.org
Apache License 2.0
8 stars 1 forks source link

New AssemblyScript compiler introduced floats #73

Open MaksymZavershynskyi opened 5 years ago

MaksymZavershynskyi commented 5 years ago

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:

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.

MaxGraey commented 5 years ago

That's strange. I can't see any f64/f32 in generated code for second example: https://webassembly.studio/?f=www28iehfj

MaksymZavershynskyi commented 5 years ago

I do not remember exactly which contract out of the two given generated floats.

willemneal commented 5 years ago

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.

willemneal commented 5 years ago

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.

MaksymZavershynskyi commented 5 years ago

@willemneal Did you figure out how to download the dropbox file?