Skip to content

Commit 0706e62

Browse files
0xMushowjimmygchen
andauthored
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>
1 parent a39558f commit 0706e62

File tree

1 file changed

+3
-3
lines changed
  • beacon_node/lighthouse_network/src/peer_manager

1 file changed

+3
-3
lines changed

beacon_node/lighthouse_network/src/peer_manager/peerdb.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ impl<E: EthSpec> PeerDB<E> {
259259
info.is_connected()
260260
&& match info.sync_status() {
261261
SyncStatus::Synced { info } => {
262-
info.has_slot(epoch.end_slot(E::slots_per_epoch()))
262+
info.has_slot(epoch.start_slot(E::slots_per_epoch()))
263263
}
264264
SyncStatus::Advanced { info } => {
265-
info.has_slot(epoch.end_slot(E::slots_per_epoch()))
265+
info.has_slot(epoch.start_slot(E::slots_per_epoch()))
266266
}
267267
SyncStatus::IrrelevantPeer
268268
| SyncStatus::Behind { .. }
@@ -332,7 +332,7 @@ impl<E: EthSpec> PeerDB<E> {
332332
info.is_connected()
333333
&& match info.sync_status() {
334334
SyncStatus::Synced { info } | SyncStatus::Advanced { info } => {
335-
info.has_slot(epoch.end_slot(E::slots_per_epoch()))
335+
info.has_slot(epoch.start_slot(E::slots_per_epoch()))
336336
}
337337
SyncStatus::IrrelevantPeer
338338
| SyncStatus::Behind { .. }

0 commit comments

Comments
 (0)