mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #18044: Use wtxid for transaction relay
0a4f1422cdFurther improve comments around recentRejects (Suhas Daftuar)0e20cfedb7Disconnect peers sending wtxidrelay message after VERACK (Suhas Daftuar)cacd85209etest: Use wtxid relay generally in functional tests (Fabian Jahr)8d8099e97atest: Add tests for wtxid tx relay in segwit test (Fabian Jahr)9a5392fdf6test: Update test framework p2p protocol version to 70016 (Fabian Jahr)dd78d1d641Rename AddInventoryKnown() to AddKnownTx() (Suhas Daftuar)4eb515574eMake TX_WITNESS_STRIPPED its own rejection reason (Suhas Daftuar)97141ca442Delay getdata requests from peers using txid-based relay (Suhas Daftuar)46d78d47deAdd p2p message "wtxidrelay" (Suhas Daftuar)2d282e0cbaignore non-wtxidrelay compliant invs (Anthony Towns)ac88e2eb61Add support for tx-relay via wtxid (Suhas Daftuar)8e68fc246dAdd wtxids to recentRejects instead of txids (Suhas Daftuar)144c385820Add wtxids of confirmed transactions to bloom filter (Suhas Daftuar)85c78d54afAdd wtxid-index to orphan map (Suhas Daftuar)08b39955ecAdd a wtxid-index to mapRelay (Suhas Daftuar)60f0acda71Just pass a hash to AddInventoryKnown (Suhas Daftuar)c7eb6b4f1fAdd wtxid to mempool unbroadcast tracking (Amiti Uttarwar)2b4b90aa8fAdd a wtxid-index to the mempool (Suhas Daftuar) Pull request description: Using txids (a transaction's hash, without witness) for transaction relay is problematic, post-segwit -- if a peer gives us a segwit transaction that fails policy checks, it could be because the txid associated with the transaction is definitely unacceptable to our node (regardless of the witness), or it could be that the transaction was malleated and with a different witness, the txid could be accepted to our mempool. We have a bloom filter of recently rejected transactions, whose purpose is to help us avoid redownloading and revalidating transactions that fail to be accepted, but because of this potential for witness malleability to interfere with relay of valid transactions, we do not use the filter for segwit transactions. This issue is discussed at some length in #8279. The effect of this is that whenever a segwit transaction that fails policy checks is relayed, a node would download that transaction from every peer announcing it, because it has no way presently to cache failure. Historically this hasn't been a big problem, but if/when policy for accepting segwit transactions were to change (eg taproot, or any other change), we could expect older nodes talking to newer nodes to be wasting bandwidth because of this. As discussed in that issue, switching to wtxid-based relay solves this problem -- by using an identifier for a transaction that commits to all the data in our relay protocol, we can be certain if a transaction that a peer is announcing is one that we've already tried to process, or if it's something new. This PR introduces support for wtxid-based relay with peers that support it (and remains backwards compatible with peers that use txids for relay, of course). Apart from code correctness, one issue to be aware of is that by downloading from old and new peers alike, we should expect there to be some bandwidth wasted, because sometimes we might download the same transaction via txid-relay as well as wtxid-relay. The last commit in this PR implements a heuristic I want to analyze, which is to just delay relay from txid-relay peers by 2 seconds, if we have at least 1 wtxid-based peer. I've just started running a couple nodes with this heuristic so I can measure how well it works, but I'm open to other ideas for minimizing that issue. In the long run, I think this will be essentially a non-issue, so I don't think it's too big a concern, we just need to bite the bullet and deal with it during upgrade. Finally, this proposal would need a simple BIP describing the changes, which I haven't yet drafted. However, review and testing of this code in the interim would be welcome. To do items: - [x] Write BIP explaining the spec here (1 new p2p message for negotiating wtxid-based relay, along with a new INV type) - [ ] Measure and evaluate a heuristic for minimizing how often a node downloads the same transaction twice, when connected to old and new nodes. ACKs for top commit: naumenkogs: utACK0a4f1422cdlaanwj: utACK0a4f1422cdTree-SHA512: d8eb8f0688cf0cbe9507bf738e143edab1f595551fdfeddc2b6734686ea26e7f156b6bfde38bad8bbbe8bec1857c7223e1687f8f018de7463dde8ecaa8f450df
This commit is contained in:
Reference in New Issue
Block a user