rippled icon indicating copy to clipboard operation
rippled copied to clipboard

Expand Number to support the full integer range

Open ximinez opened this issue 2 months ago • 1 comments

Supersedes #6000.

  • Update the conversion points between Number and {XRP,MPT,IOU,ST}Amount & STNumber.

High Level Overview of Change

Context of Change

Type of Change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Refactor (non-breaking change that only restructures code)
  • [ ] Performance (increase or change in throughput and/or latency)
  • [x] Tests (you added tests for code that already exists, or your new feature included in this PR)
  • [ ] Documentation update
  • [ ] Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • [ ] Release

API Impact

  • [ ] Public API: New feature (new methods and/or new fields)
  • [ ] Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • [ ] libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • [ ] Peer protocol change (must be backward compatible or bump the peer protocol version)

ximinez avatar Nov 12 '25 14:11 ximinez

Codecov Report

:x: Patch coverage is 97.07031% with 15 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 79.2%. Comparing base (f7a5f35) to head (451b474).

Files with missing lines Patch % Lines
src/libxrpl/basics/Number.cpp 97.5% 6 Missing :warning:
src/xrpld/app/tx/detail/LoanSet.cpp 70.6% 5 Missing :warning:
include/xrpl/basics/Number.h 97.2% 2 Missing :warning:
src/libxrpl/protocol/Issue.cpp 0.0% 2 Missing :warning:
Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                       @@
##           ximinez/lending-XLS-66-ongoing   #6025    +/-   ##
===============================================================
  Coverage                            79.1%   79.2%            
===============================================================
  Files                                 839     840     +1     
  Lines                               71380   71665   +285     
  Branches                             8318    8328    +10     
===============================================================
+ Hits                                56476   56737   +261     
- Misses                              14904   14928    +24     
Files with missing lines Coverage Δ
include/xrpl/protocol/AmountConversions.h 87.7% <100.0%> (ø)
include/xrpl/protocol/IOUAmount.h 100.0% <100.0%> (ø)
include/xrpl/protocol/Issue.h 100.0% <ø> (ø)
include/xrpl/protocol/MPTIssue.h 100.0% <ø> (ø)
include/xrpl/protocol/SField.h 100.0% <ø> (ø)
include/xrpl/protocol/STAmount.h 96.1% <100.0%> (+0.4%) :arrow_up:
include/xrpl/protocol/STNumber.h 100.0% <ø> (ø)
include/xrpl/protocol/SystemParameters.h 100.0% <ø> (ø)
src/libxrpl/protocol/IOUAmount.cpp 90.2% <100.0%> (+0.2%) :arrow_up:
src/libxrpl/protocol/Rules.cpp 98.0% <100.0%> (+0.2%) :arrow_up:
... and 25 more

... and 10 files with indirect coverage changes

Impacted file tree graph

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 02 '25 01:12 codecov[bot]

Want to make sure I understood this correctly: with largeRange, we can support full precision up to 2^63 - 1, so integer types (MPT or XRP) don’t lose precision even for large values. We’re still bounded by the signed int64 limit, but this works for existing integers since none of them exceed int64.

However, if we ever want to go beyond the 63-bit range (e.g., increasing MPT’s MaximumAmount to max(uint64) in the future), this implementation is not sufficient.

shawnxie999 avatar Dec 16 '25 19:12 shawnxie999

Want to make sure I understood this correctly: with largeRange, we can support full precision up to 2^63 - 1, so integer types (MPT or XRP) don’t lose precision even for large values. We’re still bounded by the signed int64 limit, but this works for existing integers since none of them exceed int64.

That is correct.

However, if we ever want to go beyond the 63-bit range (e.g., increasing MPT’s MaximumAmount to max(uint64) in the future), this implementation is not sufficient.

That is correct, however my current understanding is that there is no need or plan to extend the current limit.

Such a change would require an amendment, so a second expansion of Number would need to be included in that amendment work.

ximinez avatar Dec 17 '25 22:12 ximinez