Repository navigation
electrs: 0.11.0 -> 0.12.0 - #137
Conversation
ostermayer
left a comment
There was a problem hiding this comment.
I ran the adversarial review on this branch at f1e0944: DeepSeek V4.1 Flash 1017 and GLM 5.3, both at max thinking, with GPT-6 Astra at xhigh reasoning as the second opinion. In the electrs commit they found only the point you already settled in #135, that rest.enable = true turns on an unauthenticated interface on bitcoind's RPC listener for every source in rpc.allowip, which Astra rated informational. Everything else they flagged is master code that open issues already track. I also read the commit by hand and have three notes, none blocking.
-
The versioning entry says REST is enabled automatically, but users who have a non-local source in
rpc.allowipwill hit the #135 assertion at evaluation and be told to setrest.allowNonLocal. It would help to say that in the entry, so they understand they're accepting unauthenticated REST for that source rather than just silencing an error. -
On manual versus automatic: I'd keep it manual, because the index is a day of work on a big node and the operator should pick the moment, but the crash loop is avoidable. A
preStartcheck that recognises the old index (a directory that exists while a.bindexstyle marker doesn't) and exits with the same message as the versioning entry gives a single clear failure in the journal instead of a restart every 10 s, and it still deletes nothing. Writing the marker after the first successful 0.12 start keeps the check cheap. -
Dropping
listenWhitelistedis right for electrs, and btcpayserver sets it for itself, so nothing else loses the whitelisted P2P port. TheversionAtLeast 31assertion makes electrs plus Knots a hard stop, which the entry explains, so that's fine as long as the release notes repeat it.
The scripthash test is a good addition, and bitcoin-cli as root works through the -datadir wrapper like the existing calls.
|
Thanks. Rebased onto master (after #125) and addressed all three:
|
|
Maybe we should just drop bitcoind-knots from bitcoinix first (with proper documentation and versioning.nix entry) and afterwards merge this. That way we save lot of explaning that electrs does not work with bitcoind-knots. |
I completely agree with the removal. BTW: Let's release v0.1.2 now without this PR, and ship it in v0.1.3. master already has security updates (Core Lightning, Node.js, BTCPay Server, RTL, Go) that users should get soon. This PR forces a full electrs reindex, which can take up to a day, so users should be able to take those fixes without it. After v0.1.2 is tagged, I'll rebase this PR and move its versioning entry, the docs section and Agree? |
Agreed |
ostermayer
left a comment
There was a problem hiding this comment.
Rechecked the rebased head c6d5c00. All three notes from my first review are addressed, and I read the wrapper and the new test.
Three things from the second pass, none blocking:
-
modules/electrs.nix: the wrapper has noset -e, so a failingtouchof the marker still reachesexec. If electrs then builds its index, the next start rejects it as pre-0.12.touch '${bindexMarker}' || exit 1closes it. -
The marker outlives a rollback. If 0.12 writes the marker but dies before it creates the database, and the operator rolls back to 0.11, which then builds an old index, the next upgrade trusts the marker and skips the guard, so electrs fails on the old format and restarts every 10 s. That is rare enough to document rather than fix, but a line in the versioning message would help: if you roll back after the first 0.12 start, remove the marker too.
-
The versioning entry says electrs is unavailable while it reindexes. In 0.12
src/server.rsbinds the Electrum listener before the sync loop and handles requests between sync batches, so clients connect and get incomplete history and balances until indexing finishes. "Answers are incomplete until indexing finishes" is the safer warning, and the same sentence indocs/configuration.md.
GLM 5.3 run at max reasoning reviewed the rebased head and found nothing in the files this PR changes. The DeepSeek V4.1 Flash 1017 run timed out without a verdict. Codex (GPT-6 Astra, xhigh) read the diff against master and raised the three points above, which I checked against the code and against electrs 0.12's server.rs.
|
Hello @ostermayer , thanks for the second pass review!
Could you please prepare patches/fixups for these? That would be very helpful. No need to open a PR - just push them somewhere and I'll cherry-pick them here. |
|
Pushed the three fixups to
The first adds |
|
On electrs being in nixos unstable already, and whether bitcoinix is on stable:
|
|
+1 vote to remove knots |
|
I agree with dropping bitcoind-knots first. electrs 0.12 needs Core 31 and the REST interface, so a Knots option that only works without electrs would need a warning in every place that mentions it. A versioning.nix entry that tells Knots users to switch the package back to bitcoind is enough. |
electrs 0.12.0 switched to bindex: it reads blocks through bitcoind's REST interface, requires Bitcoin Core 31+ and removed `--daemon-p2p-addr`. Enable `services.bitcoind.rest.enable`, drop the p2p address and the whitelisted p2p listener, and assert the bitcoind version (bitcoind-knots 29.x lacks the `/rest/blockpart` endpoint). The new index format requires a full reindex. electrs 0.12.0 doesn't convert or delete the old index, which uses the same path, and fails at startup until it is removed, so add a versioning entry with the manual steps. pinned.nix is regenerated by helper/update-flake.sh. In the regtest test, wait until electrs has indexed all blocks and look up the history of the address that mined them. Assisted-by: Claude Code (Claude Opus 5.5)
electrs 0.12 can't read the index of earlier versions, which uses the same path, and exits at startup until it is removed. With Restart=on-failure, the unit then restarts every 10 s. Mark a 0.12 index with a file next to it, created when electrs starts without an index. When an index exists without the marker, exit with a dedicated status that is excluded from restarts and print the reindex steps. Nothing is deleted: the operator picks the moment for the reindex. Do the check in the main process: RestartPreventExitStatus doesn't apply to a failing ExecStartPre. Assisted-by: Claude Code (Claude Opus 5.5)
(cherry picked from commit e34b338)
(cherry picked from commit 8e09adc)
(cherry picked from commit af6f69b)
0.1.2 was released without electrs 0.12, so its versioning entry, the refusal message and the upgrade notes move to 0.1.3, next to the Knots removal. Knots is gone, so the notes no longer mention it. Assisted-by: Claude Code (claude-opus-5-5)
@prusnak, feel free to take another look. I think it's ready for merge. Thanks! |
Blocked by:
bitcoind: remove bitcoind-knots #143Two commits:
electrs: 0.11.0 -> 0.12.0andelectrs: refuse to start on an index of electrs < 0.12.What changes
electrs 0.12.0 switched to bindex:
final index is ~7% of
blocks/*.dat, up to ~14% during the sync. Meanwhile electrs,and mempool if it uses electrs, answers with incomplete history and balances. See
"Old index" below.
/rest/blockpartendpoint. Aneval-time assertion on
nix-bitcoin.pkgs.bitcoindfails evaluation for an olderCore ("electrs requires Bitcoin Core 31 or later."), e.g. with
useVersionLockedPkgs = false.services.bitcoind.rest.enable. REST is unauthenticated: ifrpc.allowiphasnon-local sources, evaluation fails unless
rest.allowNonLocalis set, which meansaccepting unauthenticated REST for those sources. Raw
rpcallowip/includeconfinextraConfigneedrest.allowUncheckedConfig. The versioning entry and docs say so.--daemon-p2p-addrwas removed upstream, so electrs no longer enables bitcoind'swhitelisted p2p listener (btcpayserver still enables it for itself).
pkgs/pinned.nixis regenerated byhelper/update-flake.sh, which moves electrs tounstable (the pin update held it on stable by hand until this lands).
rest=1on the other node when using a remote bitcoind.
Old index: manual reindex, no crash loop
electrs 0.12.0 doesn't convert or delete the old index, which uses the same path
(
<dataDir>/bitcoin, orregtest). On it, bindex panics withUnsupported DB format (0 < 1) - please reindex!, and withRestart=on-failurethe unit would restart every10 s.
The reindex stays manual: it takes up to a day on a big node, so the operator picks
the moment, and nothing deletes user data from a start script. A 0.1.3 versioning entry
gives the steps:
systemctl stop electrs,rm -r <dataDir>/<network>, then deploy.If the old index is still there, the unit fails once with a clear message instead of
crash-looping:
<dataDir>/<network>.bindexidentifies a 0.12 index. It is written whenelectrs starts and no index directory exists yet (fresh install, or after the
rm -r).steps and exits with status 78, which
RestartPreventExitStatusexcludes fromrestarts. Nothing is deleted.
execs electrs), not inpreStart: a failing ExecStartPre still triggersRestart=on-failure, andRestartPreventExitStatusonly applies to the main process.Tests
regtesttest now waits until electrs has indexed all blocks (0.12 serves requestswhile it is still indexing) and queries the history of the address that mined the
regtest blocks over the Electrum protocol. That exercises bindex's REST block fetches
end to end.
electrstest removes the marker and checks that the unit endsfailed(notauto-restarting) with exit status 78 and the reindex message, then restores the marker
and checks that electrs starts again.
bitcoind-resttest only runs in scenarios without electrs (e.g.lndPruned).On the current head:
-s electrsandnetnsRegtestpassed locally,nix flake checkpassed.