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

Properly handle skip slots in fork choice #1579

Merged
merged 3 commits into from
Jan 22, 2020
Merged

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Jan 21, 2020

Due to the way epoch pairs are justified/finalized and how we handle skipped slots in the consensus, we have to be careful to ensure not only that the justified/finalized block is in the chain, but that it is in the chain at the precise justified/finalized epoch (accounting for skip slots in exceptional cases)

Previously I erroneously put in conditions such the following:

assert block.slot > compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)

This just ensured that the block was in fact later than the finalized epoch, but not that the finalized root was in the chain (potentially at a skip slot) at that epoch.

To fix this, we modify get_ancestor to return the latest root at or before the queried slot in the chain in question. This mimics the behavior of how we save roots in state and how we vote on roots, and it very nicely fixes this corner case.


Helps properly handle cases in which we justify/finalize blocks after skipped epochs like in the following:

Screen Shot 2020-01-20 at 6 02 21 PM

Say block 64 at epoch 2 is finalized. Blocks that build off of block 64 at epoch 1 should not be considered in the fork choice. the modificaiton to get_ancestor protect against this case

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.

None yet

2 participants