casper-node
casper-node copied to clipboard
[2.0] `Key::from_formatted_str` produces `f64` opcodes in WASM.
trafficstars
Category
Bug/Issue
Your email address
Integration Project Name(Optional)
Odra
Casper Network
Devnet
Node Functionality
Execution Engine
Description
We have discovered that parsing Key from string in WASM produces f64 opcodes, and then the node rejects such contracts.
We use rustSDK-feat-2.0 branch.
# Cargo.toml
[package]
name = "float-test"
version = "0.1.0"
edition = "2021"
[dependencies]
casper-types = { version = "5.0.0", git = "https://github.com/casper-network/casper-node", branch = "rustSDK-feat-2.0" }
The simplest example.
// src/main.rs
#![no_main]
use casper_types::Key;
#[no_mangle]
fn is_key(key_str: &str) -> bool {
Key::from_formatted_str(key_str).is_ok()
}
This is how I build the WASM.
cargo build --target wasm32-unknown-unknown --release
wasm-opt target/wasm32-unknown-unknown/release/float-test2.wasm \
--signext-lowering \
-o target/wasm32-unknown-unknown/release/float-test2.wasm
f64 opcodes in resulting file
wasm2wat target/wasm32-unknown-unknown/release/float-test2.wasm | grep -F 'f64'
(type (;12;) (func (param i32 f64 i32 i32) (result i32)))
(type (;16;) (func (param f64 i32) (result i32)))
f64.load offset=40
f64.store offset=8
f64.convert_i64_u
i64.reinterpret_f64
(local i32 i32 f64 f64)
f64.convert_i64_u
f64.const 0x0p+0 (;=0;)
f64.eq
f64.const 0x1.1ccf385ebc8ap+1023 (;=1e+308;)
f64.div
f64.load
f64.div
f64.mul
f64.abs
f64.const inf (;=inf;)
f64.ne
f64.neg
f64.store offset=8
f64.const 0x0p+0 (;=0;)
f64.const -0x0p+0 (;=-0;)
f64.store offset=8
(local i32 i32 i32 f64 i64)
f64.load offset=8
i64.reinterpret_f64
(local i32 f64 i64)
f64.load offset=8
f64.store offset=8
(func (;103;) (type 16) (param f64 i32) (result i32)
i64.reinterpret_f64
(local i32 f64)
f64.load offset=8
f64.store offset=40
f64.reinterpret_i64
f64.const inf (;=inf;)
f64.lt
(func (;212;) (type 12) (param i32 f64 i32 i32) (result i32)
i64.reinterpret_f64
f64.eq
(func (;214;) (type 12) (param i32 f64 i32 i32) (result i32)
i64.reinterpret_f64
f64.eq
(local i32 f64)
f64.load
Toolchain: nightly-2024-04-26
Date Issue Began(optional)
No response
Attachments (optional)
No response