From db21f980531efebf4399e70ab34c0e035e438db3 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Thu, 13 Feb 2020 16:39:15 +0800 Subject: [PATCH] Change Positionining of Warning Log (#4850) * change logging * change positioning of log * fix status test Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/powchain/service.go | 15 ++++++++------- beacon-chain/powchain/service_test.go | 3 +-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/beacon-chain/powchain/service.go b/beacon-chain/powchain/service.go index 4b22d375c..705a29722 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -276,13 +276,6 @@ func (s *Service) Status() error { if s.runError != nil { return s.runError } - // use a 5 minutes timeout for block time, because the max mining time is 278 sec (block 7208027) - // (analyzed the time of the block from 2018-09-01 to 2019-02-13) - fiveMinutesTimeout := time.Now().Add(-5 * time.Minute) - // check that web3 client is syncing - if time.Unix(int64(s.latestEth1Data.BlockTime), 0).Before(fiveMinutesTimeout) { - return errors.New("eth1 client is not syncing") - } return nil } @@ -522,6 +515,14 @@ func safelyHandlePanic() { func (s *Service) handleDelayTicker() { defer safelyHandlePanic() + + // use a 5 minutes timeout for block time, because the max mining time is 278 sec (block 7208027) + // (analyzed the time of the block from 2018-09-01 to 2019-02-13) + fiveMinutesTimeout := time.Now().Add(-5 * time.Minute) + // check that web3 client is syncing + if time.Unix(int64(s.latestEth1Data.BlockTime), 0).Before(fiveMinutesTimeout) { + log.Warn("eth1 client is not syncing") + } if !s.chainStartData.Chainstarted { if err := s.checkBlockNumberForChainStart(context.Background(), big.NewInt(int64(s.latestEth1Data.LastRequestedBlock))); err != nil { s.runError = err diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 17634c686..1452081f8 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -337,8 +337,7 @@ func TestStatus(t *testing.T) { {isRunning: false, latestEth1Data: &protodb.LatestETH1Data{BlockTime: beforeFiveMinutesAgo}}: "", {isRunning: false, runError: errors.New("test runError")}: "", // "status is error" cases - {isRunning: true, latestEth1Data: &protodb.LatestETH1Data{BlockTime: beforeFiveMinutesAgo}}: "eth1 client is not syncing", - {isRunning: true, runError: errors.New("test runError")}: "test runError", + {isRunning: true, runError: errors.New("test runError")}: "test runError", } for web3ServiceState, wantedErrorText := range testCases {