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

Remove MAX_SAFE_INTEGER limitation #2082

Closed
roman-khimov opened this issue Nov 20, 2020 · 6 comments
Closed

Remove MAX_SAFE_INTEGER limitation #2082

roman-khimov opened this issue Nov 20, 2020 · 6 comments
Labels
discussion Initial issue state - proposed but not yet accepted

Comments

@roman-khimov
Copy link
Contributor

Summary or problem description
Following https://github.com/neo-project/proposals/pull/126/files#r522304412 discussion and nspcc-dev/neofs-node#122 (comment) problem. We use 256-bit integers in VM, but they don't always convert to/from JSON nicely because of MAX_SAFE_INTEGER limitation and this limit is too low, even 100M with 8 decimals can't fit there.

Do you have any solution you want to propose?
I see two options:

  • dropping MAX_SAFE_INTEGER limitation, staying with decimal representation and leaving this as a client problem (RFC 7159 recommends to stay within [-(2⁵³)+1, (2⁵³)-1], but JSON technically doesn't impose any hard limit)
  • using hex encoding (either always or when the number doesn't fit), but that may be not very convenient

Neo Version

  • Neo 3

Where in the software does this update applies to?

  • RPC (HTTP)
@roman-khimov roman-khimov added the discussion Initial issue state - proposed but not yet accepted label Nov 20, 2020
@shargon
Copy link
Member

shargon commented Nov 21, 2020

If we remove the limit, it's very possible that we will need a custom json implementation in all languages (like go), isn't it?

@roman-khimov
Copy link
Contributor Author

It's very easy to fix for me while still staying decimal, but I'm not so sure about other client/server implementations. We need to solve this one way or another though.

@ixje
Copy link
Contributor

ixje commented Nov 25, 2020

If we remove the limit, it's very possible that we will need a custom json implementation in all languages (like go), isn't it?

Pretty much everything needs a custom implementation if you want to be strict compliant with how C# works, so that's nothing new for me.

@roman-khimov
Copy link
Contributor Author

This still is a problem, create some NEP-17 token with 16 decimals and try to work with it via RPC, there will be problems doing so.

@erikzhang
Copy link
Member

This still is a problem, create some NEP-17 token with 16 decimals and try to work with it via RPC, there will be problems doing so.

The best way is to use string.

@csmuller
Copy link

csmuller commented Jun 8, 2021

The best way is to use string.

If we use strings for large integers in JSON, I think there will be a problem with StdLib.JsonDeserialize(...) in smart contracts because it will deserialize the former integers to strings instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Initial issue state - proposed but not yet accepted
Projects
None yet
Development

No branches or pull requests

5 participants