fix sending genesis blocks to peers in syncLoop#402
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the syncer's syncLoop function where empty BlockID entries in the history array could cause errors when attempting to send genesis blocks to peers during instant syncing scenarios.
Changes:
- Added a check to skip empty BlockID entries when iterating through history returned by
cm.History() - Prevents attempting to fetch state for empty block IDs, which would incorrectly trigger genesis state lookups with invalid heights
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chris124567
approved these changes
Feb 24, 2026
n8mgr
approved these changes
Feb 24, 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.
The call to
s.cm.Historymay return a history that is only partially filled in when it can't fetch blocks from the store. With instant syncing this is a real possibility.We would then ask for the state of that empty block id which is the genesis state being stored with a height of
math.MaxUint64in the store. Sending that over to the peer will then show up as{"peer": "<-66.85.74.42:15724", "rpc": "SendHeaders", "error": "index 18446744073709551615::00000000 is not on our best chain"}.