fix(peerdb): use start_slot instead of end_slot for safer actions (#8498)

Which issue # does this PR address?
None


  Discussed in private with @jimmygchen, Lighthouse's `earliest_available_slot` is guaranteed to always align with epoch boundaries, but as a safety implementation, we should use `start_slot` just in case other clients differ in their implementations.

At least we agreed it would be safer for `synced_peers_for_epoch`, I also made the change in `has_good_custody_range_sync_peer`, but this is to be reviewed please.


Co-Authored-By: Antoine James <antoine@ethereum.org>

Co-Authored-By: Jimmy Chen <jimmy@sigmaprime.io>
This commit is contained in:
0xMushow
2026-01-08 10:17:46 +04:00
committed by GitHub
parent a39558f6e5
commit 0706e62f52

View File

@@ -259,10 +259,10 @@ impl<E: EthSpec> PeerDB<E> {
info.is_connected()
&& match info.sync_status() {
SyncStatus::Synced { info } => {
info.has_slot(epoch.end_slot(E::slots_per_epoch()))
info.has_slot(epoch.start_slot(E::slots_per_epoch()))
}
SyncStatus::Advanced { info } => {
info.has_slot(epoch.end_slot(E::slots_per_epoch()))
info.has_slot(epoch.start_slot(E::slots_per_epoch()))
}
SyncStatus::IrrelevantPeer
| SyncStatus::Behind { .. }
@@ -332,7 +332,7 @@ impl<E: EthSpec> PeerDB<E> {
info.is_connected()
&& match info.sync_status() {
SyncStatus::Synced { info } | SyncStatus::Advanced { info } => {
info.has_slot(epoch.end_slot(E::slots_per_epoch()))
info.has_slot(epoch.start_slot(E::slots_per_epoch()))
}
SyncStatus::IrrelevantPeer
| SyncStatus::Behind { .. }