zmq: improve handling of invalid configurations #37060

pull jlopp wants to merge 1 commits into bitcoin:master from jlopp:zmgConfigHandler changing 7 files +192 −57
  1. jlopp commented at 5:44 PM on December 2, 2026: contributor

    While messing around with various zmq data ingestion setups for a side project I initially was perplexed because my node kept returning an empty array when I called bitcoin-cli getzmqnotifications even though I had 4 zmq emitters configured.

    Upon closer inspection, it looks like if a single zmq config is invalid / fails to be bound, it prevents all other zmq configurations from being bound. And even worse, the failure occurs silently.

    The goal of this PR is to not allow one invalid config to prevent valid configs from working and to make binding failures more obvious in the node logs. Alternatively, if reviewers find it preferable, we could make any zmq bind failure to be a hard error that blocks the node from launching.

    Initialize() now attempts every configured notifier, erases only the failed ones, and returns success if at least one remains. Failures are logged:

    • Per-notifier: Failed to initialize ZMQ notifier <type> at address <addr>; it will be disabled
    • Summary: Initialized X of Y ZMQ notifier(s); Z failed

    getzmqnotifications now reports the surviving notifiers instead of returning [].

    Added ZMQAddressKey() to canonicalize addresses for socket sharing:

    • tcp://localhost:N and tcp://127.0.0.1:N now share one socket.
    • Hostname resolution prefers IPv4 unless the address is a numeric IPv6 literal, matching IsZMQAddressIPV6()/libzmq behavior.
    • Wildcard */empty hosts map to the IPv4 any address.

    Each notifier now stores its canonical key, Shutdown() uses it, and failed init paths clear psocket after zmq_close() to avoid the previous double-close hazard.

  2. zmq: improve handling of invalid configurations bf5464bdc9
  3. DrahtBot added the label RPC/REST/ZMQ on Dec 2, 2026
  4. DrahtBot commented at 6:13 PM on December 2, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36904 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36904.svg"></sub> (log: Remove trailing and embedded newlines from log messages by maflcko)
    • #35902 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35902.svg"></sub> (zmq: Log bind error at Error level, abort startup on init error by chriszeng1010)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. DrahtBot added the label CI failed on Dec 2, 2026
  6. DrahtBot commented at 7:37 PM on December 2, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/46936548306/job/143659617167</sub> <sub>LLM reason (✨ experimental): iwyu_fail: IWYU found required include changes in several files, leaving a diff that caused the check to fail.</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.

    • Intermittent network issues can occur; re-run CI for now, and report the issue if they keep happening.

    • A functional or integration test failure may be intermittent or unrelated to this pull request. If no dedicated issue thread exists, create a new one to track it.

    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-12-04 12:51 UTC

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