test: SOCKS5 proxy: expect that connection may be reset when forwarding #35510

pull vasild wants to merge 1 commits into bitcoin:master from vasild:socks5_forward_sockets_handle_reset changing 1 files +18 −3
  1. vasild commented at 9:33 AM on June 11, 2026: contributor

    The forward_sockets() function used by the SOCKS5 proxy forwards data between two connected sockets. It might happen that one of those sockets gets closed/reset abruptly, without sending EOF first. This is to be expected if e.g. bitcoind is shutdown and shouldn't result in noisy harmless messages like:

    2026-06-03T13:23:56.966859Z TestFramework.socks5 (ERROR): socks5 request handling failed (running True)
    Traceback (most recent call last):
      File ".../socks5.py", line 199, in handle
        forward_sockets(self.conn, conn_to, self.wakeup_socket_pair[1], self.serv)
        ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../socks5.py", line 76, in forward_sockets
        data = s.recv(4096)
    ConnectionResetError: [Errno 104] Connection reset by peer
    

    Instead turn this into a debug log message with a nice prefix containing enough information to identify the two forwarded sockets.

    <!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->

  2. DrahtBot added the label Tests on Jun 11, 2026
  3. DrahtBot commented at 9:33 AM on June 11, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK danielabrozzoni

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. danielabrozzoni commented at 9:51 AM on June 11, 2026: member

    Concept ACK! I was about to open PR myself, haha :)

    I wonder if it's worth it to also catch BrokenPipeError, although IIUC it's harder to hit. My attempt at this was: https://github.com/danielabrozzoni/bitcoin/commit/d9ccf9c4ec5616d5f1dabcaf2ab7bb4c73a8fdbc

    Also, I was wondering if this could be removed in p2p_private_broadcast.py - was it added because of the ConnectionResetError, or for some other reason? https://github.com/bitcoin/bitcoin/blob/46d0e21d758c598017b5a9d86381c1c8ccfbe94d/test/functional/p2p_private_broadcast.py#L382-L385

  5. test: SOCKS5 proxy: expect that connection may be reset when forwarding
    The `forward_sockets()` function used by the SOCKS5 proxy forwards data
    between two connected sockets. It might happen that one of those sockets
    gets closed/reset abruptly, without sending EOF first. This is to be
    expected if e.g. `bitcoind` is shutdown and shouldn't result in noisy
    harmless messages like:
    
    ```
    2026-06-03T13:23:56.966859Z TestFramework.socks5 (ERROR): socks5 request handling failed (running True)
    Traceback (most recent call last):
      File ".../socks5.py", line 199, in handle
        forward_sockets(self.conn, conn_to, self.wakeup_socket_pair[1], self.serv)
        ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../socks5.py", line 76, in forward_sockets
        data = s.recv(4096)
    ConnectionResetError: [Errno 104] Connection reset by peer
    ```
    
    Instead turn this into a debug log message with a nice prefix containing
    enough information to identify the two forwarded sockets.
    8a17a9f510
  6. vasild force-pushed on Jun 11, 2026
  7. vasild commented at 9:57 AM on June 11, 2026: contributor

    @optout21, you did some improvements around this code recently, might be interested into this PR @danielabrozzoni, you reported this in #35410#pullrequestreview-4419151702, might be interested as well

  8. DrahtBot added the label CI failed on Jun 11, 2026
  9. DrahtBot commented at 9:58 AM on June 11, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task lint: https://github.com/bitcoin/bitcoin/actions/runs/27337603147/job/80765794480</sub> <sub>LLM reason (✨ experimental): CI failed due to a Python linter syntax error (invalid f-string in test/functional/test_framework/socks5.py:91, “expecting '}'”).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>


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-06-11 10:51 UTC

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