Skip to content

Change CheckPoint::push in favor of CheckPoint::insert#11

Merged
febyeji merged 2 commits intofebyeji:add-cbf-chain-sourcefrom
randomlogin:cbf-fix-checkpoint-insert
Apr 21, 2026
Merged

Change CheckPoint::push in favor of CheckPoint::insert#11
febyeji merged 2 commits intofebyeji:add-cbf-chain-sourcefrom
randomlogin:cbf-fix-checkpoint-insert

Conversation

@randomlogin
Copy link
Copy Markdown

push only appends above the tip, so when recent_history contained
blocks at or below the wallet's current checkpoint height after a reorg,
the stale hashes on the wallet checkpoint were never replaced. Switch to
CheckPoint::insert, which detects conflicting hashes and purges stale
blocks, matching bdk-kyoto's UpdateBuilder::apply_chain_event.

Also clear latest_tip on BlockHeaderChanges::Reorganized so cached
tip state does not point at an abandoned chain.

Update the checkpoint_building_handles_reorg unit test (added in
c1844b3) to exercise the fixed behaviour: a reorg where the new tip
is at the same height as the wallet's checkpoint must still result
in the reorged hashes winning.

randomlogin and others added 2 commits April 21, 2026 00:34
`push` only appends above the tip, so when `recent_history` contained
blocks at or below the wallet's current checkpoint height after a reorg,
the stale hashes on the wallet checkpoint were never replaced. Switch to
`CheckPoint::insert`, which detects conflicting hashes and purges stale
blocks, matching bdk-kyoto's `UpdateBuilder::apply_chain_event`.

Also clear `latest_tip` on `BlockHeaderChanges::Reorganized` so cached
tip state does not point at an abandoned chain.

Update the `checkpoint_building_handles_reorg` unit test (added in
c1844b3) to exercise the fixed behaviour: a reorg where the new tip
is at the same height as the wallet's checkpoint must still result
in the reorged hashes winning.

Disclosure: drafted with assistance from Claude Code.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@randomlogin randomlogin force-pushed the cbf-fix-checkpoint-insert branch from 95c65ea to 8261e32 Compare April 20, 2026 22:47
@febyeji febyeji merged commit 9a3152e into febyeji:add-cbf-chain-source Apr 21, 2026
13 of 19 checks passed
@randomlogin randomlogin deleted the cbf-fix-checkpoint-insert branch April 21, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants