ocrcommon

package
v1.6.0-debug-multikeys... Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneSet

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

CloneSet returns a copy of the input map.

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, ocrLogger logger.Logger, runResults chan<- pipeline.Run) ocrtypes.DataSource

func NewDataSourceV2

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

func NewInMemoryDataSource

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

func ParseBootstrapPeers

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

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 PeerWrapperConfig) 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 {
	LogSQL() bool
	EvmGasLimitDefault() uint64
	JobPipelineResultWriteQueueDepth() uint64
	OCRBlockchainTimeout() time.Duration
	OCRContractConfirmations() uint16
	OCRContractPollInterval() time.Duration
	OCRContractSubscribeInterval() time.Duration
	OCRContractTransmitterTransmitTimeout() time.Duration
	OCRDatabaseTimeout() time.Duration
	OCRDefaultTransactionQueueDepth() uint32
	OCRKeyBundleID() (string, error)
	OCRObservationGracePeriod() time.Duration
	OCRObservationTimeout() time.Duration
	OCRTraceLogging() bool
	OCRTransmitterAddress() (ethkey.EIP55Address, error)
	P2PBootstrapPeers() ([]string, error)
	P2PPeerID() p2pkey.PeerID
	P2PV2Bootstrappers() []commontypes.BootstrapperLocator
	FlagsContractAddress() string
	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 P2PPeer

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

type PeerWrapperConfig

type PeerWrapperConfig interface {
	config.P2PNetworking
	config.P2PV1Networking
	config.P2PV2Networking
	OCRTraceLogging() bool
	LogSQL() bool
	FeatureOffchainReporting() 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.LogConfig) (*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,
) *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

	// V1V2 adapter
	Peer *peerAdapter

	// V2 peer
	Peer2 *peerAdapter2
	// contains filtered or unexported fields
}

SingletonPeerWrapper manages all libocr peers for the application

func NewSingletonPeerWrapper

func NewSingletonPeerWrapper(keyStore keystore.Master, config PeerWrapperConfig, 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) Config

func (*SingletonPeerWrapper) IsStarted

func (p *SingletonPeerWrapper) IsStarted() bool

func (*SingletonPeerWrapper) Start

Start starts SingletonPeerWrapper.

type Transmitter

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

func NewTransmitter

func NewTransmitter(txm txManager, fromAddress common.Address, gasLimit uint64, strategy txmgr.TxStrategy, checker txmgr.TransmitCheckerSpec) Transmitter

NewTransmitter creates a new eth transmitter

Jump to

Keyboard shortcuts

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