Skip to content

fix: Prevent deletion of MPTokens with active escrow#6635

Merged
bthomee merged 4 commits intoXRPLF:developfrom
Kassaking7:DEFI-614
Apr 6, 2026
Merged

fix: Prevent deletion of MPTokens with active escrow#6635
bthomee merged 4 commits intoXRPLF:developfrom
Kassaking7:DEFI-614

Conversation

@Kassaking7
Copy link
Copy Markdown
Collaborator

@Kassaking7 Kassaking7 commented Mar 24, 2026

High Level Overview of Change

This change prevents MPTokens from being deleted while there is still an active escrow associated with them. It ensures that token state remains consistent and avoids situations where escrowed tokens reference non-existent objects.

Context of Change

The removeEmptyHolding function in src/libxrpl/ledger/View.cpp can delete an MPToken ledger object even when it has a non-zero sfLockedAmount (i.e., funds are currently held in escrow). This orphans the escrowed funds: the Escrow ledger object still exists, but the MPToken it references has been removed. Any subsequent attempt to finish or cancel the escrow fails, resulting in permanent loss of the escrowed tokens.

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)

Copy link
Copy Markdown
Collaborator

@mvadari mvadari left a comment

Choose a reason for hiding this comment

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

This change needs to be amendment-gated, since it has already been released with Supported::yes

Copy link
Copy Markdown
Collaborator

@PeterChen13579 PeterChen13579 left a comment

Choose a reason for hiding this comment

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

Good job on your first PR! Small changes requested to make the tests more readable

Comment thread src/test/app/Vault_test.cpp Outdated
Comment thread src/test/app/Vault_test.cpp Outdated
@Kassaking7
Copy link
Copy Markdown
Collaborator Author

Do we have any other fix needed. Maybe we can batch those fixes with one amendment-gate?

@kennyzlei
Copy link
Copy Markdown
Collaborator

Do we have any other fix needed. Maybe we can batch those fixes with one amendment-gate?

@Kassaking7 it is likely we may have one amendment containing other fixes too, @bthomee any suggestions for the fix amendment name here?

@mvadari
Copy link
Copy Markdown
Collaborator

mvadari commented Mar 24, 2026

/ai-review

@xrplf-ai-reviewer
Copy link
Copy Markdown
Contributor

⚠️ Review Error — The automated review failed to complete. Please re-trigger with /ai-review.

Error: Failed to post review to GitHub after 3 attempts: Server error '500 Internal Server Error' for url 'https://api.github.com/repos/XRPLF/rippled/pulls/6635/reviews'

Review by Claude Opus 4.6 · Prompt: v12

@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Mar 24, 2026

Do we have any other fix needed. Maybe we can batch those fixes with one amendment-gate?

@Kassaking7 it is likely we may have one amendment containing other fixes too, @bthomee any suggestions for the fix amendment name here?

We don't have a name for that amendment yet, but I'll add this PR to my local release tracker sheet so when the time comes we can ask @Kassaking7 to update this PR.

In the meantime, @Kassaking7, please guard the changes by a new fix amendment with a suitable name, and then later we can swap out the amendment by the collective fix amendment before merging.

Name suggestion for now:

XRPL_FIX    (MPTLockedAmount, Supported::no, VoteBehavior::DefaultNo)

@mvadari mvadari added the AI Triage Bugs and fixes that have been triaged via AI initiatives label Mar 24, 2026
@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Mar 24, 2026

/ai-review

Copy link
Copy Markdown
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.

No issues.

Review by Claude Opus 4.6 · Prompt: V12

@Kassaking7 Kassaking7 changed the title fix: removeEmptyHolding / authorizeMPToken Delete MPToken With Active Escrow (sfLockedAmount > 0) fix: RemoveEmptyHolding / authorizeMPToken Delete MPToken With Active Escrow (sfLockedAmount > 0) Mar 25, 2026
Copy link
Copy Markdown
Collaborator

@PeterChen13579 PeterChen13579 left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Copy Markdown

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

@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Mar 26, 2026

@Kassaking7 we merged the change that introduces the fix amendment, named fixSecurity_1_3_1 for now. Would you be able to update your PR to use that amendment instead?

@github-actions
Copy link
Copy Markdown

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

@Kassaking7
Copy link
Copy Markdown
Collaborator Author

Hey @mvadari, this PR is ready for review :D

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.4%. Comparing base (c0ee813) to head (6cd9143).
⚠️ Report is 16 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6635     +/-   ##
=========================================
- Coverage     81.4%   81.4%   -0.0%     
=========================================
  Files         1006    1006             
  Lines        74451   74454      +3     
  Branches      7557    7561      +4     
=========================================
- Hits         60629   60622      -7     
- Misses       13822   13832     +10     
Files with missing lines Coverage Δ
src/libxrpl/ledger/helpers/MPTokenHelpers.cpp 96.2% <100.0%> (+<0.1%) ⬆️

... and 4 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.

@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Mar 31, 2026

@Kassaking7 can you please sign your commits? Feel free to squash all commits so you only need to sign a single one.

@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Mar 31, 2026

@Kassaking7 thanks for signing the commit(s) - is this PR now ready to merge?

@mvadari
Copy link
Copy Markdown
Collaborator

mvadari commented Mar 31, 2026

@bthomee I think this should count as a 3-reviewer PR

Comment thread src/test/app/Vault_test.cpp Outdated
runTest(features - fixSecurity3_1_3);
runTest(features | fixSecurity3_1_3);
runTest(amendments - fixSecurity3_1_3);
runTest(amendments | fixSecurity3_1_3);
Copy link
Copy Markdown
Collaborator

@yinyiqian1 yinyiqian1 Apr 2, 2026

Choose a reason for hiding this comment

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

this should be runTest(amendments)

@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Apr 3, 2026

@Kassaking7 is this PR ready to merge?

@Kassaking7
Copy link
Copy Markdown
Collaborator Author

@bthomee yes it's ready to merge :D

@bthomee bthomee 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 Apr 3, 2026
@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Apr 3, 2026

@Kassaking7 can you please do the following:

  1. Change the PR title such that, when you skip over fix: and prefix it with "When merged, this change will...." you get a proper sentence.
    a. For instance, maybe it can be changed to "Prevent deletion of MPTokens with active escrow".
    b. PR titles also use normal sentence capitalization, so do not capitalize nouns unless they are regularly capitalized.
  2. Update the PR description by following the provided template.
    a. In the first section (## High Level Overview of Change) you provide a short summary of what the change actually does. This will be similar to the PR title but will have some more details. This is currently missing.
    b. In the second section (### Context of Change) you provide background information. This is more similar to the content you have right now, as it provides the rationale for the change.

@Kassaking7 Kassaking7 changed the title fix: RemoveEmptyHolding / authorizeMPToken Delete MPToken With Active Escrow (sfLockedAmount > 0) fix: prevent deletion of mptokens with active escrow Apr 3, 2026
@mvadari
Copy link
Copy Markdown
Collaborator

mvadari commented Apr 3, 2026

This PR should be rebased onto ripple/release-313

@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented Apr 3, 2026

This PR should be rebased onto ripple/release-313

Actually @Kassaking7, I think it would be easiest if this PR gets merged as it is, and you then create a separate PR that cherry-picked just the squashed merged commit, and then targets the ripple/staging-313 branch. You will likely have to resolve some conflicts, so it's better that you do that than me since you wrote this code.

@bthomee bthomee changed the title fix: prevent deletion of mptokens with active escrow fix: Prevent deletion of MPTokens with active escrow Apr 3, 2026
@bthomee bthomee added this pull request to the merge queue Apr 6, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 6, 2026
@bthomee bthomee added this pull request to the merge queue Apr 6, 2026
Merged via the queue into XRPLF:develop with commit 077e03f Apr 6, 2026
33 checks passed
Kassaking7 added a commit to Kassaking7/rippled that referenced this pull request Apr 6, 2026
Co-authored-by: Bart <bthomee@users.noreply.github.com>
mvadari pushed a commit that referenced this pull request Apr 7, 2026
Co-authored-by: Bart <bthomee@users.noreply.github.com>
bthomee added a commit that referenced this pull request Apr 8, 2026
Co-authored-by: Bart <bthomee@users.noreply.github.com>
ximinez pushed a commit that referenced this pull request Apr 14, 2026
Co-authored-by: Bart <bthomee@users.noreply.github.com>
@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
ximinez pushed a commit that referenced this pull request Apr 22, 2026
Co-authored-by: Bart <bthomee@users.noreply.github.com>
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 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.

7 participants