Skip to content

Commit

Permalink
(NOBIDS) added node sanity check for eth1indexer (#2853)
Browse files Browse the repository at this point in the history
  • Loading branch information
recy21 authored Mar 18, 2024
1 parent ff7e000 commit 33431f4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/eth1indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ func main() {
return
}

var lastBlockFromNodeOld uint64
var lastBlockFromNodeSameCount uint64
lastSuccessulBlockIndexingTs := time.Now()
for ; ; time.Sleep(time.Second * 14) {
err := HandleChainReorgs(bt, client, *reorgDepth)
Expand All @@ -237,9 +239,26 @@ func main() {

lastBlockFromNode, err := client.GetLatestEth1BlockNumber()
if err != nil {
lastBlockFromNodeSameCount++
if lastBlockFromNodeSameCount > 20 { // nearly 5 minutes no new block
utils.LogFatal(err, "no new block in 20 tries", 0, map[string]interface{}{
"lastBlockFromNode": lastBlockFromNodeOld,
})
}
logrus.Errorf("error retrieving latest eth block number: %v", err)
continue
}
if lastBlockFromNode != lastBlockFromNodeOld {
lastBlockFromNodeOld = lastBlockFromNode
lastBlockFromNodeSameCount = 0
} else {
lastBlockFromNodeSameCount++
if lastBlockFromNodeSameCount > 20 { // nearly 5 minutes no new block
utils.LogFatal(nil, "no new block in 20 tries", 0, map[string]interface{}{
"lastBlockFromNode": lastBlockFromNodeOld,
})
}
}

lastBlockFromBlocksTable, err := bt.GetLastBlockInBlocksTable()
if err != nil {
Expand Down

0 comments on commit 33431f4

Please sign in to comment.