Backport verdict: Needs clarification
Fidelity could not be established from the available evidence.
Evidence:
- Commit accounting: the packet lists bitcoin/bitcoin#35878 with commits [1278a5970d5ada0979052a5bad899e896b8ab40b], missing=[] and already_in_base=[]. Head commit 9aa2b77f22 carries 'Rebased-From: 1278a5970d…' and 'Github-Pull: #35878'. I read the original with read_upstream_commit. Apart from context lines, its patch to src/net_processing.cpp and test/functional/p2p_tx_download.py is the same as the backport.
- The range-diff shows one context difference: upstream's include block has <util/tokenbucket.h> after <util/time.h>, and 31.x has <util/trace.h> there. The new <util/hasher.h> and <unordered_set> includes sit at head lines 60 and 88. This was a context-only rebase with no change to the code.
- Dependencies exist on 31.x: SaltedUint256Hasher is in src/util/hasher.h:18 with a default constructor and operator()(const uint256&). Its definition is in src/util/hasher.cpp:10 at base. It is the same as in the upstream tree at the original commit.
- Head src/net_processing.cpp:763-764 adds 'const SaltedUint256Hasher m_txhash_hasher;' between m_rng and m_fee_filter_rounder, in the same place as upstream. It is default-constructed, so the constructor's initializer order is unaffected.
- Head src/net_processing.cpp:4147-4192 matches the upstream INV handler at 4343-4388. The seen_txids and seen_wtxids sets are built before LOCK2. The wtxidrelay mismatch filter still runs before deduplication, and the reject_tx_invs disconnect still runs before deduplication too. Deduplication picks its set with inv.IsMsgWtx(), which is the same rule ToGenTxid uses (src/protocol.cpp:121-125). So MSG_TX and MSG_WITNESS_TX share the txid set, and MSG_WTX uses its own set, as upstream intends.
- Test fit on 31.x: CInv::ToString produces '<type> <hash>', with 'witness-' prefixed when the witness flag is set (src/protocol.cpp:58-84). The test therefore finds 'got inv: tx|wtx|witness-tx <hash>'. 31.x logs 'got inv: %s %s' with two spaces, while upstream uses one. The test only matches up to the hash, so the extra space doesn't matter. MSG_WITNESS_TX is defined in test_framework/messages.py:70. TestNode.debug_log_size and debug_log_path exist (test_node.py:570/551), and TestP2PConn accepts wtxidrelay.
- The new test is called after test_large_inv_batch in run_test (head p2p_tx_download.py:458-459), the same order as upstream. That earlier test already relies on the restarted node being out of IBD, and the 'got inv' log line is only written outside IBD.
- The 31.x semantics this relies on are unchanged: IsMsgTx/IsMsgWtx check for an exact type match, and IsGenTxMsg includes MSG_WITNESS_TX (src/protocol.h:515-526). So on a wtxidrelay peer, MSG_WITNESS_TX gets past the mismatch filter and is treated as a txid, which is the case the test checks.
- Release notes: release_notes.mentions['bitcoin/bitcoin#35878'] is false. On 31.x, doc/release-notes.md entries are added in separate maintainer commits (e.g. de4a5e34b1, 'doc: update release notes for v31.2', by fanquake), not in individual backport commits. The upstream PR also says it should cause no observable change in behavior. So the missing entry is normal for this branch and not a fidelity defect.
- Fit for the target branch: the change is limited to one message, keeps processing in later messages and from other peers, and keeps txids and wtxids separate. It doesn't touch the longer-lived TxRequestTracker or orphan-resolution candidate tracking described in the captured history (#19184, #31397, BIP 339).
Limitations:
- I didn't build the code or run any tests. The PR description says p2p_tx_download.py, p2p_orphan_handling.py and p2p_opportunistic_1p1c.py passed locally, but no runner records tied to 9aa2b77f22 were provided, so those results are unverified. Unit tests and the rest of the functional suite weren't run, according to the description.
- Whether the upstream PR's full commit list contains only 1278a5970d comes from the evidence packet (sources.commits); I didn't fetch it separately from GitHub.
- Whether #35878 belongs in 31.x as an optimization rather than a bug fix rests on the packet's backport-label classification. I didn't consult maintainer discussion or the label itself.
- Adding the PR to the 31.x release notes is assumed to be left to the maintainer's later 'doc: update release notes' commit, as with earlier entries. I didn't confirm which 31.x point release this backport will go into.
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
Witness-aware transaction identifiers reconcile two competing requirements: avoid repeatedly downloading rejected transactions, while preventing an attacker from suppressing a valid transaction by first supplying an invalid witness with the same txid.
Both pinned versions distinguish txid announcements from wtxid announcements before invoking transaction-download logic. The new filter preserves that distinction with separate seen_txids and seen_wtxids sets. This historical rationale explains why identifier semantics matter: a txid does not identify a unique witness-bearing transaction, whereas a wtxid commits to the witness. Deduplicating announcements is not a determination that transactions spending conflicting inputs are interchangeable.
WTXID relay was deliberately negotiated per connection to preserve interoperability, and it did not eliminate txid-based requests for transactions whose wtxids are not known, such as missing parents.
The target base already ignores ordinary transaction INV types inconsistent with the connection's wtxidrelay setting. The head retains those checks before deduplication. BIP 339 also explains the existing comment that orphan-parent fetching can use txid GETDATA requests even on a wtxid-relay connection: parent fetching does not require a corresponding INV announcement.
Transaction request scheduling was designed to resist announcement racing and withholding, not merely to select the first advertiser. The historical proposal preferred outbound sources, introduced delays, diversified subsequent candidates, and retried after timeout, NOTFOUND, or an invalid-witness response.
The target's AddTxAnnouncement already applies preferred-peer, txid-relay, and overloaded-peer delays before forwarding announcements to the request tracker. Per-message duplicate elimination sits before this machinery; it does not replace the longer-lived accounting of candidate peers and request outcomes. The historical discussion explains why multiple sources and retry opportunities remain valuable even when repeated entries from one message are redundant.
Source 1 · Source 2 · Source 3
Orphan resolution intentionally uses all potential announcing peers to balance bandwidth efficiency, censorship resistance, and peer load. Merely changing the package-request protocol does not make a withholding peer honest.
In the pinned target, AddTxAnnouncement can recognize a known orphan, recalculate its missing parents, and consider the announcer as a resolution candidate before reaching the ordinary already-have check. This explains why an INV can remain useful even for a transaction already downloaded. It also supplies the historical context for avoiding repeated processing within one message without globally suppressing announcements from other peers or later messages.
Source 1 · Source 2 · Source 3
Ralph's inferences
The message-local filter is best understood as removing redundant input-processing work, rather than introducing a new transaction-acceptance or permanent duplicate-rejection policy.
At the base, every eligible transaction entry reaches AddKnownTx and, outside initial block download, AddTxAnnouncement. At the head, only the first occurrence of each identifier in its namespace does so within that INV message. The sets are then discarded. The tests explicitly preserve processing in a later message, group MSG_TX with the already-supported txid interpretation of MSG_WITNESS_TX, and keep txid and wtxid namespaces separate. This scope is consistent with the historical need to retain alternative announcers and later orphan-resolution opportunities; the inspected historical sources do not directly state why this particular filter must have message-local lifetime.