Skip to content

Option to use ZMQ+Rest to get blocks (as an alternative to p2p, the default) to make electrs work with nodes that connect through proxies#1274

Open
TheQuantumPhysicist wants to merge 4 commits intoromanz:masterfrom
TheQuantumPhysicist:feat/zmq-block-source
Open

Option to use ZMQ+Rest to get blocks (as an alternative to p2p, the default) to make electrs work with nodes that connect through proxies#1274
TheQuantumPhysicist wants to merge 4 commits intoromanz:masterfrom
TheQuantumPhysicist:feat/zmq-block-source

Conversation

@TheQuantumPhysicist
Copy link

@TheQuantumPhysicist TheQuantumPhysicist commented Feb 23, 2026

Nodes that connect through proxies, with the -proxy command line argument, do not bind p2p, meaning, there is no 8333 port binding on loopback. This means that, by definition, electrs will not work on them, since it depends primarily on port p2p receive blocks.

This PR fixes this issue. It uses a combination of ZMQ, for new block notifications, and rest calls to the node to get blocks. The performance is comparable to p2p.

This was done by creating an abstraction layer, a trait, BlockSource, that abstracts both p2p and zmq/rest communication with the node.

To use this branch, make sure to:

  1. Run your node with:rest=1 and zmqpubhashblock=tcp://127.0.0.1:28332 (config or command line args)
  2. Run this branch of electrs with --daemon-zmq-addr 'tcp://127.0.0.1:28332'

I've been testing this for a while and it seems to be working. Would appreciate more testing.

Fixes #901

@romanz
Copy link
Owner

romanz commented Feb 23, 2026

Many thanks for the contribution!
Please consider retargeting this PR to https://github.com/romanz/bindex - electrs will migrate to use bindex soon: #1252

@TheQuantumPhysicist
Copy link
Author

TheQuantumPhysicist commented Feb 23, 2026

Happy to do it, but there are multiple issues in my mind

  1. From reading the referenced issue, seems like it requires core 31, but I'm using this branch. Consider it extra testing. I'm on Bitcoin Knots 29.3. So if I rebase, it'll break it.

  2. I have problems with core 30+ as they're pushing nodes to hold more arbitrary data and spam with bad mempool policy with bad configurability. Recently I stopped using them, and until something like BIP-110 happens to limit that, I'm not touching core with a long stick. I'm not trying to push any agenda here, but if that branch is specifically for core 31, then I'm never gonna be able to use it or even test it.

Not sure how to reconcile all this. I didn't imagine I'd fall into such a conflict. 😅... I'm sorry!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running bitcoin core with tor proxy

2 participants