From c9caf5dfc591306870fdc241c5570d2769382389 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 21 Aug 2020 14:09:52 -0500 Subject: [PATCH] Set Healthz to Return Error if Chain Has Not Yet Started (#7077) * 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 --- beacon-chain/sync/service.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index 89851a88b41d..05eeea19a4a5 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -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 }