fix initialization of sync committee cache after loading non-epoch state #6160
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.
When initializing from a state that's not aligned to an epoch boundary, an earlier state is loaded that's epoch aligned, and subsequently topped up with the missing blocks.
dag.headSyncCommittee
is initialized prior to topping up the missing blocks, though. If the sync committee changes while applying the blocks (e.g., a sync committee period boundary hits), the cached information becomes unlinked fromdag.head
, leading to valid blocks based on that chain being rejected. To fix this, move cache initialization after the top up with blocks. This has been observed on Goerli by initializing from 7919502 and attempting to top up 7920111. The block gets rejected with an invalid state root on nodes that have restarted after setting 7919502 as head, while it gets accepted by all other nodes. Error message isblock: state root verification failed
. The incorrect initialization behaviour was introduced in #4592, before which the sync committee cache was initialized after applying blocks.