Sponsored Content
Skip to content

fix: Check trustline limits for share-denominated vault withdrawals - #6645

Merged
ximinez merged 9 commits into
developfrom
tapanito/fix-vault-withdraw-shares
Apr 1, 2026
Merged

fix: Check trustline limits for share-denominated vault withdrawals#6645
ximinez merged 9 commits into
developfrom
tapanito/fix-vault-withdraw-shares

Conversation

@Tapanito

Copy link
Copy Markdown
Contributor

VaultWithdraw preclaim skipped the canWithdraw trustline limit check when the withdrawal amount was specified in shares (MPT) rather than assets. Convert shares to the equivalent asset amount before calling canWithdraw so that the destination's trustline limit is enforced regardless of denomination.

Gated behind fixAssortedFixes 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)

VaultWithdraw preclaim skipped the canWithdraw trustline limit check
when the withdrawal amount was specified in shares (MPT) rather than
assets. Convert shares to the equivalent asset amount before calling
canWithdraw so that the destination's trustline limit is enforced
regardless of denomination.

Gated behind fixAssortedFixes for ledger replay compatibility.
Move sleIssuance ledger read inside the fixAssortedFixes branch
where it is actually needed, avoiding an unnecessary read on the
pre-amendment and asset-denominated paths. Reuse existing account
and dstAcct variables instead of recomputing from and to. Add
pre-amendment test to verify the old behavior (share-denominated
withdrawal bypasses trustline limit check) alongside the post-fix
behavior. Fix stale comments in the test.
@Tapanito Tapanito added Amendment AI Triage Bugs and fixes that have been triaged via AI initiatives labels Mar 25, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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:48
@Tapanito

Copy link
Copy Markdown
Contributor Author

/ai-review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rounding safety concern and two code-quality issues flagged inline — see comments at lines 70, 76, and 90.


Review by ReviewBot 🤖

Review by Claude Opus 4.6 · Prompt: V12

Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp
Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Outdated
Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Outdated
@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.4%. Comparing base (bee1056) to head (3545eee).
⚠️ Report is 26 commits behind head on develop.

Files with missing lines Patch % Lines
src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp 60.0% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6645     +/-   ##
=========================================
- Coverage     81.5%   81.4%   -0.0%     
=========================================
  Files          999     999             
  Lines        74467   74483     +16     
  Branches      7554    7560      +6     
=========================================
+ Hits         60660   60663      +3     
- Misses       13807   13820     +13     
Files with missing lines Coverage Δ
src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp 92.4% <60.0%> (-6.6%) ⬇️

... and 3 files 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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gave this a review

Two issues flagged inline: a rounding-direction concern in the share→asset conversion that could allow boundary bypass, and a tec/tef inconsistency on the unreachable error path.


Review by ReviewBot 🤖

Review by Claude Opus 4.6 · Prompt: V12

Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp
Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a VaultWithdraw preclaim gap where withdrawals specified in vault shares (MPT) could bypass the destination IOU trustline limit check by converting share-denominated amounts into the underlying asset amount before applying canWithdraw (gated by an amendment for replay compatibility).

Changes:

  • Update VaultWithdraw::preclaim to convert share-denominated withdrawals into asset-denominated amounts (when the fix amendment is enabled) before calling canWithdraw.
  • Add a regression test reproducing the trustline-limit bypass when withdrawing in shares vs assets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Converts share-denominated withdrawal amounts to asset amounts (behind fixSecurity3_1_3) so trustline limits are enforced consistently.
src/test/app/Vault_test.cpp Adds a unit test demonstrating the pre-fix bypass and asserting rejection post-fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Outdated
Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One inconsistency flagged inline — tecINTERNAL vs tefINTERNAL for analogous unreachable error paths.

Review by Claude Opus 4.6 · Prompt: V12

Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Outdated

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Had a read through

Trust line limit bypass for share-denominated vault withdrawals flagged inline — the fix is correctly gated behind the amendment, preserving pre-amendment ledger replay behaviour.


Review by ReviewBot 🤖

Review by Claude Opus 4.6 · Prompt: V12

Comment thread src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp
ctx.tx.isFieldPresent(sfDestinationTag)))
return ret;
}
catch (std::overflow_error const&)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Theoretically the try block can throw more error types, like std::runtime_error and STObject::FieldErr

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's right, but here we specifically want to handle only overflow exceptions. Others exceptions are handled up the call-stack.

@pratikmankawde pratikmankawde left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Tapanito Tapanito added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Mar 31, 2026
@ximinez
ximinez added this pull request to the merge queue Apr 1, 2026
Merged via the queue into develop with commit 02fa55d Apr 1, 2026
2 of 3 checks passed
@ximinez
ximinez deleted the tapanito/fix-vault-withdraw-shares branch April 1, 2026 19:54
@ximinez ximinez added this to the 3.1.3 milestone Apr 15, 2026
@ximinez ximinez modified the milestones: 3.1.3, 3.1.3 (develop) Apr 15, 2026
marek-foss-neti pushed a commit to marek-foss-neti/rippled that referenced this pull request May 5, 2026
@mvadari mvadari modified the milestones: 3.1.3 (develop), 3.2.0 May 20, 2026
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
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 Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants