Skip to content
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

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

Closed
matthew1001 opened this issue Sep 2, 2024 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@matthew1001
Copy link
Contributor

matthew1001 commented Sep 2, 2024

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 matthew1001 changed the title FF give FF returns FF22062: Negative numeric value... for large numeric input parameters Sep 2, 2024
@matthew1001
Copy link
Contributor Author

I've done most of the work to fix this under hyperledger/firefly-common#147 and hyperledger/firefly-signer#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 EnriqueL8 added the bug Something isn't working label Sep 2, 2024
@matthew1001 matthew1001 mentioned this issue Sep 3, 2024
@EnriqueL8
Copy link
Contributor

EnriqueL8 commented Sep 3, 2024

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

  • Verify that the generate OpenAPI contract interface enforces/recommends strings for all integers on /invoke and /query calls
  • Upgrade FireFly core to the latest firefly-common and verify in all the places where this fix might apply
    • The first place I would look at would be the /contract/invoke api flow
  • Verify that this fix also works for contract listeners, so emitting an event with
  • This issue has look quiet closely at the EVM path, but we also have Fabric and Tezos (fyi @denisandreenko ) to look at
  • Look at the Javascript based tools in FireFly that might have the same issue
    • The node sdk when invoking APIs...
    • The Sandbox UI
    • DataExchange... try sending a message with a large number in the data payload...
  • FireFly CLI has a deploy command where you can specify constructor parameters this might have the same problem and will need updating to the latest FireFly Common as well
  • Documentation to explain to users that the safest way to pass large numbers into the system is to keep them as strings

@EnriqueL8
Copy link
Contributor

This is now completed! Thanks @matthew1001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants