Commit Graph

10156 Commits

Author SHA1 Message Date
Vito
c57709b17a fix: clang-tidy 2026-08-13 11:50:54 +02:00
Vito
cf1a551a97 Merge branch 'tapanito/fix-lending-cross-scale' into tapanito/vault-add-assets-helper
# Conflicts:
#	include/xrpl/ledger/helpers/VaultHelpers.h
#	src/libxrpl/ledger/helpers/VaultHelpers.cpp
#	src/libxrpl/tx/transactors/lending/LoanManage.cpp
#	src/libxrpl/tx/transactors/lending/LoanPay.cpp
2026-08-13 11:38:05 +02:00
Vito
74102450a8 Merge branch 'develop' into tapanito/fix-lending-cross-scale 2026-08-13 10:40:08 +02:00
Jingchen
8e9b1791c5 feat: Add a new closed ended vault to extend SAV (#7921)
Co-authored-by: Vito Tumas <5780819+Tapanito@users.noreply.github.com>
2026-08-12 17:07:43 +00:00
Vito Tumas
91360c5126 test: Fix LoanBatch broker cover rates and schedule overflow (#7967) 2026-08-12 12:11:28 -04:00
Timur Yalymov
af36890c11 test: Verify private-vault DEX permissions survive domain loss (#7937) 2026-08-12 12:11:28 -04:00
Timur Yalymov
1281c7a222 refactor: Drop unnecessary associateAsset calls from loan delete paths (#7986)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-12 12:10:17 -04:00
Copilot
153b7839a7 refactor: Replace boost::filesystem with std::filesystem across the codebase (#7012)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
Co-authored-by: Mayukha Vadari <mvadari@gmail.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mathbunnyru <12270691+mathbunnyru@users.noreply.github.com>
2026-08-12 13:40:39 +00:00
Vito Tumas
33f839c7c7 Merge branch 'develop' into tapanito/fix-lending-cross-scale 2026-08-12 13:29:45 +02:00
Gregory Tsipenyuk
26cc683ec1 fix: Assorted MPT/DEX fixes (#7299)
Co-authored-by: Valentin Balaschenko <13349202+vlntb@users.noreply.github.com>
2026-08-11 18:15:51 +00:00
Mayukha Vadari
6ca2fb84d4 refactor: Replace Boost trim and to_lower with libxrpl helpers (#7995) 2026-08-11 18:15:35 +00:00
Vito
c12e4730ae test: Multi-loan drift regression sensor for fixCleanup3_4_0
Adds testMultiLoanDefaultDriftFixVsLegacy which runs the same
drift-inducing scenario (3 loans, different scales, partial payments,
impairment, then default) under both !fixCleanup3_4_0 and
fixCleanup3_4_0 and confirms both paths leave the vault
invariant-safe.

Empirically the two branches produce identical post-default state
because computeLoanProperties clamps loanScale >= vaultScale (via
std::max(minimumScale, amount.exponent())), so the pre-amendment
roundToAsset(vaultDefaultAmount, vaultScale, Down) is a no-op for
well-formed loans. The dust-reconciliation branch this test guards
against is doubly-defensive code — reachable only from a corrupted
ledger, not a valid transaction sequence.

The test acts as a regression sensor: any future change that breaks
the invariant on either branch (or lets them diverge) will surface
here.
2026-08-11 18:15:55 +02:00
Vito
9f4cdb80cd fix: Eliminate cross-scale arithmetic in LoanPay::doApply
Gated behind fixCleanup3_4_0. Pre-amendment, the payment path used the
same cross-scale pattern that `LoanManage::defaultLoan` addressed:
`totalPaidToVault` was rounded down to `vaultScale` before being applied
to `sfAssetsAvailable`, while `assetsTotalDelta` (`valueChange` for
accrual, `interestPaid` for cash-basis) was applied at the finer loan
scale. The `sfAssetsAvailable <= sfAssetsTotal` invariant was only
defended by an assertion after the fact.

Under the fix, drop the `roundToAsset(..., vaultScale, Downward)` step
and apply the raw `totalPaidToVault` to both the ledger update and the
cash transfer via `accountSendMulti`. The pseudo-account balance and
`sfAssetsAvailable` therefore land on the same STAmount value without
an intermediate scale reduction.

For integral assets this is a no-op (the removed rounding was already a
no-op there). For non-integral IOUs, the vault receives the full raw
payment (up to 1 vaultScale ULP more than pre-amendment) and the
existing `tecPRECISION_LOSS` / `tecINTERNAL` post-checks are no longer
needed as safety nets against an arithmetic-induced Available > Total.

`LoanPay_test` now runs the amendment-sensitive tests under both
branches by adding `fixCleanup3_4_0` to the `amendmentCombinations`
matrix, matching the sibling change to `LoanRounding_test`.
2026-08-11 18:15:55 +02:00
Vito
95850644a9 fix: Eliminate cross-scale arithmetic in LoanManage::defaultLoan
Gated behind fixCleanup3_4_0. Pre-amendment, `defaultLoan` mutated
`sfAssetsTotal` and `sfAssetsAvailable` with values at different scales --
`vaultDefaultAmount` rounded down to `vaultScale`, but `defaultCovered`
kept at the finer loan scale. That asymmetry could leave
`sfAssetsAvailable > sfAssetsTotal` from the arithmetic alone, and was
patched by a dust-reconciliation branch that snapped `Total` up to
`Available`. That snap effectively minted phantom assets on `Total`
(see `LoanRounding_test::testDustManipulation`).

Under the fix, the vault-side update is composed from two well-defined
STAmount operations at the vault asset's own scale:

  (1) Write-off: `sfAssetsTotal -= totalDefaultAmount` -- the defaulted
      loan's exposure leaves the vault.
  (2) Symmetric cash inflow: `defaultCovered` returns from first-loss
      capital. Apply the same STAmount to both `sfAssetsTotal` and
      `sfAssetsAvailable`, preserving the gap.

Because both deltas are STAmounts of the same asset, no cross-scale
rounding step is needed and `Available > Total` cannot occur from
arithmetic. The dust-branch snap and its downstream `tecINTERNAL`
guard are unreachable under the fix and only run on the pre-amendment
path.

The pre-mutation sanity check on the fix path tightens to the correct
invariant (`sfAssetsTotal - sfAssetsAvailable >= totalDefaultAmount`);
the pre-amendment path retains its original `vaultTotalProxy <
vaultDefaultAmount` check for byte-for-byte compatibility with existing
ledgers.

`LoanRounding_test` now runs `testDustManipulation` (and the other
amendment-sensitive rounding tests) under both branches by adding
`fixCleanup3_4_0` to the `amendmentCombinations` matrix. Both branches
land the same post-default equality for the specific test setup; the
fix path reaches it by clean arithmetic rather than a snap.
2026-08-11 18:15:54 +02:00
klemenfn
a3147740f2 build: Fix GCC 14 compilation (#7981)
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
2026-08-11 13:24:56 +00:00
luisfernandomendozav
d43e5acaa7 fix: Validate account/ident type in gateway_balances (#7655) 2026-08-11 13:23:07 +00:00
Alex Kremer
0a572833ea chore: Gtest migration followups second pass (#7888) 2026-08-11 12:38:40 +00:00
Chenna Keshava B S
639943123c fix: Validate buy/sell flag in nft RPC input (#7725) 2026-08-11 00:49:02 +00:00
Bryan
909cc5bba9 fix: Prevent silent zero AMM clawbacks due to integer MPT rounding (#7704)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-08-10 21:37:53 +00:00
Peter Chen
6f5de9067a chore: Mark unreachable branches in Confidential Transfer with UNREACHABLE (#7903) 2026-08-10 21:37:38 +00:00
Kassaking7
60291c3ed6 fix: Allow OverrideFreeze to bypass individual/deep freeze on AMM trust lines (#6959) 2026-08-10 21:34:28 +00:00
Braedon Klock
4173f7e499 fix: Validate account_lines peer field type (#7728)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-10 21:30:06 +00:00
yinyiqian1
b19c3c64f2 fix: Add zero keylet check in credential (#7971) 2026-08-10 17:47:16 +00:00
Mayukha Vadari
a0e1e578a0 refactor: Remove operator!= overloads that C++20 synthesizes (#7994) 2026-08-10 17:23:02 +00:00
Mayukha Vadari
07aa97fda4 test: Use std::string::starts_with/ends_with instead of Boost (#7992) 2026-08-10 17:22:40 +00:00
Mayukha Vadari
4f8819565a fix: Assorted cleanup fixes (#7988) 2026-08-10 17:18:22 +00:00
Mayukha Vadari
6580b200db refactor: Replace boost::lexical_cast with existing alternatives (#7991) 2026-08-10 17:10:18 +00:00
Mayukha Vadari
71e972cbed refactor: Act on TODOs that are unblocked by C++23 (#7990) 2026-08-10 17:05:18 +00:00
Vito
db50afa34f test: Cover Vault helper early-return branches
Adds unit-test coverage for three previously-untested branches in
VaultHelpers:

- addVaultAssets propagates a non-tes return when the underlying
  accountSend fails (exercised via a sender with no trust line for the
  vault asset).
- clawbackVaultAssets propagates a non-tes return when its accountSend
  fails (exercised via a synthetic third-party recipient with no trust
  line; the production caller always uses the asset issuer, which
  cannot hit this branch).
- moveVaultAssets short-circuits and returns tesSUCCESS without
  touching accountSendMulti when every recipient's amount is zero
  (exercised via two zero-amount recipients, which still satisfies the
  recipients.size() > 1 precondition).
2026-08-10 16:34:36 +02:00
Vito
0a4dd08700 chore: Address inline review comments on Vault helpers
- Restore the doc comment on STAmount::isRounded that was lost when it
  moved out of LendingHelpers.cpp.
- Collapse LoanManage::defaultLoan's Vault-update block into a direct
  return of addVaultAssets, since there is no follow-up work after it.
- Mark removeVaultAssets's amount==0 early-return with LCOV_EXCL_LINE: it
  is a defensive short-circuit for a branch that is only reachable in a
  vanishingly rare edge case (final withdrawal from a vault whose
  sfAssetsAvailable has already been written down to zero) and is not
  reached by any current transactor-level test.
2026-08-10 16:34:29 +02:00
Vito
5d839f4811 fix: Silence -Wunused-variable on Vault clawback/withdraw asserts
Mark `assetsAvailable`/`assetsTotal` in VaultClawback::doApply and
`assetsTotalBefore` in VaultWithdraw::doApply as [[maybe_unused]]: each
is only referenced from XRPL_ASSERT, which is compiled out in Release
(NDEBUG) builds. Without the attribute clang -Werror,-Wunused-variable
would break the release CI configurations, matching the pattern already
addressed for VaultHelpers and LoanPay.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 15:36:07 +02:00
Vito
00889a4307 fix: Silence -Wunused-variable on LoanPay asset asserts
Mark the raw pre-rounding projections `assetsAvailableAfterRaw` and
`assetsTotalAfterRaw` in LoanPay::doApply as [[maybe_unused]]: they are
only referenced from XRPL_ASSERT_PARTS, which is compiled out in Release
(NDEBUG) builds, so clang's -Werror,-Wunused-variable was breaking the
ubuntu-clang-release-amd64 and macos-arm64-release CI jobs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:34:08 +02:00
Vito
d6565f0e4d fix: Silence -Wunused-variable on the asset asserts
Mark the `Asset const asset` local in addVaultAssets and removeVaultAssets
as [[maybe_unused]]: it is only referenced from XRPL_ASSERT, which is
compiled out in Release (NDEBUG) builds, so clang's -Werror,
-Wunused-variable was breaking the ubuntu-clang-release-amd64 CI job.
The moveVaultAssets copy is used in real code paths and is unaffected.
2026-08-10 13:29:24 +02:00
Vito Tumas
72f75cbf43 Merge branch 'develop' into tapanito/vault-add-assets-helper 2026-08-10 12:51:59 +02:00
Vito
80ef2659e0 test: Add unit tests for the Vault balance-mutation helpers
Exercise addVaultAssets, clawbackVaultAssets, removeVaultAssets
(including FinalRemoval::Yes hard-reset and the amount > sfAssetsAvailable
failure path), and moveVaultAssets directly against a real Vault SLE and
ApplyView, built via jtx but bypassing the VaultDeposit/VaultWithdraw/
VaultClawback/LoanSet transactors. Covers zero-amount edges, negative
valueDelta, and the independent amount/valueDelta contract, in addition
to the existing transactor-level coverage in Vault_test.cpp,
LoanSet_test.cpp, etc.
2026-08-10 12:41:00 +02:00
Vito
518edd594c refactor: Route Vault/Loan transactors through the new Vault helpers
Wire VaultDeposit, VaultWithdraw, VaultClawback, LoanSet, LoanManage, and
LoanPay through addVaultAssets/removeVaultAssets/clawbackVaultAssets/
moveVaultAssets, replacing their ad hoc sfAssetsTotal/sfAssetsAvailable
proxy mutations and accountSend/accountSendMulti/doWithdraw calls:

- VaultDeposit and VaultWithdraw/VaultClawback use addVaultAssets and
  removeVaultAssets/clawbackVaultAssets respectively. VaultClawback uses
  the plain-accountSend overload rather than the doWithdraw-based one,
  since doWithdraw's self-holding-creation path would incorrectly reject
  a locked/frozen MPT issuance before checking that the recipient is the
  issuer (who always already holds their own asset).
- LoanSet's loan-principal-and-origination-fee disbursement uses
  moveVaultAssets.
- LoanManage's default write-off and LoanPay's payment both use
  addVaultAssets; addVaultAssets always applies valueDelta even when the
  transferred amount is zero, since a default written off entirely by
  the Vault (no first-loss capital cover) has a nonzero total delta but
  a zero transferred amount.
- LoanPay's post-rounding precision-loss guard now reads the Vault's
  actual post-rounding field values (after addVaultAssets/associateAsset
  have mutated and rounded them) instead of comparing raw pre-mutation
  arithmetic.
- associateAsset(*vault, ...) must run after the helper mutates the
  Vault's fields, never before: it rounds every asset-typed field on the
  Vault SLE to the asset's canonical precision, which the mutation
  itself does not do. Getting this ordering backwards is what caused a
  "value is already rounded" STNumber assertion failure during testing.

Also rename getAssetsTotalScale to VaultHelpers::getVaultScale at all
call sites.
2026-08-10 12:40:46 +02:00
Vito
3c51e3dad1 feat: Centralize Vault balance mutations in VaultHelpers
Add addVaultAssets, removeVaultAssets (two overloads: plain accountSend
and doWithdraw-based), clawbackVaultAssets, and moveVaultAssets as the
single points through which a Vault's sfAssetsTotal/sfAssetsAvailable are
mutated and funds move to/from its pseudo-account:

- addVaultAssets increases both fields and transfers in from a sender.
- removeVaultAssets/clawbackVaultAssets decrease both fields equally and
  transfer out; a FinalRemoval flag hard-resets both fields to exactly
  zero on a Vault's last withdrawal, since the discounted exchange-rate
  formula can produce values with more precision than the asset can
  canonically represent, and subtracting such a value would leave a
  non-canonical residual instead of an exact zero.
- moveVaultAssets decreases only sfAssetsAvailable, for disbursements
  (e.g. a loan's principal and origination fee) where sfAssetsTotal
  independently grows via accrued interest.

Also consolidate getAssetsTotalScale into VaultHelpers::getVaultScale,
and move isRounded from LendingHelpers into STAmount.h alongside the
other rounding utilities.
2026-08-10 12:40:10 +02:00
Gregory Tsipenyuk
94bccb3a5a fix: Fix MPT/DEX Audit/Attackathon reports (Phase 2) (#7537)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Sergey Kuznetsov <skuznetsov@ripple.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Andrzej Budzanowski <andrzej.budzanowski@neti-soft.com>
Co-authored-by: Marek Foss <marek.foss@neti-soft.com>
Co-authored-by: Alex Kremer <akremer@ripple.com>
Co-authored-by: Vito Tumas <5780819+Tapanito@users.noreply.github.com>
Co-authored-by: Bart <bthomee@users.noreply.github.com>
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-08-07 21:53:54 +00:00
Mayukha Vadari
0fb92c3194 refactor: Use SeqProxy instead of uint32 for all sequence-based keylets (#7890)
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-08-07 21:29:11 +00:00
Matt Van Horn
798e889ec4 fix: Deduplicate oracle entries in get_aggregate_price RPC (#6586)
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-08-07 20:24:45 +00:00
Timur Yalymov
abf5511d07 fix: Correct sign-check wording in lending protocol messages (#7913) 2026-08-07 19:41:23 +00:00
Ayaz Salikhov
a0e78b286f chore: Bump version to 3.4.0-b0 (#7976) 2026-08-07 16:56:46 +00:00
Ayaz Salikhov
9859e5ceda Merge remote-tracking branch 'upstream/release/3.3.x' into mathbunnyru/merge-3.3.0-to-develop
* upstream/release/3.3.x: (41 commits)
  chore: Bump version to 3.3.0
  chore: Bump version to 3.3.0-rc7
  fix: Increase manifest protocol message size cap and fix manifests relay
  fix: Cap untrusted manifests per message and drop oversized ones
  chore: Bump version to 3.2.1
  chore: Bump version to 3.2.1-rc1
  fix: Cap untrusted manifests per message and drop oversized ones
  fix: Reject oversized validator manifest before decoding
  fix: Reduce untrusted manifest cache cap to 100
  fix: Bound untrusted manifest cache
  chore: Bump version to 3.3.0-rc6
  feat: Package validator-keys inside rippled
  chore: Bump version to 3.3.0-rc5
  fix: Switch SponsorshipSet to use a delta for sfFeeAmount
  fix: Re-revert "fix: Set request size limits and differential pricing for get-object-by-hash calls"
  chore: Bump version to 3.3.0-rc4
  fix: Revert "fix: Set request size limits and differential pricing for get-object-by-hash calls"
  chore: Bump version to 3.3.0-rc3
  fix: Reduce untrusted manifest cache cap to 100
  fix: Revert "fix: Reject oversized SHAMap nodes in gotStaleData and fetch-pack path"
  ...
2026-08-07 16:00:25 +01:00
Ayaz Salikhov
00a178fb92 chore: Bump version to 3.3.0 2026-08-06 17:34:39 +01:00
Gregory Tsipenyuk
8d7524f03b fix: Use consistent endianness serializing MPT STIssue sequence (#7429)
Co-authored-by: Ed Hennis <ed@ripple.com>
Co-authored-by: David Fuelling <sappenin@gmail.com>
2026-08-05 17:54:44 +00:00
Ayaz Salikhov
41d6bb5f73 build: Fix build on macOS 15 and Nix environment (#7953) 2026-08-04 23:27:23 +00:00
Bart
39c8c293b3 chore: Bump version to 3.3.0-rc7 2026-08-04 17:11:00 -04:00
Pratik Mankawde
54cfdda00b fix: Increase manifest protocol message size cap and fix manifests relay
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
2026-08-04 17:08:43 -04:00
Vito Tumas
c3ee602002 test: Split Loan_test.cpp into topical suites (#7864)
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
2026-08-04 15:43:59 +00:00
Alex Kremer
06488c1318 chore: Rename CamelCase namespaces to snake_case (#7933)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-04 13:46:55 +00:00