Repository navigation
Description
Two small things in modules/mempool.nix, both low and both one-line fixes, so I'm filing them together.
1. The unit isn't ordered after nix-bitcoin-secrets.target
systemd.services.mempool = rec {
wantedBy = [ "multi-user.target" ];
requires = [ "mysql.service" ];
wants = [ "${cfg.electrumServer}.service" ];
after = requires ++ wants;
preStart = ''
...
conf=$(jq --rawfile pw '${secretsDir}/bitcoin-rpcpassword-public' ...)preStart reads the public RPC password, but the unit has no wants or after on nix-bitcoin-secrets.target, which bitcoind and the other consumers do have. On a cold boot the ordering comes indirectly through electrs or fulcrum, which sit behind bitcoind and the target, so it works by accident. When krops or a switch restarts setup-secrets while those services stay up, their start jobs are dropped as redundant and mempool can start while the secrets dir is being rewritten. jq --rawfile on a missing file fails under set -e, so the unit restarts every 10 s until the secret is there. That's fail-closed, so it costs downtime and nothing else.
Fix: wants = [ "${cfg.electrumServer}.service" "nix-bitcoin-secrets.target" ]; and keep after = requires ++ wants;.
2. An explicit settings.CORE_RPC.PASSWORD is serialized into the Nix store
configFile = builtins.toFile "mempool-config" (builtins.toJSON cfg.settings);The module sets CORE_RPC.PASSWORD = null and fills it in at start from the secret file, which is the right design. But an operator who sets the password in settings anyway gets it written verbatim into a world-readable store path that the unit references. Setting it takes an mkForce because of the module's null, as GPT-6 Astra verified against the pinned module system, so this is a footgun rather than a default. It's the same class as #64 for bitcoind's passwordHMAC.
Fix: an assertion that cfg.settings.CORE_RPC.PASSWORD == null with a message pointing at the secrets flow. A warning isn't enough, because the file is in the store by the time anyone reads it.
I can send both in one PR with the regtest scenario run, since mempool is enabled there.
Found by GLM 5.3 at max thinking in a chain-focused review of master 4452d89. GPT-6 Astra, run at xhigh reasoning as the second opinion, confirmed both and rated them low severity, and I checked them against the module.
Activity
mempool: wait for the secrets and keep the RPC password out of the store
mempool: wait for the secrets and keep the RPC password out of the st…