Skip to content

Commit 8c1d96c

Browse files
authored
Merge pull request #17 from RhinoStake/main
2 parents 7abe541 + 58f6428 commit 8c1d96c

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

example-config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ chains:
116116
# Should an alert be sent if no RPC servers are responding? (Note this alarm is instantaneous with no delay)
117117
alert_if_no_servers: yes
118118

119+
# Should alerts be sent there are open governance proposals?
120+
governance_alerts: yes
121+
119122
# for this *specific* chain it's possible to override alert settings. If the api_key or webhook addresses are empty,
120123
# the global settings will be used. Note, enabled must be set both globally and for each chain.
121124

td2/alert.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -685,18 +685,21 @@ func (cc *ChainConfig) watch() {
685685
unvotedProposalMap[id] = true
686686
}
687687

688-
for _, proposalID := range cc.unvotedOpenGovProposalIds {
689-
id := fmt.Sprintf(idTemplate, cc.valInfo.Valcons, proposalID)
690-
alertMsg := fmt.Sprintf(msgTemplate, proposalID)
688+
// Only send governance alerts if they're enabled
689+
if cc.Alerts.GovernanceAlerts {
690+
for _, proposalID := range cc.unvotedOpenGovProposalIds {
691+
id := fmt.Sprintf(idTemplate, cc.valInfo.Valcons, proposalID)
692+
alertMsg := fmt.Sprintf(msgTemplate, proposalID)
691693

692-
// Send alert for this specific proposal
693-
td.alert(
694-
cc.name,
695-
alertMsg,
696-
"warning",
697-
false,
698-
&id,
699-
)
694+
// Send alert for this specific proposal
695+
td.alert(
696+
cc.name,
697+
alertMsg,
698+
"warning",
699+
false,
700+
&id,
701+
)
702+
}
700703
}
701704

702705
// check and resolve the alert if the proposal has been voted on

td2/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ type AlertConfig struct {
189189
// AlertIfNoServers: should an alert be sent if no servers are reachable?
190190
AlertIfNoServers bool `yaml:"alert_if_no_servers"`
191191

192+
// Whether to alert on unvoted governance proposals
193+
GovernanceAlerts bool `yaml:"governance_alerts"`
194+
192195
// PagerdutyAlerts: Should pagerduty alerts be sent for this chain? Both 'config.pagerduty.enabled: yes' and this must be set.
193196
// Deprecated: use Pagerduty.Enabled instead
194197
PagerdutyAlerts bool `yaml:"pagerduty_alerts"`

td2/validator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (cc *ChainConfig) GetValInfo(first bool) (err error) {
127127
}
128128
}
129129

130+
// Query for unvoted proposals regardless of alert setting
130131
unvotedProposalIds, err := provider.QueryUnvotedOpenProposalIds(ctx)
131132
if err == nil {
132133
cc.unvotedOpenGovProposalIds = unvotedProposalIds
@@ -137,6 +138,11 @@ func (cc *ChainConfig) GetValInfo(first bool) (err error) {
137138
l(err)
138139
}
139140

141+
// Log if governance alerts are disabled (only on first run)
142+
if first && !cc.Alerts.GovernanceAlerts {
143+
l(fmt.Sprintf("ℹ️ Governance alerts disabled for %s (%s)", cc.ValAddress, cc.valInfo.Moniker))
144+
}
145+
140146
signingInfo, err := provider.QuerySigningInfo(ctx)
141147
if err != nil {
142148
return

0 commit comments

Comments
 (0)