WIP: [RFC] ipc: add Events interface for chain and mempool notifications #36985

Draft
ViniciusCestarii wants to merge 4 commits from ipc-events into master AGit
ViniciusCestarii commented 2026-11-25 20:48:35 +00:00 (Migrated from github.com)

This adds an Events IPC interface that streams block and mempool events in one ordered stream, addressing gaps in ZMQ notifications and providing a more modular interface. It supports the following subscriptions:

ZMQ sequence covers all four of these, but only carries hashes (plus the mempool sequence for "A"/"R"), and "R" doesn't include block-inclusion removals or a reason.

Why not just do it with ZMQ?

  • One ordered stream that includes the data. rawblock/rawtx have their own sequence numbers and can't be ordered against sequence. Here every event can include its serialized block or tx in the same ordered stream. Events come in the same order as ZMQ sequence, plus block-inclusion removals.
  • Typed, versioned interface. Cap'n Proto generates the client code and lets the schema evolve without breaking older clients. With ZMQ, clients parse raw bytes by hand which can't evolve existing topics without breaking changes.
  • Fixing these in ZMQ would need new topics reporting on the same events as existing ones, which is confusing for users, and changing the existing topics would break current consumers.
  • Bounded buffering. Events are buffered per subscription up to a byte limit (-ipceventsbuffer), and the client pulls them in batches with waitNext. ZMQ limits are message counts per topic (-zmqpub*hwm), which don't bound memory when messages are full blocks.

Why additional data, including derivable ones?

  • fee, vsize: neither can be derived from the tx alone, so including them saves RPC calls per tx. RPC calls can also fail if the tx was removed in the time in between.
  • mempool sequence: lets a client line events up with getrawmempool (mempool_sequence=true) to bootstrap and keep a mempool mirror in sync.
  • height: not in the serialized block, and needed to handle reorgs without an extra RPC call.
  • hash, txid, wtxid: identifiers are always included, so clients don't need to branch on include_data.

Example of simple clients using this interface, including a mempool mirror: https://github.com/ViniciusCestarii/bitcoin-ipc-events-client

Note: to make this interface usable in this PR, the Cap'n Proto union that this uses is mapped by hand in events-types.h. Ideally this support would be added to libmultiprocess first.

This adds an Events IPC interface that streams block and mempool events in one ordered stream, addressing gaps in ZMQ notifications and providing a more modular interface. It supports the following subscriptions: - `blockConnected`: fires for every block connected to the active chain, including during IBD (blocks connected by a background assumeutxo chainstate are skipped). Carries hash, height and optionally the serialized block. ZMQ `hashblock`/`rawblock` are driven by UpdatedBlockTip, so they skip intermediate blocks when several connect at once and don't fire during IBD. - `blockDisconnected`: fires for every block disconnected during a reorg, with hash, height and optionally the serialized block. - `txAddedToMempool`: fires only for mempool acceptance. Carries txid, wtxid, mempool sequence, fee, vsize and optionally the serialized tx. ZMQ `hashtx`/`rawtx` also fire for every tx in connected and disconnected blocks, so a subscriber can't tell whether a tx entered the mempool (pain point of https://github.com/bitcoin/bitcoin/pull/19462#issuecomment-658304417, https://github.com/bitcoin/bitcoin/pull/23624#issue-1065790580 and https://github.com/bitcoin/bitcoin/pull/7753). - `txRemovedFromMempool`: fires for every removal, including txs removed because they were mined (reason `block`), except during IBD, with txid, wtxid, mempool sequence, removal reason and optionally the serialized tx. ZMQ `sequence` covers all four of these, but only carries hashes (plus the mempool sequence for "A"/"R"), and "R" doesn't include block-inclusion removals or a reason. Why not just do it with ZMQ? - One ordered stream that includes the data. `rawblock`/`rawtx` have their own sequence numbers and can't be ordered against `sequence`. Here every event can include its serialized block or tx in the same ordered stream. Events come in the same order as ZMQ `sequence`, plus block-inclusion removals. - Typed, versioned interface. Cap'n Proto generates the client code and lets the schema [evolve without breaking older clients](https://capnproto.org/language.html#evolving-your-protocol). With ZMQ, clients parse raw bytes by hand which can't evolve existing topics without breaking changes. - Fixing these in ZMQ would need new topics reporting on the same events as existing ones, which is confusing for users, and changing the existing topics would break current consumers. - Bounded buffering. Events are buffered per subscription up to a byte limit (`-ipceventsbuffer`), and the client pulls them in batches with waitNext. ZMQ limits are message counts per topic (-zmqpub*hwm), which don't bound memory when messages are full blocks. Why additional data, including derivable ones? - fee, vsize: neither can be derived from the tx alone, so including them saves RPC calls per tx. RPC calls can also fail if the tx was removed in the time in between. - mempool sequence: lets a client line events up with `getrawmempool` (`mempool_sequence=true`) to bootstrap and keep a mempool mirror in sync. - height: not in the serialized block, and needed to handle reorgs without an extra RPC call. - hash, txid, wtxid: identifiers are always included, so clients don't need to branch on `include_data`. Example of simple clients using this interface, including a mempool mirror: https://github.com/ViniciusCestarii/bitcoin-ipc-events-client Note: to make this interface usable in this PR, the Cap'n Proto `union` that this uses is mapped by hand in `events-types.h`. Ideally this support would be added to libmultiprocess first.
DrahtBot commented 2026-11-25 20:48:46 +00:00 (Migrated from github.com)

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.

Type Reviewers
Concept ACK 0xB10C, m4ycon

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36188 (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36985 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36985.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36985#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [0xB10C](https://github.com/bitcoin/bitcoin/pull/36985#issuecomment-7385927842), [m4ycon](https://github.com/bitcoin/bitcoin/pull/36985#issuecomment-7393530664) | 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. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36188](https://github.com/bitcoin/bitcoin/pull/36188) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36188.svg"></sub> (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy) 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-->
First-time contributor

This is a draft pull request, so Ralph reviewed only its concept. Code review runs on the first push after it is marked ready for review.

Earlier concerns neither republished nor resolved: 1 major finding · 4 minor findings · 11 suggestions. See the Run archive linked from the Review report for their assessments.

Design and approach

Continue concept review of the submitted approach. The decisive reason is the concrete event-time information benefit over the already capable ZMQ sequence baseline: applications can receive payloads, acceptance metadata, and explicit reasoned removals without racing follow-up queries. Reusing the existing IPC architecture is a plausible way to deliver that benefit while preserving legacy feeds. Do not justify it as introducing ordering for the first time, as a durable journal, or as automatically stable because it uses Cap'n Proto. I would change to reworking the approach if representative workloads show unacceptable validation or aggregate queue costs, or if intended consumers require a least-privilege notification endpoint or cross-version guarantees that this IPC contract cannot reasonably provide. A tested bootstrap/recovery procedure, explicit compatibility policy, and representative resource measurements would strengthen the decision. The PR delivers concrete information that the ZMQ sequence feed lacks: payloads, acceptance-time fee and vsize, reasoned removals, and mined removals with their mempool sequence numbers. The open questions are about the intended consumers, the compatibility policy, access boundaries and resource cost at expected fanout. None of them undermines the PR's purpose. 1 2 3 4 5 6 7 8

Review coverage was incomplete.


Reviewed: de3bedfd354a · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:e1a29e5e677c47d383756f0fcf8f3760725c91d1104dd3ccb2f333b6217eba26:47880f5569fd2047d249266f337c4f2a509adf7d96c3ccb1c7644c2c2a650bff --> <!-- ralph-base:2f3f6397bb92beccaccce16742f0574d1617fb3e --> <!-- ralph-head:de3bedfd354a67b4e828c4c086dd82d3c40e4df8 --> <!-- ralph-case:3632d594959064aa905fcbccb8b9e7d6d9a38a32275c5ea6876676bbc65395b9 --> This is a draft pull request, so Ralph reviewed only its concept. Code review runs on the first push after it is marked ready for review. Earlier concerns neither republished nor resolved: 1 major finding · 4 minor findings · 11 suggestions. See the Run archive linked from the Review report for their assessments. ##### Design and approach Continue concept review of the submitted approach. The decisive reason is the concrete event-time information benefit over the already capable ZMQ sequence baseline: applications can receive payloads, acceptance metadata, and explicit reasoned removals without racing follow-up queries. Reusing the existing IPC architecture is a plausible way to deliver that benefit while preserving legacy feeds. Do not justify it as introducing ordering for the first time, as a durable journal, or as automatically stable because it uses Cap'n Proto. I would change to reworking the approach if representative workloads show unacceptable validation or aggregate queue costs, or if intended consumers require a least-privilege notification endpoint or cross-version guarantees that this IPC contract cannot reasonably provide. A tested bootstrap/recovery procedure, explicit compatibility policy, and representative resource measurements would strengthen the decision. The PR delivers concrete information that the ZMQ sequence feed lacks: payloads, acceptance-time fee and vsize, reasoned removals, and mined removals with their mempool sequence numbers. The open questions are about the intended consumers, the compatibility policy, access boundaries and resource cost at expected fanout. None of them undermines the PR's purpose. [1](https://git.fish.foo/bitcoin/bitcoin/pulls/36985) [2](https://github.com/bitcoin/bitcoin/blob/de3bedfd354a67b4e828c4c086dd82d3c40e4df8/src/node/interfaces.cpp#L1065-L1210) [3](https://github.com/bitcoin/bitcoin/blob/de3bedfd354a67b4e828c4c086dd82d3c40e4df8/test/functional/interface_ipc_events.py#L304-L349) [4](https://github.com/bitcoin/bitcoin/blob/0e8f70a86314bc73539b110d947c41d40c4886fc/test/functional/interface_zmq.py#L456-L552) [5](https://github.com/bitcoin/bitcoin/pull/19462#issuecomment-658304417) [6](https://git.fish.foo/bitcoin/bitcoin/pulls/19572) [7](https://github.com/bitcoin/bitcoin/pull/7762#issuecomment-203310746) [8](https://github.com/bitcoin/bitcoin/blob/0e8f70a86314bc73539b110d947c41d40c4886fc/doc/design/multiprocess.md#L103-L128) Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`de3bedfd354a`](<https://git.fish.foo/bitcoin/bitcoin/commit/de3bedfd354a67b4e828c4c086dd82d3c40e4df8>) · [Review report](<https://review.fish.foo/report/36985-de3bedfd354a67b4e828c4c086dd82d3c40e4df8-3491-5.html>) · [Previous reports](<https://review.fish.foo/traces/36985/>) [permalink](<https://review.fish.foo/report/36985-de3bedfd354a67b4e828c4c086dd82d3c40e4df8-3491-5.html>)
ViniciusCestarii commented 2026-11-26 13:30:57 +00:00 (Migrated from github.com)

Force-pushed 19e212f7b9 fixing a Ralph comment

Force-pushed 19e212f7b923fee4cb3b318d0616b61d1c0d2964 fixing a Ralph comment
ViniciusCestarii commented 2026-12-01 12:17:50 +00:00 (Migrated from github.com)

cc @0xB10C @instagibbs @ryanofsky I believe you might be interested in this :)

cc @0xB10C @instagibbs @ryanofsky I believe you might be interested in this :)
edilmedeiros (Migrated from github.com) reviewed 2026-12-02 21:59:09 +00:00
edilmedeiros (Migrated from github.com) left a comment

I think the zmq interface is quite light. Have you had the chance to measure the overhead this adds to the node operation and how it compares to zmq? Also, would be nice to have a latency comparison between them. By latency, I mean the time from the actual state transition to the notification becoming available and the time until the client receives it.

Conceptually, I don't see people talking about deprecating the zmq interface, there are probably many clients out there that depend on it. You are not proposing that here, but that's something that I anticipate from this RFC, better to think better about how a change like this would co-exist with zmq. An obvious advantage is to have more room for upgrading the interface without breaking downstream. But zmq is read-only, contrary to the potential of an interface like this.

Which makes me wonder if there's room to abstract an event interface from the "transport" mechanism used to communicate them to external consumers. I think a comparison with zmq in this regard could also be useful long-term. May also be part of a broader monitoring facility (reminds me of #35142).

I think the zmq interface is quite light. Have you had the chance to measure the overhead this adds to the node operation and how it compares to zmq? Also, would be nice to have a latency comparison between them. By latency, I mean the time from the actual state transition to the notification becoming available and the time until the client receives it. Conceptually, I don't see people talking about deprecating the zmq interface, there are probably many clients out there that depend on it. You are not proposing that here, but that's something that I anticipate from this RFC, better to think better about how a change like this would co-exist with zmq. An obvious advantage is to have more room for upgrading the interface without breaking downstream. But zmq is read-only, contrary to the potential of an interface like this. Which makes me wonder if there's room to abstract an event interface from the "transport" mechanism used to communicate them to external consumers. I think a comparison with zmq in this regard could also be useful long-term. May also be part of a broader monitoring facility (reminds me of #35142).
edilmedeiros (Migrated from github.com) commented 2026-12-02 21:58:04 +00:00

never slows down the node.

That's something I would like to see empirically.

Some potential scenarios:

  • A client subscribes but never consumes events.
  • Several clients subscribe with different consumption rates.
  • A client repeatedly connects and disconnects.
  • A burst of mempool activity causes buffers to overflow.
  • A large reorganization occurs while clients are consuming events.
> never slows down the node. That's something I would like to see empirically. Some potential scenarios: - A client subscribes but never consumes events. - Several clients subscribe with different consumption rates. - A client repeatedly connects and disconnects. - A burst of mempool activity causes buffers to overflow. - A large reorganization occurs while clients are consuming events.
ViniciusCestarii (Migrated from github.com) reviewed 2026-12-03 14:59:34 +00:00
ViniciusCestarii (Migrated from github.com) commented 2026-12-03 14:59:34 +00:00

Agreed, these are good cases to measure. I'll test them and share the results. I'll also rewrite the comment to be more precise saying the node never waits for a slow client instead of that a slow client never slows down the node.

Agreed, these are good cases to measure. I'll test them and share the results. I'll also rewrite the comment to be more precise saying the node never waits for a slow client instead of that a slow client never slows down the node.
ViniciusCestarii commented 2026-12-03 15:07:42 +00:00 (Migrated from github.com)

I think the zmq interface is quite light. Have you had the chance to measure the overhead this adds to the node operation and how it compares to zmq? Also, would be nice to have a latency comparison between them. By latency, I mean the time from the actual state transition to the notification becoming available and the time until the client receives it.

Performance isn't the motivation for this PR but I agree it's worth knowing. I'll measure that and the latency compared to ZMQ.

Conceptually, I don't see people talking about deprecating the zmq interface, there are probably many clients out there that depend on it. You are not proposing that here, but that's something that I anticipate from this RFC, better to think better about how a change like this would co-exist with zmq.

Yes, I don't intend this to replace or deprecate ZMQ. I see it like the Mining IPC interface and getblocktemplate where the new interface covers needs the older one doesn't serve well, while existing clients can keep using the older one.

Which makes me wonder if there's room to abstract an event interface from the "transport" mechanism used to communicate them to external consumers. I think a comparison with zmq in this regard could also be useful long-term.

The internal event notifications are already abstracted from the transport by CValidationInterface, which both ZMQ and this PR build on. What differs is what each exposes on top of it ZMQ publishes raw bytes per topic, while this provides typed events in a single ordered stream that clients pull from. Sharing more than that would mean refactoring ZMQ without a clear benefit, while risking behavior changes for existing clients.

> I think the zmq interface is quite light. Have you had the chance to measure the overhead this adds to the node operation and how it compares to zmq? Also, would be nice to have a latency comparison between them. By latency, I mean the time from the actual state transition to the notification becoming available and the time until the client receives it. Performance isn't the motivation for this PR but I agree it's worth knowing. I'll measure that and the latency compared to ZMQ. > Conceptually, I don't see people talking about deprecating the zmq interface, there are probably many clients out there that depend on it. You are not proposing that here, but that's something that I anticipate from this RFC, better to think better about how a change like this would co-exist with zmq. Yes, I don't intend this to replace or deprecate ZMQ. I see it like the Mining IPC interface and getblocktemplate where the new interface covers needs the older one doesn't serve well, while existing clients can keep using the older one. > Which makes me wonder if there's room to abstract an event interface from the "transport" mechanism used to communicate them to external consumers. I think a comparison with zmq in this regard could also be useful long-term. The internal event notifications are already abstracted from the transport by `CValidationInterface`, which both ZMQ and this PR build on. What differs is what each exposes on top of it ZMQ publishes raw bytes per topic, while this provides typed events in a single ordered stream that clients pull from. Sharing more than that would mean refactoring ZMQ without a clear benefit, while risking behavior changes for existing clients.
0xB10C commented 2026-12-03 17:04:50 +00:00 (Migrated from github.com)

Concept ACK (assuming there are a few consumers of this interface, I'm certainly interested!).

In 2020, I stood up a Bitcoin Core source code fork for coinmetrics.io (now called Talos) called Bitcoin ZMCE (ZMQ Mempool and Chain Events) that does something very similar. They use this in their mempool+chain data collection and monitoring. The current patch sets can be found in https://github.com/coinmetrics/fullnode/tree/master/fullnodes/bitcoin-zmce/patches - I'll ping them, maybe they have input on this PR.

Here's an LLM assisted comparison of your proposal and what I implemented back then. I think you cover most of it, but if there's an easy and cheap way of getting slightly more information out of such interface, why not? I haven't looked into any details.

ZMCE feature In this PR? Notes
Millisecond timestamp on every message No Events here carry no time field. I think that's fine, taking the timestamp on event arrival should be accurate enough for most applications.
chainheaderadded: hash, height and 80-byte header for any accepted header, including ones off the best chain No No header-level event. ZMCE adds a validation signal in AcceptBlockHeader for this. This might be useful to have, but might also be a lot of extra code & work here?
mempoolreplaced: replaced and replacement tx paired, with both fees No Here a replacement shows up as a txRemovedFromMempool with reason replaced plus a separate txAddedToMempool, with nothing linking the two. Having data on replacements has been very interesting, but also probably a bit more work
mempoolconfirmed: tx with block height, block hash and header Partial txRemovedFromMempool with reason block has no block hash or height, and is sent before the blockConnected events.
Header or prev hash without the full block (chaintipchanged, chainconnected) Partial BlockEvent has hash and height; the header and prev hash are only available inside the full block via include_data.
chaintipchanged: one event per tip update Partial Events has blockConnected per block but no tip event. Mining.waitTipChanged returns hash and height on a different interface.
mempooladded: txid, raw tx, fee Yes This PR also has wtxid, vsize and mempool sequence.
mempoolremoved with removal reason, including block Yes This PR also has wtxid and mempool sequence.
chainconnected: hash, height, raw block Yes This PR also has blockDisconnected, which ZMCE has no new topic for.
Per-topic sequence number Yes Here it is a per-subscription sequence where a jump means dropped events.
Send high-water mark raised to 100,000 Not applicable This PR uses a byte-based buffer (-ipceventsbuffer, default 128 MiB).

Thank you for working on this!

Concept ACK (assuming there are a few consumers of this interface, I'm certainly interested!). In 2020, I [stood](https://github.com/coinmetrics/fullnode/commit/50d8e3a263c7d1cfb969d9f429cacf1837a98bef) up a Bitcoin Core source code fork for coinmetrics.io (now called Talos) called Bitcoin ZMCE (ZMQ Mempool and Chain Events) that does something very similar. They use this in their mempool+chain data collection and monitoring. The current patch sets can be found in https://github.com/coinmetrics/fullnode/tree/master/fullnodes/bitcoin-zmce/patches - I'll ping them, maybe they have input on this PR. Here's an LLM assisted comparison of your proposal and what I implemented back then. I think you cover most of it, but if there's an easy and cheap way of getting slightly more information out of such interface, why not? I haven't looked into any details. | ZMCE feature | In this PR? | Notes | |---|---|---| | Millisecond timestamp on every message | No | Events here carry no time field. I think that's fine, taking the timestamp on event arrival should be accurate enough for most applications. | | `chainheaderadded`: hash, height and 80-byte header for any accepted header, including ones off the best chain | No | No header-level event. ZMCE adds a validation signal in `AcceptBlockHeader` for this. This might be useful to have, but might also be a lot of extra code & work here? | | `mempoolreplaced`: replaced and replacement tx paired, with both fees | No | Here a replacement shows up as a `txRemovedFromMempool` with reason `replaced` plus a separate `txAddedToMempool`, with nothing linking the two. Having data on replacements has been very interesting, but also probably a bit more work | | `mempoolconfirmed`: tx with block height, block hash and header | Partial | `txRemovedFromMempool` with reason `block` has no block hash or height, and is sent before the `blockConnected` events. | | Header or prev hash without the full block (`chaintipchanged`, `chainconnected`) | Partial | `BlockEvent` has hash and height; the header and prev hash are only available inside the full block via `include_data`. | | `chaintipchanged`: one event per tip update | Partial | `Events` has `blockConnected` per block but no tip event. `Mining.waitTipChanged` returns hash and height on a different interface. | | `mempooladded`: txid, raw tx, fee | Yes | This PR also has wtxid, vsize and mempool sequence. | | `mempoolremoved` with removal reason, including block | Yes | This PR also has wtxid and mempool sequence. | | `chainconnected`: hash, height, raw block | Yes | This PR also has `blockDisconnected`, which ZMCE has no new topic for. | | Per-topic sequence number | Yes | Here it is a per-subscription sequence where a jump means dropped events. | | Send high-water mark raised to 100,000 | Not applicable | This PR uses a byte-based buffer (`-ipceventsbuffer`, default 128 MiB). | Thank you for working on this!
m4ycon commented 2026-12-03 21:57:11 +00:00 (Migrated from github.com)

Concept ACK

Currently, I'm working on Cluster Mempool Observer as part of https://github.com/0xB10C/project-ideas/issues/15. It does a similar thing as Vinicius' mempool mirror, but by polling the current txids on mempool via RPC and based on this, watch how clusters are being handled (via RPC). All this data is persisted to a SQL database for later analysis.

It has worked well so far, but as I'm aiming for a good correctness rate over time (as polling can leave gaps), I'd probably change to ZMQ and let the RPC polling just as a backfiller.

Your "Why not just do it with ZMQ?" and "Why additional data, including derivable ones?" have some really great points on why I would change to IPC in my case. block(Dis)Connected not losing any batch of blocks coming or dealing with reorg, would make my life easier for sure. txAddedToMempool would save me some RPC calls and txRemovedFromMempool including why they were removed it's useful data.

It makes me wonder whether Core should always prefer extending it over ZMQ (idk the current project thoughts around it), having more freedom to change the interface (versioning), sounds like a strong pro to keep developing IPC as a long-term tooling.

Concept ACK Currently, I'm working on [Cluster Mempool Observer](https://github.com/m4ycon/cluster-mempool-observer) as part of https://github.com/0xB10C/project-ideas/issues/15. It does a similar thing as Vinicius' mempool mirror, but by polling the current txids on mempool via RPC and based on this, watch how clusters are being handled (via RPC). All this data is persisted to a SQL database for later analysis. It has worked well so far, but as I'm aiming for a good correctness rate over time (as polling can leave gaps), I'd probably change to ZMQ and let the RPC polling just as a backfiller. Your "Why not just do it with ZMQ?" and "Why additional data, including derivable ones?" have some really great points on why I would change to IPC in my case. `block(Dis)Connected` not losing any batch of blocks coming or dealing with reorg, would make my life easier for sure. `txAddedToMempool` would save me some RPC calls and `txRemovedFromMempool` including why they were removed it's useful data. It makes me wonder whether Core should always **prefer** extending it over ZMQ (idk the current project thoughts around it), having more freedom to change the interface (versioning), sounds like a strong pro to keep developing IPC as a long-term tooling.
enochaz commented 2026-12-03 23:53:05 +00:00 (Migrated from github.com)

A few thoughts from my first read through. I had something similar in mind a few months ago but didnt take it further because of the overlap with #29409. That PR would also let a client follow block and mempool changes through UnstableChain. If I’m following it correctly, the node waits for the client to return from each callback. When there are more than 10 callbacks pending, it looks like ActivateBestChain can end up waiting too.

With the pull model here, the client can fall behind and still tell from a gap in the stream that it missed something. Was the wait in #29409 part of why you went with a separate interface? Perhaps worth mentioning that PR in the description. It would help me understand where you see each one being used. Small thing I noticed too is that both PRs use @5 for a new method on Init.

I generally like the idea of using IPC outside of mining. Sjors put together a list of projects using ZMQ a while back. Have you had a chance to try this with any of those? A block explorer came to mind since it could get the tx and its fee together, and outside IBD it could tell which mempool txs got mined without having to work that out from the block. Saw your reply about measuring latency against ZMQ. I’d be curious how the numbers look if you include the RPC call a client would otherwise make to get the fee.

One thing I’m still unsure about is access. With ZMQ a client can just listen, but if I give it access to the ipcbind socket, it looks like it can also get Rpc and call any enabled RPC by default, wallet ones included. rpcwhitelist does seem to be checked, though from what I can tell the client supplies the username. Is there already a way to expose just Events on a socket? Perhaps that could be an option alongside the connection limit if there isn’t one already.

A few thoughts from my first read through. I had something similar in mind a few months ago but didnt take it further because of the overlap with #29409. That PR would also let a client follow block and mempool changes through `UnstableChain`. If I’m following it correctly, the node waits for the client to return from each callback. When there are more than 10 callbacks pending, it looks like `ActivateBestChain` can end up waiting too. With the pull model here, the client can fall behind and still tell from a gap in the stream that it missed something. Was the wait in #29409 part of why you went with a separate interface? Perhaps worth mentioning that PR in the description. It would help me understand where you see each one being used. Small thing I noticed too is that both PRs use `@5` for a new method on `Init`. I generally like the idea of using IPC outside of mining. [Sjors put together a list of projects using ZMQ](https://bitcoin.stackexchange.com/questions/125920/which-applications-use-zmq-with-bitcoin-core) a while back. Have you had a chance to try this with any of those? A block explorer came to mind since it could get the tx and its fee together, and outside IBD it could tell which mempool txs got mined without having to work that out from the block. Saw your reply about measuring latency against ZMQ. I’d be curious how the numbers look if you include the RPC call a client would otherwise make to get the fee. One thing I’m still unsure about is access. With ZMQ a client can just listen, but if I give it access to the `ipcbind` socket, it looks like it can also get `Rpc` and call any enabled RPC by default, wallet ones included. `rpcwhitelist` does seem to be checked, though from what I can tell the client supplies the username. Is there already a way to expose just `Events` on a socket? Perhaps that could be an option alongside the connection limit if there isn’t one already.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36985
No description provided.