test: use ephemeral ports in p2p_private_broadcast.py #34300

pull vasild wants to merge 1 commits into bitcoin:master from vasild:auto_ports_in_p2p_private_broadcast changing 1 files +4 −5
  1. vasild commented at 9:33 am on January 15, 2026: contributor

    The test p2p_private_broadcast.py gets some Python P2P nodes to listen and instructs the SOCKS5 proxy to redirect connections to them instead of to the requested addresses. This way the bitcoind which uses the proxy is tricked to think it has connected to real routable internet IP addresses or .onion addresses.

    Picking the ports where to Python P2P nodes to listen however is tricky to be done in a non-conflicting way, given that other tests may run in parallel. #34186 made it possible to let the OS select a free port, so use that in p2p_private_broadcast.py.


    Suggested in #29415 (review)

  2. test: use ephemeral ports in p2p_private_broadcast.py
    The test `p2p_private_broadcast.py` gets some Python P2P nodes to listen
    and instructs the SOCKS5 proxy to redirect connections to them instead
    of to the requested addresses. This way the `bitcoind` which uses the
    proxy is tricked to think it has connected to real routable internet
    IP addresses or `.onion` addresses.
    
    Picking the ports where to Python P2P nodes to listen however is tricky
    to be done in a non-conflicting way, given that other tests may run in
    parallel. https://github.com/bitcoin/bitcoin/pull/34186 made it possible
    to let the OS select a free port, so use that in
    `p2p_private_broadcast.py`.
    3e340672ec
  3. DrahtBot added the label Tests on Jan 15, 2026
  4. DrahtBot commented at 9:33 am on January 15, 2026: 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/34300.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK polespinasa, l0rinc, mzumsande

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  5. vasild commented at 9:35 am on January 15, 2026: contributor

    Before this PR:

     0Instructing the SOCKS5 proxy to redirect connection i=0 to 127.0.0.1:21337 (a Python node)
     1Instructing the SOCKS5 proxy to redirect connection i=1 to 127.0.0.1:21338 (a Python node)
     2Instructing the SOCKS5 proxy to redirect connection i=2 to 127.0.0.1:21339 (a Python node)
     3Instructing the SOCKS5 proxy to redirect connection i=3 to 127.0.0.1:21340 (a Python node)
     4Instructing the SOCKS5 proxy to redirect connection i=4 to 127.0.0.1:21341 (a Python node)
     5Instructing the SOCKS5 proxy to redirect connection i=5 to 127.0.0.1:21342 (a Python node)
     6Instructing the SOCKS5 proxy to redirect connection i=6 to 127.0.0.1:21343 (a Python node)
     7Instructing the SOCKS5 proxy to redirect connection i=7 to 127.0.0.1:21344 (a Python node)
     8Instructing the SOCKS5 proxy to redirect connection i=8 to 127.0.0.1:21345 (a Python node)
     9Instructing the SOCKS5 proxy to redirect connection i=9 to 127.0.0.1:21346 (a Python node)
    10Instructing the SOCKS5 proxy to redirect connection i=10 to 127.0.0.1:21325 (nodes[1])
    11Instructing the SOCKS5 proxy to redirect connection i=11 to 127.0.0.1:21348 (a Python node)
    12Instructing the SOCKS5 proxy to redirect connection i=12 to 127.0.0.1:21349 (a Python node)
    13Instructing the SOCKS5 proxy to redirect connection i=13 to 127.0.0.1:21350 (a Python node)
    14Instructing the SOCKS5 proxy to redirect connection i=14 to 127.0.0.1:21351 (a Python node)
    15Instructing the SOCKS5 proxy to redirect connection i=15 to 127.0.0.1:21352 (a Python node)
    16Instructing the SOCKS5 proxy to redirect connection i=16 to 127.0.0.1:21353 (a Python node)
    17Instructing the SOCKS5 proxy to redirect connection i=17 to 127.0.0.1:21354 (a Python node)
    18Instructing the SOCKS5 proxy to redirect connection i=18 to 127.0.0.1:21355 (a Python node)
    19Instructing the SOCKS5 proxy to redirect connection i=19 to 127.0.0.1:21356 (a Python node)
    

    After:

     0Instructing the SOCKS5 proxy to redirect connection i=0 to 127.0.0.1:48136 (a Python node)
     1Instructing the SOCKS5 proxy to redirect connection i=1 to 127.0.0.1:56793 (a Python node)
     2Instructing the SOCKS5 proxy to redirect connection i=2 to 127.0.0.1:57372 (a Python node)
     3Instructing the SOCKS5 proxy to redirect connection i=3 to 127.0.0.1:47092 (a Python node)
     4Instructing the SOCKS5 proxy to redirect connection i=4 to 127.0.0.1:60047 (a Python node)
     5Instructing the SOCKS5 proxy to redirect connection i=5 to 127.0.0.1:47150 (a Python node)
     6Instructing the SOCKS5 proxy to redirect connection i=6 to 127.0.0.1:45511 (a Python node)
     7Instructing the SOCKS5 proxy to redirect connection i=7 to 127.0.0.1:51333 (a Python node)
     8Instructing the SOCKS5 proxy to redirect connection i=8 to 127.0.0.1:38784 (a Python node)
     9Instructing the SOCKS5 proxy to redirect connection i=9 to 127.0.0.1:59711 (a Python node)
    10Instructing the SOCKS5 proxy to redirect connection i=10 to 127.0.0.1:23153 (nodes[1])
    11Instructing the SOCKS5 proxy to redirect connection i=11 to 127.0.0.1:59840 (a Python node)
    12Instructing the SOCKS5 proxy to redirect connection i=12 to 127.0.0.1:42837 (a Python node)
    13Instructing the SOCKS5 proxy to redirect connection i=13 to 127.0.0.1:56980 (a Python node)
    14Instructing the SOCKS5 proxy to redirect connection i=14 to 127.0.0.1:34703 (a Python node)
    15Instructing the SOCKS5 proxy to redirect connection i=15 to 127.0.0.1:38243 (a Python node)
    16Instructing the SOCKS5 proxy to redirect connection i=16 to 127.0.0.1:54689 (a Python node)
    17Instructing the SOCKS5 proxy to redirect connection i=17 to 127.0.0.1:59958 (a Python node)
    18Instructing the SOCKS5 proxy to redirect connection i=18 to 127.0.0.1:45564 (a Python node)
    19Instructing the SOCKS5 proxy to redirect connection i=19 to 127.0.0.1:35246 (a Python node)
    
  6. maflcko added this to the milestone 31.0 on Jan 15, 2026
  7. fanquake requested review from mzumsande on Jan 15, 2026
  8. polespinasa approved
  9. polespinasa commented at 12:07 pm on January 15, 2026: member

    tACK 3e340672ecadb2a32b19574a99a5162806af645e

    The change is clean and make much sense. Not much to add, tested on a pc with ubuntu and the behavior is the expected (as can be seen in the details), ports assigned are random free ports.

     0$ cat ~/Escritorio/debug_test.log | grep "Instructing the SOCKS5"
     12026-01-15T12:02:08.677968Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=0 to 127.0.0.1:40527 (a Python node)
     22026-01-15T12:02:09.180927Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=1 to 127.0.0.1:38025 (a Python node)
     32026-01-15T12:02:09.684747Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=2 to 127.0.0.1:45841 (a Python node)
     42026-01-15T12:02:10.187254Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=3 to 127.0.0.1:41685 (a Python node)
     52026-01-15T12:02:10.688802Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=4 to 127.0.0.1:37435 (a Python node)
     62026-01-15T12:02:11.193521Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=5 to 127.0.0.1:33293 (a Python node)
     72026-01-15T12:02:11.694581Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=6 to 127.0.0.1:41929 (a Python node)
     82026-01-15T12:02:12.195421Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=7 to 127.0.0.1:44423 (a Python node)
     92026-01-15T12:02:12.697424Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=8 to 127.0.0.1:39815 (a Python node)
    102026-01-15T12:02:13.199038Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=9 to 127.0.0.1:33761 (a Python node)
    112026-01-15T12:02:13.253484Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=10 to 127.0.0.1:25729 (nodes[1])
    122026-01-15T12:02:13.305812Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=11 to 127.0.0.1:41703 (a Python node)
    132026-01-15T12:02:13.357092Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=12 to 127.0.0.1:39827 (a Python node)
    142026-01-15T12:02:30.717269Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=13 to 127.0.0.1:33897 (a Python node)
    152026-01-15T12:02:30.768344Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=14 to 127.0.0.1:39527 (a Python node)
    162026-01-15T12:02:30.824610Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=15 to 127.0.0.1:41825 (a Python node)
    172026-01-15T12:02:31.025510Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=16 to 127.0.0.1:39307 (a Python node)
    182026-01-15T12:02:31.077260Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=17 to 127.0.0.1:35991 (a Python node)
    192026-01-15T12:02:31.334837Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=18 to 127.0.0.1:34345 (a Python node)
    202026-01-15T12:02:31.551738Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=19 to 127.0.0.1:34477 (a Python node)
    212026-01-15T12:02:31.708905Z TestFramework (DEBUG): Instructing the SOCKS5 proxy to redirect connection i=20 to 127.0.0.1:42799 (a Python node)
    
  10. l0rinc commented at 12:29 pm on January 15, 2026: contributor
    code review ACK 3e340672ecadb2a32b19574a99a5162806af645e
  11. mzumsande commented at 12:52 pm on January 15, 2026: contributor
    utACK 3e340672ecadb2a32b19574a99a5162806af645e
  12. fanquake merged this on Jan 15, 2026
  13. fanquake closed this on Jan 15, 2026

  14. stickies-v referenced this in commit 9fa736f8e4 on Jan 22, 2026
  15. Sjors commented at 7:58 am on January 23, 2026: member
    This might be triggering occasional test failures, e.g. #34387.
  16. vasild commented at 11:47 am on January 23, 2026: contributor

    This might be triggering occasional test failures, e.g. #34387.

    This PR fiddles with bind ports. If it causes a test failure it would be something like “cannot bind to address: already in use”. The failure in #34387 is a timeout because the transaction was not received by the expected recipient (within 60 seconds). Here is some tentative explanation: #34387 (comment)


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-02-02 06:13 UTC

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