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
12 changes: 6 additions & 6 deletions internal/adapters/notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (n *Notifier) sendNotification(payload NotificationPayload) error {
}

// SendValidatorLivenessNot sends a notification when one or more validators go offline or online.
func (n *Notifier) SendValidatorLivenessNot(validators []domain.ValidatorIndex, live bool) error {
func (n *Notifier) SendValidatorLivenessNot(validators []domain.ValidatorIndex, epoch domain.Epoch, live bool) error {
var title, body string
var priority Priority
var status Status
Expand All @@ -121,13 +121,13 @@ func (n *Notifier) SendValidatorLivenessNot(validators []domain.ValidatorIndex,
}
if live {
title = fmt.Sprintf("All validators back online (%d)", len(validators))
body = fmt.Sprintf("✅ All validators are back online and atesting on %s (%d).", n.Network, len(validators))
body = fmt.Sprintf("✅ All validators are back online and atesting at epoch %d on %s (%d).", epoch, n.Network, len(validators))
priority = Low
status = Resolved
isBanner = false
} else {
title = fmt.Sprintf("Validator(s) Offline: %s", indexesToString(validators, true))
body = fmt.Sprintf("❌ Validator(s) %s are not attesting on %s.", indexesToString(validators, true), n.Network)
body = fmt.Sprintf("❌ Validator(s) %s are not attesting at epoch %d on %s.", indexesToString(validators, true), epoch, n.Network)
priority = High
status = Triggered
isBanner = true
Expand All @@ -147,9 +147,9 @@ func (n *Notifier) SendValidatorLivenessNot(validators []domain.ValidatorIndex,
}

// SendValidatorsSlashedNot sends a notification when one or more validators are slashed.
func (n *Notifier) SendValidatorsSlashedNot(validators []domain.ValidatorIndex) error {
func (n *Notifier) SendValidatorsSlashedNot(validators []domain.ValidatorIndex, epoch domain.Epoch) error {
title := fmt.Sprintf("Validator(s) Slashed: %s", indexesToString(validators, true))
body := fmt.Sprintf("🚨 Validator(s) %s have been slashed on %s! Immediate attention required.", indexesToString(validators, true), n.Network)
body := fmt.Sprintf("🚨 Validator(s) %s have been slashed at epoch %d on %s! Immediate attention required.", indexesToString(validators, true), epoch, n.Network)
priority := Critical
status := Triggered
isBanner := true
Expand All @@ -174,7 +174,7 @@ func (n *Notifier) SendValidatorsSlashedNot(validators []domain.ValidatorIndex)
}

// SendBlockProposalNot sends a notification when a block is proposed or missed by one or more validators.
func (n *Notifier) SendBlockProposalNot(validators []domain.ValidatorIndex, epoch int, proposed bool) error {
func (n *Notifier) SendBlockProposalNot(validators []domain.ValidatorIndex, epoch domain.Epoch, proposed bool) error {
var title, body string
var priority Priority
var status Status = Triggered
Expand Down
6 changes: 3 additions & 3 deletions internal/application/ports/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ports
import "github.com/dappnode/validator-tracker/internal/application/domain"

type NotifierPort interface {
SendValidatorLivenessNot(validators []domain.ValidatorIndex, live bool) error
SendValidatorsSlashedNot(validators []domain.ValidatorIndex) error
SendBlockProposalNot(validators []domain.ValidatorIndex, epoch int, proposed bool) error
SendValidatorLivenessNot(validators []domain.ValidatorIndex, epoch domain.Epoch, live bool) error
SendValidatorsSlashedNot(validators []domain.ValidatorIndex, epoch domain.Epoch) error
SendBlockProposalNot(validators []domain.ValidatorIndex, epoch domain.Epoch, proposed bool) error
}
10 changes: 5 additions & 5 deletions internal/application/services/dutieschecker_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (a *DutiesChecker) performChecks(ctx context.Context, justifiedEpoch domain
if len(offline) > 0 && a.PreviouslyAllLive {
if notificationsEnabled[domain.Notifications.Liveness] {
logger.Debug("Sending notification for validators going offline: %v", offline)
if err := a.Notifier.SendValidatorLivenessNot(offline, false); err != nil {
if err := a.Notifier.SendValidatorLivenessNot(offline, justifiedEpoch, false); err != nil {
logger.Warn("Error sending validator liveness notification: %v", err)
}
}
Expand All @@ -111,7 +111,7 @@ func (a *DutiesChecker) performChecks(ctx context.Context, justifiedEpoch domain
if allLive && a.PreviouslyOffline {
if notificationsEnabled[domain.Notifications.Liveness] {
logger.Debug("Sending notification for all validators back online: %v", indices)
if err := a.Notifier.SendValidatorLivenessNot(indices, true); err != nil {
if err := a.Notifier.SendValidatorLivenessNot(indices, justifiedEpoch, true); err != nil {
logger.Warn("Error sending validator liveness notification: %v", err)
}
}
Expand All @@ -126,12 +126,12 @@ func (a *DutiesChecker) performChecks(ctx context.Context, justifiedEpoch domain
return err
}
if len(proposed) > 0 && notificationsEnabled[domain.Notifications.Proposal] {
if err := a.Notifier.SendBlockProposalNot(proposed, int(justifiedEpoch), true); err != nil {
if err := a.Notifier.SendBlockProposalNot(proposed, justifiedEpoch, true); err != nil {
logger.Warn("Error sending block proposal notification: %v", err)
}
}
if len(missed) > 0 && notificationsEnabled[domain.Notifications.Proposal] {
if err := a.Notifier.SendBlockProposalNot(missed, int(justifiedEpoch), false); err != nil {
if err := a.Notifier.SendBlockProposalNot(missed, justifiedEpoch, false); err != nil {
logger.Warn("Error sending block proposal notification: %v", err)
}
}
Expand All @@ -153,7 +153,7 @@ func (a *DutiesChecker) performChecks(ctx context.Context, justifiedEpoch domain
}

if len(toNotify) > 0 && notificationsEnabled[domain.Notifications.Slashed] {
if err := a.Notifier.SendValidatorsSlashedNot(toNotify); err != nil {
if err := a.Notifier.SendValidatorsSlashedNot(toNotify, justifiedEpoch); err != nil {
logger.Warn("Error sending validator slashed notification: %v", err)
}
}
Expand Down