faultdetector

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package faultdetector implements Optimism fault detector.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFirstUnfinalizedOutputIndex

func FindFirstUnfinalizedOutputIndex(ctx context.Context, logger log.Logger, fpw uint64, oracleAccessor OracleAccessor, l2RpcApi ChainAPIClient) (uint64, error)

FindFirstUnfinalizedOutputIndex finds and returns the first L2 output index that has not yet passed the fault proof window.

func NewFaultDetectorMetrics

func NewFaultDetectorMetrics(reg prometheus.Registerer) *faultDetectorMetrics

NewFaultDetectorMetrics returns [FaultDetectorMetrics] with initialized metrics and registering to prometheus registry.

Types

type ChainAPIClient

type ChainAPIClient interface {
	GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
}

type FaultDetector

type FaultDetector struct {
	// contains filtered or unexported fields
}

FaultDetector contains all the RPC providers/contract accessors and holds state information.

func GetFaultDetector

func GetFaultDetector(ctx context.Context, logger log.Logger, l1RpcApi *chain.ChainAPIClient, l2RpcApi *chain.ChainAPIClient, oracleContractAccessor OracleAccessor, faultProofWindow uint64, currentOutputIndex uint64, metrics *faultDetectorMetrics, notification *notification.Notification, diverged bool, wg *sync.WaitGroup, errorChan chan error, mutex *sync.RWMutex) *FaultDetector

GetFaultDetector create FaultDetector instance from input values.

func NewFaultDetector

func NewFaultDetector(ctx context.Context, logger log.Logger, errorChan chan error, wg *sync.WaitGroup, faultDetectorConfig *config.FaultDetectorConfig, metricRegistry *prometheus.Registry, notification *notification.Notification) (*FaultDetector, error)

NewFaultDetector will return FaultDetector with the initialized providers and configuration.

func (*FaultDetector) IsFaultDetected

func (fd *FaultDetector) IsFaultDetected() bool

IsFaultDetected returns status of the fault detector.

func (*FaultDetector) Start

func (fd *FaultDetector) Start()

Start will start the fault detector service by invoking the service every given interval.

func (*FaultDetector) Stop

func (fd *FaultDetector) Stop()

Stop will stop the ticker.

type OracleAccessor

type OracleAccessor interface {
	GetNextOutputIndex() (*big.Int, error)
	GetL2Output(index *big.Int) (chain.L2Output, error)
	FinalizationPeriodSeconds() (*big.Int, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL