Sponsored Content
Skip to content

fix: Check if the MPT first loss cover can be sent to the broker before deleting the broker - #7125

Merged
bthomee merged 10 commits into
developfrom
a1q123456/fix-loanbrokerdelete-preclaim
May 22, 2026
Merged

fix: Check if the MPT first loss cover can be sent to the broker before deleting the broker#7125
bthomee merged 10 commits into
developfrom
a1q123456/fix-loanbrokerdelete-preclaim

Conversation

@a1q123456

Copy link
Copy Markdown
Contributor

High Level Overview of Change

This PR adds some checks in LoanBrokerDelete::preclaim to ensure we can send the MPT to the broker account when we delete it.

Context of Change

It's currently possible to bypass MPT locks. preclaim() only validates the destination owner's freeze state, never the source pseudo-account. doApply() then transfers sfCoverAvailable via accountSend(), and the low-level MPT send path does not revalidate locks.

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)

@a1q123456 a1q123456 changed the title fix: check if the MPT can be sent to the broker before sending fix: check if the MPT can be sent to the broker before deleting the broker May 12, 2026
@a1q123456 a1q123456 changed the title fix: check if the MPT can be sent to the broker before deleting the broker fix: check if the MPT first loss cover can be sent to the broker before deleting the broker May 12, 2026
@a1q123456 a1q123456 changed the title fix: check if the MPT first loss cover can be sent to the broker before deleting the broker fix: Check if the MPT first loss cover can be sent to the broker before deleting the broker May 12, 2026

@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.

Went over the changes

One likely copy-paste bug flagged inline: the deep-freeze check targets brokerOwner (already checked earlier) instead of brokerPseudo, making the new check a no-op.


Review by ReviewBot 🤖

Review by Claude Opus 4.6 · Prompt: V15

Comment thread src/libxrpl/tx/transactors/lending/LoanBrokerDelete.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.

Misleading copy-pasted comments flagged inline — assertions are correct but comments need updating.

Review by Claude Opus 4.6 · Prompt: V15

Comment thread src/test/app/LoanBroker_test.cpp Outdated
@a1q123456
a1q123456 marked this pull request as draft May 12, 2026 17:05
@a1q123456

Copy link
Copy Markdown
Contributor Author

Making it a draft for a couple of hours to investigate a potential bug.

@a1q123456
a1q123456 marked this pull request as ready for review May 12, 2026 17:11

@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.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.1%. Comparing base (93836f2) to head (67726f4).
⚠️ Report is 21 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7125     +/-   ##
=========================================
- Coverage     82.1%   82.1%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        76151   76170     +19     
  Branches      7424    7410     -14     
=========================================
+ Hits         62497   62512     +15     
- Misses       13654   13658      +4     
Files with missing lines Coverage Δ
...ibxrpl/tx/transactors/lending/LoanBrokerDelete.cpp 89.9% <100.0%> (+0.8%) ⬆️

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

Comment thread src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp Outdated
@a1q123456
a1q123456 requested a review from Tapanito May 18, 2026 10:34

@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.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

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

This PR tightens LoanBrokerDelete validation to prevent bypassing MPToken lock/freeze restrictions when returning broker cover during deletion. It ensures the broker pseudo-account is eligible to send the cover back to the broker owner before deletion proceeds (amendment-gated), and adds regression tests covering both MPToken lock and IOU freeze scenarios.

Changes:

  • Add an amendment-gated preclaim() check to validate the broker pseudo-account is not frozen/locked for the vault asset when cover would be transferred.
  • Add a regression test ensuring locked MPToken cover cannot be returned to the owner via broker deletion when the fix is enabled.
  • Add a regression test ensuring a frozen IOU trustline on the broker pseudo-account blocks broker deletion early (with the fix) vs invariant failure (without).

Reviewed changes

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

File Description
src/test/app/LoanBroker_test.cpp Adds regression tests for LoanBrokerDelete behavior when the broker pseudo-account’s holding is locked (MPT) or frozen (IOU), with/without fixCleanup3_2_0.
src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp Adds fixCleanup3_2_0-gated preclaim() call to checkFrozen() on the broker pseudo-account when cover would be returned.

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

@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.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@Tapanito Tapanito 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.

Comment thread src/libxrpl/tx/transactors/lending/LoanBrokerDelete.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.

Gave this a review

One misleading log message flagged inline — the text says "deep-frozen" but the check is checkFrozen on the pseudo-account, not the owner.


Review by ReviewBot 🤖

Review by Claude Opus 4.6 · Prompt: V15

Comment thread src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp Outdated
@Tapanito Tapanito added this to the 3.2.0 milestone May 19, 2026
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>

@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.

No issues.

Review by Claude Opus 4.6 · Prompt: V15

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

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

@a1q123456
a1q123456 removed the request for review from pratikmankawde May 22, 2026 11:20
@a1q123456 a1q123456 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 May 22, 2026
@bthomee
bthomee added this pull request to the merge queue May 22, 2026
Merged via the queue into develop with commit 179e735 May 22, 2026
3 checks passed
@bthomee
bthomee deleted the a1q123456/fix-loanbrokerdelete-preclaim branch May 22, 2026 12:33
Kassaking7 pushed a commit to Kassaking7/rippled that referenced this pull request Jun 2, 2026
…re deleting the broker (XRPLF#7125)

Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants