-
Notifications
You must be signed in to change notification settings - Fork 711
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
GenesisBuilder
: arbitrary_precision
feature enabled for serde_json
#2987
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.... as an alternative maybe we should consider serializing those numbers as strings instead, if possible?
The reason being that this is not really portable, so anyone who will try to load a JSON containing such numbers in any other language, using any other library, or just using serde_json
without this flag will silently get incorrect results (if the library doesn't explicitly produce an error in such case, and I think almost all of them don't?).
json spec doesn't pose any limit to the number of bits for the As
However, I also understand @koute perplexities, i.e. popular libs and other lang implementations typically support up to u64 |
Would that means that also 64-bit integers would need to be serialized as
This for sure needs to be solved at some point. Strings would be possible, but that would require touching affected pallets. |
See discussion here: serde-rs/json#846 FWIS actually |
For perfect compatibility with everything, yes. (In languages where numbers are It is an open question whether we care, but it is a footgun that should be at the very least documented. |
You mean that other languages would fail to parse such a number? |
It's matter of json lib implementation. Some will do (ruby,python), some not (nodejs). From what I found this c++ json lib nlohmann/json is not able to parse it. |
…on` (paritytech#2987) [`arbitrary_precision`](https://github.com/serde-rs/json/blob/6d44b9fac9269b4decf76acac5d68e8ec9d10c58/Cargo.toml#L69-L75) feature allows to (de-)serialize big numbers w/o error. For some details refer also to paritytech#1256 (comment) fixes: paritytech#2963
arbitrary_precision
feature allows to (de-)serialize big numbers w/o error.For some details refer also to #1256 (comment)
fixes: #2963