Expand Number to support the full integer range
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)
- [ ]
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl) - [ ] Peer protocol change (must be backward compatible or bump the peer protocol version)
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).
Additional details and impacted files
@@ 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 |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
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.
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
int64limit, but this works for existing integers since none of them exceedint64.
That is correct.
However, if we ever want to go beyond the 63-bit range (e.g., increasing MPT’s
MaximumAmounttomax(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.