You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LocalChain::insert_block misreports PrevBlockhashMismatch as a genesis AlterCheckPointError #2357
When inserting a contiguous Header whose prev_blockhash does not link (real error: ApplyBlockError::PrevBlockhashMismatch):
height is always 0
original_hash is always the genesis hash
update_hash is usually None (changeset only contains the inserted height, not height 0)
Display therefore says "failed to remove block at height 0", which is wrong
Same-height hash conflicts are handled correctly earlier in insert_block. Only the apply_changeset error path is broken. This is distinct from #2309 (apply_changeset silently replacing genesis).
Error metadata should identify the failing height/hash (or preserve ApplyBlockError), not claim a genesis removal. Callers must be able to distinguish a mid-chain prev_blockhash clash from a genesis problem.
Build environment
BDK tag/commit: master
Crate: bdk_chain
Rust/Cargo version: MSRV 1.85.0+
Which backend(s) are relevant (if any)?
None / not backend-related (e.g. bdk_chain, bdk_core)
Is this blocking production use?
Yes
No
Additional context
Suggested fix: map ApplyBlockError into a correct AlterCheckPointError (or change the return type to expose ApplyBlockError / a unified error). Happy-path behavior need not change.
Confirmed on current master with a minimal standalone program (no electrsd): inserting a height-1 Header with a non-linking prev_blockhash yields AlterCheckPointError { height: 0, update_hash: None } and Display failed to remove block at height 0. Ignored unit test: insert_block_prev_blockhash_mismatch_error_is_not_genesis in crates/chain/tests/test_local_chain.rs.
Activity
DevaanshPathak commentedon Oct 9, 2026
Confirmed on current master with a minimal standalone program (no electrsd): inserting a height-1 Header with a non-linking prev_blockhash yields
AlterCheckPointError { height: 0, update_hash: None }and Displayfailed to remove block at height 0. Ignored unit test:insert_block_prev_blockhash_mismatch_error_is_not_genesisincrates/chain/tests/test_local_chain.rs.DevaanshPathak commentedon Oct 9, 2026
I'll work on a fix for this.