Skip to content

p2p: Use separate compact block nonce per network - #36955

Open
mzumsande wants to merge 1 commit into
bitcoin:masterfrom
mzumsande:202611_cb_fingerprint
Open

mzumsande wants to merge 1 commit into
bitcoin:masterfrom
mzumsande:202611_cb_fingerprint

Conversation

@mzumsande

Copy link
Copy Markdown
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.

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.
@DrahtBot DrahtBot added the P2P label Nov 23, 2026
@DrahtBot

DrahtBot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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
Concept ACK instagibbs, fjahr, ismaelsadeeq

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:

  • #36787 (cmpctblock: Cache serialized cmpctblock msg for relay [part of prefill series] by davidgumberg)
  • #36372 (p2p: replace full outbound peers that don't support tx relay (take 2) by fjahr)
  • #35561 (net: move some CNodeState fields to Peer by Crypt-iQ)
  • #35558 (p2p: Prefill compact blocks by davidgumberg)
  • #35522 (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.

@instagibbs

Copy link
Copy Markdown
Member

concept ACK

@mzumsande

mzumsande commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

The Ralph comment reminds me of an old conversation:
#33464 (review)

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 (#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?

@fjahr

fjahr commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

1 similar comment
@ismaelsadeeq

Copy link
Copy Markdown
Member

Concept ACK

@0xB10C

0xB10C commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

@davidgumberg how would this work together with prefilling?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants