hyperledger / firefly

Hyperledger FireFly is the first open source Supernode: a complete stack for enterprises to build and scale secure Web3 applications. The FireFly API for digital assets, data flows, and blockchain transactions makes it radically faster to build production-ready apps on popular chains and protocols.
https://hyperledger.github.io/firefly
Apache License 2.0
496 stars 204 forks source link

FF returns `FF22062: Negative numeric value...` for large numeric input parameters #1568

Open matthew1001 opened 1 week ago

matthew1001 commented 1 week ago

When passing a JSON payload that contains parameters to FireFly (e.g. to deploy a contract that has constructor parameters) evmconnect returns FF22062: Negative numeric value is invalid for component %!!(MISSING)s(uint16=256)%!!(MISSING)(EXTRA string=[0]) if the numeric parameter exceeds the maximum size of a float64.

This appears to be because Golang deserialises large JSON numbers to float64 when deserialising to an interface{}, and silently loses any precision caused by the JSON number exceeding the maximum representable value of a float64.

matthew1001 commented 1 week ago

I've done most of the work to fix this under https://github.com/hyperledger/firefly-common/pull/147 and https://github.com/hyperledger/firefly-signer/pull/76. PRs for other repos such as firefly-evmconnect and firefly-transaction-manager will be needed to pull in the updated firefly-common and firefly-signer packages.

EnriqueL8 commented 1 week ago

Thanks for the work and context on this one @matthew1001!

This fix is important for all consumers of FireFly and I think warrants a new patch release to v1.3.2.

Things that I would love to be figure out as part of this work for v1.3.2