p2p: Use separate compact block nonce per network #36955

pull mzumsande wants to merge 1 commits into bitcoin:master from mzumsande:202611_cb_fingerprint changing 2 files +84 −15
  1. mzumsande commented at 5:36 PM on November 23, 2026: contributor

    This issue was reported by ajtowns on IRC some time ago.

    For compact blocks, when we serve the last compact block from cache, we use a single nonce for all peers currently. This means anyone can request the most recent tip as a compact block via getdata(MSG_CMPCT_BLOCK) over a clearnet and a tor connection and then compare the nonces - if they match it's the same node.

    Fix this by using a different nonce per network/bind (CNode::m_network_key). This means a little bit more work in NewPoWValidBlock where we will now create CBlockHeaderAndShortTxIDs objects for each network on which a peer has made us their hb peer. More instances may be created later when serving non-hb peers via GETDATA. Note that while on master, the CBlockHeaderAndShortTxIDs was created eagerly, and its serialization lazily, we now create both objects lazily.

    From a high-level point of view, there are various remaining fingerprinting vectors even with this fix, some hard to fix, but I do think that we should be fixing at least the most obvious ones.

  2. p2p: use different compact block nonces per network
    This removes a very straightforward fingerprinting vector:
    Anyone could request the most recent tip as a compact block
    via getdata(MSG_CMPCT_BLOCK) over a clearnet and a tor connection
    and then compare the nonces - if they match it's likely the same peer.
    ee20048dda
  3. DrahtBot added the label P2P on Nov 23, 2026
  4. DrahtBot commented at 5:36 PM on November 23, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    Concept ACK instagibbs, fjahr, ismaelsadeeq

    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:

    • #36919 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36919.svg"></sub> (p2p: Track recent stale tips (BIP 332)(Stale Tip Relay) by pseudoramdom)
    • #36787 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36787.svg"></sub> (cmpctblock: Cache serialized cmpctblock msg for relay [part of prefill series] by davidgumberg)
    • #36372 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36372.svg"></sub> (p2p: replace full outbound peers that don't support tx relay (take 2) by fjahr)
    • #35561 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35561.svg"></sub> (net: move some CNodeState fields to Peer by Crypt-iQ)
    • #35558 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35558.svg"></sub> (p2p: Prefill compact blocks by davidgumberg)
    • #35522 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35522.svg"></sub> (refactor: Extract per-message helpers from SendMessages() (move-only) by pablomartin4btc)

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

  5. instagibbs commented at 6:14 PM on November 23, 2026: member

    concept ACK

  6. mzumsande commented at 6:26 PM on November 23, 2026: contributor

    The Ralph comment reminds me of an old conversation: #33464#pullrequestreview-3813897610

    As a follow-up, I think we can give every outbound onion connection a separate network_id, because they all look distinct to external observers.

    Just to add this info also here for others reading this: this is not helpful because both current functions of network_id, inv scheduling and getaddr caching, do not apply to outbounds anyway (https://github.com/bitcoin/bitcoin/pull/34456). If we use network_id for additional things in the future, we could revisit.

    So maybe we should revisit it with this PR, which also affects outbounds?

  7. fjahr commented at 10:13 PM on November 23, 2026: contributor

    Concept ACK

  8. ismaelsadeeq commented at 1:19 PM on November 24, 2026: member

    Concept ACK

  9. 0xB10C commented at 4:30 AM on December 4, 2026: contributor

    @davidgumberg how would this work together with prefilling?

  10. mzumsande commented at 11:44 AM on December 4, 2026: contributor

    Good point, I didn't think about #35558 when opening this PR. I don't think they are mutually exclusive (we could have the prefilled blocks cache keyed by network), but prefilling would introduce a different fingerprint vector, albeit weaker than the nonce. I'm not sure how much prefilled blocks would differ among nodes, but even if it turned out to be significant, there could be various possible strategies to avoid it.

    But also, I'm not sure how important or useful it is to prefill blocks on privacy networks in the first place: As far as I can see, the TCP window reasoning of #35558 may not apply when the queried CNode::m_sock is not the connection to the peer but the local proxy/daemon. Has this been tested? In addition, Tor and I2p are probably not on the critical path for network-wide propagation/selfish mining issues anyway.


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-12-05 04:51 UTC

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