Documentation ¶
Index ¶
- Constants
- func CLIFlags(envVar string) []cli.Flag
- func GetCounterValue(counter prometheus.Counter) (float64, error)
- func GetGaugeValue(gauge prometheus.Gauge) (float64, error)
- func GetGaugeVecValue(gaugeVec *prometheus.GaugeVec, labels prometheus.Labels) (float64, error)
- type CLIConfig
- type Metrics
- type Monitor
- func (m *Monitor) Close(_ context.Context) error
- func (m *Monitor) ConsumeEvent(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent) error
- func (m *Monitor) ConsumeEvents(...) error
- func (m *Monitor) GetLatestBlock() (uint64, error)
- func (m *Monitor) GetMaxBlock() (uint64, error)
- func (m *Monitor) Run(ctx context.Context)
- type State
- func (s *State) GetPercentages() (uint64, uint64)
- func (s *State) IncrementPotentialAttackOnDefenderWinsGames(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
- func (s *State) IncrementPotentialAttackOnInProgressGames(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
- func (s *State) IncrementSuspiciousEventsOnChallengerWinsGames(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
- func (s *State) IncrementWithdrawalsValidated(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
- func (s *State) LogState()
Constants ¶
const ( L1GethURLFlagName = "l1.geth.url" L2NodeURLFlagName = "l2.node.url" L2GethURLFlagName = "l2.geth.url" EventBlockRangeFlagName = "event.block.range" StartingL1BlockHeightFlagName = "start.block.height" HoursInThePastToStartFromFlagName = "start.block.hours.ago" OptimismPortalAddressFlagName = "optimismportal.address" )
const ( MetricsNamespace = "faultproof_withdrawals" DefaultHoursInThePastToStartFrom = 14 * 24 //14 days )
Variables ¶
This section is empty.
Functions ¶
func GetCounterValue ¶ added in v0.0.6
func GetCounterValue(counter prometheus.Counter) (float64, error)
Generic function to get the value of any prometheus.Counter
func GetGaugeValue ¶ added in v0.0.6
func GetGaugeValue(gauge prometheus.Gauge) (float64, error)
Generic function to get the value of any prometheus.Gauge
func GetGaugeVecValue ¶ added in v0.0.6
func GetGaugeVecValue(gaugeVec *prometheus.GaugeVec, labels prometheus.Labels) (float64, error)
Function to get the value of a specific Gauge within a GaugeVec
Types ¶
type CLIConfig ¶
type CLIConfig struct { L1GethURL string L2OpGethURL string L2OpNodeURL string EventBlockRange uint64 StartingL1BlockHeight int64 HoursInThePastToStartFrom uint64 OptimismPortalAddress common.Address }
func ReadCLIFlags ¶
type Metrics ¶
type Metrics struct { InitialL1HeightGauge prometheus.Gauge NextL1HeightGauge prometheus.Gauge LatestL1HeightGauge prometheus.Gauge LatestL2HeightGauge prometheus.Gauge EventsProcessedCounter prometheus.Counter WithdrawalsProcessedCounter prometheus.Counter NodeConnectionFailuresCounter prometheus.Counter PotentialAttackOnDefenderWinsGamesGauge prometheus.Gauge PotentialAttackOnInProgressGamesGauge prometheus.Gauge SuspiciousEventsOnChallengerWinsGamesGauge prometheus.Gauge PotentialAttackOnDefenderWinsGamesGaugeVec *prometheus.GaugeVec PotentialAttackOnInProgressGamesGaugeVec *prometheus.GaugeVec SuspiciousEventsOnChallengerWinsGamesGaugeVec *prometheus.GaugeVec // contains filtered or unexported fields }
func NewMetrics ¶
func (*Metrics) UpdateMetricsFromState ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor monitors the state and events related to withdrawal forgery.
func NewMonitor ¶
func NewMonitor(ctx context.Context, log log.Logger, m metrics.Factory, cfg CLIConfig) (*Monitor, error)
NewMonitor creates a new Monitor instance with the provided configuration. It establishes connections to the specified L1 and L2 Geth clients, initializes the withdrawal validator, and sets up the initial state and metrics.
func (*Monitor) ConsumeEvent ¶
func (m *Monitor) ConsumeEvent(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent) error
ConsumeEvent processes a single enriched withdrawal event. It logs the event details and checks for any forgery detection.
func (*Monitor) ConsumeEvents ¶
func (m *Monitor) ConsumeEvents(enrichedWithdrawalEvents map[common.Hash]validator.EnrichedProvenWithdrawalEvent) error
ConsumeEvents processes a slice of enriched withdrawal events and updates their states. It returns any events detected during the consumption that requires to be re-analysed again at a later stage (when the event referenced DisputeGame completes).
func (*Monitor) GetLatestBlock ¶
GetLatestBlock retrieves the latest block number from the L1 Geth client. It updates the state with the latest L1 height.
func (*Monitor) GetMaxBlock ¶
GetMaxBlock calculates the maximum block number to be processed. It considers the next L1 height and the defined max block range.
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) GetPercentages ¶
func (*State) IncrementPotentialAttackOnDefenderWinsGames ¶ added in v0.0.6
func (s *State) IncrementPotentialAttackOnDefenderWinsGames(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
func (*State) IncrementPotentialAttackOnInProgressGames ¶ added in v0.0.6
func (s *State) IncrementPotentialAttackOnInProgressGames(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
func (*State) IncrementSuspiciousEventsOnChallengerWinsGames ¶ added in v0.0.6
func (s *State) IncrementSuspiciousEventsOnChallengerWinsGames(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)
func (*State) IncrementWithdrawalsValidated ¶ added in v0.0.6
func (s *State) IncrementWithdrawalsValidated(enrichedWithdrawalEvent validator.EnrichedProvenWithdrawalEvent)