Repository navigation
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. |
|
See also #35917 and #35878 (comment) |
|
Concept ACK, thanks for pushing a fix for #35878 (comment). |
| if (peer.m_wtxid_relay) { | ||
| if (!inv.IsMsgWtx()) continue; | ||
| } else { | ||
| if (!inv.IsMsgTx()) continue; |
There was a problem hiding this comment.
Ignoring MSG_WITNESS_TX for wtxid relay peers seems fine, because i expect wtxid relay codebases to be newer / better maintained, and because BIP 339 explicitly states:
After a node has received a wtxidrelay message from a peer, the node MUST use the MSG_WTX inv type when announcing transactions to that peer.
However for txid relay peers, i'm afraid we are in a similar situation to unannounced transaction processing. We have supported it for a decade, and while it Is Incorrect, i'm afraid there may be an unmaintained codebase out there that relies on it. It's a bit more niche than unannounced transaction processing, but still, i think we should have some evidence this isn't being used in the wild before dropping support.
There was a problem hiding this comment.
Based on the got inv debug.log lines, my lots-of-peers node received no witness-tx invs in April-July, versus:
| Month | block | tx | wtx |
|---|---|---|---|
| April | 3,210 | 6,935,321 | 1,174,811,061 |
| May | 2,092 | 3,530,619 | 854,676,397 |
| June | 1,783 | 13,683,220 | 1,793,970,323 |
| July | 1,924 | 10,870,284 | 2,474,162,561 |
Numbers from:
zstdcat debug.log-202604*.zst | grep got.inv: | cut -d\ -f5 |
awk '{c[$0]++} END {for (l in c) printf "%8d %s\n", c[l], l}'There was a problem hiding this comment.
For people who do find instances of this, grep got.inv:.witness-tx .bitcoin/debug.log should indicate the txid being sent, as well as whether your peer already had the tx in question ("have" vs "new").
|
Concept ACK |
|
As per https://bnoc.xyz/t/any-reachable-node-receiving-tx-announcement-via-msg-witness-tx/159/5: |
Filed as lightninglabs/neutrino#384 |
BIP 144 specifies that MSG_WITNESS_TX is "only for use in getdata", so if we receive it anyway, ignore it, rather than treating it as a by-txid announcement. Also changes the code ordering so that attempting to announce txs on a connection where tx relay is disabled triggers a disconnect, even if we would have ignored the announcement for being the wrong inv type.
Previously we only checked disconnection occurs on "correct" announcements (WTX on a wtxidrelay connection); extend that to checking all possible announcements (still only on a wtxidrelay connection).
After the previous commit only one of these will ever be used for any particular INV message, so there's no need for two. Co-Authored-By: Antoine Poinsot <[email protected]>
eaaea13 to
0f9bffe
Compare
|
Changed to allow witness-tx in invs for non-wtxidrelay peers. Lame.
I didn't copy any code from you, and I'm not even sure what this is in regards to. Nothing here is substantive enough to be worth arguing about authorship. |
| pfrom.fDisconnect = true; | ||
| return; | ||
| } | ||
| // MSG_WITNESS_TX is treated as a txid, despite only being specified for getdata. |
There was a problem hiding this comment.
The deleted comment isn't wrong, the code that it referred to still exists below. The difference is that it now only runs for non-wtxidrelay peers. I would keep it around below the new code block or maybe include the information somewhere the new comments.
There was a problem hiding this comment.
Everything except MSG_WTX is always a txid, see ToGenTxid() or how MSG_WITNESS_TX is defined in bip 144 ("MSG_WITNESS_TX getdata requests should use the non-witness serialized hash."); I don't think this needs an extra comment
| assert_equal(log.count(f"got inv: {second_name} {hash_a:064x}"), 0) | ||
|
|
||
| self.log.info('Check that txids and wtxids are deduplicated separately') | ||
| self.log.info('Check that MSG_WITNESS_TX inv is ignored with wtxid relay') |
There was a problem hiding this comment.
(note to other reviewers: the actual change to the separate deduplication happens in the third commit)
Based on the redefiniton of the test now only the first of the loop runs seems still relevant. I think I would find it confusing why the test is written this way without the historic background.
self.log.info('Check that MSG_WITNESS_TX inv is ignored with wtxid relay')
peer = node.add_p2p_connection(TestP2PConn(wtxidrelay=True))
- for first_type, second_type, hash_a in [
- (MSG_WITNESS_TX, MSG_WTX, 0x8899aa),
- (MSG_WTX, MSG_WITNESS_TX, 0x99aabb),
- ]:
- log = send_invs_and_read_log(peer, [
- CInv(t=first_type, h=hash_a),
- CInv(t=second_type, h=hash_a),
- ])
- assert_equal(log.count(f"got inv: witness-tx {hash_a:064x}"), 0)
- assert_equal(log.count(f"got inv: wtx {hash_a:064x}"), 1)
+ hash = 0x8899aa
+ log = send_invs_and_read_log(peer, [
+ CInv(t=MSG_WITNESS_TX, h=hash),
+ CInv(t=MSG_WTX, h=hash),
+ ])
+ assert_equal(log.count(f"got inv: witness-tx {hash:064x}"), 0)
+ assert_equal(log.count(f"got inv: wtx {hash:064x}"), 1)There was a problem hiding this comment.
The historic background is readily available via git log: git log -M -C -L 381,392:../test/functional/p2p_tx_download.py I prefer to keep the changes to tests minimal when changing functionality, to avoid accidentally reducing coverage in a way that hides introduced bugs, so I'd rather keep this as-is.
There was a problem hiding this comment.
I don't think it would occur to me to go back in git history because there is no hint here that there is some historic context that might be helpful. And if I did, looking for the historic context of the test parts that are confusing would let me find the reason because these are the lines that are not being changed here. But not a blocker either.
There was a problem hiding this comment.
I just mean if you find a piece of code confusing, looking at the git history should always be one of the first things you consider doing. In this case you'd see the test went from 1 to 0 for witness-tx and the description went from "Check that txids and wtxids are deduplicated separately" to "Check that MSG_WITNESS_TX inv is ignored with wtxid relay" as part of the "net_processing: Ignore MSG_WITNESS_TX entries in inv messages" commit, which you could then trace through to the PR in question if it was still confusing.
| self.nodes[0].disconnect_p2ps() | ||
| h = 0x12345 | ||
| for msg_type in [MSG_WTX, MSG_TX, MSG_WITNESS_TX]: | ||
| h += 1 |
There was a problem hiding this comment.
nit: Since each loop run has its own connection this doesn't seem necessary
There was a problem hiding this comment.
It's not necessary but if one (or more) of the invs somehow gets a GETDATA response due to a bug, it makes it clearer which one was the trigger.
| peer.wait_for_disconnect() | ||
| self.nodes[0].disconnect_p2ps() | ||
| h = 0x12345 | ||
| for msg_type in [MSG_WTX, MSG_TX, MSG_WITNESS_TX]: |
There was a problem hiding this comment.
nit: Could apply the same loop to the self.log.info('Check that tx invs also violate the protocol') test above in blocksonly_mode_tests.
| } | ||
| auto& seen_hashes{inv.IsMsgWtx() ? seen_wtxids : seen_txids}; | ||
| if (!seen_hashes.insert(inv.hash).second) continue; | ||
| // Due to the check above, we're only adding hashes of one particular type here |
There was a problem hiding this comment.
nit: This would be a bit easier to understand for me
| // Due to the check above, we're only adding hashes of one particular type here | |
| // Mixing txids and wtxids here is ok because the check above only lets through | |
| // wtxids (MSG_WTX) from wtxidrelay peers and txids (MSG_TX, MSG_WITNESS_TX) otherwise. |
There was a problem hiding this comment.
We're not mixing txids and wtxids though. Each peer gets precisely one or the other added to seen_tx_hashes.
There was a problem hiding this comment.
To me this is still mixing different types in a single data structure, independent of which peer these are coming from. But it's not a blocker for me.
|
tACK 0f9bffe Built and ran p2p_blocksonly.py and p2p_tx_download.py. With net_processing.cpp reverted to the base, both fail. Each of five small breakages I tried, such as moving the wtxidrelay filter back above the disconnect or dropping the dedup, fails at least one of them. Nit: the title and description still say MSG_WITNESS_TX invs are ignored; since the neutrino change, that only holds for wtxidrelay peers. |
This comment was marked as spam.
This comment was marked as spam.
just noting it was merged a month ago |
instagibbs
left a comment
There was a problem hiding this comment.
LGTM
I'd happily review a PR that would make MSG_WITNESS_TX and MGS_WTX not sound like the same thing.
Could we get a test that ensures we GETDATA the neutrino exception, if we don't have one?
| peer.wait_for_disconnect() | ||
| self.nodes[0].disconnect_p2ps() | ||
| h = 0x12345 | ||
| for msg_type in [MSG_WTX, MSG_TX, MSG_WITNESS_TX]: |
There was a problem hiding this comment.
| for msg_type in [MSG_WTX, MSG_TX, MSG_WITNESS_TX]: | |
| for wtxidrelay, msg_type in product([True, False], [MSG_WTX, MSG_TX, | |
| MSG_WITNESS_TX]): | |
| h += 1 | |
| peer = | |
| self.nodes[0].add_outbound_p2p_connection(P2PInterface(wtxidrelay=wtxidrelay), | |
| p2p_idx=0, connection_type="block-relay-only") |
mzumsande
left a comment
There was a problem hiding this comment.
Concept ACK
Filed as lightninglabs/neutrino#384
just noting it was merged a month ago
What is the plan to deal with this? Merge as is and revisit in a few releases to then ignore MSG_WITNESS_TX also for for non-wtxidrelay peers?
22535b4 test: look for the wtxid in p2p_blocksonly (Ferdinando Ametrano) Pull request description: In `blocks_relay_conn_tests`, the check that a transaction submitted over RPC is not announced to a block-relay-only peer looks for its txid among the peer's invs. The peer is a `P2PTxInvStore`, which negotiates wtxidrelay, so an announcement would carry the wtxid. The MiniWallet transaction has a witness, so its txid and wtxid differ, and the check passes whether or not the node announces it. This checks the wtxid instead. To see the difference, open that connection as `outbound-full-relay`: the old check still passes, the new one fails. It also adds an `outbound-full-relay` peer that must receive the wtxid announcement first, so the check cannot pass silently again. #35920 also edits `blocks_relay_conn_tests`; the two do not conflict. Found while porting these tests to https://github.com/btclib-org/bitcoin-node-tests. ACKs for top commit: maflcko: lgtm ACK 22535b4 AndreaDiazCorreia: ACK 22535b4 sedited: ACK 22535b4 Tree-SHA512: ac425fafbd8f2851dc9d11799d70ffd914ea55bdf9e63087ac8313e55748ca2635c0ae266fae0d51400d1b10b05f3ee622f9fecce6d1360ae5803b8bcadc1638

When introducing wtxidrelay we added checks to skip attempts to announce txs with the wrong hash (#18044 (comment)), but didn't similarly ignore
MSG_WITNESS_TXentries in announcements, which have never been valid (see BIP-144).This PR corrects that oversight, skipping such announcements. It also moves the check to be after the disconnect code, so that attempting to announce txs on
fRelay=falsedoesn't get treated as okay just because you're doing it wrong. As a result this allows deduping theseen_tx_hashesset.