Skip to content

fix: Count partial batch progress in a TX-set reply - #8091

Open
bthomee wants to merge 1 commit into
bthomee/shamap-invalid-11-revive-timerfrom
bthomee/shamap-invalid-12-batch-progress
Open

fix: Count partial batch progress in a TX-set reply#8091
bthomee wants to merge 1 commit into
bthomee/shamap-invalid-11-revive-timerfrom
bthomee/shamap-invalid-12-batch-progress

Conversation

@bthomee

@bthomee bthomee commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Part 12/16 of a stack. Base: part 11 (bthomee/shamap-invalid-11-revive-timer).

High Level Overview of Change

TransactionAcquire::takeNodes() now accumulates one combined verdict across a whole batch instead of
stopping at the first bad node, so a packet that ends badly still gets credit — and clears the
timeout-postponing progress flag — for the good nodes ahead of it, matching what
InboundLedger::receiveNode() already does.

Context of Change

TransactionAcquire::takeNodes() accumulates one SHAMapAddNode across the batch and hands it back, so
a packet ending on one bad node still counts the nodes hooked in ahead of it. A root the set already
holds counts as a duplicate rather than passing unremarked, which is what tells a batch of nodes we
already have from one that was never examined at all.

The body moves to takeNodesLocked() and takeNodes() becomes a thin wrapper that takes the lock and
records what the batch achieved on the one exit — several of the inner exits stop the batch early, and
nothing in the compiler catches one that forgets to record progress. Progress turns on the batch being
useful rather than good, so a batch of nothing but duplicates records none: that flag is what keeps the
next timer tick from counting a timeout, and a reply carrying nothing new advanced nothing. It costs
retry budget on the ordinary second responder to a fan-out and nothing else.

InboundTransactions::gotData() asks isGood() rather than isUseful() for the useless-data charge,
which keeps that duplicate free — now that the verdict distinguishes a duplicate from an empty tally,
the useful test would charge for it while the batch that was never examined still needs charging.

testPartialBatchIsCounted feeds two good nodes followed by one at a position it cannot occupy, and
checks the verdict names both halves and that the flag is set; then a batch of nothing but a root
already held, checking it is good, not useful, and records nothing; then that root alongside a node the
set does need, checking the duplicate is reported as one while the other records the progress.

API Impact

None of the checkboxes below apply: this is an internal xrpld correctness fix with no libxrpl,
public-API, or peer-protocol surface.

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 improves TransactionAcquire::takeNodes() accounting so partial success in a TX-set node batch is preserved (good nodes counted) even when the batch ends with a bad node, and “progress” is recorded based on actual map advancement rather than “overall good.” This aligns TX-set acquisition behavior with how inbound ledger node batches are already handled.

Changes:

  • Refactors TransactionAcquire::takeNodes() to delegate to takeNodesLocked() and record progress on a single exit path based on SHAMapAddNode::isUseful().
  • Accumulates a combined SHAMapAddNode verdict across the whole batch, including explicit duplicate counting for an already-held root.
  • Updates InboundTransactions::gotData() to charge useless-data fees based on !san.isGood() (so duplicate-only replies are not charged) and adds a focused regression test.

Reviewed changes

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

File Description
src/xrpld/app/ledger/detail/TransactionAcquire.h Documents batch-level verdict semantics and introduces takeNodesLocked() for single-exit progress recording.
src/xrpld/app/ledger/detail/TransactionAcquire.cpp Implements batch verdict accumulation, early-exit returns that preserve prior counts, and progress recording only when the batch added nodes.
src/xrpld/app/ledger/detail/InboundTransactions.cpp Adjusts useless-data charging to use isGood() so duplicate-only replies aren’t penalized while empty/unprocessed replies still are.
src/test/app/TransactionAcquire_test.cpp Adds testPartialBatchIsCounted to validate partial-batch tallying, duplicate handling, and progress flag behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from e3b71c1 to 947fac1 Compare August 23, 2026 23:45
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from 947fac1 to eacc0e4 Compare August 24, 2026 14:32
@bthomee
bthomee requested a lite review from Copilot August 24, 2026 14:40

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

@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from eacc0e4 to f325d1e Compare August 24, 2026 15:00
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from f325d1e to 838f6c0 Compare August 24, 2026 15:24
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from 838f6c0 to b17ba18 Compare August 25, 2026 15:02
@github-actions

Copy link
Copy Markdown

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

@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from b17ba18 to 268450b Compare August 25, 2026 19:36
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from 268450b to 15e802f Compare August 25, 2026 19:48
@github-actions

Copy link
Copy Markdown

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

1 similar comment
@github-actions

Copy link
Copy Markdown

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

@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from 15e802f to f9b64b8 Compare August 25, 2026 21:08
TransactionAcquire::takeNodes() now accumulates one SHAMapAddNode across
the whole batch, so a packet ending on one bad node still counts the nodes
hooked in ahead of it, matching InboundLedger::receiveNode(). The body
moves to takeNodesLocked(); takeNodes() becomes a thin wrapper that
records progress once, on the single exit, since several inner exits stop
the batch early.

Progress turns on the batch being useful rather than merely good, so an
all-duplicate batch - an honest second responder to trigger()'s fan-out -
records none but still isn't charged.
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-12-batch-progress branch from f9b64b8 to 9c62a52 Compare August 25, 2026 21:58
@bthomee
bthomee marked this pull request as ready for review August 26, 2026 00:20
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/xrpld/app/ledger/detail/TransactionAcquire.cpp 90.9% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants