Skip to content

fix: Add feePayer logic in txQ#7613

Draft
yinyiqian1 wants to merge 2 commits into
XRPLF:developfrom
yinyiqian1:delegate-txQ-new
Draft

fix: Add feePayer logic in txQ#7613
yinyiqian1 wants to merge 2 commits into
XRPLF:developfrom
yinyiqian1:delegate-txQ-new

Conversation

@yinyiqian1

@yinyiqian1 yinyiqian1 commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

High Level Overview of Change

Because the delegated transactions are paid by the sfDelegate, but not sfAccount:

  • TxQ might reject some transactions that should be queueable by incorrectly counting delegate-paid fees against the principal account.
  • It may also undercount the total queued fees owed by a delegate across different accounts, allowing transactions into the queue that the actual fee payer may not be able to cover later.

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)

@yinyiqian1 yinyiqian1 force-pushed the delegate-txQ-new branch 5 times, most recently from 58a9693 to c6f58e5 Compare June 24, 2026 19:27
@yinyiqian1 yinyiqian1 marked this pull request as ready for review June 24, 2026 20:16
Comment thread src/xrpld/app/misc/detail/TxQ.cpp
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.0%. Comparing base (4fec582) to head (1a21b74).
⚠️ Report is 13 commits behind head on develop.

Files with missing lines Patch % Lines
src/xrpld/app/misc/detail/TxQ.cpp 92.7% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7613     +/-   ##
=========================================
- Coverage     82.0%   82.0%   -0.0%     
=========================================
  Files         1007    1007             
  Lines        76890   76925     +35     
  Branches      8971    8979      +8     
=========================================
+ Hits         63049   63059     +10     
- Misses       13832   13857     +25     
  Partials         9       9             
Files with missing lines Coverage Δ
src/xrpld/app/misc/TxQ.h 100.0% <100.0%> (ø)
src/xrpld/rpc/handlers/account/AccountInfo.cpp 85.5% <100.0%> (+0.1%) ⬆️
src/xrpld/app/misc/detail/TxQ.cpp 96.8% <92.7%> (-0.3%) ⬇️

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

else
{
sleAccountBump->setFieldAmount(sfBalance, accountBalance - potentialAccountSpend);
sleFeePayerBump->setFieldAmount(sfBalance, balance - totalFee);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Severity: MEDIUM

The fee payer's test-view balance is reduced only by their aggregate queued fees (totalFee), but ignores their own queued potentialSpend from their personal transaction queue. A fee payer with a large queued payment can appear to have more available balance than they will actually have, allowing delegated transactions into the queue whose fees exceed the payer's real post-spend capacity.
Helpful? Add 👍 / 👎

💡 Fix Suggestion

Suggestion: The fee payer's own queued potentialSpend (from transactions where the fee payer acts as the account) must also be deducted from their test-view balance. To fix this:

  1. After computing totalFee (around lines 1059-1072), add a new block that looks up the fee payer's own queued transactions in byAccount_[feePayer] (when feePayer != account) and sums their potentialSpend() into a new variable, e.g. feePayerOwnSpend.

  2. Update the balance gate check at line 1124 to also account for the fee payer's own potential spend: change totalFee >= balance to (totalFee + feePayerOwnSpend) >= balance (and similarly for the reserve check).

  3. At line 1159, change balance - totalFee to balance - totalFee - feePayerOwnSpend (clamped appropriately to avoid underflow), so the test-view balance reflects both the fees owed as a delegate payer and the fee payer's own queued transaction spend.

This ensures that a fee payer who has queued large payments under their own account cannot appear to have more available balance than they will actually have after those payments execute.

@yinyiqian1 yinyiqian1 marked this pull request as draft June 26, 2026 17:34
@github-actions

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant