Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider non-canonical chains when finding common ancestor #9210

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

@VolodymyrBg VolodymyrBg commented Mar 6, 2025

PR Description

This PR enhances the findCommonAncestor method in ForkChoiceStrategy to consider non-canonical local chains when finding a common ancestor with a remote chain.
Previously, when comparing a remote chain to find a common ancestor, we only compared it with our canonical head. But if the chain we selected to sync is non-canonical for us, we might have a lot of blocks on that chain that we are not considering, thus we end up unnecessarily redownloading them.
The implementation now:
1.First tries to find a direct common ancestor between the two specific chains (using the original algorithm)
2.If no direct common ancestor is found or to find a better one, checks all local chain heads (including non-canonical ones)
3.Selects the common ancestor with the highest slot number to minimize the amount of data that needs to be redownloaded
A new test case was added to verify the correct behavior when dealing with non-canonical chains.

Fixed Issue(s)

fixes #9194

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

@VolodymyrBg VolodymyrBg changed the title Issue Consider non-canonical chains when finding common ancestor Mar 6, 2025
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.

CommonAncestor should compare remote chain with non-canonical local chains too
1 participant