Merge bitcoin/bitcoin#34410: test: let connections happen in any order in p2p_private_broadcast.py

da7f70a532 test: use port 0 for I2P addresses in p2p_private_broadcast.py (Vasil Dimov)
a8ebcfd34c test: let connections happen in any order in p2p_private_broadcast.py (Vasil Dimov)
67696b207f net: extend log message to include attempted connection type (Vasil Dimov)

Pull request description:

  If the following two events happen:

  * (likely) the automatic 10 initial connections are not made to all
    networks
  * (unlikely) the network-specific logic kicks in almost immediately.
    It is using exponential distribution with a mean of 5 minutes
    (`rng.rand_exp_duration(EXTRA_NETWORK_PEER_INTERVAL)`).

  So if both happen, then the 11th connection may not be the expected
  private broadcast, but a network-specific connection.

  Fix this by retrieving the connection type from
  `destinations_factory()`. This is more flexible because it allows
  connections to happen in any order and does not break if e.g. the 11th
  connection is not the expected first private broadcast.

  This also makes the test run faster:
  before: 19-44 sec
  now: 10-25 sec
  because for example there is no need to wait for the initial 10
  automatic outbound connections to be made in order to proceed.

  Fixes: https://github.com/bitcoin/bitcoin/issues/34387

ACKs for top commit:
  achow101:
    ACK da7f70a532
  andrewtoth:
    ACK da7f70a532
  mzumsande:
    Code Review ACK da7f70a532

Tree-SHA512: 7c293e59c15c148a438e0119343b05eb278205640658c99336d4caf4848c5bae92b48e15f325fa616cbc9d5f394649abfa02406a76e802cffbd3d312a22a6885
This commit is contained in:
Ava Chow
2026-03-02 07:47:53 -08:00
2 changed files with 88 additions and 25 deletions

View File

@@ -390,8 +390,9 @@ CNode* CConnman::ConnectNode(CAddress addrConnect,
}
}
LogDebug(BCLog::NET, "trying %s connection %s lastseen=%.1fhrs\n",
LogDebug(BCLog::NET, "trying %s connection (%s) to %s, lastseen=%.1fhrs\n",
use_v2transport ? "v2" : "v1",
ConnectionTypeAsString(conn_type),
pszDest ? pszDest : addrConnect.ToStringAddrPort(),
Ticks<HoursDouble>(pszDest ? 0h : Now<NodeSeconds>() - addrConnect.nTime));