0

We are looking to enable reproducible floating point operations on chain by implementing the IEEE 754 standard as an on-chain wasm function.

As discussed in this stackoverflow post, substrate does not support naive floating point operations due to nondeterminism. Most use cases therefore go with fixed point arithmetics, which would be sub-optimal for us.

The following link gives additional insights into non-determinism in wasm: https://github.com/WebAssembly/design/blob/main/Nondeterminism.md

Given this information it still seems possible to come up with an IEEE 754 implementation that behaves deterministically in the context of substrate pallets, or am I missing something?

My questions are the following:

  1. Is there a wasm implementation of the IEEE 754 standard out there that can be used in substrate pallets? (I have not come across it in the substrate ecosystem and I wonder why that is the case).
  2. Are there any hidden pitfalls that I'm unaware of? E.g certain operations not being supported by the wasm executor used in substrate?

Any feedback would be appreciated.

1 Answer 1

2

I'm not an expert on this topic, but I expect the primary reasons there has been no effort to adopt this is

  1. Performance would be bad
  2. Substrate already has FixedPoint libraries which support fraction and decimal arithmetic, such as sp-arithmetic. There is a more advanced version maintained Encointer as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.