fix: Serialize MPToken UInt64 amounts as base-10 strings#3139
Open
ckeshava wants to merge 7 commits into
Open
Conversation
…ision of very large numbers (greater than 2^53). This commit returns a string representation instead of Number representation in the RPC outputs to solve this issue.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3139 +/- ##
========================================
Coverage 82.65% 82.66%
========================================
Files 398 398
Lines 16118 16127 +9
Branches 8443 8450 +7
========================================
+ Hits 13323 13331 +8
Misses 1674 1674
- Partials 1121 1122 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
/ai-reviewer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
account_mptokensandaccount_mpt_issuancesRPCs emitted MPToken amount fields as JSON numbers. Because many JSON parsers back numbers with IEEE-754 doubles, any value greater than 2^53 was silently rounded, so clients could not recover the exact on-ledger amount.This change serializes the affected
UInt64amount fields as base-10 JSON strings, matching rippled'sSTUInt64::getJsonbehavior so Clio's output is consistent with the reference implementation:account_mptokens:mpt_amount,locked_amountaccount_mpt_issuances:maximum_amount,outstanding_amount,locked_amountChanges
UInt64amount fields viaxrpl::STUInt64{field, value}.getJson(...)instead of inserting the raw integer into the JSON object, so the encoding matches rippled's string representation exactly.2^63 - 1,2^53 + 1, and an odd value> 2^53) round-trip as exact strings.Test plan
RPCAccountMPTokensHandlerTest.LargeAmountsSerializedAsStringsandRPCAccountMPTokenIssuancesHandlerTest.LargeAmountsSerializedAsStrings.Notes
mpt_holdersalready serializesmpt_amountcorrectly viaSTUInt64::getJson; all other handlers that expose ledgerUInt64fields (e.g.vault_info,get_aggregate_price,gateway_balances) route through rippled's own serialization orSTAmount, so they were already emitting strings and are unaffected.🤖 Generated with Claude Code