test: look for the wtxid in p2p_blocksonly #36405

Manually merged
fametrano merged 1 commit from test-blocksonly-wtxid-inv into master 2026-11-05 11:15:18 +00:00 AGit
fametrano commented 2026-10-01 20:32:02 +00:00 (Migrated from github.com)

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.

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.
DrahtBot commented 2026-10-01 20:32:12 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK maflcko, AndreaDiazCorreia, sedited

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36257 (qa: assert_equals -> assert_true/assert_false by hodlinator)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36405 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36405.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36405#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [maflcko](https://github.com/bitcoin/bitcoin/pull/36405#issuecomment-6161642824), [AndreaDiazCorreia](https://github.com/bitcoin/bitcoin/pull/36405#pullrequestreview-5646511712), [sedited](https://github.com/bitcoin/bitcoin/pull/36405#pullrequestreview-5783938484) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36257](https://github.com/bitcoin/bitcoin/pull/36257) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36257.svg"></sub> (qa: assert_equals -> assert_true/assert_false by hodlinator) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: a773e1e33b349dc819b5a0edc1c7a4839dc73b48
Head: 22535b460568be47e57aadfbe50d489becb77577

Alternatives

Also assert the txid is absent from the block-relay-only peer. Keep the full-relay wtxid positive assertion and the restricted-peer wtxid absence assertion, and add a restricted-peer absence assertion for the txid. Benefit: Detects a leaked MSG_TX announcement as well as the expected MSG_WTX announcement, even if the restricted peer’s relay identifier differs from the one the positive control observes. Trade-off: Adds one assertion and retains both identifiers in the test’s local setup. Unresolved: The existing inventory store records hashes for MSG_TX and MSG_WTX without retaining their types, so this remains limited to those stored inventory types.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:1e40d4c29146a38cb238a037edaa35c22b13996a5383ed7a85e089a15d569009:c9412d948811529792d161d97aa6951829440e3d548b7c576bb8d4df4183e0d0 --> Base: `a773e1e33b349dc819b5a0edc1c7a4839dc73b48` Head: `22535b460568be47e57aadfbe50d489becb77577` ##### Alternatives **Also assert the txid is absent from the block-relay-only peer.** Keep the full-relay wtxid positive assertion and the restricted-peer wtxid absence assertion, and add a restricted-peer absence assertion for the txid. Benefit: Detects a leaked MSG_TX announcement as well as the expected MSG_WTX announcement, even if the restricted peer’s relay identifier differs from the one the positive control observes. Trade-off: Adds one assertion and retains both identifiers in the test’s local setup. Unresolved: The existing inventory store records hashes for MSG_TX and MSG_WTX without retaining their types, so this remains limited to those stored inventory types. [Full review report](<https://review.fish.foo/traces/36405-22535b460568be47e57aadfbe50d489becb77577-1345-7.html>)
mercie-ux commented 2026-10-07 14:23:48 +00:00 (Migrated from github.com)

Concept Ack

Concept Ack
maflcko (Migrated from github.com) reviewed 2026-10-12 12:33:09 +00:00
maflcko (Migrated from github.com) commented 2026-10-12 12:33:00 +00:00

maybe there should be another peer to check it is received for it? Otherwise the test will likely silently break again in the future?

maybe there should be another peer to check it is received for it? Otherwise the test will likely silently break again in the future?
fametrano (Migrated from github.com) reviewed 2026-10-13 10:31:09 +00:00
fametrano (Migrated from github.com) commented 2026-10-13 10:31:09 +00:00

Done in c765571. I added an outbound-full-relay peer that must receive the wtxid announcement before the block-relay-only peer is checked, so the test fails if the node stops announcing the transaction or announces it under another id.

Done in c765571. I added an outbound-full-relay peer that must receive the wtxid announcement before the block-relay-only peer is checked, so the test fails if the node stops announcing the transaction or announces it under another id.
maflcko (Migrated from github.com) reviewed 2026-10-13 10:45:55 +00:00
maflcko (Migrated from github.com) commented 2026-10-13 10:45:55 +00:00

There is no need to wait for a broadcast, when not using the unbroadcast set for this test. Also, with mocktime, this should probably be a sync_with_ping instead?

Finally, the point was that the test has the relevant assert directly inside, so that it is somewhat "self-checking". So the difference between the two asserts is just the not.

There is no need to wait for a broadcast, when not using the unbroadcast set for this test. Also, with mocktime, this should probably be a sync_with_ping instead? Finally, the point was that the test has the relevant assert directly inside, so that it is somewhat "self-checking". So the difference between the two asserts is just the `not`.
fametrano (Migrated from github.com) reviewed 2026-10-14 05:24:30 +00:00
fametrano (Migrated from github.com) commented 2026-10-14 05:24:30 +00:00

Thanks, done in 22535b4. I dropped the wait and sync both peers with a ping; the two asserts now differ only by not.

Thanks, done in 22535b4. I dropped the wait and sync both peers with a ping; the two asserts now differ only by `not`.
maflcko commented 2026-10-14 05:31:55 +00:00 (Migrated from github.com)

lgtm ACK 22535b4605

lgtm ACK 22535b460568be47e57aadfbe50d489becb77577
AndreaDiazCorreia (Migrated from github.com) reviewed 2026-10-26 01:42:04 +00:00
AndreaDiazCorreia (Migrated from github.com) left a comment

ACK 22535b4605

Ran p2p_blocksonly.py with v1 and v2 transport. With conn changed to outbound-full-relay, the new assertion fails while the old txid check still passes. Using txid in both assertions also fails at the positive control.

ACK 22535b460568be47e57aadfbe50d489becb77577 Ran p2p_blocksonly.py with v1 and v2 transport. With conn changed to outbound-full-relay, the new assertion fails while the old txid check still passes. Using txid in both assertions also fails at the positive control.
sedited (Migrated from github.com) approved these changes 2026-11-05 11:11:05 +00:00
sedited (Migrated from github.com) left a comment
ACK 22535b460568be47e57aadfbe50d489becb77577
fanquake commented 2026-11-05 11:18:05 +00:00 (Migrated from github.com)

Backported to 32.x in #36727.

Backported to `32.x` in #36727.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36405
No description provided.