-
Notifications
You must be signed in to change notification settings - Fork 937
Consistent logic to select range sync start_slot #8416
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
base: unstable
Are you sure you want to change the base?
Conversation
|
|
||
| pub enum PeerSyncTypeAdvanced { | ||
| Finalized { | ||
| target_slot: Slot, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs comment
| Finalized { | ||
| target_slot: Slot, | ||
| target_root: Hash256, | ||
| start_epoch: Epoch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be per-peer?
| } | ||
|
|
||
| #[derive(Clone)] | ||
| pub(crate) struct LocalSyncInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a comment
| let status = chain.status_message(); | ||
| // Max with the store in case the node has triggered manual finalization | ||
| let local_irreversible_epoch = std::cmp::max( | ||
| chain.head().finalized_checkpoint().epoch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May as well use status.finalized_epoch() here to avoid potential inconsistencies. It's also likely to be marginally quicker
| PeerSyncType::FullySynced | ||
| } else { | ||
| PeerSyncType::Advanced | ||
| let finality_advanced = remote.finalized_epoch > local.finalized_epoch + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment or a const for this + 1 would be good I think
|
Changing this to waiting-on-author, I think you said last week you were planning to make some more changes |
Issue Addressed
From #8382 I noted that the logic in range sync to decide where to start syncing from is scattered. When manual finalization is triggered, sync will fetch useless epochs.
Proposed Changes
This is a somewhat sensitive change that I don't want to have buried in #8382. Since manual finalization is an avaialble feature in current stable I think it's okay to fix separately to #8382.
This PR merges the logic to decide if a peer:
In a single function. Plus, the variant
PeerSyncType::Advancedincludes which slot sync should start from.