esplora: don't bubble transient backend errors to lightningd - #103
Open
vincenzopalazzo wants to merge 2 commits into
Open
esplora: don't bubble transient backend errors to lightningd#103vincenzopalazzo wants to merge 2 commits into
vincenzopalazzo wants to merge 2 commits into
Conversation
When the upstream esplora endpoint returns a 5xx / 429 / connection reset, `sync_block_by_height` and `sync_estimate_fees` propagate the post-retry `Err` up to clightningrpc-plugin, which serializes it as a JSON-RPC error response. lightningd's bitcoind plugin handler (`bitcoind.c:bitcoin_plugin_error`) treats any error response on `getrawblockbyheight` or `estimatefees` as fatal and aborts the daemon with SIGABRT. In production this surfaced as repeated `FATAL SIGNAL 6` crashes whenever mempool.space had a hiccup. The plugin contract already says the right thing for both methods: - `sync_block_by_height` (folgore-common, line ~69): "The plugin must set all fields to null if no block was found at the specified height." — extending that to "no block currently retrievable" is consistent with the spirit of the contract and is what lightningd expects (it will simply poll again on the next tick). - `sync_estimate_fees` (folgore-common, line ~65): "If fee estimation fails, the plugin must set all the fields to null." — this case was never wired up; the previous code returned `Err`. Wrap each method body in an IIFE so all internal `?` short-circuits land in one place, log the underlying error at WARN, and reply with the contract-defined null payload. No change for the success path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…path The hand-rolled fallback object in sync_estimate_fees omitted feerate_floor, which lightningd v25 treats as a protocol error: estimatefees_callback -> bitcoin_plugin_error -> fatal() -> abort(). The shared helper in folgore-common/client/fee_estimator.rs already produces the correct null-but-shape-complete payload, so use it. Closes #104. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Pushed 4103b80 extending this PR to also cover Full root-cause writeup and crash backtrace in #104 (closed by 4103b80). Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sync_block_by_heightandsync_estimate_feespropagate the post-retryErrup toclightningrpc-plugin. That serializes as a JSON-RPC error response, and lightningd's bitcoind plugin handler (bitcoind.c:bitcoin_plugin_error) treats any error response ongetrawblockbyheight/estimatefeesas fatal — it aborts the daemon with SIGABRT.sync_block_by_height→ setblockhashandblocktonullsync_estimate_fees→ set every fee field tonullWhy this matters
Observed in production on a node running mainnet + testnet against
mempool.space. Going back through the testnet log:Every one of these is upstream esplora having a transient hiccup and folgore translating it into a daemon abort. The merged #102 fixed the panic-on-bad-bytes case in
raw_to_num; this PR closes the remaining contract-violation path that turns transient failures into crashes.Test plan
cargo build --release -p folgore-esploracargo fmt -p folgore-esplora -- --check(clean)cargo clippy -p folgore-esplora --no-deps -- -D warnings(clean)🤖 Generated with Claude Code