Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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. |
jeanpablojp
left a comment
There was a problem hiding this comment.
Concept ACK
0.0.0.0 is the default for -bind itself, and -bind=0.0.0.0:8334=onion passes the new check while tagging nothing. addr_bind comes from GetBindAddress on the accepted socket, so what CreateNodeFromAcceptedSocket compares against m_onion_binds is the concrete address the peer reached.
Same node, same arriving address, same -whitelist. With -bind=0.0.0.0:P=onion the inbound peer is classified by its IP network in getpeerinfo and keeps its noban. Spelling that same address out instead of the wildcard gives onion with no permissions. [::] is classified the same way, and either wildcard is what reaches Tor as the ADD_ONION target.
Rejecting a wildcard onion bind would close that. Naming 127.0.0.1:8334=onion in the message would only make it less likely. Is the first one in scope here?
| A shared bind cannot distinguish Tor-forwarded connections from direct connections, | ||
| which can grant Tor peers unintended IP-based whitelist permissions. | ||
| Users should add a dedicated onion bind to accept incoming Tor connections, or set | ||
| `-listenonion=0` to disable automatic onion service creation. |
There was a problem hiding this comment.
The release note covers upgraders. For someone setting Tor up from scratch, the -bind help advertises default: 127.0.0.1:8334=onion, which still holds with no explicit -bind but not once one is given, and section 2 of doc/tor.md does not mention the dedicated bind. Would a line in one of the two be worth it?
There was a problem hiding this comment.
Thanks, added this to both the -bind help and section 2 of doc/tor.md. They now explain when the default onion bind is added and when an explicit, non-wildcard =onion bind is required.
| assert_raises(FailedToStartError, self.start_node, 2, extra_args=self.expected[2][0] + ["-listenonion=1"]) | ||
| self.nodes[2].wait_until_stopped(expected_ret_code=1, expected_stderr=re.compile("Tor onion service cannot share")) |
There was a problem hiding this comment.
nit: this could use the helper the file already uses further down, and then re, assert_raises and FailedToStartError drop out of the imports. It does loosen the exit status from exactly 1 to any non-zero. Ran it that way and it passes.
| assert_raises(FailedToStartError, self.start_node, 2, extra_args=self.expected[2][0] + ["-listenonion=1"]) | |
| self.nodes[2].wait_until_stopped(expected_ret_code=1, expected_stderr=re.compile("Tor onion service cannot share")) | |
| self.nodes[2].assert_start_raises_init_error( | |
| self.expected[2][0] + ["-listenonion=1"], | |
| "Error: The Tor onion service cannot share a -bind address", | |
| match=ErrorMatch.PARTIAL_REGEX) |
There was a problem hiding this comment.
Switched to assert_start_raises_init_error, thanks.
7fb68e3 to
69116ee
Compare
l0rinc
left a comment
There was a problem hiding this comment.
Rejecting a wildcard onion bind would close that. Naming 127.0.0.1:8334=onion in the message would only make it less likely. Is the first one in scope here?
Thanks , added a wildcard-bind check and test (added you as coauthor), but I’d appreciate a second look from e.g. @vasild who has more experience with this part of the networking code than I do.
| A shared bind cannot distinguish Tor-forwarded connections from direct connections, | ||
| which can grant Tor peers unintended IP-based whitelist permissions. | ||
| Users should add a dedicated onion bind to accept incoming Tor connections, or set | ||
| `-listenonion=0` to disable automatic onion service creation. |
There was a problem hiding this comment.
Thanks, added this to both the -bind help and section 2 of doc/tor.md. They now explain when the default onion bind is added and when an explicit, non-wildcard =onion bind is required.
| assert_raises(FailedToStartError, self.start_node, 2, extra_args=self.expected[2][0] + ["-listenonion=1"]) | ||
| self.nodes[2].wait_until_stopped(expected_ret_code=1, expected_stderr=re.compile("Tor onion service cannot share")) |
There was a problem hiding this comment.
Switched to assert_start_raises_init_error, thanks.
| if (connOptions.onion_binds.empty()) { | ||
| return InitError(_("The automatic Tor onion service requires a dedicated onion bind when -bind is set. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0.")); | ||
| } |
There was a problem hiding this comment.
Isn't this check redundant? Seems to be the same as the added check in AppInitParameterInteraction(). Better have just one. I prefer this one because it uses connOptions.onion_binds. The other one manually "parses" the arguments and checks for =onion suffix which is redundant with the code that sets connOptions.onion_binds. That is, if =onion would have to be changed to e.g. to support case insensitive match, then it would have to be changed in two places, not nice.
There was a problem hiding this comment.
I originally added it to reject the configuration before loading chainstate, but I agree that duplicating the argument parsing just for this case isn’t worth it - removed, thanks
| if (std::ranges::any_of(connOptions.onion_binds, [](auto& b) { return b.IsBindAny(); })) { | ||
| return InitError(_("The automatic Tor onion service cannot use a wildcard onion bind because incoming Tor connections would not be identified. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0.")); | ||
| } |
There was a problem hiding this comment.
This message is technically not correct. If wildcard address is used, incoming Tor connections will still be identified just fine. For example: -bind=1.2.3.4:8333 -bind=0.0.0.0:8334=onion - anything that arrives on port 8334 will be correctly identified as incoming Tor.
The problem, however, is that 0.0.0.0:8334 in addition to being used for binding and classifying connections is also used to instruct the Tor daemon to forward incoming connections to it. And telling the Tor daemon to forward connections to 0.0.0.0:8334 is ill.
So, maybe something like: "The automatic Tor onion service cannot use a wildcard onion bind because the Tor daemon wouldn't be able to forward incoming connections to us. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0."
Or just: "The automatic Tor onion service cannot use a wildcard onion bind. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0."
There was a problem hiding this comment.
Used your shorter version, thanks.
|
|
||
| Nodes configured with `-bind` but no specific `-bind=<addr>=onion` now refuse to start when `-listenonion` is enabled. | ||
| This includes nodes without Tor configured, since `-listenonion` is enabled by default when listening. | ||
| Shared and wildcard binds cannot distinguish Tor-forwarded connections from direct connections, which can grant Tor peers unintended IP-based whitelist permissions. |
There was a problem hiding this comment.
| Shared and wildcard binds cannot distinguish Tor-forwarded connections from direct connections, which can grant Tor peers unintended IP-based whitelist permissions. | |
| Shared binds cannot distinguish Tor-forwarded connections from direct connections, which can grant Tor peers unintended IP-based whitelist permissions. |
same reasoning as in the comment above, wildcard can distinguish.
There was a problem hiding this comment.
I kept "wildcard" here because the IPv4 and IPv6 checks described above both showed misclassification and retained whitelist permissions.
There was a problem hiding this comment.
Further clarification (thanks for double checking this after an offline chat):
-
Indeed shared binds cannot distinguish incoming Tor vs direct connections. E.g. if we bind on
1.2.3.4:8333and accept incoming Tor and incoming direct connections on that address and port then we can't distinguish, obviously. -
If we use a wildcard bind for Tor, e.g.
-bind=0.0.0.0:8334=onion, then the problem is slightly different. I got this wrong initially, thanks for correcting me. The wildcard will bind on all addresses of the machine, e.g.127.0.0.1:8334,1.2.3.4:8334,5.6.7.8:8334and there will be no overlap between those and the direct connections1.2.3.4:8333. So far so good, but when an incoming Tor connection arrives, we will then compare the address it arrived on e.g.5.6.7.8:8334to whatever was given to-bindwhich is0.0.0.0:8334and that will not match 💣. So the connection will be wrongly not considered as an incoming Tor connection. In theory, if we want to fix this:
Line 1791 in 6301d46
then we would have to tweak that comparison to "if there is an entry in m_onion_bind that is a wildcard and the port matches to the port in addr_bind, then consider they are equal. I think that is unnecessary.
s/Tor-forwarded connections/incoming Tor connections/
|
Keep in mind that when running in a container, it is considered best practise to bind to The issue that |
…given and correct the bind release note 5f40d56 partial Merge bitcoin#36170: net: require a dedicated bind for automatic Tor (Konstantin Akimov) 72b3c71 docs: correct when the implicit onion bind is added in release notes (pasta) 5bb8eb3 fix(net): keep a dedicated onion listener when -bind is given (pasta) Pull request description: ## Issue being fixed or feature implemented The backport of bitcoin#22729 (#7300) changed what happens when a node is started with an explicit `-bind=<addr>` but no `-bind=...=onion`. Before, Dash Core always added the dedicated onion listener `127.0.0.1:9996` (`19996` testnet, `19896` regtest) and pointed the automatically created Tor onion service (`-listenonion`, on by default) at it. Now it binds no onion listener and points the onion service at the first `-bind` address. That listener is not in `onion_binds`, so every peer Tor forwards to it is classified by its source address: Tor's loopback address, or the node's own IP when `-bind` is a routable address. It is not classified as an onion peer. As a result, a node that runs an onion service next to a clearnet address (`-externalip`, or a discovered/bound routable address) advertises its clearnet address to peers that reached it through its `.onion` address. That links the two identities, which the privacy-network check in `GetLocal()` is meant to prevent. Those peers also lose the rest of the onion-specific handling, such as `getpeerinfo` `network` and eviction protection for onion peers. The release note added for #7300 has a related problem. It says `-listenonion=0` drops the implicit onion bind, but it never did: the bind is added before `-listenonion` is looked at. An operator whose `127.0.0.1:9996` is taken who follows the note still gets a node that refuses to start. Both changes are only in v24.0.0-rc.1 and rc.2. ### Why this is a real problem Code path at c14104b: - [`src/init.cpp#L2678-L2695`](https://github.com/dashpay/dash/blob/c14104b172a2/src/init.cpp#L2678-L2695): with `vBinds` non-empty and no `=onion` bind, `onion_service_target = connOptions.vBinds.front()` ([L2682](https://github.com/dashpay/dash/blob/c14104b172a2/src/init.cpp#L2682)). It is not pushed into `onion_binds`, and `StartTorControl(onion_service_target)` still runs ([L2694](https://github.com/dashpay/dash/blob/c14104b172a2/src/init.cpp#L2694)). - [`src/net.h#L1291`](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.h#L1291) copies only `onion_binds` into `m_onion_binds`. [`src/net.cpp#L1977`](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.cpp#L1977) sets `inbound_onion` only for listeners in `m_onion_binds`. - [`src/net.cpp#L584-L592`](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.cpp#L584-L592): without `m_inbound_onion`, `ConnectedThroughNetwork()` and `IsConnectedThroughPrivacyNet()` fall back to the peer's source address. The privacy filter in `GetLocal()` ([L186-L193](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.cpp#L186-L193)) then skips the node's own onion address for that peer and lets the clearnet one through. I reproduced this on the unfixed build with a small functional-test-style script. A minimal fake Tor control port accepts `PROTOCOLINFO`/`AUTHENTICATE`/`ADD_ONION` and records the target dashd asks Tor to forward to. A P2P peer then connects to exactly that target, as Tor does for every inbound onion connection, and sends `getaddr`. The node runs with `-bind=127.0.0.1:<port> -listenonion=1 -externalip=1.2.3.4`. Unfixed (c14104b): ``` Tor control commands received: ['PROTOCOLINFO 1', 'AUTHENTICATE', 'GETINFO net/listeners/socks', 'ADD_ONION NEW:ED25519-V3 Port=19899,127.0.0.1:17626'] onion-service target handed to Tor: 127.0.0.1:17626 getnetworkinfo localaddresses: [{'address': '1.2.3.4', 'port': 17626, 'score': 4}, {'address': 'pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion', 'port': 19899, 'score': 4}] Connecting a peer to 127.0.0.1:17626, as Tor would for an inbound onion connection getpeerinfo: addr=127.0.0.1:63442 addrbind=127.0.0.1:17626 network=not_publicly_routable addresses self-advertised to this peer: ['1.2.3.4:17626'] ``` The onion service forwards to the clearnet listener, the forwarded peer is `not_publicly_routable` instead of `onion`, and it is sent the node's clearnet address `1.2.3.4`. In the fixed run the list is empty for two reasons. The privacy filter withholds `1.2.3.4` from an onion peer, and the test `P2PInterface` never sends `sendaddrv2`, so the node cannot send it the v3 onion address either. The fixed run also prints a `wait_until() failed` line after the 10 s wait for addresses; that line is left out of the excerpt above. With this PR: ``` Tor control commands received: ['PROTOCOLINFO 1', 'AUTHENTICATE', 'GETINFO net/listeners/socks', 'ADD_ONION NEW:ED25519-V3 Port=19899,127.0.0.1:19896'] onion-service target handed to Tor: 127.0.0.1:19896 getnetworkinfo localaddresses: [{'address': '1.2.3.4', 'port': 18132, 'score': 4}, {'address': 'pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion', 'port': 19899, 'score': 4}] Connecting a peer to 127.0.0.1:19896, as Tor would for an inbound onion connection getpeerinfo: addr=127.0.0.1:50581 addrbind=127.0.0.1:19896 network=onion addresses self-advertised to this peer: [] ``` <details><summary>Reproduction script (run with <code>WORKTREE=<src root> python3 repro_tor_target.py --configfile=<src root>/test/config.ini</code>)</summary> ```python #!/usr/bin/env python3 """Reproduction: with an explicit -bind (no =onion) and -listenonion=1, which listener does dashd hand to Tor as the onion-service target, and how is a peer that Tor forwards to that target classified? A minimal fake Tor control port answers PROTOCOLINFO/AUTHENTICATE/ADD_ONION and records the target from the ADD_ONION command. The test then connects a P2P peer to exactly that target (what Tor does for every inbound onion connection), prints getpeerinfo's network field, sends getaddr and prints the addresses the node self-advertises to that peer. Run from anywhere: python3 repro_tor_target.py --configfile=<worktree>/test/config.ini """ import os import socket import sys import threading WORKTREE = os.environ["WORKTREE"] sys.path.insert(0, os.path.join(WORKTREE, "test", "functional")) from test_framework.messages import msg_getaddr # noqa: E402 from test_framework.p2p import P2PInterface # noqa: E402 from test_framework.test_framework import BitcoinTestFramework # noqa: E402 from test_framework.util import p2p_port # noqa: E402 ONION_ID = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd" EXTERNAL_IP = "1.2.3.4" class FakeTorControl: def __init__(self): self.srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.srv.bind(("127.0.0.1", 0)) self.srv.listen(1) self.port = self.srv.getsockname()[1] self.commands = [] self.target = None threading.Thread(target=self._serve, daemon=True).start() def _serve(self): conn, _ = self.srv.accept() f = conn.makefile("rwb", buffering=0) while True: line = f.readline() if not line: return cmd = line.decode().strip() self.commands.append(cmd) if cmd.startswith("PROTOCOLINFO"): f.write(b'250-PROTOCOLINFO 1\r\n250-AUTH METHODS=NULL\r\n250-VERSION Tor="0.4.8.12"\r\n250 OK\r\n') elif cmd.startswith("ADD_ONION"): # ADD_ONION NEW:ED25519-V3 Port=<virtport>,<target> self.target = cmd.split("Port=")[1].split(",", 1)[1] f.write(f"250-ServiceID={ONION_ID}\r\n250-PrivateKey=ED25519-V3:AAAA\r\n250 OK\r\n".encode()) else: f.write(b"250 OK\r\n") class AddrCollector(P2PInterface): def __init__(self): super().__init__() self.addrs = [] def on_addr(self, message): self.addrs += [f"{a.ip}:{a.port}" for a in message.addrs] def on_addrv2(self, message): self.addrs += [f"{a.ip}:{a.port}" for a in message.addrs] class ReproTorTarget(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.bind_to_localhost_only = False self.num_nodes = 1 def setup_network(self): self.tor = FakeTorControl() self.extra_args = [[ f"-bind=127.0.0.1:{p2p_port(0)}", "-listenonion=1", f"-torcontrol=127.0.0.1:{self.tor.port}", f"-externalip={EXTERNAL_IP}", "-debug=tor", ]] self.setup_nodes() def run_test(self): node = self.nodes[0] self.log.info(f"dashd args: {self.extra_args[0]}") self.wait_until(lambda: self.tor.target is not None) self.log.info(f"Tor control commands received: {self.tor.commands}") self.log.info(f"onion-service target handed to Tor: {self.tor.target}") self.log.info(f"getnetworkinfo localaddresses: {node.getnetworkinfo()['localaddresses']}") self.generate(node, 1, sync_fun=self.no_op) # leave IBD so self-advertisement happens host, port = self.tor.target.rsplit(":", 1) self.log.info(f"Connecting a peer to {host}:{port}, as Tor would for an inbound onion connection") peer = node.add_p2p_connection(AddrCollector(), dstaddr=host, dstport=int(port)) info = [p for p in node.getpeerinfo() if p["addrbind"] == f"{host}:{port}"][0] self.log.info(f"getpeerinfo: addr={info['addr']} addrbind={info['addrbind']} network={info['network']}") peer.send_and_ping(msg_getaddr()) try: self.wait_until(lambda: len(peer.addrs) > 0, timeout=10) except AssertionError: pass self.log.info(f"addresses self-advertised to this peer: {peer.addrs}") if __name__ == "__main__": ReproTorTarget().main() ``` </details> Release-note claim, unfixed build, with `127.0.0.1:19896` held by another process: ``` $ src/dashd -regtest -datadir=$D -listenonion=0 -port=18555 -rpcport=18556 -printtoconsole=0 Error: Unable to bind to 127.0.0.1:19896 on this computer. Dash Core is probably already running. Error: Failed to listen on any port. Use -listen=0 if you want this. exit=1 ``` ### Why it matters Running an onion service alongside a clearnet address is a supported setup. Operators who also pass an explicit `-bind`, which is common on servers and masternodes, would silently lose the separation between the two once v24.0.0 ships: any peer that connects to the `.onion` address can learn the node's clearnet IP from self-advertisement. Exposure needs a working Tor control connection and a routable local address (`-externalip`, or discovery or a routable `-bind`), so it does not affect every node. Nodes with `-bind` that do not use Tor are unaffected either way. The release-note error is only an operational trap, but it would ship in the v24.0.0 notes. ## What was done? - `src/init.cpp`: drop the branch that used `vBinds.front()` as the onion-service target, so the target is always the first `onion_binds` entry. Without a `-bind=...=onion`, the default onion target is now added to `onion_binds` and used as the Tor target unless `-bind` is given **and** `-listenonion` is disabled. In that one case no onion bind is added and Tor control is not started. `-listenonion` is read after parameter interaction, so `-listen=0` (which soft-sets `-listenonion=0`) is handled as before. The `-bind` help text now mentions the exception. - `doc/release-notes-7300.md`: describe the actual rule. The implicit bind is added unless `-bind` is given together with `-listenonion=0`. `-bind=...=onion` moves it, `-listenonion=0` alone or `-whitebind` alone keeps it, and `-listen=0` disables all binds. - `test/functional/feature_bind_extra.py`: node 2 (explicit `-bind`, no extra port) now says `-listenonion=0` explicitly. Before, it relied on the framework's config default. A new node 3 with explicit `-bind` and `-listenonion=1` must listen on both its `-bind` port and `127.0.0.1:19896`, and a peer connecting to `19896` must show up with `network` `onion`. Node 3's `-torcontrol` points at an unused port so the test never creates an onion service through a Tor instance running on the test host. - `test/functional/feature_proxy.py`: one step starts node 1 with `-listenonion=1` on top of the framework's `bind=127.0.0.1`. With this PR that node would also bind the fixed regtest onion target `127.0.0.1:19896`, which is the port `feature_bind_extra.py` node 3 holds, and since #7300 a failed bind stops startup. Under `test_runner.py -jN` the two tests could then collide. The step now passes `-bind=127.0.0.1:<tor_port(1)>=onion`, the same per-node port the framework uses when it adds the binds itself. I kept this local to the one test rather than teaching `TestNode.start()` a new rule, because it is the only test that enables `-listenonion` together with an explicit bind. ### Why this is the correct minimal fix The root cause is that the onion service can be pointed at a listener that is not tagged as onion. The only listener that can be both the Tor target and correctly tagged is one in `onion_binds`, so the target must always come from `onion_binds`. The alternative of adding `vBinds.front()` to `onion_binds` would tag every clearnet peer on that port as onion, which leaks the onion address to clearnet peers and distorts eviction, so it is not an option. Two other designs would avoid the multi-instance cost described under Breaking Changes. Both are reasonable, and the choice is up to maintainers: - When `-bind` is given without `=onion` and `-listenonion` is not set explicitly, soft-set `-listenonion=0` during parameter interaction. This keeps rc.1's "respect `-bind`" behavior and avoids the extra bind. The cost is that nodes upgrading from v23 with `-bind` and an automatic onion service would silently lose that onion service. - Keep the default onion bind, but treat a failure to bind it as non-fatal and skip Tor control in that case. This brings back v23's tolerance for this one bind and gives up part of #7300's "fail on any bind error" rule. This PR does neither. It keeps v23's behavior for the onion service, plus the stricter bind handling from #7300. bitcoin#22729's goal was to let users avoid the extra `127.0.0.1:9996` bind. This PR keeps that, but only when the user also says they don't want an onion service (`-listenonion=0`). Without an onion service there is nothing to tag. Nothing changes for nodes without `-bind`, with `-bind=...=onion`, or with `-listen=0`. The stricter "fail startup if any bind fails" part of bitcoin#22729 is unchanged too. ### Relation to upstream Bitcoin Core has the same bug. The open upstream fix, bitcoin#36170 ("net: require a dedicated bind for automatic Tor"), has an Approach ACK. It also removes the `vBinds.front()` fallback, but handles the `-bind` + `-listenonion` case differently: instead of adding the default onion bind, it refuses to start until the operator adds `-bind=<addr>=onion` or `-listenonion=0`. That turns every existing `-bind` setup with the default `-listenonion=1` into a startup error, including many masternodes, so this PR keeps v23's default onion bind for that case. The `src/init.cpp` block uses the same layout as bitcoin#36170: the default bind is added up front under one condition, and the Tor target is always `onion_binds[0]` inside the `-listenonion` branch. Backporting bitcoin#36170 later then only changes that condition and adds its errors. bitcoin#36170 also rejects a wildcard `=onion` bind. That is left to the backport, since it is a separate new startup error. This should also go to the v24.0.x release branch, since the behavior was introduced in v24.0.0-rc.1. ## How Has This Been Tested? macOS arm64, `--enable-debug` build, functional tests run outside any sandbox. - Reproduction script above: unfixed build shows the onion target `127.0.0.1:<bind port>`, peer `network=not_publicly_routable`, and the peer is sent `1.2.3.4`. Fixed build shows target `127.0.0.1:19896`, peer `network=onion`, and no clearnet address is sent. - `feature_bind_extra.py` with the new cases. The test is Linux-only (it reads `/proc/net/tcp`), so I ran it locally through a wrapper that swaps `get_bind_addrs()` for an `lsof`-based equivalent and lifts the platform skip. The test itself is unchanged. Nodes 0–2 pass on both builds. - Unfixed (only the `src/init.cpp` hunks reverted): fails at node 3 with `AssertionError: not({('7f000001', 17013)} == {('7f000001', 17013), ('7f000001', 19896)})`. - Fixed: passes, including the `network == "onion"` check. - `feature_proxy.py` with `--nocleanup`, checking the `Bound to` lines in node 1's `debug.log`: - Fixed build without the `feature_proxy.py` change: node 1 binds `127.0.0.1:19896`. This is the collision described above. - Fixed build with the change: node 1 binds only its p2p port and its `tor_port()`, and nothing on `19896`. The test passes. - Unfixed build with the change: same binds, and the test passes. - Release-note cases on the fixed build, with `127.0.0.1:19896` held by another process: `-listenonion=0` alone still fails with `Unable to bind to 127.0.0.1:19896`, as the corrected note says. `-bind=127.0.0.1:18555 -listenonion=0` starts. - `test/functional/test_runner.py feature_proxy.py p2p_eviction.py rpc_net.py` (after the test changes) and earlier `feature_config_args.py`: all passed. `feature_config_args.py` failed once in a `-j4` run with `Unable to start HTTP server` (an RPC port collision with another run on the same host) and passed on rerun. `feature_bind_extra.py`, `feature_bind_port_*.py` and `rpc_bind.py` are skipped on macOS by the runner. CI covers them on Linux. - `test/lint/lint-whitespace.py` and flake8 with the codes enabled in `test/lint/lint-python.py` pass. The `-bind` help line keeps the single-line `AddArg` style of its neighbours rather than the clang-format suggestion. ## Breaking Changes Compared with v24.0.0-rc.1/rc.2 only: a node started with an explicit `-bind` and `-listenonion` enabled (the default) binds `127.0.0.1:9996` (`19996` testnet) again, as v23 did. With the stricter bind handling from #7300, it fails to start if that port is unavailable. This breaks one setup that works on rc.1/rc.2: several `dashd` instances on one host and one chain, each with its own explicit `-bind`, and `-listenonion` left at its default. For example, several masternodes on separate IPs on one server. On rc.1/rc.2 each instance binds only its own `-bind` address. With this PR every instance also tries to bind `127.0.0.1:9996`; the first one gets it and every later one fails to start. v23 started all of them because a failed bind was only a warning there, and avoiding this extra bind was the reason for bitcoin#22729. Operators with that setup need one of these per instance: - `-listenonion=0`, if the instance does not need an automatic onion service; or - a distinct `-bind=127.0.0.1:<port>=onion` for each instance. Maintainers should weigh this cost against the self-advertisement problem above before merging. The alternatives listed under "Why this is the correct minimal fix" avoid this cost but make other trade-offs. ## Checklist: - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: knst: self-ACK 5f40d56 Tree-SHA512: 049a3879405756f81ac5fd5a7f1322cc56a1e78d705dd7774e6e0a144fd6a0da0439d9dd106901c91fb3c9dd8395c0143bfa58c363f0b2ec80ffe43ee123312c
…given and correct the bind release note 5f40d56 partial Merge bitcoin#36170: net: require a dedicated bind for automatic Tor (Konstantin Akimov) 72b3c71 docs: correct when the implicit onion bind is added in release notes (pasta) 5bb8eb3 fix(net): keep a dedicated onion listener when -bind is given (pasta) Pull request description: ## Issue being fixed or feature implemented The backport of bitcoin#22729 (#7300) changed what happens when a node is started with an explicit `-bind=<addr>` but no `-bind=...=onion`. Before, Dash Core always added the dedicated onion listener `127.0.0.1:9996` (`19996` testnet, `19896` regtest) and pointed the automatically created Tor onion service (`-listenonion`, on by default) at it. Now it binds no onion listener and points the onion service at the first `-bind` address. That listener is not in `onion_binds`, so every peer Tor forwards to it is classified by its source address: Tor's loopback address, or the node's own IP when `-bind` is a routable address. It is not classified as an onion peer. As a result, a node that runs an onion service next to a clearnet address (`-externalip`, or a discovered/bound routable address) advertises its clearnet address to peers that reached it through its `.onion` address. That links the two identities, which the privacy-network check in `GetLocal()` is meant to prevent. Those peers also lose the rest of the onion-specific handling, such as `getpeerinfo` `network` and eviction protection for onion peers. The release note added for #7300 has a related problem. It says `-listenonion=0` drops the implicit onion bind, but it never did: the bind is added before `-listenonion` is looked at. An operator whose `127.0.0.1:9996` is taken who follows the note still gets a node that refuses to start. Both changes are only in v24.0.0-rc.1 and rc.2. ### Why this is a real problem Code path at c14104b: - [`src/init.cpp#L2678-L2695`](https://github.com/dashpay/dash/blob/c14104b172a2/src/init.cpp#L2678-L2695): with `vBinds` non-empty and no `=onion` bind, `onion_service_target = connOptions.vBinds.front()` ([L2682](https://github.com/dashpay/dash/blob/c14104b172a2/src/init.cpp#L2682)). It is not pushed into `onion_binds`, and `StartTorControl(onion_service_target)` still runs ([L2694](https://github.com/dashpay/dash/blob/c14104b172a2/src/init.cpp#L2694)). - [`src/net.h#L1291`](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.h#L1291) copies only `onion_binds` into `m_onion_binds`. [`src/net.cpp#L1977`](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.cpp#L1977) sets `inbound_onion` only for listeners in `m_onion_binds`. - [`src/net.cpp#L584-L592`](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.cpp#L584-L592): without `m_inbound_onion`, `ConnectedThroughNetwork()` and `IsConnectedThroughPrivacyNet()` fall back to the peer's source address. The privacy filter in `GetLocal()` ([L186-L193](https://github.com/dashpay/dash/blob/c14104b172a2/src/net.cpp#L186-L193)) then skips the node's own onion address for that peer and lets the clearnet one through. I reproduced this on the unfixed build with a small functional-test-style script. A minimal fake Tor control port accepts `PROTOCOLINFO`/`AUTHENTICATE`/`ADD_ONION` and records the target dashd asks Tor to forward to. A P2P peer then connects to exactly that target, as Tor does for every inbound onion connection, and sends `getaddr`. The node runs with `-bind=127.0.0.1:<port> -listenonion=1 -externalip=1.2.3.4`. Unfixed (c14104b): ``` Tor control commands received: ['PROTOCOLINFO 1', 'AUTHENTICATE', 'GETINFO net/listeners/socks', 'ADD_ONION NEW:ED25519-V3 Port=19899,127.0.0.1:17626'] onion-service target handed to Tor: 127.0.0.1:17626 getnetworkinfo localaddresses: [{'address': '1.2.3.4', 'port': 17626, 'score': 4}, {'address': 'pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion', 'port': 19899, 'score': 4}] Connecting a peer to 127.0.0.1:17626, as Tor would for an inbound onion connection getpeerinfo: addr=127.0.0.1:63442 addrbind=127.0.0.1:17626 network=not_publicly_routable addresses self-advertised to this peer: ['1.2.3.4:17626'] ``` The onion service forwards to the clearnet listener, the forwarded peer is `not_publicly_routable` instead of `onion`, and it is sent the node's clearnet address `1.2.3.4`. In the fixed run the list is empty for two reasons. The privacy filter withholds `1.2.3.4` from an onion peer, and the test `P2PInterface` never sends `sendaddrv2`, so the node cannot send it the v3 onion address either. The fixed run also prints a `wait_until() failed` line after the 10 s wait for addresses; that line is left out of the excerpt above. With this PR: ``` Tor control commands received: ['PROTOCOLINFO 1', 'AUTHENTICATE', 'GETINFO net/listeners/socks', 'ADD_ONION NEW:ED25519-V3 Port=19899,127.0.0.1:19896'] onion-service target handed to Tor: 127.0.0.1:19896 getnetworkinfo localaddresses: [{'address': '1.2.3.4', 'port': 18132, 'score': 4}, {'address': 'pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion', 'port': 19899, 'score': 4}] Connecting a peer to 127.0.0.1:19896, as Tor would for an inbound onion connection getpeerinfo: addr=127.0.0.1:50581 addrbind=127.0.0.1:19896 network=onion addresses self-advertised to this peer: [] ``` <details><summary>Reproduction script (run with <code>WORKTREE=<src root> python3 repro_tor_target.py --configfile=<src root>/test/config.ini</code>)</summary> ```python #!/usr/bin/env python3 """Reproduction: with an explicit -bind (no =onion) and -listenonion=1, which listener does dashd hand to Tor as the onion-service target, and how is a peer that Tor forwards to that target classified? A minimal fake Tor control port answers PROTOCOLINFO/AUTHENTICATE/ADD_ONION and records the target from the ADD_ONION command. The test then connects a P2P peer to exactly that target (what Tor does for every inbound onion connection), prints getpeerinfo's network field, sends getaddr and prints the addresses the node self-advertises to that peer. Run from anywhere: python3 repro_tor_target.py --configfile=<worktree>/test/config.ini """ import os import socket import sys import threading WORKTREE = os.environ["WORKTREE"] sys.path.insert(0, os.path.join(WORKTREE, "test", "functional")) from test_framework.messages import msg_getaddr # noqa: E402 from test_framework.p2p import P2PInterface # noqa: E402 from test_framework.test_framework import BitcoinTestFramework # noqa: E402 from test_framework.util import p2p_port # noqa: E402 ONION_ID = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd" EXTERNAL_IP = "1.2.3.4" class FakeTorControl: def __init__(self): self.srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.srv.bind(("127.0.0.1", 0)) self.srv.listen(1) self.port = self.srv.getsockname()[1] self.commands = [] self.target = None threading.Thread(target=self._serve, daemon=True).start() def _serve(self): conn, _ = self.srv.accept() f = conn.makefile("rwb", buffering=0) while True: line = f.readline() if not line: return cmd = line.decode().strip() self.commands.append(cmd) if cmd.startswith("PROTOCOLINFO"): f.write(b'250-PROTOCOLINFO 1\r\n250-AUTH METHODS=NULL\r\n250-VERSION Tor="0.4.8.12"\r\n250 OK\r\n') elif cmd.startswith("ADD_ONION"): # ADD_ONION NEW:ED25519-V3 Port=<virtport>,<target> self.target = cmd.split("Port=")[1].split(",", 1)[1] f.write(f"250-ServiceID={ONION_ID}\r\n250-PrivateKey=ED25519-V3:AAAA\r\n250 OK\r\n".encode()) else: f.write(b"250 OK\r\n") class AddrCollector(P2PInterface): def __init__(self): super().__init__() self.addrs = [] def on_addr(self, message): self.addrs += [f"{a.ip}:{a.port}" for a in message.addrs] def on_addrv2(self, message): self.addrs += [f"{a.ip}:{a.port}" for a in message.addrs] class ReproTorTarget(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.bind_to_localhost_only = False self.num_nodes = 1 def setup_network(self): self.tor = FakeTorControl() self.extra_args = [[ f"-bind=127.0.0.1:{p2p_port(0)}", "-listenonion=1", f"-torcontrol=127.0.0.1:{self.tor.port}", f"-externalip={EXTERNAL_IP}", "-debug=tor", ]] self.setup_nodes() def run_test(self): node = self.nodes[0] self.log.info(f"dashd args: {self.extra_args[0]}") self.wait_until(lambda: self.tor.target is not None) self.log.info(f"Tor control commands received: {self.tor.commands}") self.log.info(f"onion-service target handed to Tor: {self.tor.target}") self.log.info(f"getnetworkinfo localaddresses: {node.getnetworkinfo()['localaddresses']}") self.generate(node, 1, sync_fun=self.no_op) # leave IBD so self-advertisement happens host, port = self.tor.target.rsplit(":", 1) self.log.info(f"Connecting a peer to {host}:{port}, as Tor would for an inbound onion connection") peer = node.add_p2p_connection(AddrCollector(), dstaddr=host, dstport=int(port)) info = [p for p in node.getpeerinfo() if p["addrbind"] == f"{host}:{port}"][0] self.log.info(f"getpeerinfo: addr={info['addr']} addrbind={info['addrbind']} network={info['network']}") peer.send_and_ping(msg_getaddr()) try: self.wait_until(lambda: len(peer.addrs) > 0, timeout=10) except AssertionError: pass self.log.info(f"addresses self-advertised to this peer: {peer.addrs}") if __name__ == "__main__": ReproTorTarget().main() ``` </details> Release-note claim, unfixed build, with `127.0.0.1:19896` held by another process: ``` $ src/dashd -regtest -datadir=$D -listenonion=0 -port=18555 -rpcport=18556 -printtoconsole=0 Error: Unable to bind to 127.0.0.1:19896 on this computer. Dash Core is probably already running. Error: Failed to listen on any port. Use -listen=0 if you want this. exit=1 ``` ### Why it matters Running an onion service alongside a clearnet address is a supported setup. Operators who also pass an explicit `-bind`, which is common on servers and masternodes, would silently lose the separation between the two once v24.0.0 ships: any peer that connects to the `.onion` address can learn the node's clearnet IP from self-advertisement. Exposure needs a working Tor control connection and a routable local address (`-externalip`, or discovery or a routable `-bind`), so it does not affect every node. Nodes with `-bind` that do not use Tor are unaffected either way. The release-note error is only an operational trap, but it would ship in the v24.0.0 notes. ## What was done? - `src/init.cpp`: drop the branch that used `vBinds.front()` as the onion-service target, so the target is always the first `onion_binds` entry. Without a `-bind=...=onion`, the default onion target is now added to `onion_binds` and used as the Tor target unless `-bind` is given **and** `-listenonion` is disabled. In that one case no onion bind is added and Tor control is not started. `-listenonion` is read after parameter interaction, so `-listen=0` (which soft-sets `-listenonion=0`) is handled as before. The `-bind` help text now mentions the exception. - `doc/release-notes-7300.md`: describe the actual rule. The implicit bind is added unless `-bind` is given together with `-listenonion=0`. `-bind=...=onion` moves it, `-listenonion=0` alone or `-whitebind` alone keeps it, and `-listen=0` disables all binds. - `test/functional/feature_bind_extra.py`: node 2 (explicit `-bind`, no extra port) now says `-listenonion=0` explicitly. Before, it relied on the framework's config default. A new node 3 with explicit `-bind` and `-listenonion=1` must listen on both its `-bind` port and `127.0.0.1:19896`, and a peer connecting to `19896` must show up with `network` `onion`. Node 3's `-torcontrol` points at an unused port so the test never creates an onion service through a Tor instance running on the test host. - `test/functional/feature_proxy.py`: one step starts node 1 with `-listenonion=1` on top of the framework's `bind=127.0.0.1`. With this PR that node would also bind the fixed regtest onion target `127.0.0.1:19896`, which is the port `feature_bind_extra.py` node 3 holds, and since #7300 a failed bind stops startup. Under `test_runner.py -jN` the two tests could then collide. The step now passes `-bind=127.0.0.1:<tor_port(1)>=onion`, the same per-node port the framework uses when it adds the binds itself. I kept this local to the one test rather than teaching `TestNode.start()` a new rule, because it is the only test that enables `-listenonion` together with an explicit bind. ### Why this is the correct minimal fix The root cause is that the onion service can be pointed at a listener that is not tagged as onion. The only listener that can be both the Tor target and correctly tagged is one in `onion_binds`, so the target must always come from `onion_binds`. The alternative of adding `vBinds.front()` to `onion_binds` would tag every clearnet peer on that port as onion, which leaks the onion address to clearnet peers and distorts eviction, so it is not an option. Two other designs would avoid the multi-instance cost described under Breaking Changes. Both are reasonable, and the choice is up to maintainers: - When `-bind` is given without `=onion` and `-listenonion` is not set explicitly, soft-set `-listenonion=0` during parameter interaction. This keeps rc.1's "respect `-bind`" behavior and avoids the extra bind. The cost is that nodes upgrading from v23 with `-bind` and an automatic onion service would silently lose that onion service. - Keep the default onion bind, but treat a failure to bind it as non-fatal and skip Tor control in that case. This brings back v23's tolerance for this one bind and gives up part of #7300's "fail on any bind error" rule. This PR does neither. It keeps v23's behavior for the onion service, plus the stricter bind handling from #7300. bitcoin#22729's goal was to let users avoid the extra `127.0.0.1:9996` bind. This PR keeps that, but only when the user also says they don't want an onion service (`-listenonion=0`). Without an onion service there is nothing to tag. Nothing changes for nodes without `-bind`, with `-bind=...=onion`, or with `-listen=0`. The stricter "fail startup if any bind fails" part of bitcoin#22729 is unchanged too. ### Relation to upstream Bitcoin Core has the same bug. The open upstream fix, bitcoin#36170 ("net: require a dedicated bind for automatic Tor"), has an Approach ACK. It also removes the `vBinds.front()` fallback, but handles the `-bind` + `-listenonion` case differently: instead of adding the default onion bind, it refuses to start until the operator adds `-bind=<addr>=onion` or `-listenonion=0`. That turns every existing `-bind` setup with the default `-listenonion=1` into a startup error, including many masternodes, so this PR keeps v23's default onion bind for that case. The `src/init.cpp` block uses the same layout as bitcoin#36170: the default bind is added up front under one condition, and the Tor target is always `onion_binds[0]` inside the `-listenonion` branch. Backporting bitcoin#36170 later then only changes that condition and adds its errors. bitcoin#36170 also rejects a wildcard `=onion` bind. That is left to the backport, since it is a separate new startup error. This should also go to the v24.0.x release branch, since the behavior was introduced in v24.0.0-rc.1. ## How Has This Been Tested? macOS arm64, `--enable-debug` build, functional tests run outside any sandbox. - Reproduction script above: unfixed build shows the onion target `127.0.0.1:<bind port>`, peer `network=not_publicly_routable`, and the peer is sent `1.2.3.4`. Fixed build shows target `127.0.0.1:19896`, peer `network=onion`, and no clearnet address is sent. - `feature_bind_extra.py` with the new cases. The test is Linux-only (it reads `/proc/net/tcp`), so I ran it locally through a wrapper that swaps `get_bind_addrs()` for an `lsof`-based equivalent and lifts the platform skip. The test itself is unchanged. Nodes 0–2 pass on both builds. - Unfixed (only the `src/init.cpp` hunks reverted): fails at node 3 with `AssertionError: not({('7f000001', 17013)} == {('7f000001', 17013), ('7f000001', 19896)})`. - Fixed: passes, including the `network == "onion"` check. - `feature_proxy.py` with `--nocleanup`, checking the `Bound to` lines in node 1's `debug.log`: - Fixed build without the `feature_proxy.py` change: node 1 binds `127.0.0.1:19896`. This is the collision described above. - Fixed build with the change: node 1 binds only its p2p port and its `tor_port()`, and nothing on `19896`. The test passes. - Unfixed build with the change: same binds, and the test passes. - Release-note cases on the fixed build, with `127.0.0.1:19896` held by another process: `-listenonion=0` alone still fails with `Unable to bind to 127.0.0.1:19896`, as the corrected note says. `-bind=127.0.0.1:18555 -listenonion=0` starts. - `test/functional/test_runner.py feature_proxy.py p2p_eviction.py rpc_net.py` (after the test changes) and earlier `feature_config_args.py`: all passed. `feature_config_args.py` failed once in a `-j4` run with `Unable to start HTTP server` (an RPC port collision with another run on the same host) and passed on rerun. `feature_bind_extra.py`, `feature_bind_port_*.py` and `rpc_bind.py` are skipped on macOS by the runner. CI covers them on Linux. - `test/lint/lint-whitespace.py` and flake8 with the codes enabled in `test/lint/lint-python.py` pass. The `-bind` help line keeps the single-line `AddArg` style of its neighbours rather than the clang-format suggestion. ## Breaking Changes Compared with v24.0.0-rc.1/rc.2 only: a node started with an explicit `-bind` and `-listenonion` enabled (the default) binds `127.0.0.1:9996` (`19996` testnet) again, as v23 did. With the stricter bind handling from #7300, it fails to start if that port is unavailable. This breaks one setup that works on rc.1/rc.2: several `dashd` instances on one host and one chain, each with its own explicit `-bind`, and `-listenonion` left at its default. For example, several masternodes on separate IPs on one server. On rc.1/rc.2 each instance binds only its own `-bind` address. With this PR every instance also tries to bind `127.0.0.1:9996`; the first one gets it and every later one fails to start. v23 started all of them because a failed bind was only a warning there, and avoiding this extra bind was the reason for bitcoin#22729. Operators with that setup need one of these per instance: - `-listenonion=0`, if the instance does not need an automatic onion service; or - a distinct `-bind=127.0.0.1:<port>=onion` for each instance. Maintainers should weigh this cost against the self-advertisement problem above before merging. The alternatives listed under "Why this is the correct minimal fix" avoid this cost but make other trade-offs. ## Checklist: - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: knst: self-ACK 5f40d56 Tree-SHA512: 049a3879405756f81ac5fd5a7f1322cc56a1e78d705dd7774e6e0a144fd6a0da0439d9dd106901c91fb3c9dd8395c0143bfa58c363f0b2ec80ffe43ee123312c (cherry picked from commit d721bef)
fbe6526 Merge #7807: feat(consensus): hold EvoNode shares and multiple payouts behind a new evo_shares deployment (pasta) 57fd2d9 Merge #7776: fix: keep a pending ProUpServTx across a registrar update that keeps the operator key (pasta) ca69801 Merge #7803: fix: return non-zero amount of accounts after sethdseed (pasta) 57a8f07 Merge #7796: backport: bitcoin#26720 (remaining), partial bitcoin#29523: weight-check the knapsack exact-match selection (pasta) 4eb82f6 Merge #7786: fix(net): keep a dedicated onion listener when -bind is given and correct the bind release note (pasta) 70626a0 Merge #7793: backport: partial bitcoin#28868 (wallet: reload wallet if migration exited early, keep mixed watchonly txs) (pasta) 250a3cd Merge #7790: fix: guard cached governance object flags with the object lock (pasta) 700c195 Merge #7787: fix: only sign EHF signals inside the deployment's start/timeout window (pasta) a3b0f3c Merge #7785: fix: restore the txindex requirement when governance validation is enabled (pasta) 2d1735d Merge #7794: fix(wallet): floor the denomination gap threshold so rebalancing cannot oscillate (pasta) d9f6592 Merge #7783: fix: stop fish completion from re-running the typed dash-cli command (pasta) 89d44c8 Merge #7795: backport: bitcoin#34272, partial bitcoin#31650 (pass PSBT by const reference in PSBTInputSignedAndVerified) (pasta) a1d7411 Merge #7779: fix!: report legacy evonode Platform addresses when listdiff changes its address (pasta) 73f6ea2 Merge #7789: fix(qt): report malformed lang/font settings instead of aborting at startup (pasta) 40de493 Merge #7781: fix(rpc): use a consistent tip height in quorum dkgstatus (pasta) 7d1a90d Merge #7791: fix(net): request object votes from nPeersPerHashMax peers (pasta) 51b145c Merge #7778: test: use single-member in functional tests: feature_mnehf, feature_notifications, p2p_instantsend (pasta) Pull request description: ## Issue being fixed or feature implemented Backports for v24.0.0-rc.3. `v24.0.x` was cut at the v24.0.0-rc.2 tag (1e239d4), and develop has since moved to 24.1.0 (#7775), so rc.3 is built from this branch instead of being tagged on develop like rc.1 and rc.2. ## What was done? Cherry-picked (`git cherry-pick -m1 -x`) every develop merge since rc.2 that carries `backport-candidate-24.0.x`, plus #7778, which #7807's test needs. They are in develop merge order: - #7778 test: use single-member in functional tests: feature_mnehf, feature_notifications, p2p_instantsend (test-only. Needed because #7807's `feature_evo_shares_activation.py` depends on its `mine_quorum_single_member()` fix and fails without it.) - #7791 fix(net): request object votes from nPeersPerHashMax peers - #7781 fix(rpc): use a consistent tip height in quorum dkgstatus - #7789 fix(qt): report malformed lang/font settings instead of aborting at startup - #7779 fix!: report legacy evonode Platform addresses when listdiff changes its address - #7795 backport: bitcoin#34272, partial bitcoin#31650 (pass PSBT by const reference in PSBTInputSignedAndVerified) - #7783 fix: stop fish completion from re-running the typed dash-cli command - #7794 fix(wallet): floor the denomination gap threshold so rebalancing cannot oscillate - #7785 fix: restore the txindex requirement when governance validation is enabled - #7787 fix: only sign EHF signals inside the deployment's start/timeout window - #7790 fix: guard cached governance object flags with the object lock - #7793 backport: partial bitcoin#28868 (wallet: reload wallet if migration exited early, keep mixed watchonly txs) - #7786 fix(net): keep a dedicated onion listener when -bind is given and correct the bind release note. Includes partial bitcoin#36170 (5f40d56). Upstream's dedicated-onion-bind changes to `feature_torcontrol.py` and `p2p_private_broadcast.py` are not included, because those tests depend on upstream commits (5693833, e74d54e) that Dash does not have. - #7796 backport: bitcoin#26720 (remaining), partial bitcoin#29523: weight-check the knapsack exact-match selection - #7803 fix: return non-zero amount of accounts after sethdseed - #7776 fix: keep a pending ProUpServTx across a registrar update that keeps the operator key - #7807 feat(consensus): hold EvoNode shares and multiple payouts behind a new evo_shares deployment One pick needed conflict resolution, in a test only, described in its commit message: #7793, `test/functional/wallet_migration.py`. `test_conflict_txs()` comes from bitcoin#28542 (#7762), which is not on this branch, so it is left out. The C++ part of #7793 is identical to develop. Merged since rc.2 but intentionally not included: #7775 (24.1 version bump), #7260 and #7804 (new Qt feature and its CI fix), #7584 (refactor), routine upstream backports #7257, #7759, #7762, #7768, #7788, #7801, and test/CI-only changes #7777 and #7797. No version change is needed. `configure.ac` is already 24.0.0 with `CLIENT_VERSION_IS_RELEASE` false, so the build takes its version string from the `v24.0.0-rc.3` tag, as it did for rc.2. ## How Has This Been Tested? Built on macOS arm64 against depends with `--enable-debug --enable-werror` (dashd, dash-qt, tests). - `make check`: all unit test suites pass, including `test_dash-qt`. - Functional tests, all passing: `feature_evo_shares_activation.py`, `feature_masternode_shares.py`, `feature_mnehf.py`, `feature_governance.py --descriptors`, `feature_governance_objects.py`, `feature_governance_txindex_devnet.py`, `feature_proxy.py`, `feature_notifications.py`, `feature_llmq_connections.py`, `feature_llmq_chainlocks_automatic.py`, `feature_llmq_singlenode.py`, `p2p_instantsend.py`, `rpc_blockchain.py` (v1 and v2 transport), `rpc_netinfo.py`, `rpc_quorum.py`, `rpc_verifychainlock.py`, `wallet_hd.py` (legacy and descriptors), `wallet_migration.py`. - `feature_bind_extra.py` (from #7786) only runs on Linux and was skipped locally, so CI covers it. Every touched file was diffed against develop. The remaining differences come only from develop PRs that are not part of this backport. ## Breaking Changes Carried over from the picked PRs: - #7807: consensus change behind the new `evo_shares` deployment (bit 14). Mainnet and testnet are unaffected until it activates. Devnets with `v24` already active and an EvoNode carrying several owner payouts need to check or reset. New RPC `protx shared_register_prepare_evo`. - #7785: outside regtest, a node with `-txindex=0` and without `-disablegovernance` refuses to start again, as before v23.1.0. - #7786: carries a partial bitcoin#36170. A node started with `-bind` but no specific `-bind=<addr:port>=onion` now refuses to start while `-listenonion` is enabled. That is the default when listening, even without Tor configured. A wildcard onion bind is also refused. Such nodes need `-bind=127.0.0.1:<port>=onion` or `-listenonion=0`. Nodes without `-bind`, including those using only `-whitebind`, keep the default `127.0.0.1:9996` (`19996` testnet) onion target. See `doc/release-notes-7300.md`. - #7779: `protx listdiff` now includes `platform_p2p` and `platform_https` for a legacy-address evonode whose core P2P address changes. ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone 🤖 Generated with [Claude Code](https://claude.com/claude-code) Top commit has no ACKs. Tree-SHA512: 8cb01bdb0234f31b5dd2c105b69673de148922991a7523627395c0e0ccfa22b94be5ffbecc842398d443bc90fd9baf2eee6a9cf6fcdbbd1626eb00b93726a55a
69116ee to
5527295
Compare
l0rinc
left a comment
There was a problem hiding this comment.
Addressed @vasild’s suggestions: reused the configured test arguments, removed the duplicate early check, shortened the errors, and clarified the release notes.
The issue that
0.0.0.0/[::]are unsuitable to pass via Tor control should imho be solved by a second configuration option
I'd keep rejecting these configurations in this PR and handle that support separately. What do you think @vasild?
| if (std::ranges::any_of(connOptions.onion_binds, [](auto& b) { return b.IsBindAny(); })) { | ||
| return InitError(_("The automatic Tor onion service cannot use a wildcard onion bind because incoming Tor connections would not be identified. Use a specific address such as -bind=127.0.0.1:<port>=onion, or disable the service with -listenonion=0.")); | ||
| } |
There was a problem hiding this comment.
Used your shorter version, thanks.
|
|
||
| Nodes configured with `-bind` but no specific `-bind=<addr>=onion` now refuse to start when `-listenonion` is enabled. | ||
| This includes nodes without Tor configured, since `-listenonion` is enabled by default when listening. | ||
| Shared and wildcard binds cannot distinguish Tor-forwarded connections from direct connections, which can grant Tor peers unintended IP-based whitelist permissions. |
There was a problem hiding this comment.
I kept "wildcard" here because the IPv4 and IPv6 checks described above both showed misclassification and retained whitelist permissions.
vasild
left a comment
There was a problem hiding this comment.
ACK 5527295
The issue that
0.0.0.0/[::]are unsuitable to pass via Tor control should imho be solved by a second configuration option
IMO it would be an overkill to add one more configuration option to cover this. I think it should be possible to retrieve the IP address that docker assigned to the VM or instruct docker to assign a given one.
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK 5527295cb4b606cc372159cf040acbbe742b91ec
> The issue that `0.0.0.0` / `[::]` are unsuitable to pass via Tor control should imho be solved by a second configuration option
IMO it would be an overkill to add one more configuration option to cover this. I think it should be possible to retrieve the IP address that docker assigned to the VM or instruct docker to assign a given one.
-----BEGIN PGP SIGNATURE-----
iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmrV4QIbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/TN0f/R+EbsI+jQJdDAntyXfC
wWpQ+eFu3j3AC7K/CoYrtVwhPUomeJMOJL8Q8RzZWE7XkdXU7Zu/ey9ezML3m3KD
sKXdTc9YA/d6+MTGHZbReqksTzoX0sWS8ayXjyIpoSB/FtPE2mAvHnCLHXt+ZAtM
DlZbZ1ocGXwxURECUGSwve92lvBnLv6ayS0lrmZPoMvq4kSgw1K9eR6Neqq0VTT6
n2eVYc7Y2eFjCX4RDbXua9AYMoF+15KCXegABF0HzuCek929LaQeQMhrZXMn/3xK
c47752l96wwRTgw3AigbtlwvT4jvlyD1s9jxhgTWRCX4uCWw55NImS5Yab5bsL6+
YqfrsXOiWJ8hkqEcBnYP270iJV51wOOx3F+6a7laFo6fXkw+Sa1O/R0K6zldR/ud
70aVQBVRrp0SxTyz5o4FeIqWEBXmkWTTRTZWU7BW0ZOwlCEMGDZqCb/oA9D8v5t3
7KxdXsWg4rfJpQADr07GYTQO4JaouB+HY+ncpi3M7fXosO/okP2yu8zfyEn+N2zs
TtE67DFJM28m8eCq2Fk1RX26Xjyd/EPpc4TT/WUpaEJrirwxoe6n4yENUC9fEfIW
LNJfbV+n436P59fe7TQxhJDuFLN5N64pqViOPJcO6su2+QK5KnSPdjsMmvmFXSmQ
uVcQgz91Lgh8NfrPTT04Hyj3mMsEkb8UH1qiNz+qCM/OHlWX9nUnT66aPG/b/uzh
IlhWSBJwjDVxWe56H31LmVMFviSIpwZ1XU2J7leYUuFgr+P9wlGlT5BIInPhbuWp
5fznSMTGSpglRH6UgOF5D4v/v9RpmKbmOcqkltjL0TD5xDrOzLXcaEJo7xb5lBTa
rIjMxevrNx/2SFCMtNCtjoezRLexR+/MuDMZMHEAwXf5NmcMnpny5/co07+JHSX1
24KrTq/3xGGiT+iuFU4ZjrY3TsUXpR84PA6nFpBWiVwl+Kkw7USJFt+6W2fc9tQ1
IPgYo6Bho3HYUu/vXdgWCywaD18SZtdUshxi4FBx5XL6qwhv4QVJwzSfB628orDd
Q8aP54a/pQrr+V3j14tHOJqYjIZgXNhyMASgoE0uU5jFDrY90yhIq/oz6siDOf1W
D9VZ1HE9TRVlE2di1RrlmA2DM+gjjLPqFWnKXdPrr3StSa+6819Mgw5sffQO//wb
mYO6mxhvXSGXmqMnbEGWKXaAk56NJL10HLL3t1xtQqBwYY1SdgF6T6DDr1bOh8Qm
MO1DkHELCKZ+QLawGaKkPOIGBTtOlbauANxUd1uuJ9Hka30kjsj4+7+o4Lytpu6B
O/CB0qlkOzeDIIjy9aCTd3lCvIz/4jg3D+7+LqjtRPPxVrw8UoYSA9jOLNV93vtQ
9sw=
=4syh
-----END PGP SIGNATURE-----
vasild's public key is on openpgp.org
Doing a cursory search, singular binds in general seem very common, it's even on the bitcoin wiki. I did find a couple of deployment configurations that don't include tor and set a single bind (1, 2).
I don't see why we would necessarily have to brick it. Wouldn't using the current default bind if not onion bind is provided just continue working for most deployments? |
That is to ditch this PR? Then leave the problem it tries to resolve opened, from the OP:
FWIW I considered this fine (to not be able to distinguish incoming Tor from IP), but I didn't think it would be widespread. It is a misconfiguration. And then AIs came and told us this this dangerous and I kind of agree to some extent... |
I'm not suggesting doing nothing. Maybe I'm not quite following the actual problems, but what I'm suggesting is basically along the lines of adding |
|
Requested comments on IRC:
|
|
Wonder if we can navigate this issue through only failing during startup if: But maybe I'm missing some detail, I've just had a first look. |
mzumsande
left a comment
There was a problem hiding this comment.
I agree with sedited that this solution, which makes non-tor users of -bind change their setup by changing a tor-related config option set by default is not great. They haven't misconfigured anything, and it is not their fault that -listenonion is enabled by default if they don't use it or even know about it, so they should not be expected to turn it off.
My favourite short-term solution would be to do what vasild mentioned ("Brick only the Tor listening service"). We could log a warning in torcontrol, but could still have tor outbounds with torcontrol.
Having inbounds is, for the most part, a service to the network, and unlike on clearnet, inbound capacity isn't scarce on the tor network, so a couple of nodes not having inbounds anymore until they fix their config wouldn't be a major problem in my opinion.
As a long-term solution, I would agree that replacing -listenonion makes sense, but that would require every tor user to change their config, so is not easily done.
"-listenonion AND -bind=IP AND -whitelist has been set." would work, but it feels a little bit like a hack to me to disallow a certain combination of options that are not really related logically.
5527295 to
ac8e9e3
Compare
|
Thanks for the reviews and discussions! Rebased and pushed, a missing dedicated onion bind now disables only automatic incoming service creation instead of preventing startup, preserving the configured listeners and outbound proxy discovery. Tor control now waits for successful binding before requesting a service, and wildcard onion binds remain rejected with |
07a3560 to
281c9d9
Compare
|
Rebased after #36637: its new |
Prepare the mock-controller fixture to check explicit onion service targets and peer permissions. Co-authored-by: HouseOfHufflepuff <[email protected]> Co-authored-by: JP <[email protected]>
Record that automatic service creation forwards to a shared P2P bind, that wildcard onion binds start normally, and that Tor control starts even when binding fails. Check outbound proxy discovery alongside incoming service creation so the fixes can preserve outgoing Tor connections. Co-authored-by: HouseOfHufflepuff <[email protected]> Co-authored-by: JP <[email protected]>
Start Tor control only after successful P2P binding so a failed bind cannot race service creation with a target owned by another process.
Reject wildcard onion binds while automatic onion service creation is enabled because incoming connections report a concrete local address that does not match the configured wildcard. Co-authored-by: Vasil Dimov <[email protected]> Co-authored-by: JP <[email protected]>
With normal `-bind` options (but no `=onion` bind), retain the Tor controller for outbound proxy discovery but skip automatic incoming service creation, warning after authentication instead of forwarding incoming Tor connections to a normal P2P listener. This preserves explicit listener selection without refusing startup on non-Tor nodes, while retaining the default onion listener when no `-bind` is supplied. Co-authored-by: Vasil Dimov <[email protected]> Co-authored-by: JP <[email protected]>
281c9d9 to
0dfaa81
Compare
|
Rebase after #36759 |

Problem: With a normal
-bindbut no dedicated onion bind, the automatically created Tor onion service can forward incoming connections to the normal P2P listener, where they may be misclassified and inherit IP-based whitelist permissions.Fix: Without a dedicated onion bind, keep Tor control available for outbound proxy discovery but skip automatic onion service creation and log a warning after authenticating with Tor.
The node starts with its configured listeners, including the default onion listener when no
-bindis supplied, and starts Tor control only after those listeners have opened successfully.To accept incoming Tor connections, add a specific non-wildcard
-bind=<addr>:<port>=onionreachable from the Tor daemon.Wildcard onion binds are rejected when
-listenonionis enabled.With
-listenonion=0, they remain accepted, but incoming connections are not identified as Tor connections.