p2p: Use network-dependent timers for inbound inv scheduling #33464

pull mzumsande wants to merge 2 commits into bitcoin:master from mzumsande:202509_inv_inbound_per_network changing 8 files +75 −36
  1. mzumsande commented at 5:19 pm on September 23, 2025: contributor

    Currently, NextInvToInbounds schedules each round of inv at the same time for all inbound peers. It’s being done this way because with a separate timer per peer (like it’s done for outbounds), an attacker could do multiple connections to learn about the time a transaction arrived. (#13298).

    However, having a single timer for inbounds of all networks is also an obvious fingerprinting vector: Connecting to a suspected pair of privacy-network and clearnet addresses and observing the inv pattern makes it trivial to confirm or refute that they are the same node.

    This PR changes it such that a separate timer is used for each network. It uses the existing method from getaddr caching and generalizes it to be saved in a new field m_network_key in CNode which will be used for both getaddr caching and inv scheduling, and can also be used for any future anti-fingerprinting measures.

  2. net: use generic network key for addrcache
    The generic key can also be used in other places
    where behavior between different network identities should
    be uncorrelated to avoid fingerprinting.
    This also changes RANDOMIZER_ID - since it is not
    being persisted to disk, there are no compatibility issues.
    94db966a3b
  3. p2p: Use different inbound inv timer per network
    Currently nodes schedule their invs to all inbound peers at the same time.
    It is trivial to make use this timing pattern for fingerprinting
    identities on different networks. Using a separate timers for each network will
    make the fingerprinting harder.
    beb75e48ae
  4. DrahtBot added the label P2P on Sep 23, 2025
  5. DrahtBot commented at 5:19 pm on September 23, 2025: contributor

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

    Code Coverage & Benchmarks

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK danielabrozzoni

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. mzumsande marked this as ready for review on Sep 23, 2025
  7. danielabrozzoni commented at 4:42 pm on September 25, 2025: contributor

    tACK beb75e48ae1d5771932f427a490c7e1b6c1720d3

    I tested locally by adding a log line, and checking that different networks schedule different inv times:

     0diff --git a/src/net_processing.cpp b/src/net_processing.cpp
     1index f5f04c7a17..fec1cfcb6b 100644
     2--- a/src/net_processing.cpp
     3+++ b/src/net_processing.cpp
     4@@ -5716,6 +5716,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
     5                     fSendTrickle = true;
     6                     if (pto->IsInboundConn()) {
     7                         tx_relay->m_next_inv_send_time = NextInvToInbounds(current_time, INBOUND_INVENTORY_BROADCAST_INTERVAL, pto->m_network_key);
     8+                        LogInfo("Scheduling next inv send time for inbound peer on network %d at time %d", pto->m_network_key, tx_relay->m_next_inv_send_time);
     9                     } else {
    10                         tx_relay->m_next_inv_send_time = current_time + m_rng.rand_exp_duration(OUTBOUND_INVENTORY_BROADCAST_INTERVAL);
    11                     }
    
     0$ tail -f ~/.bitcoin/debug.log | grep "Scheduling next inv send time"
     12025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     22025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     32025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     42025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     52025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     62025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     72025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     82025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
     92025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
    102025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
    112025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
    122025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 2336814389803672515 at time 1758809657846106us
    132025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 406641846476317050 at time 1758809650020936us
    142025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 406641846476317050 at time 1758809650020936us
    152025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 406641846476317050 at time 1758809650020936us
    162025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 406641846476317050 at time 1758809650020936us
    172025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 406641846476317050 at time 1758809650020936us
    182025-09-25T14:14:09Z Scheduling next inv send time for inbound peer on network 406641846476317050 at time 1758809650020936us
    

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: 2025-09-26 15:13 UTC

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