Skip to content

fix: Report no ledger from a failed acquisition - #8092

Open
bthomee wants to merge 1 commit into
bthomee/shamap-invalid-12-batch-progressfrom
bthomee/shamap-invalid-13-no-ledger-on-failure
Open

fix: Report no ledger from a failed acquisition#8092
bthomee wants to merge 1 commit into
bthomee/shamap-invalid-12-batch-progressfrom
bthomee/shamap-invalid-13-no-ledger-on-failure

Conversation

@bthomee

@bthomee bthomee commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Part 13/16 of a stack. Base: part 12 (bthomee/shamap-invalid-12-batch-progress).

High Level Overview of Change

InboundLedger::getLedger() now returns nothing once the acquisition has failed, so a partially-built
(and potentially unsound) ledger can never leak out through the one accessor, without requiring every
caller to check isFailed() first.

Context of Change

InboundLedger::getLedger() reports nothing once the acquisition has failed. A failed acquisition can
still hold a partially built ledger, and that ledger must never be used, so the guard sits at the one
accessor rather than resting on every caller checking isFailed() first. The pointer itself is kept,
since getJson() reports on the partial maps of a failed acquire, which is what an operator inspecting
one needs.

Two existing cases gain the assertion: the one whose transaction map is a chain found in a fetch pack,
and the one that waits out a whole timeout chain. Both already checked the failure itself; what's new is
that nothing is handed back with it.

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 prevents partially-built ledgers from being observable through InboundLedger::getLedger() after an acquisition has failed, ensuring callers can’t accidentally use an unsound ledger even if they forget to check isFailed().

Changes:

  • Update InboundLedger::getLedger() to return nullptr when the acquisition is marked failed.
  • Add/extend unit test assertions that failed acquisitions do not hand back a ledger (including cases involving a locally-resolvable tx-chain via fetch pack and a full timeout chain failure).

Reviewed changes

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

File Description
src/xrpld/app/ledger/InboundLedger.h Guard getLedger() so failed acquisitions never return the (potentially partial) ledger pointer.
src/test/app/InboundLedger_test.cpp Add assertions ensuring getLedger() returns nullptr when acquisitions fail in the covered scenarios.

💡 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-13-no-ledger-on-failure branch from ad4cebe to 4b10ea8 Compare August 23, 2026 23:45
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch from 4b10ea8 to cf629e4 Compare August 24, 2026 14:32
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

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

Comment thread src/xrpld/app/ledger/InboundLedger.h Outdated
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch from cf629e4 to cf3531e Compare August 24, 2026 15:00
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch from cf3531e to 0f0ff0d Compare August 24, 2026 15:24
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch 2 times, most recently from b4a90b0 to 59f8bfd Compare August 25, 2026 19:36
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch from 59f8bfd to 1395a13 Compare August 25, 2026 19:48
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch from 1395a13 to a69203b Compare August 25, 2026 21:08
InboundLedger::getLedger() now reports nothing once the acquisition has
failed, since a failed acquisition can still hold a partially built
ledger that must never be used. The guard sits at the one accessor rather
than relying on every caller to check isFailed() first; the pointer itself
is kept, since getJson() still reports on the partial maps of a failed
acquire.
@bthomee
bthomee force-pushed the bthomee/shamap-invalid-13-no-ledger-on-failure branch from a69203b to cd79b1b Compare August 25, 2026 21:58
@bthomee
bthomee marked this pull request as ready for review August 26, 2026 00:21
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 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