Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Add config param for missed-blocks-threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Jul 21, 2022
1 parent 0b8d482 commit b31be3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type ValidatorMonitor struct {
ChainID string `yaml:"chain-id"`
DiscordStatusMessageID *string `yaml:"discord-status-message-id"`
RPCRetries *int `yaml:"rpc-retries"`
MissedBlocksThreshold *int64 `yaml:"missed-blocks-threshold"`
Sentries *[]Sentry `yaml:"sentries"`
}

Expand Down
16 changes: 12 additions & 4 deletions cmd/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
)

const (
rpcErrorRetries = 5
outOfSyncThreshold = 5
haltThresholdNanoseconds = 3e11 // if nodes are stuck for > 5 minutes, will be considered halt
rpcErrorRetries = 5
outOfSyncThreshold = 5
haltThresholdNanoseconds = 3e11 // if nodes are stuck for > 5 minutes, will be considered halt
defaultMissedBlocksThreshold = 0
)

func monitorValidator(
Expand Down Expand Up @@ -108,7 +109,14 @@ func monitorValidator(
}
}

if !vm.FullNode && stats.RecentMissedBlocks > 0 {
var missedBlocksThreshold int64
if vm.MissedBlocksThreshold == nil {
missedBlocksThreshold = defaultMissedBlocksThreshold
} else {
missedBlocksThreshold = *vm.MissedBlocksThreshold
}

if !vm.FullNode && stats.RecentMissedBlocks > missedBlocksThreshold {
errs = append(errs, newMissedRecentBlocksError(stats.RecentMissedBlocks))
// Go back to find last signed block
if stats.LastSignedBlockHeight == -1 {
Expand Down

0 comments on commit b31be3c

Please sign in to comment.