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

Simplify database anchor #6397

Merged
merged 5 commits into from
Sep 19, 2024

Conversation

michaelsproul
Copy link
Member

Proposed Changes

Based on a suggestion from @dapplion, simplify the database's anchor by making it non-optional.

Rippling this change through the codebase also allowed for some other simplifications including deleting the BackFillState::NotRequired enum variant, which was redundant. Previously there were two checks for a backfill sync having already completed: checking if the anchor was None (the BackFillState::NotRequired case) and checking if all desired blocks had been downloaded based on the anchor's oldest_block_slot (the BackFillState::Complete case). I see no need to handle these cases differently, so I've deleted the NotRequired variant in the process of deleting the code that handled anchor == None which is no longer a possible state.

@michaelsproul michaelsproul added work-in-progress PR is a work-in-progress tree-states Upcoming state and database overhaul labels Sep 16, 2024
@@ -905,9 +905,6 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {

let block_root = get_block_header_root(block_header);

// Disallow blocks that conflict with the anchor (weak subjectivity checkpoint), if any.
check_block_against_anchor_slot(block.message(), chain)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks were unnecessary because the anchor slot is always older than finalization, so any block older than the anchor is also older than finalization and will be caught by check_block_against_finalized_slot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if checkpoint sync to a non-finalized checkpoint though? In that case, the checkpoint slot could be ahead of finalized slot.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we force-initialize the fork-choice as if that checkpoint was finalized.

Copy link
Member

@pawanjay176 pawanjay176 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a question.

@@ -905,9 +905,6 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {

let block_root = get_block_header_root(block_header);

// Disallow blocks that conflict with the anchor (weak subjectivity checkpoint), if any.
check_block_against_anchor_slot(block.message(), chain)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if checkpoint sync to a non-finalized checkpoint though? In that case, the checkpoint slot could be ahead of finalized slot.

@michaelsproul michaelsproul removed the work-in-progress PR is a work-in-progress label Sep 19, 2024
@michaelsproul michaelsproul merged commit 1890278 into sigp:tree-states-archive Sep 19, 2024
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tree-states Upcoming state and database overhaul
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants