Repository navigation
modules: replace regtest with services.bitcoind.network - #253
Conversation
9de177e to
44059ed
Compare
44059ed to
f98fbd9
Compare
|
@viberaven @prusnak @seberm I"m looking forward to trying this. I'm hoping we can get it working on Testnet5 (yes, five) |
e57638d to
052260d
Compare
ostermayer
left a comment
There was a problem hiding this comment.
Reviewed 052260d7. Mainnet looks the same as on master: ports, data paths, network names, units and secrets don't change, and the networkName callers give the old makeNetworkName result on both networks. charge-lnd still reads /run/lnd/charge-lnd.macaroon (0400, its own user), and flags in extraFlags still come last.
The problems are in the upgrade path for existing regtest configs.
1. The old regtest = true doesn't reach network, so notices that depend on the network see mainnet.
services.bitcoind.regtest is now a removed option, so on an old regtest config network is "mainnet" until the user migrates. The versioning error shows before the removed-option error, so the notices are computed for mainnet:
modules/versioning/0.2.0/mempool-network.nix:4checksnetwork == "regtest", so it never fires for a regtest node that's upgrading. Withregtest = true,services.mempool.enable = trueandconfigVersion = "0.1.6", the error lists only thebitcoin-networknotice and says to setconfigVersion = "0.2.0". The user never sees the Mempool notice.modules/versioning/0.1.3/electrs-reindex.nix:8andmodules/versioning/0.1.2/bitcoind-rpc-cookie.nix:10now print mainnet paths. Withregtest = true, electrs andconfigVersion = "0.1.1", the error saysrm -r /var/lib/electrs/bitcoinand names/var/lib/bitcoind/.cookie. Master says/var/lib/electrs/regtestand/var/lib/bitcoind/regtest/.cookiefor the same config. The regtest index stays, and electrs 0.12 then refuses to start.- The tests don't catch this, because
testHistoricalNetworkMigrationPathsandtestMempoolNetworkMigrationsetnetwork = "regtest"at old config versions, where that option didn't exist.
One fix is mkChangedOptionModule from regtest to network, so the old value still reaches network during the upgrade. Another is to read options.services.bitcoind.regtest in these notices too.
2. Is this meant to merge after the v0.1.6 tag?
The notices are in modules/versioning/0.2.0/ and examples/configuration.nix:287 sets 0.2.0, but the upcoming release is 0.1.6. AGENTS.md:174 says to bump only the last component. If this merges before the tag, 0.1.6 ships notices that say to set configVersion = "0.2.0". A config at 0.2.0 then skips every 0.1.6 notice that lands later, for example the one in #258.
3. The makeNetworkName part of the bitcoin-network notice can't fire, and the replacement text names a variable users don't have.
- On master
makeNetworkNameis read-only with a default (modules/bitcoind.nix:157-160atf91deeaf), so no config could define it, andoptions.services.bitcoind.makeNetworkName.isDefinedis never true for a real upgrade. A config that calls it gets themkRemovedOptionModulemessage instead, which is clear.testRemovedNetworkNameHelperdefines the option, which wasn't possible before. modules/versioning/0.2.0/bitcoin-network.nix:11,modules/obsolete-options.nix:23anddocs/upgrading.md:45saynbLib.networkName.nbLibis a let binding inside the modules, so in a user config it's an undefined variable.docs/release-notes.md:12has the right name,config.nix-bitcoin.lib.networkName.
4. Minor: the charge-lnd notice also fires for configs that aren't affected.
modules/versioning/0.2.0/charge-lnd-credentials.nix:5 fires on any --lnddir, also when extraFlags gives --tlscert and --macaroon too. charge-lnd then doesn't use --lnddir for the credentials, so the paths are the same before and after.
I checked the errors in 1 with nix eval against the PR head and master. The configuration checks pass on the head.
|
Addressed in 809b5f7 and 36cbdf5:
Flake checks, docs build, shellcheck, and targeted migration checks passed. |
ostermayer
left a comment
There was a problem hiding this comment.
Checked 36cbdf5e. All four points are fixed:
- With
regtest = trueandconfigVersion = "0.1.1", the electrs and cookie notices now give/var/lib/electrs/regtestand/var/lib/bitcoind/regtest/.cookie. With Mempool andconfigVersion = "0.1.6", the Mempool notice fires. - Merging after v0.1.6 settles the version question.
- The removed-helper message says
config.nix-bitcoin.lib.networkName, and the docs show wherenbLibcomes from. - The charge-lnd notice no longer fires when
extraFlagssets both--tlscertand--macaroon, and it still fires for--lnddiralone.
I checked each with nix eval against the head.
|
@prusnak Fable review Reviewed 36cbdf5. One must-fix that the earlier review rounds didn't cover; the migration path and charge-lnd changes look right. Must fix
Nits
Exposure: no new listener or netns connection. Tested: eval only, against 36cbdf5 and master. Mainnet Mempool frontend drvPath comparison (above); Assisted-by: Claude Code (Claude Fable 5.1, Claude Fable 5.1 as advisor) |
|
Fixed in e42fbe4:
Flake checks, docs build, test-runner check, and focused Mempool VM tests on mainnet and regtest passed. |
seberm
left a comment
There was a problem hiding this comment.
Thanks for the changes - let's hold the merge until v0.1.6 is tagged.
Replace services.bitcoind.regtest with nix-bitcoin.network and migrate network consumers. Add configuration contracts and migration guidance for 0.2.0. Assisted-by: Codex (GPT-6 Astra)
Use services.bitcoind.network as the writable deployment-wide enum and update consumers, tests and 0.2.0 migration guidance. Assisted-by: Codex (GPT-6 Astra)
Use services.bitcoind.network directly. Document the 0.2.0 migration and reject obsolete helper definitions. Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Replace repeated network name mappings with networkName, preserving unmapped names. Update migration guidance and test empty, partial and full overrides. Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Follow the release-note convention introduced on master. Assisted-by: Codex (GPT-6 Astra)
Configure backend and frontend network settings for mainnet and regtest. Keep the selected network at the site root, preserve frontend overrides, and cover the served config and regtest API in integration tests. Add 0.2.0 migration guidance for existing regtest deployments. Assisted-by: Codex (GPT-6 Astra)
Assisted-by: Codex (GPT-6 Astra)
Pass explicit TLS certificate and macaroon paths and remove the unused state directory and symlink setup. Document the migration for custom --lnddir flags and verify direct credential access on both networks. Assisted-by: Codex (GPT-6 Astra)
Add release and upgrade entry headings following the documentation convention. Check that the extracted historical notices still resolve cookie and electrs paths for both networks. Assisted-by: Codex (GPT-6 Astra)
Forward the old regtest boolean to services.bitcoind.network so existing configs receive the Mempool notice and the correct historical cookie and electrs paths. Cover legacy configurations and conflicting old/new selections. Remove the unreachable makeNetworkName definition check, test a real call to the removed helper, and make the replacement instructions usable in user modules. Assisted-by: Codex (GPT-6 Astra)
Only notify configurations that use --lnddir without explicitly overriding both credential paths. Cover separate, equals and mixed flag forms, including partially overridden credentials, and clarify the upgrade instructions. Assisted-by: Codex (GPT-6 Astra)
Apply frontend network defaults only off mainnet, preserving the package derivation and avoiding an unnecessary Angular rebuild. Verify derivation selection for both networks and adapt the VM check for compiled mainnet defaults. Render port default descriptions as Markdown and document removal of the obsolete charge-lnd proxy tree after upgrading. Assisted-by: Codex (GPT-6 Astra)
e42fbe4 to
fd01856
Compare
bitcoinix currently selects packages from stable and unstable nixpkgs. This change uses a single `nixpkgs` input tracking `nixos-unstable` for systems and packages. The flake NixOS module defaults `nix-bitcoin.useVersionLockedPkgs` to true; the 0.2.0 migration explains when callers instead control the service package pin. - Remove the separate input and `pkgsUnstable` plumbing. Inline package selection in `pkgs/default.nix`, remove generated `pkgs/pinned.nix`, and simplify version reporting and update helpers. Preserve public `.pinned` paths and the non-flake lock-file adapter. - Adapt I2P, FUSE replication mounts, VM/debug runners and deployment examples to unstable NixOS. Preserve SAM-only I2P exposure and replication recovery, and allow Core Lightning's memory-locking syscalls in nspawn examples and test containers. - Add the 0.2.0 notices as separate files under `modules/versioning/0.2.0/`, using master's collector and its automatic documentation references. Cover package-pinning/database downgrade risks, whole-system unstable evaluation, firewall/FUSE defaults and custom containers. Document I2P validation limits. Keep the NixOS assertion safeguard against migration recursion, and test both individual notices and the assertion. Read the container runner's config version from the notice directories. - Preserve master's network selection, secret validation, RTL certificate pinning/lifecycle and Tor-enforcement changes. Use the single package set's Bun for Unbeholden Wallet. Preserve all released upgrade/release-note sections and their headings. - Fetch both patches from nbd-wtf/trustedcoin#44 (`3210fc9`, `21a1f43`) with the supplied hashes, replacing the local patch. They fix initialization races and reporting height zero without a source. - Use the unmodified nixpkgs electrs package: the refreshed pin supplies pkg-config and zstd, so the override is removed. Rebased on `master` at `cf39a66` (including #253 and the versioning refactor). Ran `helper/update-flake.sh`; the single nixpkgs input is now `d5cc6833999746cffdfe0598f7bc801a57b887a9`, verified as the current `nixos-unstable` head on 2026-11-16. Core Lightning stays at 26.06.10; compared with the previous PR head, LND moves to 0.21.8-beta and RTL to 0.15.17. Rechecked treewide TODO-EXTERNAL comments and the CVE exceptions against the new runtime closure. Validation after this rebase/update: - `nix flake check --all-systems` (including module/migration checks, test-runner checks, LND macaroon filters, CVE tools and workflow checks). - Builds of the unmodified electrs package and TrustedCoin with both upstream patches, including TrustedCoin's package tests. - VM scenarios passed: `default`, `netns`, `netnsRegtest`, `trustedcoin`, `i2p` and `i2pLocal`. The first `netnsRegtest` run failed during LND's automatic macaroon-cleanup restart with `panic: unable to subscribe to chans: subscription server shutting down`; the unchanged VM retry passed. This PR and current master select the identical LND 0.21.8-beta derivation. - Flakes and Colmena deployment examples built with their deployment tools. The persistent container example also built with CLN enabled and config version 0.2.0; its generated nspawn configuration includes `--system-call-filter=@memlock`. - Generated-version check, shellcheck, mdBook build and nixos-search export. The export was run directly because the CI script's Cachix setup requires permissions unavailable to this local user. - Representative node runtime closure (including Unbeholden Wallet) built and scanned with/without the whitelist. Retained exception packages have unchanged outputs; the same eight other CVE identifiers across brotli, dhcpcd, jq, rsync and sqlite remain visible for triage. This is not a clean vulnerability scan. ARM outputs were evaluated, not built or VM-tested. Other VM scenarios and the complete package build set were not rerun.
Target release **v0.2.0**. Follows #253 and addresses #17 for signet and testnet4. Set `services.bitcoind.network` to `"signet"` or `"testnet4"` to configure Bitcoin Core and its dependent services. Core Lightning, electrs, Fulcrum, Unbeholden Wallet, Mempool and BTCPay Server can use either network. Evaluation rejects LND on both because the packaged `lndinit` cannot initialize those wallets. CLBOSS and Trustedcoin are rejected on testnet4. The configuration guide warns that switching networks in place reuses the Fulcrum, Mempool, BTCPay Server and NBXplorer databases. Use separate deployments to keep their data apart. On regtest, the generated Tor mapping now forwards port 18444 to local port 18445. Users who maintain their own mapping can update its target or keep `services.bitcoind.onionPort = 8334;`. The 0.2.0 migration notice targets nodes using the default. **Verification** - Offline signet and testnet4 VMs verified genesis hashes, Core Lightning network selection, NBXplorer cookie access and Mempool frontend settings. - A regtest VM verified that bitcoind listens on 18445. Evaluation tests cover the generated mapping, explicit overrides and incompatible service combinations. - The release-note validator and documentation build passed with the 0.2.0 drafts.
Target release: 0.2.0. Merge after the v0.1.6 release.
Replace
services.bitcoind.regtestwith a writableservices.bitcoind.networkenum:"mainnet"(default) or"regtest". Service modules and VM scenarios use this selection while preserving existing ports, daemon network names and data paths. The old boolean forwards to the new option during migration, so existing regtest configurations receive the Mempool notice and correct historical cookie and electrs paths. Continued use after updating the config version emits a deprecation warning.Replace the positional
services.bitcoind.makeNetworkNamehelper withnix-bitcoin.lib.networkName. In modules that takeconfig, bindnbLib = config.nix-bitcoin.lib;. Callers specify only names to override; other names pass through unchanged:Mempool 3.3.2 supports regtest, but the module previously configured it as mainnet even when connected to a regtest node. Its backend now follows
services.bitcoind.network. On regtest, frontend defaults select the same network usingMAINNET_ENABLED,REGTEST_ENABLEDandROOT_NETWORK, keeping the site and API at their existing URLs. Mainnet uses the unchanged packaged frontend, avoiding an unnecessary Angular rebuild. Explicit frontend settings remain overridable. Existing regtest deployments receive a 0.2.0 migration notice covering automatic cache clearing and custom frontend settings.Include release and upgrade notes, the example config-version update, configuration tests for network selection, helper overrides and migrations, and VM checks for the served Mempool frontend configuration and regtest genesis block through its API.
Charge-LND now receives explicit certificate and macaroon paths instead of staging symlinks under a synthetic mainnet directory. Remove its unused state directory and setup script. Default deployments need no changes; configurations selecting credentials through
--lnddirinextraFlagsreceive a targeted 0.2.0 migration notice only if either--tlscertor--macaroonis missing.Migration notices use the per-change files introduced in #257, including updated network paths in historical notices. Release and upgrade entries follow #259's heading convention; #260's services guide changes are preserved.
Validation after rebasing onto
master(72e6be0):nix flake check --all-systems, the docs build, and shellcheck passed.default(mainnet) VM suite passed with the updated dependency pins, RTL certificate-pinning checks, and Tor-enforcement tests.netnsRegtestrun failed after LND 0.21.8 panicked during a stop in the configuration-replacement test (unable to subscribe to chans: subscription server shutting down). LND recovered, but the later clean-exit test detected the failure recorded in the journal. A full rerun passed without code changes.