Sponsored Content
Skip to content

fix: Use account ledger entry when canceling token escrows - #6171

Merged
bthomee merged 7 commits into
developfrom
dangell7/fix-token-escrow
May 18, 2026
Merged

fix: Use account ledger entry when canceling token escrows#6171
bthomee merged 7 commits into
developfrom
dangell7/fix-token-escrow

Conversation

@dangell7

@dangell7 dangell7 commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

This PR fixes a critical bug in EscrowCancel.

Context of Change

1. EscrowCancel Bug Fix (Original Issue)

A bug in EscrowCancel::doApply() caused a edge case when canceling token escrows in a specific scenario:

Scenario:

  1. Account creates an escrow with tokens
  2. Account deletes their trust line after paying back tokens
  3. Account attempts to cancel the escrow

Problem: Line 1288 incorrectly passed the escrow ledger entry (slep) instead of the account ledger entry (sle) to escrowUnlockApplyHelper, causing it to access the wrong object type when checking OwnerCount for trust line recreation.

Solution: Pass the correct account SLE, allowing proper trust line recreation and token return.

Type of Change

  • Bug fix (fixes EscrowCancel runtime exception)
  • Tests (comprehensive test coverage for all changes)

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change
  • Peer protocol change

Before / After

Before

  1. EscrowCancel bug: Canceling escrow with deleted trust line → tefEXCEPTION

After (with fixCleanup3_2_0)

  1. EscrowCancel fix: Canceling escrow with deleted trust line → tesSUCCESS (recreates trust line)

@dangell7
dangell7 requested review from a team and Copilot January 5, 2026 22:49
@dangell7 dangell7 changed the title feature TokenEscrowV2 fix/feature TokenEscrowV2 Jan 5, 2026

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 consolidates the TokenEscrow feature and fixTokenEscrowV1 fix into a new TokenEscrowV2 amendment, while addressing a critical bug in EscrowCancel that caused an edge case when canceling token escrows after trust line deletion.

  • Fixes a bug in EscrowCancel::doApply() where the escrow ledger entry was incorrectly passed instead of the account ledger entry to the token return helper function
  • Consolidates TokenEscrow and fixTokenEscrowV1 into a single TokenEscrowV2 amendment for cleaner implementation
  • Adds comprehensive test coverage for IOU and MPT escrow cancellation scenarios after trust line deletion

Reviewed changes

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

Show a summary per file
File Description
include/xrpl/protocol/detail/features.macro Introduces TokenEscrowV2 feature and retires TokenEscrow and fixTokenEscrowV1
src/xrpld/app/tx/detail/Escrow.cpp Fixes critical bug (line 1283: passes sle instead of slep), updates all feature checks to featureTokenEscrowV2, and simplifies MPT unlock logic
src/xrpld/app/tx/detail/SetAccount.cpp Updates feature check for trust line locking flag to use featureTokenEscrowV2
src/xrpld/rpc/handlers/AccountInfo.cpp Updates feature check for trust line locking flag to use featureTokenEscrowV2
src/libxrpl/ledger/View.cpp Removes fixTokenEscrowV1 conditional logic from rippleUnlockEscrowMPT
src/test/app/EscrowToken_test.cpp Adds testIOUCancelDoApply and testMPTCancelDoApply tests for the bug fix scenario, updates feature references, removes fixTokenEscrowV1 test variant
src/test/app/Escrow_test.cpp Updates feature checks to featureTokenEscrowV2
src/test/app/AccountDelete_test.cpp Updates feature check to featureTokenEscrowV2
src/test/rpc/Feature_test.cpp Updates feature name test to expect "TokenEscrowV2"
src/test/rpc/AccountInfo_test.cpp Updates feature checks to featureTokenEscrowV2
src/test/jtx/Env_test.cpp Updates all test feature bitset operations to use featureTokenEscrowV2

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

@codecov

codecov Bot commented Jan 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.1%. Comparing base (ad7232c) to head (55550f9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6171     +/-   ##
=========================================
- Coverage     82.1%   82.1%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        76163   76164      +1     
  Branches      7414    7413      -1     
=========================================
- Hits         62503   62502      -1     
- Misses       13660   13662      +2     
Files with missing lines Coverage Δ
src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp 100.0% <100.0%> (ø)

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

@dangell7 dangell7 closed this Jan 5, 2026
@dangell7
dangell7 force-pushed the dangell7/fix-token-escrow branch from f36b160 to 44d21b8 Compare January 5, 2026 23:34
@dangell7 dangell7 reopened this Jan 5, 2026
@dangell7 dangell7 changed the title fix/feature TokenEscrowV2 fix TokenEscrowV2 Jan 5, 2026
@dangell7 dangell7 changed the title fix TokenEscrowV2 Fix: EscrowCancel Runtime Exception with Token Escrows Jan 5, 2026
Comment thread include/xrpl/protocol/detail/features.macro Outdated
Copilot AI review requested due to automatic review settings January 6, 2026 00:00
@dangell7
dangell7 force-pushed the dangell7/fix-token-escrow branch from 63d3115 to c543d42 Compare January 6, 2026 00:02

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 3 out of 3 changed files in this pull request and generated 1 comment.


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

Comment thread src/test/app/EscrowToken_test.cpp Outdated
Comment thread src/xrpld/app/tx/detail/Escrow.cpp Outdated
@dangell7 dangell7 changed the title Fix: EscrowCancel Runtime Exception with Token Escrows Fix: Token Escrow - Enable AMM/Blackholed Issuers and Fix EscrowCancel Feb 6, 2026
Copilot AI review requested due to automatic review settings February 6, 2026 10:20

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 8 out of 8 changed files in this pull request and generated no new comments.


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

Copilot AI review requested due to automatic review settings February 6, 2026 12:42

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 8 out of 8 changed files in this pull request and generated no new comments.


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

Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/AMM_test.cpp Outdated
Comment thread src/test/app/EscrowToken_test.cpp Outdated
@github-actions

Copy link
Copy Markdown

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

@godexsoft

This comment has been minimized.

@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

@mvadari mvadari added this to the 3.2.0 milestone May 12, 2026
@mvadari

mvadari commented May 12, 2026

Copy link
Copy Markdown
Contributor

Please fix clang-tidy

@mvadari
mvadari requested a review from oleks-rip May 12, 2026 13:18

@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

@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

@mvadari

mvadari commented May 14, 2026

Copy link
Copy Markdown
Contributor

@dangell7 is this ready to merge?
cc @bthomee

@dangell7

Copy link
Copy Markdown
Contributor Author

@dangell7 is this ready to merge? cc @bthomee

Should be good after this conflict resolve

@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

@mvadari

mvadari commented May 15, 2026

Copy link
Copy Markdown
Contributor

@dangell7 looks like everything broke lol

@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

@mvadari mvadari 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 16, 2026
@bthomee bthomee changed the title fix: Token Escrow - Fix EscrowCancel fix: Use account ledger entry when canceling token escrows May 18, 2026
@bthomee
bthomee added this pull request to the merge queue May 18, 2026
@bthomee
bthomee removed this pull request from the merge queue due to a manual request May 18, 2026
@bthomee
bthomee enabled auto-merge May 18, 2026 19:35

@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

@bthomee
bthomee added this pull request to the merge queue May 18, 2026
Merged via the queue into develop with commit ad3d172 May 18, 2026
3 checks passed
@bthomee
bthomee deleted the dangell7/fix-token-escrow branch May 18, 2026 20:45
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