olisystems / BEST-Energy

Integritee off-chain worker and sidechain validateer
Apache License 2.0
2 stars 0 forks source link

Use fixed point numbers instead of floats for orders #26

Open clangenb opened 1 year ago

clangenb commented 1 year ago

Floats are, in general, bad practice in a blockchain environment, as they are not deterministic across different architectures. In essense our offchain-worker could handle this, but when it comes to verifying merkle-root hashes, we might have issues; the client might be unlucky and get a different leaf hash compared to the offchain-worker.

Options:

  1. Use fixed point numbers. This might be a bit hard to implement, depending on the client and its programming language.
  2. The orders are stored as a json-string, so instead of calculating the Merkle hashes over the actual data, we can always use strings in the hashing operations. A bit hacky, but maybe easier to implement for certain clients.