Don't insert head to proto array DAG as index 0 #4749
Merged
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.
Looking at the Vizgraph, I was confused on why initial sync and regular sync don’t belong in the same branch. As we didn’t think it was that big of the deal, the following warning log was temporary as it eventually goes away:
[2020-02-04 15:31:07] WARN blockchain: Skip head update for slot 187055: head at slot 187008 with weight 4831 is not eligible, finalizedEpoch 5842 != 5843, justifiedEpoch 5843 != 5844
After looking at this more, we realized to resume syncing, node gets the 1.) head block then start start sync from 2.) last finalized check point. So fork choice insert head block into the array as index 0. The issue is illustrated as the following:
What's wrong with above is the node at index 889 got built on top of index 0 instead of index 888 and became its separate branch. So everything from index 1 to index 888 basically didn’t count which is why it takes some time to get a new head when node first starts. Bottom branch is 1 to 888. And top is 889 built on top of index 0. The graph proved it:
To fix this, a node simply should not insert head to index 0, there's just no reason to do it.