Documentation ¶
Index ¶
- Constants
- Variables
- func IsLaterThan(incoming gethTypes.Log, existing gethTypes.Log) bool
- func NewDB(sqldb *sql.DB, oracleSpecID int32) *db
- func NewLogger(l *logger.Logger, trace bool, saveError func(string)) ocrtypes.Logger
- func ValidatedOracleSpecToml(config ValidationConfig, tomlString string) (job.Job, error)
- type ArbitrumBlockTranslator
- type BlockTranslator
- type ConfigOverriderImpl
- type ContractFlags
- type Delegate
- type DelegateConfig
- type DiscovererDatabase
- type NetworkingConfig
- type OCRContractConfigSubscription
- type OCRContractTracker
- func (t *OCRContractTracker) Close() error
- func (t *OCRContractTracker) ConfigFromLogs(ctx context.Context, changedInBlock uint64) (c ocrtypes.ContractConfig, err error)
- func (t *OCRContractTracker) Connect(*models.Head) error
- func (t *OCRContractTracker) HandleLog(lb log.Broadcast)
- func (t *OCRContractTracker) IsV2Job() bool
- func (t *OCRContractTracker) JobID() models.JobID
- func (t *OCRContractTracker) JobIDV2() int32
- func (t *OCRContractTracker) LatestBlockHeight(ctx context.Context) (blockheight uint64, err error)
- func (t *OCRContractTracker) LatestConfigDetails(ctx context.Context) (changedInBlock uint64, configDigest ocrtypes.ConfigDigest, err error)
- func (t *OCRContractTracker) LatestRoundRequested(_ context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error)
- func (t *OCRContractTracker) OnNewLongestChain(_ context.Context, h models.Head)
- func (t *OCRContractTracker) Start() error
- func (t *OCRContractTracker) SubscribeToNewConfigs(context.Context) (ocrtypes.ContractConfigSubscription, error)
- type OCRContractTrackerDB
- type OCRContractTransmitter
- func (oc *OCRContractTransmitter) ChainID() *big.Int
- func (oc *OCRContractTransmitter) FromAddress() gethCommon.Address
- func (oc *OCRContractTransmitter) LatestRoundRequested(ctx context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error)
- func (oc *OCRContractTransmitter) LatestTransmissionDetails(ctx context.Context) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, ...)
- func (oc *OCRContractTransmitter) Transmit(ctx context.Context, report []byte, rs, ss [][32]byte, vs [32]byte) error
- type P2PPeer
- type Pstorewrapper
- type RunResultSaver
- type SingletonPeerWrapper
- type Transmitter
- type ValidationConfig
Constants ¶
const ConfigOverriderPollInterval = 30 * time.Second
const InitialHibernationStatus = false
InitialHibernationStatus - hibernation state set until the first successful update from the chain
Variables ¶
var ( OCRContractConfigSet = getEventTopic("ConfigSet") OCRContractLatestRoundRequested = getEventTopic("RoundRequested") )
Functions ¶
func IsLaterThan ¶ added in v0.10.3
IsLaterThan returns true if the first log was emitted "after" the second log from the blockchain's point of view
func ValidatedOracleSpecToml ¶ added in v0.9.10
func ValidatedOracleSpecToml(config ValidationConfig, tomlString string) (job.Job, error)
ValidatedOracleSpecToml validates an oracle spec that came from TOML
Types ¶
type ArbitrumBlockTranslator ¶ added in v0.10.9
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 ¶ added in v0.10.9
func NewArbitrumBlockTranslator(ethClient eth.Client) *ArbitrumBlockTranslator
NewArbitrumBlockTranslator returns a concrete ArbitrumBlockTranslator
func (*ArbitrumBlockTranslator) BinarySearch ¶ added in v0.10.9
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 arbtrarily 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 ¶ added in v0.10.9
func (a *ArbitrumBlockTranslator) NumberToQueryRange(ctx context.Context, changedInL1Block uint64) (fromBlock *big.Int, toBlock *big.Int)
NumberToQueryRange implements BlockTranslator interface
type BlockTranslator ¶ added in v0.10.9
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 ¶ added in v0.10.9
func NewBlockTranslator(chain *chains.Chain, client eth.Client) BlockTranslator
NewBlockTranslator returns the block translator for the given chain
type ConfigOverriderImpl ¶ added in v0.10.14
type ConfigOverriderImpl struct { utils.StartStopOnce DeltaCFromAddress time.Duration // contains filtered or unexported fields }
func NewConfigOverriderImpl ¶ added in v0.10.14
func NewConfigOverriderImpl( logger *logger.Logger, contractAddress ethkey.EIP55Address, flags *ContractFlags, pollTicker utils.TickerBase, ) (*ConfigOverriderImpl, error)
func (*ConfigOverriderImpl) Close ¶ added in v0.10.14
func (c *ConfigOverriderImpl) Close() error
func (*ConfigOverriderImpl) ConfigOverride ¶ added in v0.10.14
func (c *ConfigOverriderImpl) ConfigOverride() *ocrtypes.ConfigOverride
func (*ConfigOverriderImpl) Start ¶ added in v0.10.14
func (c *ConfigOverriderImpl) Start() error
type ContractFlags ¶ added in v0.10.14
type ContractFlags struct {
flags_wrapper.FlagsInterface
}
ContractFlags wraps the a contract
func NewFlags ¶ added in v0.10.14
func NewFlags(addrHex string, ethClient eth.Client) (*ContractFlags, error)
NewFlags constructs a new Flags from a flags contract address
func (*ContractFlags) Contract ¶ added in v0.10.14
func (f *ContractFlags) Contract() flags_wrapper.FlagsInterface
Contract returns the flags contract
func (*ContractFlags) ContractExists ¶ added in v0.10.14
func (f *ContractFlags) ContractExists() bool
ContractExists returns whether a flag contract exists
type Delegate ¶ added in v0.9.10
type Delegate struct {
// contains filtered or unexported fields
}
func NewDelegate ¶ added in v0.9.10
func NewDelegate( db *gorm.DB, txm txManager, jobORM job.ORM, config DelegateConfig, keyStore *keystore.OCR, pipelineRunner pipeline.Runner, ethClient eth.Client, logBroadcaster log.Broadcaster, peerWrapper *SingletonPeerWrapper, monitoringEndpoint ocrtypes.MonitoringEndpoint, chain *chains.Chain, headBroadcaster httypes.HeadBroadcaster, ) *Delegate
func (Delegate) AfterJobCreated ¶ added in v0.10.11
func (Delegate) BeforeJobDeleted ¶ added in v0.10.11
type DelegateConfig ¶ added in v0.10.11
type DelegateConfig interface { Chain() *chains.Chain ChainID() *big.Int Dev() bool EthGasLimitDefault() uint64 JobPipelineResultWriteQueueDepth() uint64 OCRBlockchainTimeout(time.Duration) time.Duration OCRContractConfirmations(uint16) uint16 OCRContractPollInterval(time.Duration) time.Duration OCRContractSubscribeInterval(time.Duration) time.Duration OCRContractTransmitterTransmitTimeout() time.Duration OCRDatabaseTimeout() time.Duration OCRDefaultTransactionQueueDepth() uint32 OCRKeyBundleID(*models.Sha256Hash) (models.Sha256Hash, error) OCRObservationGracePeriod() time.Duration OCRObservationTimeout(time.Duration) time.Duration OCRTraceLogging() bool OCRTransmitterAddress(*ethkey.EIP55Address) (ethkey.EIP55Address, error) P2PBootstrapPeers([]string) ([]string, error) P2PPeerID(*p2pkey.PeerID) (p2pkey.PeerID, error) P2PV2Bootstrappers() []ocrtypes.BootstrapperLocator FlagsContractAddress() string }
type DiscovererDatabase ¶ added in v0.10.10
type DiscovererDatabase struct {
// contains filtered or unexported fields
}
func NewDiscovererDatabase ¶ added in v0.10.10
func NewDiscovererDatabase(db *sql.DB, peerID p2ppeer.ID) *DiscovererDatabase
func (*DiscovererDatabase) ReadAnnouncements ¶ added in v0.10.10
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 ¶ added in v0.10.10
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 NetworkingConfig ¶ added in v0.10.11
type NetworkingConfig interface { OCRBootstrapCheckInterval() time.Duration OCRDHTLookupInterval() int OCRIncomingMessageBufferSize() int OCRNewStreamTimeout() time.Duration OCROutgoingMessageBufferSize() int OCRTraceLogging() bool P2PAnnounceIP() net.IP P2PAnnouncePort() uint16 P2PBootstrapPeers([]string) ([]string, error) P2PDHTAnnouncementCounterUserPrefix() uint32 P2PListenIP() net.IP P2PListenPort() uint16 P2PNetworkingStack() ocrnetworking.NetworkingStack P2PPeerID(override *p2pkey.PeerID) (p2pkey.PeerID, error) P2PPeerstoreWriteInterval() time.Duration P2PV2AnnounceAddresses() []string P2PV2Bootstrappers() []ocrtypes.BootstrapperLocator P2PV2DeltaDial() models.Duration P2PV2DeltaReconcile() models.Duration P2PV2ListenAddresses() []string }
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 ¶
func (sub *OCRContractConfigSubscription) Configs() <-chan ocrtypes.ContractConfig
Configs complies with ContractConfigSubscription interface
type OCRContractTracker ¶ added in v0.10.3
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 ¶ added in v0.10.3
func NewOCRContractTracker( contract *offchain_aggregator_wrapper.OffchainAggregator, contractFilterer *offchainaggregator.OffchainAggregatorFilterer, contractCaller *offchainaggregator.OffchainAggregatorCaller, ethClient eth.Client, logBroadcaster log.Broadcaster, jobID int32, logger logger.Logger, gdb *gorm.DB, db OCRContractTrackerDB, chain *chains.Chain, headBroadcaster httypes.HeadBroadcaster, ) (o *OCRContractTracker)
NewOCRContractTracker makes a new OCRContractTracker
func (*OCRContractTracker) Close ¶ added in v0.10.3
func (t *OCRContractTracker) Close() error
Close should be called after teardown of the OCR job relying on this tracker
func (*OCRContractTracker) ConfigFromLogs ¶ added in v0.10.3
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) Connect ¶ added in v0.10.9
func (t *OCRContractTracker) Connect(*models.Head) error
Connect conforms to HeadTrackable
func (*OCRContractTracker) HandleLog ¶ added in v0.10.3
func (t *OCRContractTracker) HandleLog(lb log.Broadcast)
HandleLog complies with LogListener interface It is not thread safe
func (*OCRContractTracker) IsV2Job ¶ added in v0.10.3
func (t *OCRContractTracker) IsV2Job() bool
IsV2Job complies with LogListener interface
func (*OCRContractTracker) JobID ¶ added in v0.10.3
func (t *OCRContractTracker) JobID() models.JobID
JobID complies with LogListener interface
func (*OCRContractTracker) JobIDV2 ¶ added in v0.10.3
func (t *OCRContractTracker) JobIDV2() int32
JobIDV2 complies with LogListener interface
func (*OCRContractTracker) LatestBlockHeight ¶ added in v0.10.3
func (t *OCRContractTracker) LatestBlockHeight(ctx context.Context) (blockheight uint64, err error)
LatestBlockHeight queries the eth node for the most recent header
func (*OCRContractTracker) LatestConfigDetails ¶ added in v0.10.3
func (t *OCRContractTracker) LatestConfigDetails(ctx context.Context) (changedInBlock uint64, configDigest ocrtypes.ConfigDigest, err error)
LatestConfigDetails queries the eth node
func (*OCRContractTracker) LatestRoundRequested ¶ added in v0.10.3
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 ¶ added in v0.10.9
func (t *OCRContractTracker) OnNewLongestChain(_ context.Context, h models.Head)
OnNewLongestChain conformed to HeadTrackable and updates latestBlockHeight
func (*OCRContractTracker) Start ¶ added in v0.10.3
func (t *OCRContractTracker) Start() error
Start must be called before logs can be delivered It ought to be called before starting OCR
func (*OCRContractTracker) SubscribeToNewConfigs ¶ added in v0.10.3
func (t *OCRContractTracker) SubscribeToNewConfigs(context.Context) (ocrtypes.ContractConfigSubscription, error)
SubscribeToNewConfigs returns the tracker aliased as a ContractConfigSubscription
type OCRContractTrackerDB ¶ added in v0.10.3
type OCRContractTrackerDB interface { SaveLatestRoundRequested(tx *sql.Tx, rr offchainaggregator.OffchainAggregatorRoundRequested) error LoadLatestRoundRequested() (rr offchainaggregator.OffchainAggregatorRoundRequested, err error) }
type OCRContractTransmitter ¶ added in v0.9.6
type OCRContractTransmitter struct {
// contains filtered or unexported fields
}
func NewOCRContractTransmitter ¶ added in v0.9.6
func NewOCRContractTransmitter( address gethCommon.Address, contractCaller *offchainaggregator.OffchainAggregatorCaller, contractABI abi.ABI, transmitter Transmitter, logBroadcaster log.Broadcaster, tracker *OCRContractTracker, chainID *big.Int, ) *OCRContractTransmitter
func (*OCRContractTransmitter) ChainID ¶ added in v0.10.8
func (oc *OCRContractTransmitter) ChainID() *big.Int
func (*OCRContractTransmitter) FromAddress ¶ added in v0.9.6
func (oc *OCRContractTransmitter) FromAddress() gethCommon.Address
func (*OCRContractTransmitter) LatestRoundRequested ¶ added in v0.10.3
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 ¶ added in v0.9.6
func (oc *OCRContractTransmitter) LatestTransmissionDetails(ctx context.Context) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, latestAnswer ocrtypes.Observation, latestTimestamp time.Time, err error)
type Pstorewrapper ¶ added in v0.9.6
type Pstorewrapper struct { utils.StartStopOnce Peerstore p2ppeerstore.Peerstore // contains filtered or unexported fields }
func NewPeerstoreWrapper ¶ added in v0.9.6
func NewPeerstoreWrapper(db *gorm.DB, writeInterval time.Duration, peerID p2pkey.PeerID) (*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 ¶ added in v0.9.6
func (p *Pstorewrapper) Close() error
func (*Pstorewrapper) Start ¶ added in v0.9.6
func (p *Pstorewrapper) Start() error
func (*Pstorewrapper) WriteToDB ¶ added in v0.9.6
func (p *Pstorewrapper) WriteToDB() error
type RunResultSaver ¶ added in v0.10.3
type RunResultSaver struct { utils.StartStopOnce // contains filtered or unexported fields }
func NewResultRunSaver ¶ added in v0.10.3
func NewResultRunSaver(db *gorm.DB, runResults <-chan pipeline.RunWithResults, pipelineRunner pipeline.Runner, done chan struct{}, logger logger.Logger, ) *RunResultSaver
func (*RunResultSaver) Close ¶ added in v0.10.3
func (r *RunResultSaver) Close() error
func (*RunResultSaver) Start ¶ added in v0.10.3
func (r *RunResultSaver) Start() error
type SingletonPeerWrapper ¶ added in v0.9.9
type SingletonPeerWrapper struct { PeerID p2pkey.PeerID Peer peer utils.StartStopOnce // contains filtered or unexported fields }
SingletonPeerWrapper manages all libocr peers for the application
func NewSingletonPeerWrapper ¶ added in v0.9.9
func NewSingletonPeerWrapper(keyStore *keystore.OCR, config *config.Config, db *gorm.DB) *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 ¶ added in v0.9.9
func (p *SingletonPeerWrapper) Close() error
Close closes the peer and peerstore
func (*SingletonPeerWrapper) IsStarted ¶ added in v0.9.9
func (p *SingletonPeerWrapper) IsStarted() bool
func (*SingletonPeerWrapper) Start ¶ added in v0.9.9
func (p *SingletonPeerWrapper) Start() error
type Transmitter ¶
type Transmitter interface { CreateEthTransaction(ctx context.Context, toAddress gethCommon.Address, payload []byte) error FromAddress() gethCommon.Address }
func NewTransmitter ¶
func NewTransmitter(txm txManager, db *gorm.DB, fromAddress common.Address, gasLimit uint64, strategy bulletprooftxmanager.TxStrategy) Transmitter
NewTransmitter creates a new eth transmitter
type ValidationConfig ¶ added in v0.10.11
type ValidationConfig interface { Dev() bool OCRBlockchainTimeout(override time.Duration) time.Duration OCRContractConfirmations(override uint16) uint16 OCRContractPollInterval(override time.Duration) time.Duration OCRContractSubscribeInterval(override time.Duration) time.Duration OCRContractTransmitterTransmitTimeout() time.Duration OCRDatabaseTimeout() time.Duration OCRObservationTimeout(override time.Duration) time.Duration OCRObservationGracePeriod() time.Duration }