Sync finalized sync to 2 epochs + 1 slot past our peer's finalized slot in order to finalize the chain locally

This commit is contained in:
Jimmy Chen 2023-06-28 16:14:39 +10:00
parent dfbe4b1add
commit d1146ec8b5
No known key found for this signature in database
GPG Key ID: 7AAEE02659DCF690

View File

@ -142,13 +142,20 @@ where
debug!(self.log, "Finalization sync peer joined"; "peer_id" => %peer_id);
self.awaiting_head_peers.remove(&peer_id);
// Because of our change in finalized sync batch size from 2 to 1 and our transition
// to using exact epoch boundaries for batches (rather than one slot past the epoch
// boundary), we need to sync finalized sync to 2 epochs + 1 slot past our peer's
// finalized slot in order to finalize the chain locally.
let target_head_slot =
remote_finalized_slot + (2 * T::EthSpec::slots_per_epoch()) + 1;
// Note: We keep current head chains. These can continue syncing whilst we complete
// this new finalized chain.
self.chains.add_peer_or_create_chain(
local_info.finalized_epoch,
remote_info.finalized_root,
remote_finalized_slot,
target_head_slot,
peer_id,
RangeSyncType::Finalized,
network,