Repository navigation
fix(chain): reindex on startup when headers outlive the saved height - #1486
Open
Micah-Shallom wants to merge 1 commit into
Open
Micah-Shallom wants to merge 1 commit into
Micah-Shallom wants to merge 1 commit into
Conversation
The best height is only written on flush, so if florestad is killed during header sync, the stored headers are ahead of the saved height and the node restarts thinking it's at that older height. Today it only notices when a peer sends a header we already have, which with presync means after a full presync pass. Now `open` checks for a header one past the saved height and reindexes right away. Closes getfloresta#1479
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.
If florestad is killed during header sync, the headers it already downloaded are on disk but the best height isn't, since that's only saved on flush. On restart the node thinks it's back at the old height and only finds the stored headers once a peer sends one it already has. With presync (#1249) that means a full presync pass first.
Now
ChainState::openchecks for a stored header one past the saved height and runsreindex_chainbefore any peer is involved.Tested on signet by killing florestad with
kill -9at around 44k headers and restarting:A clean Ctrl+C restart loads the saved height and doesn't reindex. There's also a unit test that reopens the store after headers were accepted without a flush, both before and after a first flush.
Closes #1479