Skip to content

Commit

Permalink
Set Healthz to Return Error if Chain Has Not Yet Started (#7077)
Browse files Browse the repository at this point in the history
* healthz in sync when chain not started
* Merge refs/heads/master into fix-healthz-when-process-deposits
* Merge refs/heads/master into fix-healthz-when-process-deposits
* Merge refs/heads/master into fix-healthz-when-process-deposits
  • Loading branch information
rauljordan authored Aug 21, 2020
1 parent b4c7a14 commit c9caf5d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions beacon-chain/sync/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,17 @@ func (s *Service) Stop() error {

// Status of the currently running regular sync service.
func (s *Service) Status() error {
if s.chainStarted {
if s.initialSync.Syncing() {
return errors.New("waiting for initial sync")
}
// If our head slot is on a previous epoch and our peers are reporting their head block are
// in the most recent epoch, then we might be out of sync.
if headEpoch := helpers.SlotToEpoch(s.chain.HeadSlot()); headEpoch+1 < helpers.SlotToEpoch(s.chain.CurrentSlot()) &&
headEpoch+1 < s.p2p.Peers().HighestEpoch() {
return errors.New("out of sync")
}
if !s.chainStarted {
return errors.New("chain not yet started")
}
if s.initialSync.Syncing() {
return errors.New("waiting for initial sync")
}
// If our head slot is on a previous epoch and our peers are reporting their head block are
// in the most recent epoch, then we might be out of sync.
if headEpoch := helpers.SlotToEpoch(s.chain.HeadSlot()); headEpoch+1 < helpers.SlotToEpoch(s.chain.CurrentSlot()) &&
headEpoch+1 < s.p2p.Peers().HighestEpoch() {
return errors.New("out of sync")
}
return nil
}
Expand Down

0 comments on commit c9caf5d

Please sign in to comment.