test: Add explicit onion bind to p2p_permissions #30805

pull achow101 wants to merge 1 commits into bitcoin:master from achow101:no-tor-p2p-permissions changing 1 files +5 −0
  1. achow101 commented at 8:26 pm on September 3, 2024: member

    When the bind option is replaced in the bitcoin.conf, bitcoind will attempd to bind to the default tor listening port. If another bitcoind is running that is already bound to that port, the bind will fail which, since #22729, causes the test to fail.

    This failure can be avoided by explicitly binding the tor port when the bind is removed.

  2. DrahtBot commented at 8:26 pm on September 3, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK tdb3, theStack, glozow
    Stale ACK ismaelsadeeq

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

  3. DrahtBot added the label Tests on Sep 3, 2024
  4. ismaelsadeeq commented at 4:22 pm on September 4, 2024: member

    Tested ACK e9ad9e01409eaa2009f75deb1cf834983c5a6137

    I was able to recreate the issue locally when running the p2p_permissions test while bitcoind was running on regtest.

     0abubakarismail@Abubakars-MacBook-Pro bitcoin % build/test/functional/p2p_permissions.py
     12024-09-01T12:48:15.964000Z TestFramework (INFO): PRNG seed is: 6689536799961214212
     22024-09-01T12:48:15.964000Z TestFramework (INFO): Initializing test directory /var/folders/dj/d8p8jhd172n7wnq81ryfl6rc0000gn/T/bitcoin_func_test_3_85hfs5
     32024-09-01T12:48:22.801000Z TestFramework (INFO): 127.0.0.1:13395
     42024-09-01T12:48:23.230000Z TestFramework (ERROR): Unexpected exception caught during testing
     5Traceback (most recent call last):
     6  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_framework.py", line 132, in main
     7    self.run_test()
     8  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/build/test/functional/p2p_permissions.py", line 61, in run_test
     9    self.checkpermission(
    10  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/build/test/functional/p2p_permissions.py", line 144, in checkpermission
    11    self.restart_node(1, args)
    12  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_framework.py", line 602, in restart_node
    13    self.start_node(i, extra_args)
    14  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_framework.py", line 554, in start_node
    15    node.wait_for_rpc_connection()
    16  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_node.py", line 275, in wait_for_rpc_connection
    17    raise FailedToStartError(self._node_msg(
    18test_framework.test_node.FailedToStartError: [node 1] bitcoind exited with status 1 during initialization. Error: Unable to bind to 127.0.0.1:18445 on this computer. Bitcoin Core is probably already running.
    19Error: Failed to listen on any port. Use -listen=0 if you want this.
    20************************
    21
    222024-09-01T12:48:23.288000Z TestFramework (INFO): Stopping nodes
    23Traceback (most recent call last):
    24  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/build/test/functional/p2p_permissions.py", line 154, in <module>
    25    P2PPermissionsTests(__file__).main()
    26  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_framework.py", line 155, in main
    27    exit_code = self.shutdown()
    28                ^^^^^^^^^^^^^^^
    29  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_framework.py", line 318, in shutdown
    30    self.stop_nodes()
    31  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_framework.py", line 587, in stop_nodes
    32    node.stop_node(wait=wait, wait_until_stopped=False)
    33  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_node.py", line 395, in stop_node
    34    self.stop(wait=wait)
    35    ^^^^^^^^^
    36  File "/Users/abubakarismail/Desktop/Work/bitcoin-dev/bitcoin/test/functional/test_framework/test_node.py", line 214, in __getattr__
    37    assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
    38           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    39AssertionError: [node 1] Error: no RPC connection
    40[node 1] Cleaning up leftover process
    
    0abubakarismail@Abubakars-MacBook-Pro bitcoin % build/test/functional/p2p_permissions.py
    12024-09-04T16:02:29.124000Z TestFramework (INFO): PRNG seed is: 5770220854766863290
    22024-09-04T16:02:29.124000Z TestFramework (INFO): Initializing test directory /var/folders/dj/d8p8jhd172n7wnq81ryfl6rc0000gn/T/bitcoin_func_test_y1jzos9h
    32024-09-04T16:02:39.269000Z TestFramework (INFO): Stopping nodes
    42024-09-04T16:02:39.436000Z TestFramework (INFO): Cleaning up /var/folders/dj/d8p8jhd172n7wnq81ryfl6rc0000gn/T/bitcoin_func_test_y1jzos9h on exit
    52024-09-04T16:02:39.436000Z TestFramework (INFO): Tests successful
    
  5. in test/functional/p2p_permissions.py:63 in e9ad9e0140 outdated
    58@@ -57,11 +59,13 @@ def run_test(self):
    59         # by modifying the configuration file.
    60         ip_port = "127.0.0.1:{}".format(p2p_port(1))
    61         self.nodes[1].replace_in_config([("bind=127.0.0.1", "whitebind=bloomfilter,forcerelay@" + ip_port)])
    62+        append_config(self.nodes[1].datadir_path, [f"bind=127.0.0.1:{tor_port(self.nodes[1].index)}=onion"])
    


    tdb3 commented at 0:51 am on September 5, 2024:

    nit: adding a comment explaining the reason the line was re-added could help prevent regression in the future.

    e.g.

    0# explicitly bind the tor port to prevent collision with the default tor port 
    

    achow101 commented at 8:00 pm on September 10, 2024:
    Done
  6. tdb3 approved
  7. tdb3 commented at 0:55 am on September 5, 2024: contributor

    ACK e9ad9e01409eaa2009f75deb1cf834983c5a6137

    Good find, thanks. Tested similarly to @ismaelsadeeq (ran bitcoind on regtest independently of p2p_permissions) and observed the PR branch preventing collision (while the master branch encountered it).

    Left a very minor nit. Feel free to ignore.

  8. theStack approved
  9. theStack commented at 12:09 pm on September 10, 2024: contributor
    Tested ACK e9ad9e01409eaa2009f75deb1cf834983c5a6137
  10. achow101 force-pushed on Sep 10, 2024
  11. tdb3 approved
  12. tdb3 commented at 8:03 pm on September 10, 2024: contributor
    ACK a1e737ef089d407256428ea29be20f46bbea71fe
  13. DrahtBot requested review from theStack on Sep 10, 2024
  14. DrahtBot requested review from ismaelsadeeq on Sep 10, 2024
  15. test: Add explicit onion bind to p2p_permissions
    When the bind option is replaced in the bitcoin.conf, bitcoind will
    attempd to bind to the default tor listening port. If another bitcoind
    is running that is already bound to that port, the bind will fail which,
    since #22729, causes the test to fail.
    
    This failure can be avoided by explicitly binding the tor port when the
    bind is removed.
    082779d606
  16. achow101 force-pushed on Sep 10, 2024
  17. tdb3 approved
  18. tdb3 commented at 8:36 pm on September 10, 2024: contributor
    ACK 082779d6062c5b72f3497bb864e4dbb4373a3a4c
  19. theStack approved
  20. theStack commented at 9:08 pm on September 10, 2024: contributor
    re-ACK 082779d6062c5b72f3497bb864e4dbb4373a3a4c
  21. glozow commented at 1:48 am on September 11, 2024: member
    ACK 082779d6062c5b72f3497bb864e4dbb4373a3a4c
  22. glozow merged this on Sep 11, 2024
  23. glozow closed this on Sep 11, 2024


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: 2024-09-20 04:12 UTC

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