Commit Graph

14337 Commits

Author SHA1 Message Date
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 3.3.0 2026-08-06 17:34:39 +01:00
Ayaz Salikhov
cb425647a4 ci: Generate protocol_autogen only once in CI (#7918) 2026-08-06 13:25:28 +00:00
Ayaz Salikhov
5bf24c4045 ci: Use a separate benchmark filter (#7919) 2026-08-06 11:04:41 +00: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
Ed Hennis
15d08770bf Merge branch 'release/3.2.x' into ximinez/merge-321-to-330
* release/3.2.x:
  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
2026-08-04 13:28:52 -04:00
Ayaz Salikhov
a75488e5ff docs: Add a fix for command not found: nix on macOS (#7951) 2026-08-04 16:17:41 +00: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
Vito Tumas
e0de716ee6 fix: Watch nix/*.nix files for direnv cache invalidation (#7948) 2026-08-04 13:49:18 +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
Luc des Trois Maisons
b8451ffa32 fix: Add missing value_type to JSON iterators (#7907) 2026-08-03 21:17:23 +00:00
Timur Yalymov
765babb20d fix: Add VaultInvariant check that lossUnrealized is non-negative (#7863)
Co-authored-by: Vito Tumas <5780819+Tapanito@users.noreply.github.com>
2026-08-03 21:11:33 +00:00
Braedon Klock
97f35add2e fix: Add null check for account object reads (#7717)
Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
2026-08-03 21:08:42 +00:00
Pratik Mankawde
8461ded0d8 fix: Cap untrusted manifests per message and drop oversized ones 2026-08-03 12:00:11 -04:00
Ed Hennis
d4c1359921 chore: Bump version to 3.2.1 3.2.1 2026-07-31 19:46:17 -04:00
Bart
a88ba66fce chore: Bump version to 3.2.1-rc1 2026-07-31 19:43:19 -04:00
Valentin Balaschenko
4bd1d1ca2f fix: Cap untrusted manifests per message and drop oversized ones
Bound the number of manifests carried in a single TMManifests message
(kMaxManifestsPerMessage). Trusted manifests are always included and
processed; untrusted gossip is capped per message on both send and
receive, and the sender is charged only when untrusted entries are
actually skipped. Oversized TMManifests messages are dropped without
penalty at the protocol layer so an unpatched peer is not disconnected.

Complements the cache bound from #276/#323.
2026-07-31 19:43:18 -04:00
Bart
0cce5a06d9 fix: Reject oversized validator manifest before decoding 2026-07-31 19:43:18 -04:00
Pratik Mankawde
32a9cc4038 fix: Reduce untrusted manifest cache cap to 100 2026-07-31 19:43:15 -04:00
Pratik Mankawde
587505ef18 fix: Bound untrusted manifest cache 2026-07-31 19:43:04 -04:00
Alex Kremer
ecdd457f35 chore: Gtest migration followups first pass (#7884) 2026-07-30 23:04:38 +00:00
Ayaz Salikhov
85e73cbd32 ci: Run coverage first in CI (#7917) 2026-07-30 19:28:31 +00:00
Bart
4eece4003d chore: Bump version to 3.3.0-rc6 2026-07-30 16:34:46 +01:00
Ayaz Salikhov
3ad6ce236e feat: Package validator-keys inside rippled 2026-07-30 11:29:37 -04:00
Bart
21cd615407 perf: Replace node ID by depth in TMLedgerNode (#6353)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-07-30 15:02:05 +00:00
Olek
3c0659d26b test: Add confidential mpt bulletproof tests (#7816) 2026-07-30 12:18:33 +00:00
Copilot
532506541f fix: Apply asfDisallowIncomingTrustline blocker to OfferCreate (#6307)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Mayukha Vadari <mvadari@gmail.com>
Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
2026-07-30 12:17:32 +00:00
Vito Tumas
8a5eded4f1 feat: Implement LoanBroker cash-basis accounting (#7817) 2026-07-30 11:55:39 +00:00
Alex Kremer
6ddad54985 chore: Move lexical cast tests to gtest (#7873) 2026-07-29 22:54:46 +00:00
Bart
ccb9db0bc7 chore: Bump version to 3.3.0-rc5 2026-07-29 14:25:13 -04:00
Mayukha Vadari
24b6dad287 fix: Switch SponsorshipSet to use a delta for sfFeeAmount 2026-07-29 14:24:55 -04:00
Bart
e290005db5 fix: Re-revert "fix: Set request size limits and differential pricing for get-object-by-hash calls" 2026-07-28 14:02:49 -04:00
Alex Kremer
86832edc70 chore: Move semantic version tests to gtest (#7872)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-27 18:48:53 +00:00