Skip to content

Commit 395f3d4

Browse files
karalabefjl
andauthored
eth/catalyst: warn less frequently if no beacon client is available (#25569)
* eth/catalyst: warn less frequently if no beacon client is available * eth/catalyst: tweak warning frequency a bit * eth/catalyst: some more tweaks * Update api.go Co-authored-by: Felix Lange <[email protected]>
1 parent 02418c2 commit 395f3d4

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

eth/catalyst/api.go

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,23 @@ const (
6161
// have lead to some bad ancestor block. It's just an OOM protection.
6262
invalidTipsetsCap = 512
6363

64-
// beaconUpdateTimeout is the max time allowed for a beacon client to signal
65-
// use (from the last heartbeat) before it's consifered offline and the user
64+
// beaconUpdateStartupTimeout is the time to wait for a beacon client to get
65+
// attached before starting to issue warnings.
66+
beaconUpdateStartupTimeout = 30 * time.Second
67+
68+
// beaconUpdateExchangeTimeout is the max time allowed for a beacon client to
69+
// do a transition config exchange before it's considered offline and the user
6670
// is warned.
67-
beaconUpdateTimeout = 30 * time.Second
71+
beaconUpdateExchangeTimeout = 2 * time.Minute
72+
73+
// beaconUpdateConsensusTimeout is the max time allowed for a beacon client
74+
// to send a consensus update before it's considered offline and the user is
75+
// warned.
76+
beaconUpdateConsensusTimeout = 30 * time.Second
77+
78+
// beaconUpdateWarnFrequency is the frequency at which to warn the user that
79+
// the beacon client is offline.
80+
beaconUpdateWarnFrequency = 5 * time.Minute
6881
)
6982

7083
type ConsensusAPI struct {
@@ -545,9 +558,9 @@ func (api *ConsensusAPI) invalid(err error, latestValid *types.Header) beacon.Pa
545558
//
546559
// TODO(karalabe): Spin this goroutine down somehow
547560
func (api *ConsensusAPI) heartbeat() {
548-
// Sleep a bit more on startup since there's obviously no beacon client yet
561+
// Sleep a bit on startup since there's obviously no beacon client yet
549562
// attached, so no need to print scary warnings to the user.
550-
time.Sleep(beaconUpdateTimeout)
563+
time.Sleep(beaconUpdateStartupTimeout)
551564

552565
var (
553566
offlineLogged time.Time
@@ -576,9 +589,9 @@ func (api *ConsensusAPI) heartbeat() {
576589
// If there have been no updates for the past while, warn the user
577590
// that the beacon client is probably offline
578591
if api.eth.BlockChain().Config().TerminalTotalDifficultyPassed || api.eth.Merger().TDDReached() {
579-
if time.Since(lastForkchoiceUpdate) > beaconUpdateTimeout && time.Since(lastNewPayloadUpdate) > beaconUpdateTimeout {
580-
if time.Since(lastTransitionUpdate) > beaconUpdateTimeout {
581-
if time.Since(offlineLogged) > beaconUpdateTimeout {
592+
if time.Since(lastForkchoiceUpdate) > beaconUpdateConsensusTimeout && time.Since(lastNewPayloadUpdate) > beaconUpdateConsensusTimeout {
593+
if time.Since(lastTransitionUpdate) > beaconUpdateExchangeTimeout {
594+
if time.Since(offlineLogged) > beaconUpdateWarnFrequency {
582595
if lastTransitionUpdate.IsZero() {
583596
log.Warn("Post-merge network, but no beacon client seen. Please launch one to follow the chain!")
584597
} else {
@@ -588,7 +601,7 @@ func (api *ConsensusAPI) heartbeat() {
588601
}
589602
continue
590603
}
591-
if time.Since(offlineLogged) > beaconUpdateTimeout {
604+
if time.Since(offlineLogged) > beaconUpdateWarnFrequency {
592605
if lastForkchoiceUpdate.IsZero() && lastNewPayloadUpdate.IsZero() {
593606
log.Warn("Beacon client online, but never received consensus updates. Please ensure your beacon client is operational to follow the chain!")
594607
} else {
@@ -597,10 +610,12 @@ func (api *ConsensusAPI) heartbeat() {
597610
offlineLogged = time.Now()
598611
}
599612
continue
613+
} else {
614+
offlineLogged = time.Time{}
600615
}
601616
} else {
602-
if time.Since(lastTransitionUpdate) > beaconUpdateTimeout {
603-
if time.Since(offlineLogged) > beaconUpdateTimeout {
617+
if time.Since(lastTransitionUpdate) > beaconUpdateExchangeTimeout {
618+
if time.Since(offlineLogged) > beaconUpdateWarnFrequency {
604619
// Retrieve the last few blocks and make a rough estimate as
605620
// to when the merge transition should happen
606621
var (
@@ -654,6 +669,8 @@ func (api *ConsensusAPI) heartbeat() {
654669
offlineLogged = time.Now()
655670
}
656671
continue
672+
} else {
673+
offlineLogged = time.Time{}
657674
}
658675
}
659676
}

0 commit comments

Comments
 (0)