From: merge-script Date: Wed, 22 Apr 2026 06:34:21 +0000 (+0000) Subject: Merge bitcoindevkit/bdk#2115: Add `prev_blockhash` validation to `CheckPoint` X-Git-Url: http://internal-gitweb-vhost/parse/serde/ser/static/gitweb.css?a=commitdiff_plain;h=HEAD;p=bdk Merge bitcoindevkit/bdk#2115: Add `prev_blockhash` validation to `CheckPoint` c486ba75865806bbe1d88c646385ac57df611ef5 docs: address review feedback on `prev_blockhash` validation (志宇) 031b30fb3fbc19894c85dccc0d6a5515442e5bce docs(core): address review feedback on docs and tests (志宇) ef35b199376b3b88bc7b8985aa1afa6c81bda5c1 fix(chain)!: make genesis immutable in `merge_chains` (志宇) d8cb41f2c22ed684fe493b29c86de02ddc921423 test(core): address review feedback on checkpoint tests (志宇) 9c0453c7d9767002b6722c888ac1f694c792c0d2 docs(core): Add module-level docs for `checkpoint_entry` (志宇) 3ef6ed866d364d6f8c9136d0b6696f2b90e572be feat(chain)!: Add `ApplyBlockError` for `prev_blockhash` validation (志宇) bf6541b43d3d65f20a7c081129197337f09d25b6 feat(chain)!: Relax the generic parameter for `LocalChain` (志宇) 19b900648f9308d671849c927abf4084d6843942 test(core): add tests for CheckPoint::push and insert methods (志宇) 9971fda5367cfa69917445a11c4b8c9d6de3f713 test(chain): Test `apply_update` with a single `CheckPoint
` (valued mammal) 3df06096f9209a0ed12e109e0d809174a7b1a73b test(chain): make `TestLocalChain` generic and add `prev_blockhash` test (志宇) c314b2567b2574da38e060bb57c02c9929082c08 fix(chain): `merge_chains` now takes account of `prev_blockhash`es (志宇) f10ba0ecb1e60aef40820298a357eb394bc190e9 fix(core): `Checkpoint::insert` now evicts on `prev_blockhash` mismatch (志宇) 046a771b7842dac74d5cb82a56b28fbbbbe1a33a fix(core): `push` now errors on `prev_blockhash` mismatch (志宇) 68d1ef4466cf64104b0338a3feed902080a35e05 feat(core): Initial work on `CheckPointEntry` (志宇) d4bdff08f7de754461d9364302b7e8371e3d234e feat(core): Add `prev_blockhash` method to `ToBlockHash` trait (志宇) Pull request description: Closes #2021 Related to #2076 Replaces #2024 Replaces #2091 ### Description This PR adds `prev_blockhash` awareness to `CheckPoint`, enabling proper chain validation when merging checkpoint chains that store block headers or similar data with previous block hash information. ### Notes to the reviewers This PR replaces some prior attempts: * #2024 - where we made the `CheckPoint::data` optional - however this resulted in internal complexity and an API with annoying edge cases. The tests from this PR were still useful. * #2091 - This second attempt had some good ideas, but was distracted from the goal of #2021. I mostly reused the `CheckPoint::insert` implementation of that PR. ### Changelog notice ```md Added: - `ToBlockHash::prev_blockhash()` - optional method to expose previous block hash - `CheckPointEntry` - new type for iterating with `prev_blockhash` awareness, yielding "placeholder" entries for heights inferred from `prev_blockhash` - `ApplyBlockError` - this is a new error type with two variants; `MissingGenesis` and `PrevBlockhashMismatch`. The second variant is a new error case introduced by `prev_blockhash` awareness. Changed: - `CheckPoint::push` - now errors when `prev_blockhash` conflicts with current tip (contiguous heights) - `CheckPoint::insert` - now evicts/displaces checkpoints on `prev_blockhash` conflict - `merge_chains` - now validates `prev_blockhash` consistency when merging - `LocalChain` generic parameter - relaxed constraint to `D: Clone` instead of `D: Copy`. Fixed: - `merge_chains` no longer replaces the genesis block. ``` ### Checklists #### All Submissions: * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: evanlinjin: self-ACK c486ba75865806bbe1d88c646385ac57df611ef5 Tree-SHA512: 5622a8a418034443931c8b5938e708c2222c42c05efbdac71d47a4e0ce1b4f4b0b7bcd2e1e14e2f295cc056e12c03e5750b40b1a1313cdbdf59a009d81d0b8a1 --- 86420a2bb3ac4ae26f4af013331409253479bb65