Skip to content

Commit

Permalink
dispute-mon: Set claim statuses that no longer have games back to 0 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored May 3, 2024
1 parent 3f198f3 commit a6d4eed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
13 changes: 13 additions & 0 deletions op-dispute-mon/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ const (
SecondHalfNotExpiredUnresolved
)

func ZeroClaimStatuses() map[ClaimStatus]int {
return map[ClaimStatus]int{
FirstHalfExpiredResolved: 0,
FirstHalfExpiredUnresolved: 0,
FirstHalfNotExpiredResolved: 0,
FirstHalfNotExpiredUnresolved: 0,
SecondHalfExpiredResolved: 0,
SecondHalfExpiredUnresolved: 0,
SecondHalfNotExpiredResolved: 0,
SecondHalfNotExpiredUnresolved: 0,
}
}

type HonestActorData struct {
PendingClaimCount int
ValidClaimCount int
Expand Down
2 changes: 1 addition & 1 deletion op-dispute-mon/mon/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewClaimMonitor(logger log.Logger, clock RClock, honestActors []common.Addr
}

func (c *ClaimMonitor) CheckClaims(games []*types.EnrichedGameData) {
claimStatus := make(map[metrics.ClaimStatus]int)
claimStatus := metrics.ZeroClaimStatuses()
honest := make(map[common.Address]*metrics.HonestActorData)
for actor := range c.honestActors {
honest[actor] = &metrics.HonestActorData{
Expand Down
16 changes: 16 additions & 0 deletions op-dispute-mon/mon/claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ func TestClaimMonitor_CheckClaims(t *testing.T) {
require.Equal(t, 1, cMetrics.calls[metrics.SecondHalfNotExpiredUnresolved])
})

t.Run("ZeroRecordsClaims", func(t *testing.T) {
monitor, _, cMetrics := newTestClaimMonitor(t)
var games []*types.EnrichedGameData
monitor.CheckClaims(games)
// Check we zero'd out any categories that didn't have games in them (otherwise they retain their previous value)
require.Contains(t, cMetrics.calls, metrics.FirstHalfExpiredResolved)
require.Contains(t, cMetrics.calls, metrics.FirstHalfExpiredUnresolved)
require.Contains(t, cMetrics.calls, metrics.FirstHalfNotExpiredResolved)
require.Contains(t, cMetrics.calls, metrics.FirstHalfNotExpiredUnresolved)

require.Contains(t, cMetrics.calls, metrics.SecondHalfExpiredResolved)
require.Contains(t, cMetrics.calls, metrics.SecondHalfExpiredUnresolved)
require.Contains(t, cMetrics.calls, metrics.SecondHalfNotExpiredResolved)
require.Contains(t, cMetrics.calls, metrics.SecondHalfNotExpiredUnresolved)
})

t.Run("RecordsUnexpectedClaimResolution", func(t *testing.T) {
monitor, cl, cMetrics := newTestClaimMonitor(t)
games := makeMultipleTestGames(uint64(cl.Now().Unix()))
Expand Down

0 comments on commit a6d4eed

Please sign in to comment.