Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ default_alert_config:
consecutive_enabled: yes
# How many missed blocks should trigger a notification?
consecutive_missed: 5
# The following option can be used to exclude cases where a validator submits prevote and precommit, but the proposer does not include it in the block
consecutive_missed_exclude_preactions: false
# Consecutive Missed alert Pagerduty Severity
consecutive_priority: critical

Expand Down
2 changes: 2 additions & 0 deletions td2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ type AlertConfig struct {
ConsecutivePriority string `yaml:"consecutive_priority"`
// Whether to alert on consecutive missed blocks
ConsecutiveAlerts *bool `yaml:"consecutive_enabled"`
// Whether to exclude prevote/precommit misses from consecutive miss counting
ConsecutiveMissExcludePreactions *bool `yaml:"consecutive_missed_exclude_preactions"`

// Window is how many blocks missed as a percentage of the slashing window to trigger an alert
Window *int `yaml:"percentage_missed"`
Expand Down
2 changes: 1 addition & 1 deletion td2/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func alertConfigsEqual(a, b AlertConfig) bool {
intPtrEqual(a.ConsecutiveMissed, b.ConsecutiveMissed) &&
a.ConsecutivePriority == b.ConsecutivePriority &&
boolPtrEqual(a.ConsecutiveAlerts, b.ConsecutiveAlerts) &&
boolPtrEqual(a.ConsecutiveMissExcludePreactions, b.ConsecutiveMissExcludePreactions) &&
intPtrEqual(a.Window, b.Window) &&
a.PercentagePriority == b.PercentagePriority &&
boolPtrEqual(a.PercentageAlerts, b.PercentageAlerts) &&
Expand Down Expand Up @@ -499,4 +500,3 @@ func TestFloatVal(t *testing.T) {
})
}
}

12 changes: 9 additions & 3 deletions td2/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ func (cc *ChainConfig) WsRun() {
cc.lastBlockTime = time.Now()
info := getAlarms(cc.name)
cc.blocksResults = append([]int{int(signState)}, cc.blocksResults[:len(cc.blocksResults)-1]...)
excludePreactions := boolVal(cc.Alerts.ConsecutiveMissExcludePreactions)
if signState < 3 && cc.valInfo.Bonded {
warn := fmt.Sprintf("❌ warning %s missed block %d on %s", cc.valInfo.Moniker, update.Height, cc.ChainId)
missTypes := []string{"block", "precommit", "prevote"}
warn := fmt.Sprintf("❌ warning %s missed %s %d on %s", cc.valInfo.Moniker, missTypes[signState], update.Height, cc.ChainId)
info += warn + "\n"
cc.lastError = time.Now().UTC().String() + " " + info
l(warn)
Expand All @@ -141,11 +143,15 @@ func (cc *ChainConfig) WsRun() {
case StatusPrecommit:
cc.statPrecommitMiss += 1
cc.statTotalMiss += 1
cc.statConsecutiveMiss += 1
if !excludePreactions {
cc.statConsecutiveMiss += 1
}
case StatusPrevote:
cc.statPrevoteMiss += 1
cc.statTotalMiss += 1
cc.statConsecutiveMiss += 1
if !excludePreactions {
cc.statConsecutiveMiss += 1
}
case StatusSigned:
cc.statTotalSigns += 1
cc.statConsecutiveMiss = 0
Expand Down
Loading