Sponsored Content
Skip to content

fix: Prevent stale AuthAccounts from persisting after tfTwoAssetIfEmpty re-initialization - #6996

Merged
bthomee merged 12 commits into
XRPLF:developfrom
Kassaking7:DEFI-648
May 9, 2026
Merged

fix: Prevent stale AuthAccounts from persisting after tfTwoAssetIfEmpty re-initialization#6996
bthomee merged 12 commits into
XRPLF:developfrom
Kassaking7:DEFI-648

Conversation

@Kassaking7

Copy link
Copy Markdown
Contributor

High Level Overview of Change

When an AMM pool is emptied and re-initialized via a tfTwoAssetIfEmpty deposit, initializeFeeAuctionVote() resets the auction slot fields (sfAccount, sfExpiration, sfPrice, sfDiscountedFee) but does not clear sfAuthAccounts. Stale authorized accounts from the previous auction slot holder persist and get discounted trading fees (TradingFee/10) without the new depositor's knowledge or consent.

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)

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.1%. Comparing base (af89854) to head (6b8473b).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6996     +/-   ##
=========================================
- Coverage     82.1%   82.1%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        76040   76070     +30     
  Branches      7371    7375      +4     
=========================================
+ Hits         62423   62437     +14     
- Misses       13617   13633     +16     
Files with missing lines Coverage Δ
src/libxrpl/ledger/helpers/AMMHelpers.cpp 95.6% <100.0%> (+<0.1%) ⬆️

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

@Kassaking7 Kassaking7 changed the title fix: prevent stale AuthAccounts persist after tfTwoAssetIfEmpty re-initialization fix: Prevent stale AuthAccounts persist after tfTwoAssetIfEmpty re-initialization Apr 22, 2026
Comment thread include/xrpl/protocol/detail/features.macro Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
@github-actions

Copy link
Copy Markdown

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

Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
@Kassaking7
Kassaking7 requested a review from yinyiqian1 April 28, 2026 16:08
@github-actions

Copy link
Copy Markdown

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

@yinyiqian1

Copy link
Copy Markdown
Contributor

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
@Kassaking7
Kassaking7 requested a review from yinyiqian1 April 28, 2026 17:27

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

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

@Kassaking7 Kassaking7 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 6, 2026
@bthomee
bthomee requested a review from Copilot May 7, 2026 15:56

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 an AMM fee-auction state bug where sfAuthAccounts could persist across an empty-pool reinitialization (via tfTwoAssetIfEmpty deposit), unintentionally granting discounted fees to previously authorized accounts after the auction slot is reset.

Changes:

  • Clear sfAuthAccounts during initializeFeeAuctionVote() when fixCleanup3_2_0 is enabled, preventing stale authorized accounts from persisting across re-initialization.
  • Add a regression test that reproduces the empty-pool reinit scenario and asserts the corrected sfAuctionSlot / sfVoteSlots state (with and without the fix enabled).

Reviewed changes

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

File Description
src/libxrpl/ledger/helpers/AMMHelpers.cpp Clears sfAuthAccounts on AMM empty-state reinitialization when the relevant fix is enabled.
src/test/app/AMM_test.cpp Adds a regression test covering stale sfAuthAccounts persistence across tfTwoAssetIfEmpty reinitialization.

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

Comment thread src/test/app/AMM_test.cpp
@bthomee bthomee changed the title fix: Prevent stale AuthAccounts persist after tfTwoAssetIfEmpty re-initialization fix: Prevent stale AuthAccounts from persisting after tfTwoAssetIfEmpty re-initialization May 7, 2026
@bthomee
bthomee added this pull request to the merge queue May 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 7, 2026
@bthomee
bthomee added this pull request to the merge queue May 9, 2026
Merged via the queue into XRPLF:develop with commit 779b49c May 9, 2026
3 checks passed
@mvadari mvadari added this to the 3.2.0 milestone May 20, 2026
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
…pty` re-initialization (XRPLF#6996)

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

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