This PR removes the rejection cache filtering part of all txid-based tx requests. In practice, this seems to only be used for orphan resolution because everybody supports wtxidrelay. And so in essence, this PR removes the logic that stops us from attempting orphan resolution when parents are found in the rejection filter.
Background:
We have 2 bloom filters for remembering transactions that we’ve rejected so we don’t redownload them, RecentRejectsFilter
and RecentRejectsReconsiderableFilter
. This lets us save a little bit of bandwidth on rejected transactions, particularly if we have policy differences. It’s not designed to stop attackers from wasting our download bandwidth, as they can create as many policy-invalid transactions with different witnesses as they want. We generally only put wtxids and not txids in them (see #18044), except for these cases:
(A) When we specifically know that the rejection reason is not due to the witness (however, this is only done for !AreInputsStandard
, even though there are other cases we could apply)
(B) When the transaction has no witness, so its txid == wtxid
(C) (With #32379) When the transaction’s witness has been stripped, so txid == wtxid
We check the filters to decide whether to send a getdata for an inv, whether we should validate a tx we just downloaded, and whether we should keep an orphan: we look the missing parents up by (prevout) txid and throw the orphan away if its parents were already rejected. That means there are very few cases where we save bandwidth by finding a txid in the filter.
Rationale: mainly that the additional complexity is not worth the bandwidth savings. TLDR: this case does not seem to ever hit in practice. Even if that is circumstantial, the number of transactions this filter could apply to is extremely small.
I collected some stats over a couple of weeks, setting mempoolexpiry to 1 hour to try to artificially increase orphan rates (though I don’t know whether the effect is significant):
- I’m seeing 100% of peers support wtxidrelay. Bitcoin Core has been doing this since ~5 years ago. I’m sure there are some nodes that don’t do it, but it’ll probably be rare that we are surrounded by txidrelay peers and that we have a policy difference causing us to reject the transaction that they all send us.
- Orphan parent fetching was 3.64% of my transaction requests.
- 93.77% of all transactions I receive have witnesses (includes accepted and rejected ones). 96.20% of orphan parents I fetched had witnesses.
- I found no cases of already-rejected parent txids in the past week. This could be because all my peers have the same policy as me (which might not always be true), but the number of nonsegwit orphan parents in general is just so tiny - a few dozen requests per day.