Repository navigation
fix(rpc): error when the node lacks our genesis, and a README from #2244 - #2398
evanlinjin wants to merge 2 commits into
Conversation
When the node didn't have `last_cp`'s genesis (e.g. it's on another network), `Emitter` replaced its checkpoint chain with the node's genesis and kept emitting. The emitted checkpoints then no longer connected to the caller's chain. `Emitter::next_block` now returns the node's "not found" RPC error instead. Fixes bitcoindevkit#2290 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README is now the crate doc (`include_str!`), as for `bdk_esplora` and `bdk_file_store`, so crates.io and docs.rs show the same text. It keeps the old crate docs (including the trust section) and adds an example syncing a `LocalChain` from `Emitter`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2398 +/- ##
==========================================
- Coverage 80.26% 80.17% -0.10%
==========================================
Files 31 31
Lines 6168 6179 +11
Branches 292 293 +1
==========================================
+ Hits 4951 4954 +3
- Misses 1147 1152 +5
- Partials 70 73 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tvpeter
left a comment
There was a problem hiding this comment.
tACK 66dc95c
Thank you for working on this.
nit: for the same situation, FilterIter::find_base returns Error::ReorgDepthExceeded, so the two emitters in this crate report a network mismatch differently.
Out of curiosity I looked at how Bitcoin Core handles a wallet attached to a node on another chain. In CWallet::AttachChain (bitcoin/bitcoin#18554) it compares the wallet's stored genesis with the node's genesis up front, and refuses to load the wallet if they differ. This is a single comparison, done before any fork-finding.
This PR reaches the same result, but only after poll_once has called getblock on every checkpoint in last_cp. A LocalChain synced through the Emitter holds one checkpoint per block, so on a node from another network the number of RPC calls grows linearly with the chain (O(n)).
Checking genesis once the tip fails to match will bring this down to 2 RPC calls at any chain size. The normal path is unchanged, and the error this PR documents is kept. I don't think this should block the PR, so I will open an issue as a follow-up.
Description
The parts of #2244 that don't depend on moving to
bdk_bitcoind_client, on top ofbitcoincore-rpc:Emitterreplaced its checkpoint chain with the node's genesis and kept emitting blocks that don't connect to the caller's chain.next_blocknow returns the node's "not found" RPC error instead. This is fix(bitcoind_rpc): surface RPC error on genesis mismatch #2365's approach: it isn't breaking, and it covers everylast_cpfrom aLocalChain(which always has genesis). A hand-builtlast_cpwithout genesis still re-roots, which is the right recovery after a re-org deeper than all of its checkpoints.include_str!, as forbdk_esplora), keeps the trust section, and has a usage example syncing aLocalChain.Compared with #2244, this keeps
bitcoincore-rpcand the currentEmitter::newsignature, and leaves outEmitterError, theconnected_to()fallback and theNO_EXPECTED_MEMPOOL_TXSremoval.Emitternever emits a checkpoint without a previous one, so that fallback only affected hand-built events. The constant is what lets an emptyexpected_mempool_txsinfer its item type, so it stays. It also leaves out the generic checkpoint data (#2105), thestart_heightbuilder and the electrsd/bitcoind bump.Replaces #2244
Fixes #2290
Changelog notice
last_cp,Emitter::next_blockreturns the node's "not found" RPC error instead of silently re-rooting at the node's genesis. Emitter silently replaces the caller’s genesis on a network mismatch #2290Checklists
All Submissions:
Bugfixes:
🤖 Generated with Claude Code