mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 16:02:38 +00:00
orphanage: Fix orphan reconsideration disconnect hole, add 1p1c invariant harness #36437
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36437
Loading…
Reference in a new issue
No description provided.
Delete branch "2026-10-orphan-reconsider-handoff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The first commit adds
p2p_1p1c_liveness, an end-to-end fuzz target for parent and child relay. Itdrives a real PeerManager with real messages and validation, and checks that if an honest peer announces
the child of an acceptable parent and child, the child reaches the mempool within a bounded time,
whatever other peers do. Known liveness holes are marked in the target as flags that turn the check off
once opened, including this one. With that flag turned off, the target finds this bug on master from an
empty corpus in under an hour on one core; an earlier version found it first
(https://github.com/bitcoin/bitcoin/pull/36371#issuecomment-5937814761).
The second commit hands reconsideration over to a remaining announcer when the marked announcement is
erased, and removes the flag.
Follow-up PR to fill the holes is here: https://github.com/bitcoin/bitcoin/pull/36506
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Prior harness found this PR's issue that is fixed, and this harness development found "R11", so I think it's already paid for itself
Concept review notes
Diff. Two commits.
294d6ffcd0changesTxOrphanageImpl::Erasein about 20 lines. When the erased announcement was theone marked for reconsideration, the mark moves to the remaining announcer with the lowest NodeId. The
comment in
AddChildrenToWorkSetand the doc comment forEraseForPeerare updated, andtxorphanage_simandorphanage_testsare updated to match.345497515aadds thep2p_1p1c_livenessfuzz target (547 lines, test-only).The description matches the diff.
Problem. The node is sent a parent and a child (for example a CPFP), and the child does not reach the
mempool until the orphan expires or is evicted. The trigger is one announcer leaving at the wrong
moment, and an adversary can try to cause it. The evidence is a fuzzer reproduction on master. There is
no reported incident. The goal one level up is that 1p1c relay gets a child accepted in bounded time
whatever adversarial peers do.
Baseline. The child is delayed until orphan expiry or eviction. The attacker needs to be the randomly
chosen announcer, which is likelier with many sybil connections, and it must disconnect before its next
ProcessMessagesturn. In that turnProcessOrphanTxruns first, and the turn is skipped oncefDisconnectis set. If the attacker also supplies the parent and then closes the socket, the race isplausible. The cost is delay, not loss.
Payoff. The fix closes the hole for both the disconnect and the eviction path. The new unit and sim
tests demonstrate it, and the liveness harness checks it end to end. The payoff is modest but real.
Risks.
announcement exists." It is enforced by construction, because every removal of an announcement goes
through
Erase<Tag>.exposure, and no new Asserts.
maintenance work and flakiness.
Prior discussion. This came up in #31666, which introduced the single random announcer:
(https://github.com/bitcoin/bitcoin/pull/31666#discussion_r1934078679), and instagibbs laid out the
disconnect attack.
entries "on to another random announcer" at disconnect
(https://github.com/bitcoin/bitcoin/pull/31666#discussion_r1934886294).
That proposal was deferred, not rejected. This PR implements it, and the fuzzer reproduction is new
evidence against the impracticality point. No closed PRs attempt this fix.
Alternatives.
changes the TxOrphanage interface and moves the cost of other peers' work into each peer's processing
turn.
yet known, but adds a second mechanism and CPU cost.
ed24e01696(at most one reconsiderable announcementper wtxid) and wastes work. This is glozow's argument from #31666.
Also glozow's argument from #31666.
processing budget, a larger change in a costlier place.
The PR takes the shallowest placement of the candidates.
Dominance: none.
Verdict: Concept ACK. The fix delivers the payoff without the harness. The harness is test-only and
has already found bugs, so splitting it out would not change the verdict.
🔵 Suggestion · Confirmed funding inputs hide a remaining lost-announcement case
Every harness child has a confirmed funding input, preventing ordinary non-exempt runs from testing the lost-announcement window when all parent txids are AlreadyHaveTx.
Location:
src/test/fuzz/p2p_1p1c_liveness.cpp:139(head).🔵 Suggestion · The honest peer's lowest NodeId bypasses adversarial handover recipients
Once the honest peer is an announcer, every handover goes directly to it, leaving end-to-end coverage without an older adversary receiving the work and then disconnecting.
Location:
src/test/fuzz/p2p_1p1c_liveness.cpp:297(head).🔵 Suggestion · The fuzz target relies on transitive includes for std::span
The new target directly uses std::span without including , leaving that dependency implicit.
Location:
src/test/fuzz/p2p_1p1c_liveness.cpp:196(head).🔵 Suggestion · Waive the liveness check only when the stripped parent opens the hole
p2p_1p1c_liveness.cpp:472-476 sets parent_stripped before processing, without checking for an orphaned child or a pending parent request. An early stripped parent ends the prefix, skips the honest announcement and waives the assertion, although later orphan resolution would still request the parent.
Location:
src/test/fuzz/p2p_1p1c_liveness.cpp:472(head).Review coverage was incomplete.
Reviewed:
5cf83407d55b· Full review report · Previous reportspermalink
pushed an update to address ralph review: #36437
Concept ACK
added coinbase-based censorship cast stuff to the PR. Does not add any new holes per se, but covers more ground.
@FlashWayne this PR and the follow-up in the OP should cover known holes. If we can get this in first, then subtracting holes just becomes a matter of implementation debate, and which are worth filling.
parent_strippeddoes seem worth filling, for sure.tACK
65b48ba1f1I reproduced the hole end to end with a Boost case of my own. Peer A sends twelve children and peer B announces each of them by wtxid, so each orphan has two announcers. A then sends the parent and disconnects before its next turn, and B runs until it has no more work. On master 6 of the 12 children reach the mempool, and the other 6 stay in the orphanage with nobody to reconsider them. With this PR all 12 are accepted in 13 turns of B, and the orphanage is empty. The updated
peer_worksetscase fails on master at its new hand-over checks and passes here.The hand-over keeps the callers' iterators valid.
EraseForPeer,EraseTxInternalandLimitOrphansadvance their iterator before each erase. InErase(),lower_boundcan land on the announcement being erased, and the++skips it.modify()only changes the other announcement'sm_reconsider, which moves it withinByPeeralone, and that key stays unique throughm_entry_sequence.I tested the head merged into master
a773e1e33b, in a Debug build, with the orphanage, denialofservice and txdownload unit tests, p2p_orphan_handling and p2p_opportunistic_1p1c. Under libFuzzer, p2p_1p1c_liveness ran for 10 minutes and txorphanage_sim for 3, with no crash. I repeated all of it with #36594 and #36578 merged on top, with the liveness target for 5 minutes and txorphanage_sim for 1. I can share the test case as a gist.Could rebase this now
rebased
Concept ACK
Concept ACK
I reproduced it on regtest: peer A sends 12 orphan children, peer B announces them, then A sends the parent and disconnects. With the fix reverted, the children assigned to A stay stuck in the orphanage (30/60). With this PR, all are accepted.
With the fix reverted,
peer_worksetsfails andtxorphanage_simcrashes on the qa-assets corpus.With help from an LLM I tried to get
p2p_1p1c_livenessto find the bug with the fix reverted, but it didn't (30 min, 7 workers). It looks like a disconnect only happens afterprocess()drains all work sets. Is this path still reachable by the current harness?@AndreaDiazCorreia
XHgAAAQAAAEAAAQBAwIAAQEAAAIBAQEAAQABAQEAAQAAAQECshould do it. I'm double checking if it's reachable naturally in a short amount of time. process() does not always drain work setedit: yeah seems hard to reach, but definitely can
closing in favor of https://github.com/bitcoin/bitcoin/pull/36506