p2p: plug "tier 1" 1p1c liveness holes

bitcoin/bitcoin: PR #36506

1 minor finding · 2 suggestions

Earlier concerns neither republished nor resolved: 1 major finding · 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Failed assertions leave connman with a dangling m_msgproc

known_parent_in_package_does_not_poison_after_eviction can call a destroyed PeerManager during teardown if a BOOST_REQUIRE fails before the manual cleanup.

Location: src/test/txdownload_tests.cpp:482 (head).

Details and suggested fix

The test declares connman before peerman, sets m_msgproc to peerman.get(), and registers two nodes with AddTestNode. If an intermediate BOOST_REQUIRE fails, stack unwinding destroys peerman while those nodes remain registered. ~CConnman then reaches StopNodes and DeleteNode, which calls m_msgproc->FinalizeNode through the dangling pointer. This can turn the assertion failure into a teardown crash. Install a scoped cleanup guard before the assertions that finalizes the peers, calls ClearTestNodes, and resets m_msgproc while peerman is still alive.


Optional improvements

Link

[suggestion] · Retained-orphan test does not check failed-pair suppression

The new functional test would not detect repeated evaluation of the same rejected package after its child is retained.

Location: test/functional/p2p_opportunistic_1p1c.py:390 (head).

Details and suggested fix

After the two-announcer assertions, a retransmitted tx_parent_padded reaches Find1P1CPackage through the reconsiderable branch of ReceivedTx. Without the package-cache insertion, the pair would fail feerate again while leaving the currently asserted orphan and mempool state unchanged. Before step 4, resend it from attacker with send_and_ping inside node.assert_debug_log(expected_msgs=[], unexpected_msgs=["package evaluation for"]). This checks that ProcessPackageResult records the failed pair and the lookup suppresses it. Keep the existing honest different-witness acceptance to verify that the cache does not suppress a different pair.


Link

[suggestion] · Tracker primitives and relay behavior share one commit

a30665c3 combines independently testable tracker state transitions with the relay-policy change, making their separate invariants harder to validate.

Location: src/txrequest.cpp:566 at a30665c3c66f (commit) (commit).

Details and suggested fix

In commit a30665c3c66f90f9130e43bcd231f26ddd89f73e, the typed ForgetTxHash adds peer collection, completion, deletion, and candidate promotion logic alongside the MempoolRejectedTx behavior change. Put the src/txrequest.cpp and src/txrequest.h additions, including typed GetCandidatePeers, together with their unit and fuzz tests in a preceding tracker-only commit. Leave the production call-site switch, net_processing invariant update, and txdownload and functional regression tests in the following behavior commit. The prerequisite is additive and leaves existing callers on the uint256 overload, allowing the container invariants to be reviewed separately from the argument for preserving txid-typed requests without changing the final tree.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Rejection caches were intended to suppress repeated downloads and validation while distinguishing transactions that cannot currently be accepted from transactions that may succeed with fee-paying relatives. The reconsiderable-cache introduction explicitly records individual wtxids and rejected package hashes, permits later package submission of an individually rejected transaction, and resets the cache on chain-tip changes.

This is the historical basis for retaining a standalone low-feerate verdict without treating it as a prohibition on all packages containing that transaction. The base documentation also expressly included reconsiderable package-member wtxids, but did not explain why that scope was appropriate independently of the package result.

Source 1

The cache's bandwidth benefit chiefly concerns repeated relay under differing node policies, not a comprehensive defense against malicious bandwidth consumption. Historical discussion notes that an attacker can manufacture arbitrarily many policy-invalid witness variants.

This qualifies the anti-reprocessing objective affected by excluding already-known results and narrowing package-member rejection handling: cached results avoid repeating equivalent work, but the historical design did not promise to eliminate all adversarial retries.

Source 1 · Source 2

Witness-scoped rejection was a censorship defense. Sdaftuar explained that caching a witness-stripped transaction under its wtxid also caches its txid, potentially preventing retrieval of the valid witness-bearing version from a txid-relay peer. The historical exception for witness-independent failures allowed broader suppression only when changing the witness could not repair the failure.

Missing-parent resolution still requests by txid. Thus the identity distinction remains relevant even when ordinary announcements use wtxids: a verdict about one witness representation has a different scope from a request for a transaction identified by its non-witness data.

Source 1 · Source 2 · Source 3

The 1p1c integration sought to preserve existing orphan cleanup after non-missing-input outcomes. Its discussion also proposed deleting orphans with rejected parents specifically to avoid trying them again through another peer; the author deferred that additional change while preserving old behavior.

This explains the anti-reprocessing motivation surrounding transaction-wide orphan erasure. It does not establish that a failure of one parent-child combination was intended to establish an equally broad verdict about the child under every announcer.

Source 1 · Source 2 · Source 3 · Source 4

Multi-peer orphan resolution was motivated by censorship resistance, bandwidth efficiency, and load balancing. Every announcer can be a candidate for supplying missing parents; those requests use the ordinary request tracker to avoid duplicate requests and retain its outbound preference and overload handling. Announcers must remain in the orphanage because the downloaded child's request-tracker entries are removed.

Preserving another peer's txid-typed parent request maintains the fallback opportunity this design introduced. The request-tracker redesign also deliberately bounded tracked announcements and delayed overloaded peers rather than refusing all further requests from them.

Source 1 · Source 2 · Source 3

Single-announcer reconsideration was introduced to avoid redundant work when an orphan still lacked inputs. A subsequent optimization made the invariant explicit: at most one reconsiderable announcement per wtxid, avoiding both repeated validation by callers and repeated internal traversal. The original single-announcer change also explicitly stated that an assigned peer should not be able to stop processing by disconnecting.

The historical objective combines bounded duplicate work with independence from the selected peer's continued connection. Handoff concerns ownership of one pending local retry, not another download or simultaneous validation through every announcer.

Source 1 · Source 2

Peer-owned orphan announcements and work sets were designed to prevent one spammy peer from churning away another peer's useful orphans. The DoS redesign bounded operation latency globally, reserved memory per peer, evicted announcements according to peer resource consumption, and bounded a peer's work set by making it a subset of that peer's announcements.

These are the fairness constraints surrounding reassignment: retaining the transaction while another announcer remains protects that announcer's opportunity, while assigning work only to an existing announcement preserves peer-owned accounting. The motivation was directly connected to keeping opportunistic 1p1c useful under orphan spam.

Source 1

Ralph's inferences

Equal txid/wtxid hashes were combined because the original tracker assumed equality identified a non-segwit transaction, making either fetch form equivalent. Hash-based serialization also avoids redundant downloads, while retaining failed announcements prevents repeated announcements from improving a peer's selection chances. The head changes forgetting, not this shared scheduling identity: it removes only the rejected identifier type and promotes a remaining candidate through the existing completion machinery.

Typed preservation separates a verdict about one received representation from outstanding txid requests that may obtain another witness. It does not create independent concurrent request lanes or remove the per-peer/hash uniqueness rule. This distinguishes preserving a useful fallback from granting the rejected wtxid repeated chances.

The head separates package-scoped fee failure from transaction-scoped rejection without abandoning rejection caching. Failed packages still enter the package cache, standalone reconsiderable failures still enter the wtxid cache, and ordinary orphan reconsideration still removes transactions whose outcomes are no longer missing-input failures. Already-known outcomes are handled separately from invalidity.

Keeping a child after one package-feerate failure leaves room for a different parent witness combination, while the failed package remains subject to anti-reprocessing. Excluding TX_CONFLICT and DIFFERENT_WITNESS similarly avoids assigning an invalidity-style cache consequence merely because a version is already known. These are scope distinctions, not evidence that unlimited reconsideration was historically intended.

Source 1

Handing pending reconsideration to the lowest remaining NodeId is deterministic ownership transfer, not a new trust ranking. The head marks an already-existing announcement, keeps one pending reconsideration per wtxid, and leaves the initial random assignment intact. Transfer does not itself validate the transaction or add another stored announcement.

This preserves the historical duplicate-work bound and work-set membership constraint while preventing disappearance of the current owner from discarding the pending opportunity. Deterministic fallback differs from randomized initial distribution; the inspected history does not establish a requirement that every ownership transfer be uniformly random.

Source 1 · Source 2

Unresolved disagreements

Historical discussion did not settle the broader value of txid-based rejection filtering. One proposal argued that its narrow applicability and observed rarity did not justify the complexity; an objection identified potential bandwidth protection for nodes behind newer spend-type consensus or policy changes. The proposal was closed 'for now,' rather than resolving that general tradeoff.

The current change preserves txid-based rejection mechanisms while narrowing particular consequences. The earlier debate supplies context for their bandwidth-versus-identity-complexity tradeoff, but does not establish consensus either to remove them or to retain every existing scope.

Source 1 · Source 2 · Source 3