-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow floats feature #567
Comments
Thanks for the explanation. I would not accept a no_floats feature -- I would prefer if this could be maintained outside of serde-rs/json as a fork. |
As we're falling into this category as well, I'd appreciate to learn about the current state of this ticket.
Is this still up to date? If so, I think this issue can be closed, right? |
Closing the issue. |
Motivation:
Many modern day blockchains use Rust smart contracts compiled to WebAssembly. Unfortunately, to enforce determinism they have to scan the compiled *.wasm contract before the execution and check whether it uses floats of float operations. This is not a problem for most of the smart contracts that do not actually use floats. However, if smart contract imports serde_json crate and deserializes a struct the compiler has to include some of the code branches that use f64/f32 even if these branches are never entered by the smart contract execution.
JSON is a fundamental format which is a natural choice for smart contract when they need to interact with the front-end (e.g. written in JS). It is highly desirable for smart contracts to be able to import serde_json crate and use it for deserialization.
Solution:
Have a
no_floats
feature that comments out certain branches of the code sufficiently enough so that when serde_json deserializer is used in a code that does not use f64/f32 no f64/f32 operations are generated in WebAssembly format. This can be implemented like this: nearprotocol#1 (disregard the added test).Question:
Do serde-rs/json maintainers want to have it as a feature or they want us (https://nearprotocol.com) to create a permanent fork with this feature?
The text was updated successfully, but these errors were encountered: