When using ArLocal, the value is effectively a number, it is however not the case when using the mainnet, which in this case returns the height in a string. This causes the assertion to fail and crash the Rust contract that would try to get the current height of the tx.
To Reproduce
Deploy a Rust contract to mainnet that makes use of Block::height()
Publish a transaction that triggers the contract to call Block::height()
Notice how Warp now crashes every time we try to evaluate the contract
Here is the log of the crash. The first line is from a debug log I added right before the call to _assertNum:
wasmLogger.error(`ret type: \`${typeof ret}\`; ret value: \`${JSON.stringify(ret)}\``);
2024-03-12T14:49:55.147Z ERROR [WASM:Rust] ret type: `string`; ret value: `"1381371"` []
wasm-bindgen: imported JS function that was not marked as `catch` threw an error: expected a number argument
Stack:
/home/noom/dev/pianity/transaction-sender/node_modules/warp-contracts/lib/cjs/core/modules/impl/wasm/rust-wasm-imports.js:141
throw new Error('expected a number argument');
^
Error: expected a number argument
at _assertNum (/home/noom/dev/pianity/transaction-sender/node_modules/warp-contracts/lib/cjs/core/modules/impl/wasm/rust-wasm-imports.js:141:19)
at <anonymous> (/home/noom/dev/pianity/transaction-sender/node_modules/warp-contracts/lib/cjs/core/modules/impl/wasm/rust-wasm-imports.js:605:17)
at logError (/home/noom/dev/pianity/transaction-sender/node_modules/warp-contracts/lib/cjs/core/modules/impl/wasm/rust-wasm-imports.js:320:22)
at __wbg_height (/home/noom/dev/pianity/transaction-sender/node_modules/warp-contracts/lib/cjs/core/modules/impl/wasm/rust-wasm-imports.js:602:20)
at wasm://wasm/00132f36:wasm-function[65]:0x6335
at wasm://wasm/00132f36:wasm-function[62]:0x2b1a
at wasm://wasm/00132f36:wasm-function[73]:0xf7dd
at wasm://wasm/00132f36:wasm-function[62]:0x2dc6
at wasm://wasm/00132f36:wasm-function[76]:0x1385f
at wasm://wasm/00132f36:wasm-function[143]:0x2c490
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
The function
__wbg_height
in the Rust WASM imports expects that the value returned byrawImports.Block.height()
is a number.https://github.com/warp-contracts/warp/blob/25b2abd35172cb14f4aff384eb3e07961c2a1eb8/src/core/modules/impl/wasm/rust-wasm-imports.ts#L710
When using ArLocal, the value is effectively a
number
, it is however not the case when using the mainnet, which in this case returns the height in astring
. This causes the assertion to fail and crash the Rust contract that would try to get the current height of the tx.To Reproduce
Block::height()
Block::height()
Here is the log of the crash. The first line is from a debug log I added right before the call to
_assertNum
: