Skip to content

fix: Clamp VaultClawback to assetsAvailable for zero-amount clawback#6646

Open
Tapanito wants to merge 3 commits intodevelopfrom
tapanito/fix-vault-clawback-clamp
Open

fix: Clamp VaultClawback to assetsAvailable for zero-amount clawback#6646
Tapanito wants to merge 3 commits intodevelopfrom
tapanito/fix-vault-clawback-clamp

Conversation

@Tapanito
Copy link
Collaborator

Zero-amount clawback (meaning "clawback all") returned early without clamping to assetsAvailable, allowing more assets to be recovered than available when there was an outstanding loan. Move the zero-amount path inside the try block so it shares the same clamping logic as non-zero clawback.

The old early-return behavior is retained behind a !fixAssortedFixes gate for ledger replay compatibility.

High Level Overview of Change

Context of Change

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)

Zero-amount clawback (meaning "clawback all") returned early without
clamping to assetsAvailable, allowing more assets to be recovered than
available when there was an outstanding loan. Move the zero-amount
path inside the try block so it shares the same clamping logic as
non-zero clawback.

The old early-return behavior is retained behind a !fixAssortedFixes
gate for ledger replay compatibility.
@Tapanito Tapanito added Amendment AI Triage Bugs and fixes that have been triaged via AI initiatives labels Mar 25, 2026
- Add test for the pre-fixAssortedFixes legacy code path where
  zero-amount clawback does not clamp to assetsAvailable, verifying
  the transaction fails with tefINTERNAL for ledger replay fidelity
- Remove unused sharesBefore variable in zero-amount post-fix test
- Normalize env.balance() calls to use PrettyAsset directly
- Strengthen non-zero clawback share assertions from inequality
  checks to exact expected values matching the zero-amount test
@github-actions
Copy link

This PR has conflicts, please resolve them in order for the PR to be reviewed.

…_1_3

Resolve amendment conflict: drop placeholder fixAssortedFixes, adopt
fixSecurity3_1_3 (Supported::no) from develop. Update VaultClawback
and tests to reference the new amendment name and explicitly enable
it in the test Env since it is disabled by default.
@github-actions
Copy link

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@Tapanito Tapanito marked this pull request as ready for review March 26, 2026 09:47
@Tapanito
Copy link
Collaborator Author

/ai-review

Copy link
Contributor

@xrplf-ai-reviewer xrplf-ai-reviewer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One low-severity naming collision in setupVault — see inline.

Review by Claude Opus 4.6 · Prompt: V12

@codecov
Copy link

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.5%. Comparing base (2c765f6) to head (1dbf8dd).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6646   +/-   ##
=======================================
  Coverage     81.4%   81.5%           
=======================================
  Files          998     998           
  Lines        74443   74450    +7     
  Branches      7563    7558    -5     
=======================================
+ Hits         60632   60640    +8     
+ Misses       13811   13810    -1     
Files with missing lines Coverage Δ
src/libxrpl/tx/transactors/vault/VaultClawback.cpp 97.8% <100.0%> (+0.1%) ⬆️

... and 1 file with indirect coverage changes

Impacted file tree graph

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Triage Bugs and fixes that have been triaged via AI initiatives Amendment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant