net_processing: Ignore MSG_WITNESS_TX entries from INV messages #35920

pull ajtowns wants to merge 3 commits into bitcoin:master from ajtowns:202608-inv-msg-witness changing 3 files +28 −25
  1. ajtowns commented at 8:41 PM on August 6, 2026: contributor

    When introducing wtxidrelay we added checks to skip attempts to announce txs with the wrong hash (https://github.com/bitcoin/bitcoin/pull/18044#discussion_r403953004), but didn't similarly ignore MSG_WITNESS_TX entries 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=false doesn't get treated as okay just because you're doing it wrong. As a result this allows deduping the seen_tx_hashes set.

  2. DrahtBot commented at 8:41 PM on August 6, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35920.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    Concept ACK fjahr, l0rinc

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. ajtowns commented at 8:56 PM on August 6, 2026: contributor

    See also #35917 and #35878 (review)

  4. l0rinc commented at 9:02 PM on August 6, 2026: contributor

    Concept ACK, thanks for pushing a fix for #35878 (review). If you touch again, please add me as coauthor.

  5. ajtowns renamed this:
    net_processing: Ignore MSG_TX_WITNESS entries from INV messages
    net_processing: Ignore MSG_WITNESS_TX entries from INV messages
    on Aug 6, 2026
  6. DrahtBot closed this on Aug 7, 2026

  7. DrahtBot reopened this on Aug 7, 2026

  8. in src/net_processing.cpp:4383 in eaaea13cda
    4381 | +                // This ignores any MSG_WITNESS_TX entries, as that inv
    4382 | +                // type is only for use with GETDATA (per BIP 144).
    4383 | +                if (peer.m_wtxid_relay) {
    4384 | +                    if (!inv.IsMsgWtx()) continue;
    4385 | +                } else {
    4386 | +                    if (!inv.IsMsgTx()) continue;
    


    darosior commented at 9:01 PM on August 7, 2026:

    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.


    ajtowns commented at 1:26 AM on August 8, 2026:

    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}'
    

    ajtowns commented at 3:19 AM on August 12, 2026:

    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").

  9. fjahr commented at 1:50 PM on August 11, 2026: contributor

    Concept ACK

  10. 0xB10C commented at 3:02 PM on August 12, 2026: contributor
  11. net_processing: Ignore MSG_WITNESS_TX entries in inv messages
    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.
    2eefc296d4
  12. tests: Check we disconnect on tx INVs on blocks-only conns
    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).
    a24f315175
  13. net_processing: Combine seen_txids and seen_wtxids
    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 <mail@antoinep.com>
    0f9bffe6e1
  14. ajtowns force-pushed on Aug 12, 2026
  15. ajtowns commented at 10:09 PM on August 12, 2026: contributor

    Changed to allow witness-tx in invs for non-wtxidrelay peers. Lame.

    Concept ACK, thanks for pushing a fix for #35878 (comment). If you touch again, please add me as coauthor.

    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.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-14 18:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me