ocr

package
v2.5.1-mercury-20230919 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigOverriderPollInterval = 30 * time.Second
View Source
const InitialHibernationStatus = false

InitialHibernationStatus - hibernation state set until the first successful update from the chain

Variables

View Source
var (
	OCRContractConfigSet            = getEventTopic("ConfigSet")
	OCRContractLatestRoundRequested = getEventTopic("RoundRequested")
)

Functions

func IsLaterThan

func IsLaterThan(incoming gethTypes.Log, existing gethTypes.Log) bool

IsLaterThan returns true if the first log was emitted "after" the second log from the blockchain's point of view

func NewDB

func NewDB(sqlxDB *sqlx.DB, oracleSpecID int32, lggr logger.Logger, cfg pg.QConfig) *db

NewDB returns a new DB scoped to this oracleSpecID

func ValidatedOracleSpecToml

func ValidatedOracleSpecToml(legacyChains evm.LegacyChainContainer, tomlString string) (job.Job, error)

ValidatedOracleSpecToml validates an oracle spec that came from TOML

func ValidatedOracleSpecTomlCfg

func ValidatedOracleSpecTomlCfg(configFn func(id *big.Int) (evmconfig.ChainScopedConfig, error), tomlString string) (job.Job, error)

Types

type Config

type Config interface {
	pg.QConfig
}

Config contains OCR configurations for a job.

type ConfigOverriderImpl

type ConfigOverriderImpl struct {
	utils.StartStopOnce

	DeltaCFromAddress time.Duration
	// contains filtered or unexported fields
}

func NewConfigOverriderImpl

func NewConfigOverriderImpl(
	logger logger.Logger,
	contractAddress ethkey.EIP55Address,
	flags *ContractFlags,
	pollTicker utils.TickerBase,
) (*ConfigOverriderImpl, error)

func (*ConfigOverriderImpl) Close

func (c *ConfigOverriderImpl) Close() error

func (*ConfigOverriderImpl) ConfigOverride

func (c *ConfigOverriderImpl) ConfigOverride() *ocrtypes.ConfigOverride

func (*ConfigOverriderImpl) Start

Start starts ConfigOverriderImpl.

type ContractFlags

type ContractFlags struct {
	flags_wrapper.FlagsInterface
}

ContractFlags wraps the a contract

func NewFlags

func NewFlags(addrHex string, ethClient evmclient.Client) (*ContractFlags, error)

NewFlags constructs a new Flags from a flags contract address

func (*ContractFlags) Contract

Contract returns the flags contract

func (*ContractFlags) ContractExists

func (f *ContractFlags) ContractExists() bool

ContractExists returns whether a flag contract exists

func (*ContractFlags) IsLowered

func (f *ContractFlags) IsLowered(contractAddr common.Address) (bool, error)

IsLowered determines whether the flag is lowered for a given contract. If a contract does not exist, it is considered to be lowered

type Delegate

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

func NewDelegate

func NewDelegate(
	db *sqlx.DB,
	jobORM job.ORM,
	keyStore keystore.Master,
	pipelineRunner pipeline.Runner,
	peerWrapper *ocrcommon.SingletonPeerWrapper,
	monitoringEndpointGen telemetry.MonitoringEndpointGenerator,
	legacyChains evm.LegacyChainContainer,
	lggr logger.Logger,
	cfg Config,
	mailMon *utils.MailboxMonitor,
) *Delegate

func (*Delegate) AfterJobCreated

func (d *Delegate) AfterJobCreated(spec job.Job)

func (*Delegate) BeforeJobCreated

func (d *Delegate) BeforeJobCreated(spec job.Job)

func (*Delegate) BeforeJobDeleted

func (d *Delegate) BeforeJobDeleted(spec job.Job)

func (*Delegate) JobType

func (d *Delegate) JobType() job.Type

func (*Delegate) OnDeleteJob

func (d *Delegate) OnDeleteJob(spec job.Job, q pg.Queryer) error

func (*Delegate) ServicesForSpec

func (d *Delegate) ServicesForSpec(jb job.Job, qopts ...pg.QOpt) (services []job.ServiceCtx, err error)

ServicesForSpec returns the OCR services that need to run for this job

type OCRContractConfigSubscription

type OCRContractConfigSubscription OCRContractTracker

OCRContractConfigSubscription only exists to comply with the ContractConfigSubscription interface, it's just a simple shell around OCRContractTracker that defines two methods

func (*OCRContractConfigSubscription) Close

func (sub *OCRContractConfigSubscription) Close()

Close is a no-op since Subscribing/Unsubscribing is handled in the Start/Close methods of the OCRContractTracker

func (*OCRContractConfigSubscription) Configs

Configs complies with ContractConfigSubscription interface

type OCRContractTracker

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

OCRContractTracker complies with ContractConfigTracker interface and handles log events related to the contract more generally

func NewOCRContractTracker

func NewOCRContractTracker(
	contract *offchain_aggregator_wrapper.OffchainAggregator,
	contractFilterer *offchainaggregator.OffchainAggregatorFilterer,
	contractCaller *offchainaggregator.OffchainAggregatorCaller,
	ethClient evmclient.Client,
	logBroadcaster log.Broadcaster,
	jobID int32,
	logger logger.Logger,
	db *sqlx.DB,
	ocrDB OCRContractTrackerDB,
	cfg ocrcommon.Config,
	q pg.QConfig,
	headBroadcaster httypes.HeadBroadcaster,
	mailMon *utils.MailboxMonitor,
) (o *OCRContractTracker)

NewOCRContractTracker makes a new OCRContractTracker

func (*OCRContractTracker) Close

func (t *OCRContractTracker) Close() error

Close should be called after teardown of the OCR job relying on this tracker

func (*OCRContractTracker) ConfigFromLogs

func (t *OCRContractTracker) ConfigFromLogs(ctx context.Context, changedInBlock uint64) (c ocrtypes.ContractConfig, err error)

ConfigFromLogs queries the eth node for logs for this contract

func (*OCRContractTracker) HandleLog

func (t *OCRContractTracker) HandleLog(lb log.Broadcast)

HandleLog complies with LogListener interface It is not thread safe

func (*OCRContractTracker) JobID

func (t *OCRContractTracker) JobID() int32

JobID complies with LogListener interface

func (*OCRContractTracker) LatestBlockHeight

func (t *OCRContractTracker) LatestBlockHeight(ctx context.Context) (blockheight uint64, err error)

LatestBlockHeight queries the eth node for the most recent header

func (*OCRContractTracker) LatestConfigDetails

func (t *OCRContractTracker) LatestConfigDetails(ctx context.Context) (changedInBlock uint64, configDigest ocrtypes.ConfigDigest, err error)

LatestConfigDetails queries the eth node

func (*OCRContractTracker) LatestRoundRequested

func (t *OCRContractTracker) LatestRoundRequested(_ context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error)

LatestRoundRequested returns the configDigest, epoch, and round from the latest RoundRequested event emitted by the contract. LatestRoundRequested may or may not return a result if the latest such event was emitted in a block b such that b.timestamp < tip.timestamp - lookback.

If no event is found, LatestRoundRequested should return zero values, not an error. An error should only be returned if an actual error occurred during execution, e.g. because there was an error querying the blockchain or the database.

As an optimization, this function may also return zero values, if no RoundRequested event has been emitted after the latest NewTransmission event.

func (*OCRContractTracker) OnNewLongestChain

func (t *OCRContractTracker) OnNewLongestChain(_ context.Context, h *evmtypes.Head)

OnNewLongestChain conformed to HeadTrackable and updates latestBlockHeight

func (*OCRContractTracker) Start

Start must be called before logs can be delivered It ought to be called before starting OCR

func (*OCRContractTracker) SubscribeToNewConfigs

SubscribeToNewConfigs returns the tracker aliased as a ContractConfigSubscription

type OCRContractTrackerDB

type OCRContractTrackerDB interface {
	SaveLatestRoundRequested(tx pg.Queryer, rr offchainaggregator.OffchainAggregatorRoundRequested) error
	LoadLatestRoundRequested() (rr offchainaggregator.OffchainAggregatorRoundRequested, err error)
}

type OCRContractTransmitter

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

func NewOCRContractTransmitter

func NewOCRContractTransmitter(
	address gethCommon.Address,
	contractCaller *offchainaggregator.OffchainAggregatorCaller,
	contractABI abi.ABI,
	transmitter ocrcommon.Transmitter,
	logBroadcaster log.Broadcaster,
	tracker *OCRContractTracker,
	chainID *big.Int,
	effectiveTransmitterAddress gethCommon.Address,
) *OCRContractTransmitter

func (*OCRContractTransmitter) ChainID

func (oc *OCRContractTransmitter) ChainID() *big.Int

func (*OCRContractTransmitter) FromAddress

func (oc *OCRContractTransmitter) FromAddress() gethCommon.Address

func (*OCRContractTransmitter) LatestRoundRequested

func (oc *OCRContractTransmitter) LatestRoundRequested(ctx context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error)

LatestRoundRequested returns the configDigest, epoch, and round from the latest RoundRequested event emitted by the contract. LatestRoundRequested may or may not return a result if the latest such event was emitted in a block b such that b.timestamp < tip.timestamp - lookback.

If no event is found, LatestRoundRequested should return zero values, not an error. An error should only be returned if an actual error occurred during execution, e.g. because there was an error querying the blockchain or the database.

As an optimization, this function may also return zero values, if no RoundRequested event has been emitted after the latest NewTransmission event.

func (*OCRContractTransmitter) LatestTransmissionDetails

func (oc *OCRContractTransmitter) LatestTransmissionDetails(ctx context.Context) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, latestAnswer ocrtypes.Observation, latestTimestamp time.Time, err error)

func (*OCRContractTransmitter) Transmit

func (oc *OCRContractTransmitter) Transmit(ctx context.Context, report []byte, rs, ss [][32]byte, vs [32]byte) error

type OCRValidationConfig added in v2.3.0

type OCRValidationConfig interface {
	BlockchainTimeout() time.Duration
	CaptureEATelemetry() bool
	ContractPollInterval() time.Duration
	ContractSubscribeInterval() time.Duration
	KeyBundleID() (string, error)
	ObservationTimeout() time.Duration
	TransmitterAddress() (ethkey.EIP55Address, error)
}

type ValidationConfig

type ValidationConfig interface {
	ChainType() config.ChainType
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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