Skip to content

Commit 05a0ba4

Browse files
committed
Fix peer's status stale information should not appear too early.
1 parent 35cd5c5 commit 05a0ba4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

beacon_chain/sync/sync_overseer2.nim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const
3737
## Number of requests performed by single peer in one syncing step
3838
RepeatingFailuresCount* = 2
3939
## Number of repeating errors before starting rewind process.
40+
StatusStalePeriod* = 5
41+
## Number of slots before peer's status information could be stale.
4042

4143
func shortLog(optblkid: Opt[BlockId]): string =
4244
if optblkid.isNone():
@@ -1102,6 +1104,7 @@ proc doPeerUpdateStatus(
11021104
peer: Peer
11031105
): Future[bool] {.async: (raises: [CancelledError]).} =
11041106
let
1107+
dag = overseer.consensusManager.dag
11051108
peerHead = peer.getHeadBlockId()
11061109
peerFinalizedCheckpoint = peer.getFinalizedCheckpoint()
11071110
peerStatusAge = Moment.now() - peer.getStatusLastTime()
@@ -1129,8 +1132,11 @@ proc doPeerUpdateStatus(
11291132
newPeerHead = peer.getHeadBlockId()
11301133

11311134
if peerHead.slot >= newPeerHead.slot:
1132-
peer.updateScore(PeerScoreStaleStatus)
1133-
debug "Peer's status information is stale"
1135+
let stalePeriod =
1136+
(dag.cfg.timeParams.SLOT_DURATION * StatusStalePeriod)
1137+
if peerStatusAge >= stalePeriod:
1138+
peer.updateScore(PeerScoreStaleStatus)
1139+
debug "Peer's status information is stale"
11341140
else:
11351141
# Updating data structures about newly received Peer's status information.
11361142
overseer.updatePeer(peer)

0 commit comments

Comments
 (0)