Skip to content

Commit

Permalink
fixing review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaele-oplabs committed Oct 8, 2024
1 parent 204614e commit d46532a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package faultproof_withdrawals
import (
"context"
"fmt"
"io"
"math/big"
"os"
"strconv"
Expand Down Expand Up @@ -43,8 +44,7 @@ func NewTestMonitorMainnet() *Monitor {
}

clicfg := oplog.DefaultCLIConfig()
// output_writer := io.Discard // discard log output during tests to avoid pollution of the standard output
output_writer := os.Stdout
output_writer := io.Discard // discard log output during tests to avoid pollution of the standard output
log := oplog.NewLogger(output_writer, clicfg)

metricsRegistry := opmetrics.NewRegistry()
Expand Down
12 changes: 6 additions & 6 deletions op-monitorism/faultproof_withdrawals/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type State struct {
// possible attacks detected

// Forgeries detected on games that are already resolved
potentialAttackOnDefenderWinsGames map[common.Hash]validator.EnrichedProvenWithdrawalEvent
numberOfPotentialAttackOnDefenderWinsGames uint64
potentialAttackOnDefenderWinsGames map[common.Hash]validator.EnrichedProvenWithdrawalEvent
numberOfPotentialAttacksOnDefenderWinsGames uint64

// Forgeries detected on games that are still in progress
// Because games are still in progress and Faulproof system should make them invalid
Expand All @@ -54,8 +54,8 @@ func NewState(logger log.Logger, nextL1Height uint64, latestL1Height uint64, lat
}

ret := State{
potentialAttackOnDefenderWinsGames: make(map[common.Hash]validator.EnrichedProvenWithdrawalEvent),
numberOfPotentialAttackOnDefenderWinsGames: 0,
potentialAttackOnDefenderWinsGames: make(map[common.Hash]validator.EnrichedProvenWithdrawalEvent),
numberOfPotentialAttacksOnDefenderWinsGames: 0,
suspiciousEventsOnChallengerWinsGames: func() *lru.Cache {
cache, err := lru.New(suspiciousEventsOnChallengerWinsGamesCacheSize)
if err != nil {
Expand Down Expand Up @@ -116,7 +116,7 @@ func (s *State) IncrementPotentialAttackOnDefenderWinsGames(enrichedWithdrawalEv

s.logger.Error("STATE WITHDRAWAL: is NOT valid, forgery detected", "TxHash", fmt.Sprintf("%v", enrichedWithdrawalEvent.Event.Raw.TxHash), "enrichedWithdrawalEvent", enrichedWithdrawalEvent)
s.potentialAttackOnDefenderWinsGames[key] = enrichedWithdrawalEvent
s.numberOfPotentialAttackOnDefenderWinsGames++
s.numberOfPotentialAttacksOnDefenderWinsGames++

if _, ok := s.potentialAttackOnInProgressGames[key]; ok {
s.logger.Error("STATE WITHDRAWAL: added to potential attacks. Removing from inProgress", "TxHash", fmt.Sprintf("%v", enrichedWithdrawalEvent.Event.Raw.TxHash), "enrichedWithdrawalEvent", enrichedWithdrawalEvent)
Expand Down Expand Up @@ -353,7 +353,7 @@ func (m *Metrics) UpdateMetricsFromState(state *State) {
m.LatestL1HeightGauge.Set(float64(state.latestL1Height))
m.LatestL2HeightGauge.Set(float64(state.latestL2Height))

m.PotentialAttackOnDefenderWinsGamesGauge.Set(float64(state.numberOfPotentialAttackOnDefenderWinsGames))
m.PotentialAttackOnDefenderWinsGamesGauge.Set(float64(state.numberOfPotentialAttacksOnDefenderWinsGames))
m.PotentialAttackOnInProgressGamesGauge.Set(float64(state.numberOfPotentialAttackOnInProgressGames))
m.SuspiciousEventsOnChallengerWinsGamesGauge.Set(float64(state.numberOfSuspiciousEventsOnChallengerWinsGames))

Expand Down

0 comments on commit d46532a

Please sign in to comment.