Commit Graph

14073 Commits

Author SHA1 Message Date
Ed Hennis
03ea1deed1 Merge remote-tracking branch 'upstream/develop' into ximinez/lending-rebased
* upstream/develop:
  chore: Set version 3.1.0-b0 (5986)
  ci: Clean workspace on Windows self-hosted runners (6024)
  docs: fix spelling in comments (6002)
  fix: floating point representation errors in vault (5997)
  ci: Specify bash as the default shell in workflows (6021)
  refactor: Add `XRPL_RETIRE_FIX` and `XRPL_RETIRE_FEATURE` macros (6014)
  refactor: Retire DepositPreAuth and DepositAuth amendments (5978)
  chore: Move running of unit tests out of coverage target (6018)
  refactor: Retire PayChanRecipientOwnerDir amendment (5946)
  ci: Update Conan to 2.22.2 (6019)
  refactor: Update RocksDB, SQLite, Doctest (6015)
  fix: JSON parsing of negative `STNumber` and `STAmount` (5990)
  chore: Make CMake improvements (6010)
  refactor: Retire CheckCashMakesTrustLine amendment (5974)
  chore: Unify build & test, add ctest to coverage (6013)
  chore: Point xrpld symlink to rippled (6012)
  chore: Removes unnecessary creation of symlink in CMake install file (6009)
  fix: domain order book insertion 5998
  refactor: Retire fixTrustLinesToSelf amendment (5989)
2025-11-12 18:54:49 -05:00
Ed Hennis
bdffe99022 Disable inner Batch transactions for Vault and Loan types 2025-11-12 18:42:04 -05:00
Ed Hennis
9582f75ce2 Convert sfNextPaymentDueDate from optional to default
- Simplifies some of the updates and checks
2025-11-12 18:42:04 -05:00
Ed Hennis
d786035fe0 Reorder payment options to do full early payment first
- Since all the special cases are now specified with flags, the order is
  less important.
- Avoids computing the periodic payment parts that are not needed for
  full payment computation.
- A late payment without the late payment flag will override everything
  else, though.
2025-11-12 18:42:04 -05:00
Ed Hennis
ba19d7f32f Add tfLoanLatePayment flag; full payment is no longer a special case
- A regular payment that is late, or a tfLoanLatePayment that is not
  late will fail.
- Flags are mutually exclusive.
- Add a few interest computation shortcuts and overflow prevention
  checks that return 0 if there's no time to compute for.
2025-11-12 18:42:04 -05:00
Ed Hennis
c438852b41 review feedback: Use the specific type in the "SendMulti" functions 2025-11-12 18:42:04 -05:00
Ed Hennis
fb941ed1af Fix service fee accounting when a borrower is the broker (#6016)
- Add unit-test to verify the fix.
2025-11-12 18:42:04 -05:00
Ed Hennis
b50d728461 Fix build issue - unused variable 2025-11-12 18:42:04 -05:00
Ed Hennis
fa93ca7128 test: Add a test case reproducing the issue in RIPD-3902 2025-11-12 18:42:03 -05:00
Ed Hennis
7e94916d08 Always round cover minimum calculations up
- Addresses RIPD-4016.
- Add and update testRoundingAllowsUndercoverage() unit test from ticket.
2025-11-12 18:42:03 -05:00
Ed Hennis
f3677c9bed fix: Check for empty or zero VaultID in LoanBrokerSet
- Resolves RIPD-4067.
2025-11-12 18:42:03 -05:00
Ed Hennis
1fa366576e doc: Expand explanation for LoanBrokerCoverClawback::determineBrokerID 2025-11-12 18:42:03 -05:00
Ed Hennis
6e4f6eab3b Minor test fixes
- Don't deposit cover if the amount is 0.
- Handle missing next payment date in getCurrentState.
2025-11-12 18:42:03 -05:00
Ed Hennis
348e7f7cfc Fix RIPD-3901 - faulty assert
- Assert requires that an overpayment reduces the value of a loan. If
  the overall loan interest is low enough, it could leave it unchanged.
  Update the assert to require that the overpayment does not increase
  the value of the loan.
- Adds a unit test provided by @gregtatcam to demonstrate this issue.
2025-11-12 18:42:03 -05:00
Ed Hennis
43174d31d1 Update the test case for RIPD-3459 with more detailed output data 2025-11-12 18:42:02 -05:00
Ed Hennis
4fbf687166 Add test case to reproduce RIPD-3459
- Improve a few loan test helper functions.
- Make Loan.GracePeriod a default field.
2025-11-12 18:42:02 -05:00
Ed Hennis
cc46e94308 Check for Grace Period overflow in LoanSet 2025-11-12 18:42:02 -05:00
Ed Hennis
e485d5d6ad Add Grace Period to testLoanNextPaymentDueDateOverflow
- Demonstrates that Grace Period can overflow.
- Expected to fail.
2025-11-12 18:42:02 -05:00
Gregory Tsipenyuk
54d738b93e Implicitly authorize Vault and LoanBroker pseudo-accounts (#5976)
- Vault and LoanBroker pseudo-accounts can hold MPTs, regardless of MPTRequireAuth setting.
- Add requireAuth check in LoanBrokerCoverDeposit and LoanPay.
- Fail attempts to unauthorize pseudo-accounts by MPT issuers.
2025-11-12 18:42:02 -05:00
Ed Hennis
3fdd3cb495 Refactor loan test helpers into reusable functions
- Try to reproduce RIPD-3831
2025-11-12 18:42:02 -05:00
Gregory Tsipenyuk
2a9eec6c4f Fix empty/zero broker ID in LoanBrokerSet and LoanSet (#5977)
- Add checks for empty/zero brokerID where needed
- Extend unit-tests.
2025-11-12 18:42:02 -05:00
Ed Hennis
3a45fc3364 fix: Use ".value()" instead of "->" when with STObject::Proxy objects
- Turns out that "Proxy::operator->" is not a safe substitute for
  "Proxy::value()." if the field is not required. The implementation
  is different such that "operator->" will return a null ptr if the
  field is not present. This includes default fields with a value of
  zero!
2025-11-12 18:41:54 -05:00
Ed Hennis
8428255866 Handle zero rate in computePaymentFactor 2025-11-12 18:06:00 -05:00
Ed Hennis
e001681ada fix: Improve rounding for IOU loans
- Scale the loan to the Vault, so that amounts moving to the vault are
  less likely to have rounding errors.
- Similar to LoanPay, when LoanManage defaults a loan, round the amounts
  to the Vault scale (because the Vault scale can change) before
  applying them to the Vault.
2025-11-12 18:05:59 -05:00
Ed Hennis
d2f8e3817e Another arbitrary test case to try 2025-11-12 18:05:59 -05:00
Ed Hennis
a38e09e327 Add testDustManipulation test, which is expected to fail 2025-11-12 18:05:59 -05:00
Bronek Kozicki
8580a5795a chore: Set version 3.1.0-b0 (#5986)
Technically b0 is not a release, so no "release" prefix here. It marks the point at which we moved the preceding release (3.0.0 in this case) from Beta to Release Candidate.
3.1.0-b0
2025-11-12 18:55:49 +00:00
Bart
9b53bd9871 ci: Clean workspace on Windows self-hosted runners (#6024)
This change updates the `cleanup-workspace` action to its latest version, which added support for Windows.
2025-11-12 09:30:45 -05:00
hustrust
5fc07e3979 docs: fix spelling in comments (#6002) 2025-11-12 08:23:45 -05:00
Bronek Kozicki
2ebc2ca885 fix: floating point representation errors in vault (#5997)
This change fixes floating point errors in conversion of shares to assets and other way, used in `VaultDeposit`, `VaultWithdraw` and `VaultClawback`. In the floating point calculations the division introduces a larger error than multiplication. If we do division first, then the error introduced will be increased by the multiplication that follows, which is therefore the wrong order to perform these two operations. This change flips the order of arithmetic operations, which minimizes the error.
2025-11-11 19:39:09 +00:00
Ayaz Salikhov
c2a90b706f ci: Specify bash as the default shell in workflows (#6021) 2025-11-11 18:17:03 +00:00
Jingchen
9ffb434315 refactor: Add XRPL_RETIRE_FIX and XRPL_RETIRE_FEATURE macros (#6014)
Rather than having a single `XRPL_RETIRE` macro that applies to both feature and fix amendments, this change replaces it by new `XRPL_RETIRE_FIX` and `XRPL_RETIRE_FEATURE` macros that avoids confusion between whether to prefix the amendment name with `feature` or `fix`.
2025-11-11 12:45:13 -05:00
Jingchen
ff18cfef96 refactor: Retire DepositPreAuth and DepositAuth amendments (#5978)
Amendments activated for more than 2 years can be retired. This change retires the fDepositPreAuth and DepositAuth amendments.
2025-11-11 15:21:07 +00:00
Bronek Kozicki
03704f712b chore: Move running of unit tests out of coverage target (#6018)
This change makes the progress of unit tests visible and also gives more flexibility when running them.
2025-11-11 14:55:16 +00:00
Pratik Mankawde
9b332d88c1 refactor: Retire PayChanRecipientOwnerDir amendment (#5946)
Amendments activated for more than 2 years can be retired. This change retires the PayChanRecipientOwnerDir amendment.
2025-11-11 09:07:45 -05:00
Ayaz Salikhov
33309480d4 ci: Update Conan to 2.22.2 (#6019)
This updates the CI image hashes after following change: https://github.com/XRPLF/ci/pull/81. And, since we use latest Conan, we can have `conan.lock` with a newline at the end, and we don't need to exclude it from `pre-commit` hooks any longer.
2025-11-10 16:23:40 -05:00
Bart
098eadca0a refactor: Update RocksDB, SQLite, Doctest (#6015) 2025-11-10 18:02:35 +00:00
Bronek Kozicki
3b810c305a fix: JSON parsing of negative STNumber and STAmount (#5990)
This change fixes JSON parsing of negative `int` input in `STNumber` and `STAmount`. The conversion of JSON to `STNumber` or `STAmount` may trigger a condition where we negate smallest possible `int` value, which is undefined behaviour. We use a temporary storage as `int64_t` to avoid this bug. Note that this only affects RPC, because we do not parse JSON in the protocol layer, and hence no amendment is needed.
2025-11-10 17:33:20 +00:00
Bart
3968efb5f1 chore: Make CMake improvements (#6010)
This change removes unused definitions from the CMake files, moves variable definitions from `XrplSanity` to `XrplSettings` where they better belong, and updates the minimum GCC and Clang versions to match what we actually minimally support.
2025-11-10 16:33:54 +00:00
Jingchen
12c629a1d2 refactor: Retire CheckCashMakesTrustLine amendment (#5974)
Amendments activated for more than 2 years can be retired. This change retires the CheckCashMakesTrustLine amendment.
2025-11-10 16:03:10 +00:00
Bronek Kozicki
8d2dff2e48 chore: Unify build & test, add ctest to coverage (#6013)
This change unifies the build and test jobs into a single job, and adds `ctest` to coverage reporting.

The mechanics of coverage reporting is slightly complex and most of it is encapsulated in the `coverage` target. The status quo way of preparing coverage reports involves running a single target `cmake --build . --target coverage`, which does three things:
* Build the `rippled` binary (via target dependency)
* Prepare coverage reports:
  * Run `./rippled -u` unit tests.
  * Gather test output and build reports.

This makes it awkward to add an additional `ctest` step between build and coverage reporting steps. The better solution is to split `coverage` target into separate build, followed by `ctest`, followed by test generation. Luckily, the `coverage` target has been designed specifically to support such case; it does not need to build `rippled`, it's just a dependency. Similarly it allows additional tests to be run before gathering test outputs; in principle we could even strip it from running tests and run them separately instead. This means we can keep build, `ctest` and generation of coverage reports as separate steps, as long as the state of build directory is fully (including file timestamps, additional coverage files etc.) preserved between the steps. This means that in order to run `ctest` for coverage reporting we need to integrate build and test into a single job, which this change does.
2025-11-10 10:32:08 -05:00
Michael Legleux
c39f9c561c chore: Point xrpld symlink to rippled (#6012)
As part of renaming ripple(d) to xrpl(d), the xrpld symlink was made to point to itself instead of to the rippled binary. This change fixes the symlink.
2025-11-07 10:51:12 +00:00
Bart
173f9f7bb0 chore: Removes unnecessary creation of symlink in CMake install file (#6009) 2025-11-06 09:06:45 +00:00
Shawn Xie
28a1f90938 fix: domain order book insertion #5998 2025-11-05 23:08:10 +00:00
Ed Hennis
165478b929 Remove the shortage code completely 2025-11-05 13:28:03 -05:00
Ed Hennis
95fdbe520f Partially revert aed8e2b166 Fill in payment computation shortages (#5941)
- Do not attempt to fill in payment computation shortages. Fixes, tests,
  and optimizations are left intact.
2025-11-05 12:48:14 -05:00
Jingchen
673fb06c75 refactor: Retire fixTrustLinesToSelf amendment (#5989)
Amendments activated for more than 2 years can be retired. This change retires the fixTrustLinesToSelf amendment.
2025-11-05 14:56:20 +00:00
Ed Hennis
34db04ffc1 Update Lending files for the xrpl rename 2025-11-04 19:37:58 -05:00
Ed Hennis
65e6746b5c Merge branch 'develop' into ximinez/lending-XLS-66 2025-11-04 18:02:38 -05:00
Ed Hennis
aed8e2b166 Fill in payment computation shortages (#5941)
- Ensures a consistent fixed payment amount for the entire life of the
  loan, except the final payment, which is guaranteed to be the same or
  smaller.
- Convert some Loan structs to compute values that had need manual
  updates to stay consistent.
- Fail the transaction in `LoanPay` if it violates the Vault `assetsAvailable <=
  assetsTotal` invariant.
- Use constexpr to check that min mantissa value for Number and STAmount
  is a power of 10, and compute the max in terms of the min.
- Improve unit tests:
  - Use BrokerParameters and Loan Parameters instead of semi-global
    class values
  - In tests, check that the expected number of loan payments are made.
  - Add LoanBatch manual test to generate a set number of random loans,
    set them up, and pay them off.
  - Add LoanArbitrary manual test to run a single test with specific
    (hard-coded for now) parameters.
  - Add Number support to XRP_t.
2025-11-04 22:56:16 +00:00