Repository navigation
Conversation
|
Hello all. Here running rbitcoin for a few weeks on my node. Bitcoin-core should be swappable or running simultaneously to any list of nodes per user desire (btcd, bitcoin-js, whatever full node). Low priority pull. I'll keep running it locally for sure. |
|
Oh yeah it's a low resource drop in core/electrs in short |
feae5be to
fc5407b
Compare
fc5407b to
6db85a0
Compare
ostermayer
left a comment
There was a problem hiding this comment.
I read the module, the mempool wiring and the package against rbitcoin cc07062. The package is pinned by revision and hash and the cargo vendor hash is fixed, so nothing fetches at build time. Four things worth a change:
-
mempool gets rbitcoin's admin credential.
modules/mempool.nix:385puts the mempool user inrbitcoinrpc, which reads the cookie. rbitcoin's RPC has one bearer token and one optional cookie (crates/rbitcoin-rpc/src/auth.rs) and no method restriction per credential, so the dispatcher inmethods/mod.rs:494servesstop,invalidateblockand the rest to anyone with the cookie. With bitcoind, mempool only holds the whitelistedpublicuser. A compromised explorer backend can stop the node or invalidate blocks. rbitcoin has no restricted credential to hand out today, so either say so in theelectrumServerdocs and therpc.enabledescription, or ask upstream for a read-only token and gate the option on it. -
modules/rbitcoin.nix:286: the root cookie script works on paths the service user owns./run/rbitcoinis the unit'sRuntimeDirectory, owned byrbitcoin, so that user can make it listable and replace$tmpwith a symlink betweenmktempand theprintf,chownandchmodthat follow by path. Root then writes the cookie into the target and hands it to the service user. The window needs a process running as that user whileExecStartPreruns, which systemd's cgroup kill makes rare, but it is the pattern the lnd macaroon fix removed. Build the file in a root-onlymktemp -dunder/run, set owner and mode there, andmv -fTit into place. -
modules/rbitcoin.nix:294:escapeShellArgsdoesn't protect anExecStartline. systemd expands%specifiers and$VARinside quotes too, so anextraArgsentry such as--alert-notify=echo %sloses its placeholder.utils.escapeSystemdExecArgsdoes the right escaping. -
netns id 33 is also claimed by #141 (
modules/netns-isolation.nix). Whichever PR merges second needs a new id.
Checked and fine: the cookie keeps Core's format and mode 0640 with --rpc-cookie-perms group, the unix socket stays in the 0750 data dir, mempool reads the cookie by path so it survives the regeneration on restart, txindex is no longer forced on bitcoind when rbitcoin is the node, the port collision assertions cover bitcoind, electrs and fulcrum, and the data dir assertion keeps the two nodes apart.
GLM 5.3 run at max reasoning reviewed the tree at 8bc4bd9 and found nothing in the files this PR changes. DeepSeek V4.1 Flash 1017 run at max reasoning timed out without a verdict. Codex (GPT-6 Astra, xhigh) read the diff and raised the first three points, which I checked against the module and rbitcoin's auth.rs, server.rs and methods/mod.rs.
|
It runs my Sparrow backend, it runs my mempool.space backend, the project lead is pushing for production-ready status soon, so I'm putting this PR out there. I think this is especially important with knots being removed to have an alternative client. |
|
@ostermayer thanks for the review https://www.stephanlivera.com/775 |
|
@reardencode hello world :D |
|
I am following the development closely. I think rbitcoin is a nice project. Let's wait until 0.9.0 is released and then let's get it into nixpkgs. Then we can split this PR into smaller PR where we discuss individual steps. |
|
Yeah, upstream to nixpkgs definitely preferred. I encourage everyone who wants to try it to branch off this PR - I run this legit as my main now! I'll talk to Brandon about upstreaming to nixpkgs I'm sure he's in support after 0.9/1.0. |
|
I read 8c9c72e. It fixes the four points from my review: the cookie is written in a root-only Models: GLM 5.3 (max) and Codex (GPT-6 Astra, xhigh) reviewed the tree at 8c9c72e and found nothing in the files this PR touches. GLM's one finding was in modules/mempool.nix and is #133. DeepSeek V4.1 Flash 1017 (max) timed out at the provider twice and gave no result. |
|
PR NixOS/nixpkgs#584178 has been merged to master - tracking its way to nixos-unstable: https://pr.bitcoinix.net/?pr=584178 |
|
ALERT THE TROOPS - WE HAVE A NIXPKGS MERGE -HUZZAH |
c8fd2cb to
f56a263
Compare
f56a263 to
524b775
Compare
|
Rebased on master (5a8d756) and pushed 524b775. Changes since f56a263:
Tested locally at 524b775:
In CI, Assisted-by: Claude Code (claude-opus-5-5) |
sebsgent
left a comment
There was a problem hiding this comment.
No must-fix items. One should:
- Should: the 20 commits land on master as they are, and several record intermediate states that are wrong on master: 39d144e gives rbitcoin netns id 34, which unbeholden-lnurl already uses (fixed only in 837500f);
pkgs/rbitcoinis added, bumped five times and removed in 524b775; 673ec08 says the module passes--rpc-cookie-perms group, but the final code passesowner. Please squash them into logical commits, e.g. the netns-isolation unique-id check, the rbitcoin module with the mempool backend and tests, and the docs.
Optional: without netns isolation, the Electrum port opens hours after the RPC port (once the address index is built), while mempool is already running. A local user listening on it first would see which addresses are looked up in the explorer and could answer with forged data. electrs and fulcrum likely share this, so a docs note recommending netns isolation would be enough.
Tested: CI green at 524b775. Ran the uncovered combination locally, mempool on rbitcoin with netns isolation (netnsBase + rbitcoinMempool): passed, including rbitcoin-mempool. Checked against the 0.9.2 source that seed hostnames go through the SOCKS proxy and are never looked up locally.
Assisted-by: Claude Code (Claude Opus 5.5)
|
Hi @prusnak, @ostermayer, I've moved the milestone to v0.2.2 because I'm not sure this will be finished before the v0.2.1 release. Could you please review it? We may still make it in time, but I'd rather not rush it. Thanks! |
524b775 to
4af3362
Compare
|
Thanks for the review. Squashed and force-pushed 4af3362, on the same base (master 5a8d756):
The message of the second commit describes the final code: id 35, rbitcoin from nixpkgs, On the optional point: I checked it against the code. mempool waits only for the RPC cookie ( Checked locally:
I did not rerun the VM tests, since the code is the same as the 524b775 run. #284 is rebased onto these three commits (166d9c4). Assisted-by: Claude Code (claude-opus-5-5) |
Nothing checked that the ids were unique, so rbitcoin and unbeholden-lnurl both evaluated with id 34 after a rebase and got the same address. Check all entries, enabled or not, so a clash in the modules shows up in the module-config check rather than only on a node running both. Assisted-by: Claude Code (claude-opus-5-5) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`services.rbitcoin` runs rbitcoin 0.9.2 from nixpkgs, with its own data
directory:
- P2P, optionally through Tor (`tor.proxy`, set by secure-node.nix via
enable-tor.nix; seed lookups go to the proxy too).
- A Core-compatible JSON-RPC over TCP (`rpc.enable`), authenticated by a
cookie. rbitcoin writes a new one on every start, readable only by
itself (`--rpc-cookie-perms owner`).
- The unit `rbitcoin-rpc-cookie` publishes that cookie for clients at
/run/rbitcoin-rpc/rpc.cookie, group `rbitcoinrpc`. rbitcoin binds its RPC
port only after catch-up, hours or days after the start on mainnet, and
until then any local user could listen on the port without netns
isolation and receive the cookie from a client. So the unit publishes it
only while every listener that would take a client's connection is a
socket of rbitcoin's main process, matched by inode against
/proc/<pid>/fd, not by process name, which any user can fake in `ss -p`
output. It keeps watching, removes the cookie if rbitcoin loses the
port, and the cookie goes away with its runtime directory when rbitcoin
stops. It runs as root because clients run with PrivateUsers.
- The unix socket at {dataDir}/rpc.sock, always on, used by the operator's
`rbitcoin-cli` wrapper.
- Electrum (`electrum.enable`) with the scripthash index and its
`maxShCreates` query cap.
- nbLib.defaultHardening, except ProcSubset=all: the store sizes its caches
from /proc/meminfo.
- Assertions against data directories nested with bitcoind's, and against
listeners that collide with bitcoind, electrs or fulcrum (all default to
127.0.0.1 and Core's ports without netns isolation).
`services.mempool.electrumServer = "rbitcoin"` makes rbitcoin mempool's node
and Electrum server. mempool joins `rbitcoinrpc`, waits for the published
cookie in ExecStart (so no start job blocks during the sync) and reads it
from COOKIE_PATH, so it picks up a new cookie after an HTTP 401. It gets no
bitcoind RPC user, and bitcoind's txindex is only forced for the
electrs/fulcrum backends.
netns-isolation gets an rbitcoin namespace (id 35); mempool's connections
follow its backend. nodeinfo lists rbitcoin. versions.json and the docs
versions table list it.
Tests:
- `regtest` (and `netnsRegtest`): rbitcoin syncs from bitcoind as its only
peer and must report the same tip hash; socket-only RPC.
- New `rbitcoinMempool` scenario, added to the basic/CI set: cookie mode and
group, cookie auth accepted and wrong credentials rejected over TCP RPC,
Electrum tip height, an Electrum-backed scripthash lookup through mempool,
mempool following a new block after rbitcoin restarts with a new cookie,
and no bitcoind RPC user for mempool. A process named `pid=1,` holds the
RPC port as `nobody`: the cookie stays unpublished, neither cookie reaches
it, and a crash removes the cookie until the next instance holds the port.
- Test VMs get a 4 GiB disk when rbitcoin is enabled (~900 MB at 100
regtest blocks).
Assisted-by: Claude Code (claude-opus-5-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A page at docs/service/rbitcoin.md, listed in services.md and SUMMARY.md, covers ports, the admin cookie, the data directory, one-way upgrades, the address index, RPC readiness, Tor, the large-address cap and netns isolation. It also says that without netns isolation the Electrum port opens hours after mempool starts, so a local user could take it first. README, the example config and a 0.2.1 release note link to it. Assisted-by: Claude Code (claude-opus-5-5) Co-Authored-By: Claude Opus 5.5 <[email protected]>
4af3362 to
5645899
Compare
|
Master moved to 7a6dc3b (#347), so I rebased again: the three commits are now Since #347 now explains the port takeover under network namespace isolation, the Electrum note in At 5645899, Assisted-by: Claude Code (claude-opus-5-5) |
nixpkgs still has 0.9.2, so pkgs/default.nix overrides its package with the v0.10.0 source and cargoHash until it catches up; versions.json lists it as local again. 0.10.0 rewrites a 0.9 data directory to store schema 31 in place, with no reindex, and 0.9 refuses it afterwards. Its peers file also has a header 0.9 doesn't read. No bitcoinix release has shipped rbitcoin yet, so no migration notice; the service page says so for later rollbacks. Every flag the module passes is unchanged (https://github.com/rbitcoin-org/rbitcoin/blob/v0.10.0/CHANGELOG.md). Assisted-by: Claude Code (claude-opus-5-5) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Bumped rbitcoin to 0.10.0, released today, in a new commit on top of the three:
Tested locally at 59b8234:
#284 is rebased onto it. Assisted-by: Claude Code (claude-opus-5-5) |
JFYI rbitcoin 0.10.0 will hit nixos-unstable soon - see https://pr.bitcoinix.net/?pr=595405 |
|
I got so excited I forgot we're tracking nixpkgs now - my error!!!
…On Mon, Nov 30, 2026, 5:00 PM Pavol Rusnak ***@***.***> wrote:
*prusnak* left a comment (bitcoinix/bitcoinix#70)
<#70 (comment)>
- nixpkgs still has 0.9.2, so pkgs/default.nix overrides its package
with the v0.10.0 source and cargoHash, marked TODO-EXTERNAL.
versions.json lists it as local until nixpkgs catches up.
JFYI rbitcoin 0.10.0 will hit nixos-unstable soon - see
https://pr.bitcoinix.net/?pr=595405
—
Reply to this email directly, view it on GitHub
<#70?email_source=notifications&email_token=AAON37GL6E33FC4OPCCSPH353XUZLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMRZGMZDCNBXHA32M4TFMFZW63VGMFZXG2LHN2SWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-7293214787>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAON37EPUGFIJSZXZ2IUESD53XUZLAVCNFSNUABGKJSXA33TNF2G64TZHMYTIMBYHE2DMNRUGE5US43TOVSTWNJYHEZTKOBQG44DLILWAI>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAON37AI43EBJSR2SVLB3ET53XUZLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMRZGMZDCNBXHA32M4TFMFZW63VGMFZXG2LHN2SWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/AAON37G2CZGWO55LFSSBUV353XUZLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMRZGMZDCNBXHA32M4TFMFZW63VGMFZXG2LHN2SWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you were assigned.Message ID:
***@***.***>
|
This reverts commit 59b8234. Track nixpkgs' rbitcoin instead of overriding its source. The locked nixpkgs (78cc855f) has 0.9.2, so pkgs/default.nix inherits `rbitcoin` from `pinned` again and versions.json lists it as unstable. 0.10.0 comes in through a normal nixpkgs update once nixpkgs packages it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
rbitcoin is now in nixos-unstable (https://pr.bitcoinix.net/?pr=595405) |
This reverts commit 59b8234, as bitcoinix#70 does: track nixpkgs' rbitcoin (0.9.2 at the locked rev) instead of overriding its source. rbitcoin.space 0.5.0 is built and tested upstream against rbitcoin 0.9.2, so the module needs no change. The conflicts are the adjacent rbitcoin-space entries in pkgs/default.nix and docs/versions-table.md; the table is regenerated from versions.json. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #74.
This proposes rbitcoin as a new
service, per the "New services" policy, so the PR doubles as the discussion.
rbitcoin is an experimental Bitcoin full node in Rust with built-in Electrum
and Esplora servers. It is actively developed (dozens of merges a week). I run
it on a mainnet node behind mempool, which is where this module comes from.
What it adds
Package: rbitcoin 0.9.2, from nixpkgs
rbitcoin: init) is in the pinned nixpkgs at 0.9.2, sothe PR carries no
pkgs/rbitcoinand no override:pkgs/default.nixinheritsit from
pinned, andversions.jsonlists it asunstable. 0.10.0 arrivesthrough a normal nixpkgs update once nixpkgs packages it.
(store: unlink a scripthash reorg from the tail rbitcoin-org/rbitcoin#1021); 0.9.2 also stops IBD from connecting a block
that re-spends an output already spent lower in the same write. Opening a
0.9.0 data directory moves it to schema 27, one way (see the docs page).
services.rbitcointor.proxypasses--proxy/--onion, andsecure-node turns it on via
enable-tor.nix. rbitcoin sends seed hostnamesto the proxy instead of resolving them.
rpc.enable), a Bitcoin Core compatible subset,authenticated by a cookie:
ExecStartPrewrites a new cookie on every start, built in aroot-only temp dir and moved into place; rbitcoin reads a private copy;
rbitcoin-rpc-cookieunit publishes it at/run/rbitcoin-rpc/rpc.cookie(mode 0640, grouprbitcoinrpc) only whileevery listener on the RPC address is a socket of rbitcoin's own process,
so a local user squatting the port during the sync never gets it;
PrivateUsershides that group from theservice.
{dataDir}/rpc.sock: always on, mode 0660, and used bythe operator's
rbitcoin-cliwrapper.electrum.enable) with the scripthash index and itsmaxShCreatesquery cap.nbLib.defaultHardeningwith one exception,ProcSubset = "all", because the store sizes its caches from/proc/meminfo. io_uring is in@system-service(through@aio).isolation they all default to 127.0.0.1 on Core's ports, and rbitcoin only
warns when its RPC listener fails to bind.
entries with the same id), nodeinfo, a docs page (
docs/service/rbitcoin.md,linked from
docs/services.mdandSUMMARY.md), the README and the examples.mempool
electrumServer = "rbitcoin"makes rbitcoin mempool's node and Electrumserver.
COOKIE_PATH, so it picks up the new cookieafter a 401.
txindex, and mempool's own bitcoind RPC user and secrets (clightning, mempool: connect to bitcoind as their own RPC users #277),are set up only for the electrs/fulcrum backends. On rbitcoin, mempool has no
bitcoind user; a test checks that its secret isn't created.
nbLib.address(a no-op for the existingdefaults).
Tests
regtestandnetnsRegtest: rbitcoin syncs from bitcoind, its onlypeer, and must report the same tip hash; RPC is socket-only.
rbitcoinMempoolscenario:rbitcoinMempoolis added to thebasicset and the CI matrix,because it's the only scenario for
electrumServer = "rbitcoin".~900 MB at 100 regtest blocks.
Rebased on master (7a6dc3b) and squashed into three commits: the netns-isolation
unique-id check, the rbitcoin module with the mempool backend and tests, and the docs.
Apart from master's #347, the tree at 5645899 is 524b775's plus a docs note on the Electrum port without netns
isolation. On 5a8d756, each commit passed
checks.x86_64-linux.module-configand evaluated.#ciTestInfo.Tested at b97809e (the 0.10.0 override reverted; tree identical to 5645899):
pinned.rbitcoinevaluates to the same store path as nixpkgs' rbitcoin 0.9.2at the locked rev (78cc855f);
checks.x86_64-linux.module-configandtest/ci/check-versions.sh: passed.Tested locally at 524b775, with nixpkgs' rbitcoin 0.9.2:
./test/run-tests.sh -snetns,rbitcoinMempoolandnetnsRegtest:passed;
nix eval .#ciTestInfo(whatbuild_test_driversevaluates): passed. Beforethe fix it failed with
attribute 'rbitcoin' missing, becausetest.data.rbitcoinread rbitcoin's netns address in scenarios withoutrbitcoin;
checks.x86_64-linuxand./test/shellcheck.sh: passed.Tested locally on 0.9.0:
./test/run-tests.sh(default,netns,netnsRegtest,rbitcoinMempool);rbitcoinMempoolagain with rbitcoin's own static musl build in place of thepackage;
nix flake check --all-systemsand./test/shellcheck.sh.Known limitations
--rpc-cookie-perms group(older revs only logged a warning). The modulepasses the flag, because mode 0640 is what lets group
rbitcoinrpcread thecookie.
maxShCreates, the explorer can't show addresses with more outputsthan the cap. On a 4 GiB mainnet node, a cap of 100k cost up to about a
minute and 2 GiB per query (Unpaged scripthash join cost at mainnet scale; the mempool explorer 500s on every address over --max-sh-creates rbitcoin-org/rbitcoin#1036 has the measurements).
Hostheaderfrom mempool when
rpc.addressis IPv6.Independent of #69, which fixes the mempool backend's bind address.
🤖 Generated with Claude Code