Skip to content

zmq: improve handling of invalid configurations - #37060

Open
jlopp wants to merge 1 commit into
bitcoin:masterfrom
jlopp:zmgConfigHandler
Open

jlopp wants to merge 1 commit into
bitcoin:masterfrom
jlopp:zmgConfigHandler

Conversation

@jlopp

@jlopp jlopp commented Dec 2, 2026 •

Copy link
Copy Markdown
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 at address ; 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.

@DrahtBot

DrahtBot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36904 (log: Remove trailing and embedded newlines from log messages by maflcko)
  • #35902 (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.

@DrahtBot

DrahtBot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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

Hints

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants