Skip to content

Commit

Permalink
Change Positionining of Warning Log (#4850)
Browse files Browse the repository at this point in the history
* change logging

* change positioning of log

* fix status test

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
nisdas and prylabs-bulldozer[bot] committed Feb 13, 2020
1 parent b7adf55 commit db21f98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 8 additions & 7 deletions beacon-chain/powchain/service.go
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions beacon-chain/powchain/service_test.go
Expand Up @@ -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 {
Expand Down

0 comments on commit db21f98

Please sign in to comment.