Repository navigation
fix(chain): make LocalChain canonicalization and request builder exts generic over D - #2439
Open
evanlinjin wants to merge 2 commits into
Open
evanlinjin wants to merge 2 commits into
evanlinjin wants to merge 2 commits into
Conversation
`is_block_in_chain`, `chain_tip`, `canonicalize` and `canonical_view` only need block hashes, which any checkpoint data provides, but they were in `impl LocalChain<BlockHash>`, so a `LocalChain<Header>` could not canonicalize a `TxGraph`. Make that impl block generic over `D`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`SyncRequestBuilderExt` and `FullScanRequestBuilderExt` never touch the checkpoint data, but were only implemented for `D = BlockHash`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2439 +/- ##
==========================================
+ Coverage 80.66% 81.23% +0.57%
==========================================
Files 31 31
Lines 6236 6236
Branches 293 294 +1
==========================================
+ Hits 5030 5066 +36
+ Misses 1136 1100 -36
Partials 70 70
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:
|
reez
approved these changes
Oct 30, 2026
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.
Description
Makes the rest of
bdk_chain's accidentallyBlockHash-only API generic over the checkpoint dataD:LocalChain::{is_block_in_chain, chain_tip, canonicalize, canonical_view}: theirimpl LocalChain<BlockHash>block becomesimpl<D> LocalChain<D>, andapply_header*get aBlockHashblock of their own. The four only useget/hash/block_id, so aLocalChain<Header>can now canonicalize aTxGraph.SyncRequestBuilderExtandFullScanRequestBuilderExtare implemented for builders with anyD, sorevealed_spks_from_indexer,unused_spks_from_indexerandspks_from_indexerwork with aCheckPoint<Header>tip.The rest of the
BlockHash-only API is that way on purpose:apply_header*buildBlockHashcheckpoints, the sqlitelocal_chain::ChangeSetstores hashes, the chain sources fetch hashes, andSyncRequestBuilder<()>::spksstaysBlockHash-only soSyncRequest::builder().spks(..)keeps inferringD.Fixes #2437
Replaces #2438, adding the
LocalChainmethods and leaving out its unrelated MSRV pin change (#2435 has it).Notes to the reviewers
None of this API is released (
chain-0.23.xhas a non-genericLocalChain,core-0.6.xbuilders have noD), so there's no changelog entry.This conflicts with #2139, which moves
is_block_in_chaininto theD: ToBlockHashimpl and renamescanonicalize/canonical_view. This is the smaller fix; #2139 can rebase onto it.Against master, this can break type inference where nothing else pins
D:LocalChainbuilt from generic data (e.g.Hash::hash(..)) whose only use wascanonicalize/canonical_view. Two tests here needed aLocalChain<BlockHash>annotation.revealed_spks_from_indexer/spks_from_indexer, withoutchain_tip, and never passed to a chain source. Passing it to esplora/electrumsync/full_scanstill infersD.Changelog notice
None: fixes unreleased API.
Checklists
All Submissions:
Bugfixes:
🤖 Generated with Claude Code