From 951d857ea782abad962f79d3f1741b8e60fcbf7d Mon Sep 17 00:00:00 2001 From: Long Zhang Date: Tue, 28 Oct 2025 13:23:46 +0100 Subject: [PATCH] #56 exclude precommit and prevote for missing consecutive blocks alert Signed-off-by: Long Zhang --- example-config.yml | 2 ++ td2/types.go | 2 ++ td2/types_test.go | 2 +- td2/ws.go | 12 +++++++++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/example-config.yml b/example-config.yml index 865fdae..aa3c440 100644 --- a/example-config.yml +++ b/example-config.yml @@ -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 diff --git a/td2/types.go b/td2/types.go index 67d7206..ad3da5e 100644 --- a/td2/types.go +++ b/td2/types.go @@ -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"` diff --git a/td2/types_test.go b/td2/types_test.go index d7fc392..381d48a 100644 --- a/td2/types_test.go +++ b/td2/types_test.go @@ -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) && @@ -499,4 +500,3 @@ func TestFloatVal(t *testing.T) { }) } } - diff --git a/td2/ws.go b/td2/ws.go index 826c6db..1883f54 100644 --- a/td2/ws.go +++ b/td2/ws.go @@ -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) @@ -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