@@ -61,10 +61,23 @@ const (
61
61
// have lead to some bad ancestor block. It's just an OOM protection.
62
62
invalidTipsetsCap = 512
63
63
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
66
70
// 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
68
81
)
69
82
70
83
type ConsensusAPI struct {
@@ -545,9 +558,9 @@ func (api *ConsensusAPI) invalid(err error, latestValid *types.Header) beacon.Pa
545
558
//
546
559
// TODO(karalabe): Spin this goroutine down somehow
547
560
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
549
562
// attached, so no need to print scary warnings to the user.
550
- time .Sleep (beaconUpdateTimeout )
563
+ time .Sleep (beaconUpdateStartupTimeout )
551
564
552
565
var (
553
566
offlineLogged time.Time
@@ -576,9 +589,9 @@ func (api *ConsensusAPI) heartbeat() {
576
589
// If there have been no updates for the past while, warn the user
577
590
// that the beacon client is probably offline
578
591
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 {
582
595
if lastTransitionUpdate .IsZero () {
583
596
log .Warn ("Post-merge network, but no beacon client seen. Please launch one to follow the chain!" )
584
597
} else {
@@ -588,7 +601,7 @@ func (api *ConsensusAPI) heartbeat() {
588
601
}
589
602
continue
590
603
}
591
- if time .Since (offlineLogged ) > beaconUpdateTimeout {
604
+ if time .Since (offlineLogged ) > beaconUpdateWarnFrequency {
592
605
if lastForkchoiceUpdate .IsZero () && lastNewPayloadUpdate .IsZero () {
593
606
log .Warn ("Beacon client online, but never received consensus updates. Please ensure your beacon client is operational to follow the chain!" )
594
607
} else {
@@ -597,10 +610,12 @@ func (api *ConsensusAPI) heartbeat() {
597
610
offlineLogged = time .Now ()
598
611
}
599
612
continue
613
+ } else {
614
+ offlineLogged = time.Time {}
600
615
}
601
616
} 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 {
604
619
// Retrieve the last few blocks and make a rough estimate as
605
620
// to when the merge transition should happen
606
621
var (
@@ -654,6 +669,8 @@ func (api *ConsensusAPI) heartbeat() {
654
669
offlineLogged = time .Now ()
655
670
}
656
671
continue
672
+ } else {
673
+ offlineLogged = time.Time {}
657
674
}
658
675
}
659
676
}
0 commit comments