Repository navigation
Conversation
fetch_tip_and_latest_blocks returned the previous tip as soon as Electrum reported a lower height. After a re-org to a shorter chain, or when the server lags behind, the local chain kept an orphaned tip and later syncs could not replace it. Skip only the local checkpoints above the server's tip and search for the point of agreement among the rest, so the update can lower the tip. This matches how the Esplora backend handles the same case. Add a test that replaces the last blocks with fewer new ones and checks the local tip follows the server.
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
When Electrum reported a tip height lower than the local tip,
fetch_tip_and_latest_blocksreturned the previous tip right away. After a re-org to a shorter chain (or a lagging server),LocalChainkept an orphaned tip and later syncs could not replace it.Now only the local checkpoints above the server's tip are skipped, and the point of agreement is searched among the rest, so the chain update can lower the tip. The Esplora backend already behaves this way.
Notes to the reviewers
The early return and the assert that relied on it are removed. The new test invalidates 3 blocks and mines 2 new ones, so the server tip ends one block lower than the local tip with different hashes. It fails without the change (local tip stays at 11, server is at 10) and passes with it.
Changelog notice
Fixed
bdk_electrumkeeping an orphaned local tip when the Electrum server's tip height is lower than the local tip.Checklists
All Submissions:
Bugfixes:
Fixes #2356