ocrcommon

package
v2.5.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 48 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PromBridgeJsonParseValues = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: "bridge_json_parse_values",
		Help: "Values returned by json_parse for bridge task",
	},
		[]string{"job_id", "job_name", "bridge_name", "task_id"})

	PromOcrMedianValues = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: "ocr_median_values",
		Help: "Median value returned by ocr job",
	},
		[]string{"job_id", "job_name"})
)

Functions

func CloneSet

func CloneSet(in map[string]struct{}) map[string]struct{}

CloneSet returns a copy of the input map.

func EnqueueEnhancedTelem added in v2.2.0

func EnqueueEnhancedTelem[T EnhancedTelemetryData | EnhancedTelemetryMercuryData](ch chan<- T, data T)

EnqueueEnhancedTelem sends data to the telemetry channel for processing

func GetValidatedBootstrapPeers

func GetValidatedBootstrapPeers(specPeers []string, configPeers []commontypes.BootstrapperLocator) ([]commontypes.BootstrapperLocator, error)

GetValidatedBootstrapPeers will error unless at least one valid bootstrap peer is found

func NewDataSourceV1

func NewDataSourceV1(pr pipeline.Runner, jb job.Job, spec pipeline.Spec, lggr logger.Logger, runResults chan<- pipeline.Run, chEnhancedTelemetry chan EnhancedTelemetryData) ocr1types.DataSource

func NewDataSourceV2

func NewDataSourceV2(pr pipeline.Runner, jb job.Job, spec pipeline.Spec, lggr logger.Logger, runResults chan<- pipeline.Run, enhancedTelemChan chan EnhancedTelemetryData) median.DataSource

func NewInMemoryDataSource

func NewInMemoryDataSource(pr pipeline.Runner, jb job.Job, spec pipeline.Spec, lggr logger.Logger) median.DataSource

func ParseBootstrapPeers

func ParseBootstrapPeers(peers []string) (bootstrapPeers []commontypes.BootstrapperLocator, err error)

func ShouldCollectEnhancedTelemetry added in v2.2.0

func ShouldCollectEnhancedTelemetry(job *job.Job) bool

ShouldCollectEnhancedTelemetry returns whether EA telemetry should be collected

func ShouldCollectEnhancedTelemetryMercury added in v2.2.0

func ShouldCollectEnhancedTelemetryMercury(job *job.Job) bool

ShouldCollectEnhancedTelemetryMercury checks if enhanced telemetry should be collected and sent

func ValidateExplicitlySetKeys

func ValidateExplicitlySetKeys(tree *toml.Tree, expected map[string]struct{}, notExpected map[string]struct{}, peerType string) error

ValidateExplicitlySetKeys checks if the values in expected are present and the values in notExpected are not present in the toml tree. Works on top level keys only.

func ValidatePeerWrapperConfig

func ValidatePeerWrapperConfig(config config.P2P) error

Types

type ArbitrumBlockTranslator

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

ArbitrumBlockTranslator uses Arbitrum's special L1BlockNumber to optimise log lookups Performance matters here hence aggressive use of the cache We want to minimise fetches because calling eth_getBlockByNumber is relatively expensive

func NewArbitrumBlockTranslator

func NewArbitrumBlockTranslator(ethClient evmclient.Client, lggr logger.Logger) *ArbitrumBlockTranslator

NewArbitrumBlockTranslator returns a concrete ArbitrumBlockTranslator

func (*ArbitrumBlockTranslator) BinarySearch

func (a *ArbitrumBlockTranslator) BinarySearch(ctx context.Context, targetL1 int64) (l2lowerBound *big.Int, l2upperBound *big.Int, err error)

BinarySearch uses both cache and RPC calls to find the smallest possible range of L2 block numbers that encompasses the given L1 block number

Imagine as a virtual array of L1 block numbers indexed by L2 block numbers L1 values are likely duplicated so it looks something like [42, 42, 42, 42, 42, 155, 155, 155, 430, 430, 430, 430, 430, ...] Theoretical max difference between L1 values is typically about 5, "worst case" is 6545 but can be arbitrarily high if sequencer is broken The returned range of L2s from leftmost thru rightmost represent all possible L2s that correspond to the L1 value we are looking for nil can be returned as a rightmost value if the range has no upper bound

func (*ArbitrumBlockTranslator) NumberToQueryRange

func (a *ArbitrumBlockTranslator) NumberToQueryRange(ctx context.Context, changedInL1Block uint64) (fromBlock *big.Int, toBlock *big.Int)

NumberToQueryRange implements BlockTranslator interface

type BlockTranslator

type BlockTranslator interface {
	NumberToQueryRange(ctx context.Context, changedInL1Block uint64) (fromBlock *big.Int, toBlock *big.Int)
}

BlockTranslator converts emitted block numbers (from block.number) into a block number range suitable for query in FilterLogs

func NewBlockTranslator

func NewBlockTranslator(cfg Config, client evmclient.Client, lggr logger.Logger) BlockTranslator

NewBlockTranslator returns the block translator for the given chain

type Config

type Config interface {
	ChainType() config.ChainType
}

type DiscovererDatabase

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

func NewDiscovererDatabase

func NewDiscovererDatabase(db *sql.DB, peerID p2ppeer.ID) *DiscovererDatabase

func (*DiscovererDatabase) ReadAnnouncements

func (d *DiscovererDatabase) ReadAnnouncements(ctx context.Context, peerIDs []string) (map[string][]byte, error)

ReadAnnouncements returns one serialized announcement (if available) for each of the peerIDs in the form of a map keyed by each announcement's corresponding peer ID.

func (*DiscovererDatabase) StoreAnnouncement

func (d *DiscovererDatabase) StoreAnnouncement(ctx context.Context, peerID string, ann []byte) error

StoreAnnouncement has key-value-store semantics and stores a peerID (key) and an associated serialized announcement (value).

type EnhancedTelemetryData added in v2.2.0

type EnhancedTelemetryData struct {
	TaskRunResults pipeline.TaskRunResults
	FinalResults   pipeline.FinalResult
	RepTimestamp   ObservationTimestamp
}

type EnhancedTelemetryMercuryData added in v2.2.0

type EnhancedTelemetryMercuryData struct {
	TaskRunResults pipeline.TaskRunResults
	Observation    relaymercuryv1.Observation
	RepTimestamp   ocrtypes.ReportTimestamp
}

type EnhancedTelemetryService added in v2.2.0

type EnhancedTelemetryService[T EnhancedTelemetryData | EnhancedTelemetryMercuryData] struct {
	utils.StartStopOnce
	// contains filtered or unexported fields
}

func NewEnhancedTelemetryService added in v2.2.0

func NewEnhancedTelemetryService[T EnhancedTelemetryData | EnhancedTelemetryMercuryData](job *job.Job, chTelem <-chan T, done chan struct{}, me commontypes.MonitoringEndpoint, lggr logger.Logger) *EnhancedTelemetryService[T]

func (*EnhancedTelemetryService[T]) Close added in v2.2.0

func (e *EnhancedTelemetryService[T]) Close() error

func (*EnhancedTelemetryService[T]) Start added in v2.2.0

Start starts

type ObservationTimestamp added in v2.1.0

type ObservationTimestamp struct {
	Round        uint8
	Epoch        uint32
	ConfigDigest string
}

ObservationTimestamp abstracts ocr2types.ReportTimestamp and ocr1types.ReportTimestamp

type P2PPeer

type P2PPeer struct {
	ID        string
	Addr      string
	PeerID    string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type PeerWrapperOCRConfig added in v2.3.0

type PeerWrapperOCRConfig interface {
	TraceLogging() bool
}

type Pstorewrapper

type Pstorewrapper struct {
	utils.StartStopOnce
	Peerstore p2ppeerstore.Peerstore
	// contains filtered or unexported fields
}

func NewPeerstoreWrapper

func NewPeerstoreWrapper(db *sqlx.DB, writeInterval time.Duration, peerID p2pkey.PeerID, lggr logger.Logger, cfg pg.QConfig) (*Pstorewrapper, error)

NewPeerstoreWrapper creates a new database-backed peerstore wrapper scoped to the given jobID Multiple peerstore wrappers should not be instantiated with the same jobID

func (*Pstorewrapper) Close

func (p *Pstorewrapper) Close() error

func (*Pstorewrapper) Start

func (p *Pstorewrapper) Start() error

func (*Pstorewrapper) WriteToDB

func (p *Pstorewrapper) WriteToDB() error

type RunResultSaver

type RunResultSaver struct {
	utils.StartStopOnce
	// contains filtered or unexported fields
}

func NewResultRunSaver

func NewResultRunSaver(runResults <-chan pipeline.Run, pipelineRunner pipeline.Runner, done chan struct{},
	logger logger.Logger, maxSuccessfulRuns uint64,
) *RunResultSaver

func (*RunResultSaver) Close

func (r *RunResultSaver) Close() error

func (*RunResultSaver) Start

func (r *RunResultSaver) Start(context.Context) error

Start starts RunResultSaver.

type SingletonPeerWrapper

type SingletonPeerWrapper struct {
	utils.StartStopOnce

	PeerID p2pkey.PeerID

	// OCR1 peer adapter
	Peer1 *peerAdapterOCR1

	// OCR2 peer adapter
	Peer2 *peerAdapterOCR2
	// contains filtered or unexported fields
}

SingletonPeerWrapper manages all libocr peers for the application

func NewSingletonPeerWrapper

func NewSingletonPeerWrapper(keyStore keystore.Master, p2pCfg config.P2P, ocrCfg PeerWrapperOCRConfig, dbConfig pg.QConfig, db *sqlx.DB, lggr logger.Logger) *SingletonPeerWrapper

NewSingletonPeerWrapper creates a new peer based on the p2p keys in the keystore It currently only supports one peerID/key It should be fairly easy to modify it to support multiple peerIDs/keys using e.g. a map

func (*SingletonPeerWrapper) Close

func (p *SingletonPeerWrapper) Close() error

Close closes the peer and peerstore

func (*SingletonPeerWrapper) HealthReport

func (p *SingletonPeerWrapper) HealthReport() map[string]error

func (*SingletonPeerWrapper) IsStarted

func (p *SingletonPeerWrapper) IsStarted() bool

func (*SingletonPeerWrapper) Name

func (p *SingletonPeerWrapper) Name() string

func (*SingletonPeerWrapper) P2PConfig added in v2.3.0

func (p *SingletonPeerWrapper) P2PConfig() config.P2P

func (*SingletonPeerWrapper) Start

Start starts SingletonPeerWrapper.

type Transmitter

type Transmitter interface {
	CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error
	FromAddress() common.Address
}

func NewPipelineTransmitter

func NewPipelineTransmitter(
	lgr logger.Logger,
	fromAddress common.Address,
	gasLimit uint32,
	effectiveTransmitterAddress common.Address,
	strategy types.TxStrategy,
	checker txmgr.TransmitCheckerSpec,
	pr pipeline.Runner,
	spec job.Job,
	chainID string,
) Transmitter

NewPipelineTransmitter creates a new eth transmitter using the job pipeline mechanism

func NewTransmitter

func NewTransmitter(
	txm txManager,
	fromAddresses []common.Address,
	gasLimit uint32,
	effectiveTransmitterAddress common.Address,
	strategy types.TxStrategy,
	checker txmgr.TransmitCheckerSpec,
	chainID *big.Int,
	keystore roundRobinKeystore,
) (Transmitter, error)

NewTransmitter creates a new eth transmitter

Jump to

Keyboard shortcuts

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