-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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: AssemblyScript#732
To reproduce:
- Start local node (you would need to install rust)
git clone https://github.com/nearprotocol/nearcore/
cd nearcore
git checkout staging
./scripts/start_unittest.py --local
-
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 near-runtime-ts and near-shell should depend on a fixed version of AssemblyScript compiler near-runtime-ts#85 and I cannot tell what AssemblyScript will be like at the moment of someone trying to reproduce this issue);
-
Launch contracts:
cd wasm-project-it8oemvbn
near create_account studio-it8oemvbn --masterAccount=test.near --homeDir=/Users/zaver/Projects/nearcore/testdir
near deploy --accountId=studio-it8oemvbn --homeDir=/Users/zaver/Projects/nearcore/testdir --wasmFile=./out/main.wasm
cd ../wasm-project-kr22owu3d
near create_account studio-kr22owu3d --masterAccount=test.near --homeDir=/Users/zaver/Projects/nearcore/testdir
near deploy --accountId=studio-kr22owu3d --homeDir=/Users/zaver/Projects/nearcore/testdir --wasmFile=./out/main.wasm
(Fix the path to nearcore)
- Call the contract:
near call studio-it8oemvbn calculate "{}" --accountId=test.near --homeDir=/Users/zaver/Projects/nearcore/testdir
Observe the error message:
[studio-it8oemvbn]: Runtime error: wasm async call execution failed with error: PrepareError("Gas instrumentation failed.")
Error: Error: Transaction 5bGQZ6KSiMWft5Wd3CKzaDitye3gBQiZakzuqcfMnE5c failed. Runtime error: wasm async call execution failed with error: PrepareError("Gas instrumentation failed.")
at Account.signAndSendTransaction (/usr/local/lib/node_modules/near-shell/node_modules/nearlib/lib/account.js:89:23)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Object.exports.scheduleFunctionCall (/usr/local/lib/node_modules/near-shell/index.js:110:34)
at async exitOnError (/usr/local/lib/node_modules/near-shell/bin/near:8:5)
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.