Repository navigation
orphanage: Fix orphan reconsideration disconnect hole, add 1p1c invariant harness - #36437
instagibbs wants to merge 2 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, 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 notesDiff. Two commits.
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 Baseline. The child is delayed until orphan expiry or eviction. The attacker needs to be the randomly Payoff. The fix closes the hole for both the disconnect and the eviction path. The new unit and sim Risks.
Prior discussion. This came up in #31666, which introduced the single random announcer:
That proposal was deferred, not rejected. This PR implements it, and the fuzzer reproduction is new Alternatives.
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 |
3454975 to
d4bb72b
Compare
|
pushed an update to address ralph review: https://git.fish.foo/bitcoin/bitcoin/pulls/36437#author-ralph |
be57df6 to
e974d21
Compare
|
Concept ACK |
ef0f976 to
65b48ba
Compare
|
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. |
|
tACK 65b48ba I 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 The hand-over keeps the callers' iterators valid. I tested the head merged into master a773e1e, 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 |
Check that if an honest peer announces the child of an acceptable parent and child, the child ends up in the mempool within a bounded time, whatever other peers do. The target drives a real PeerManager with real messages and validation, which the existing targets cannot, as they model validation results. After an adversarial prefix the honest peer only answers requests. With an outbound honest peer the adversaries keep acting; with an inbound one they go quiet. Adversary connections are limited, and adversaries do not refill outbound slots. Known liveness holes are marked in the target and turn the check off once opened, including the lost orphan reconsideration fixed in the next commit.
A child that arrives before its parent is kept as an orphan. Once the parent is accepted on its own, the orphan is put in one randomly chosen announcer's work set to be retried. If that announcer disconnects or is evicted first, the orphan is never retried, and re-announcements by the other announcers don't fetch it again since it is already held. This keeps e.g. a CPFP child of a parent that pays for itself out of the mempool until the orphan is evicted, and an announcer can cause it on purpose. Hand reconsideration over to the remaining announcer with the lowest NodeId instead. Remove its hole from the liveness target.
65b48ba to
5cf8340
Compare
|
rebased |
AndreaDiazCorreia
left a comment
There was a problem hiding this comment.
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_worksets fails and txorphanage_sim crashes on the qa-assets corpus.
With help from an LLM I tried to get p2p_1p1c_liveness to find the bug with the fix reverted, but it didn't (30 min, 7 workers). It looks like a disconnect only happens after process() drains all work sets. Is this path still reachable by the current harness?
|
@AndreaDiazCorreia edit: yeah seems hard to reach, but definitely can |
|
closing in favor of #36506 |

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
(#36371 (comment)).
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: #36506