Skip to content

Commit

Permalink
avoid alarm for initial rating
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Dec 11, 2024
1 parent 6d3bce7 commit 5c828fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions checkers/blsRatingsChecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const minAlarmDeltaRatingDrop = float64(0.0)
const maxAlarmDeltaRatingDrop = float64(100.0)
const jailThreshold = float32(10)
const startRating = float32(50)
const ratingDropMessageFormat = "Rating drop detected: temp rating: %0.2f, rating: %0.2f"
const imminentJailMessageFormat = "Imminent jail: temp rating: %0.2f, rating: %0.2f"

Expand Down Expand Up @@ -74,6 +75,9 @@ func (checker *blsRatingsChecker) Check(statistics map[string]*core.ValidatorSta
if stats.TempRating+checker.alarmDeltaRatingDrop > stats.Rating {
continue
}
if stats.TempRating == startRating && stats.TempRating < stats.Rating {
continue
}

log.Debug("found node with rating drop", "checker", checker.name, "bls key", blsKey)
results = append(results, core.CheckResponse{
Expand Down
12 changes: 12 additions & 0 deletions checkers/blsRatingsChecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func TestBlsRatingsChecker_Check(t *testing.T) {
TempRating: 50,
Rating: 50,
},
"bls11": {
TempRating: 50,
Rating: 100,
},
"": { // this should not be triggered on any test
TempRating: 0,
Rating: 0,
Expand Down Expand Up @@ -140,6 +144,14 @@ func TestBlsRatingsChecker_Check(t *testing.T) {
assert.Nil(t, err)
assert.Empty(t, response)
})
t.Run("bls key start rating should not signal", func(t *testing.T) {
t.Parallel()

instance, _ := NewBLSRatingsChecker([]string{"bls11"}, "test", 1.0)
response, err := instance.Check(testMap, nil)
assert.Nil(t, err)
assert.Empty(t, response)
})
t.Run("bls key rating increase not signal", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 5c828fa

Please sign in to comment.