offchainreporting

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func IsLaterThan added in v0.10.3

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(sqldb *sql.DB, oracleSpecID int32) *db

NewDB returns a new DB scoped to this oracleSpecID

func NewLogger added in v0.9.3

func NewLogger(l *logger.Logger, trace bool, saveError func(string)) ocrtypes.Logger

func ValidatedOracleSpecToml added in v0.9.10

func ValidatedOracleSpecToml(config *orm.Config, tomlString string) (job.Job, error)

ValidatedOracleSpecToml validates an oracle spec that came from TOML

Types

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,
	jobORM job.ORM,
	config *orm.Config,
	keyStore *KeyStore,
	pipelineRunner pipeline.Runner,
	ethClient eth.Client,
	logBroadcaster log.Broadcaster,
	peerWrapper *SingletonPeerWrapper,
	monitoringEndpoint ocrtypes.MonitoringEndpoint,
) *Delegate

func (Delegate) JobType added in v0.9.10

func (d Delegate) JobType() job.Type

func (Delegate) ServicesForSpec added in v0.9.10

func (d Delegate) ServicesForSpec(jobSpec job.Job) (services []job.Service, err error)

type KeyStore added in v0.9.3

type KeyStore struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func NewKeyStore added in v0.9.3

func NewKeyStore(db *gorm.DB, scryptParams utils.ScryptParams) *KeyStore

func (KeyStore) ArchiveEncryptedOCRKeyBundle added in v0.9.3

func (ks KeyStore) ArchiveEncryptedOCRKeyBundle(key *ocrkey.EncryptedKeyBundle) error

ArchiveEncryptedOCRKeyBundle deletes the provided encrypted OCR key bundle

func (KeyStore) ArchiveEncryptedP2PKey added in v0.9.3

func (ks KeyStore) ArchiveEncryptedP2PKey(key *p2pkey.EncryptedP2PKey) error

func (KeyStore) CreateEncryptedOCRKeyBundle added in v0.9.3

func (ks KeyStore) CreateEncryptedOCRKeyBundle(encryptedKey *ocrkey.EncryptedKeyBundle) error

CreateEncryptedOCRKeyBundle creates an encrypted OCR private key record

func (KeyStore) DecryptedOCRKey added in v0.9.3

func (ks KeyStore) DecryptedOCRKey(hash models.Sha256Hash) (ocrkey.KeyBundle, bool)

func (KeyStore) DecryptedP2PKey added in v0.9.3

func (ks KeyStore) DecryptedP2PKey(peerID p2ppeer.ID) (p2pkey.Key, bool)

func (KeyStore) DecryptedP2PKeys added in v0.9.9

func (ks KeyStore) DecryptedP2PKeys() (keys []p2pkey.Key)

func (KeyStore) DeleteEncryptedOCRKeyBundle added in v0.9.3

func (ks KeyStore) DeleteEncryptedOCRKeyBundle(key *ocrkey.EncryptedKeyBundle) error

DeleteEncryptedOCRKeyBundle deletes the provided encrypted OCR key bundle

func (KeyStore) DeleteEncryptedP2PKey added in v0.9.3

func (ks KeyStore) DeleteEncryptedP2PKey(key *p2pkey.EncryptedP2PKey) error

func (KeyStore) ExportOCRKeyBundle added in v0.9.9

func (ks KeyStore) ExportOCRKeyBundle(id models.Sha256Hash, newPassword string) ([]byte, error)

ExportOCRKeyBundle exports an OCR key bundle from the database

func (KeyStore) ExportP2PKey added in v0.9.9

func (ks KeyStore) ExportP2PKey(ID int32, newPassword string) ([]byte, error)

ExportP2PKey exports a p2p key from the database

func (KeyStore) FindEncryptedOCRKeyBundleByID added in v0.9.3

func (ks KeyStore) FindEncryptedOCRKeyBundleByID(id models.Sha256Hash) (ocrkey.EncryptedKeyBundle, error)

FindEncryptedOCRKeyBundleByID finds an EncryptedKeyBundle bundle by its ID

func (KeyStore) FindEncryptedOCRKeyBundles added in v0.9.3

func (ks KeyStore) FindEncryptedOCRKeyBundles() (keys []ocrkey.EncryptedKeyBundle, err error)

FindEncryptedOCRKeyBundles finds all the encrypted OCR key records

func (KeyStore) FindEncryptedP2PKeyByID added in v0.9.3

func (ks KeyStore) FindEncryptedP2PKeyByID(id int32) (*p2pkey.EncryptedP2PKey, error)

func (KeyStore) FindEncryptedP2PKeys added in v0.9.3

func (ks KeyStore) FindEncryptedP2PKeys() (keys []p2pkey.EncryptedP2PKey, err error)

func (KeyStore) GenerateEncryptedOCRKeyBundle added in v0.9.3

func (ks KeyStore) GenerateEncryptedOCRKeyBundle() (ocrkey.KeyBundle, ocrkey.EncryptedKeyBundle, error)

func (KeyStore) GenerateEncryptedP2PKey added in v0.9.3

func (ks KeyStore) GenerateEncryptedP2PKey() (p2pkey.Key, p2pkey.EncryptedP2PKey, error)

func (KeyStore) ImportOCRKeyBundle added in v0.9.9

func (ks KeyStore) ImportOCRKeyBundle(keyJSON []byte, oldPassword string) (*ocrkey.EncryptedKeyBundle, error)

ImportOCRKeyBundle imports an OCR key bundle to the database

func (KeyStore) ImportP2PKey added in v0.9.9

func (ks KeyStore) ImportP2PKey(keyJSON []byte, oldPassword string) (*p2pkey.EncryptedP2PKey, error)

ImportP2PKey imports a p2p key to the database

func (*KeyStore) Unlock added in v0.9.3

func (ks *KeyStore) Unlock(password string) error

func (KeyStore) UpsertEncryptedOCRKeyBundle added in v0.9.9

func (ks KeyStore) UpsertEncryptedOCRKeyBundle(encryptedKey *ocrkey.EncryptedKeyBundle) error

func (KeyStore) UpsertEncryptedP2PKey added in v0.9.3

func (ks KeyStore) UpsertEncryptedP2PKey(k *p2pkey.EncryptedP2PKey) error

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 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,
	db OCRContractTrackerDB,
) (o *OCRContractTracker, err error)

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) 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 TODO(sam): This could (should?) be optimised to use the head tracker https://www.pivotaltracker.com/story/show/177006717

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) OnConnect added in v0.10.3

func (t *OCRContractTracker) OnConnect()

OnConnect complies with LogListener interface

func (*OCRContractTracker) OnDisconnect added in v0.10.3

func (t *OCRContractTracker) OnDisconnect()

OnDisconnect complies with LogListener interface

func (*OCRContractTracker) Start added in v0.10.3

func (t *OCRContractTracker) Start() (err 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

SubscribeToNewConfigs returns the tracker aliased as a ContractConfigSubscription

type OCRContractTrackerDB added in v0.10.3

type OCRContractTrackerDB interface {
	SaveLatestRoundRequested(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,
) *OCRContractTransmitter

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)

func (*OCRContractTransmitter) Transmit added in v0.9.6

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

type P2PPeer added in v0.9.6

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

func (P2PPeer) TableName added in v0.9.6

func (P2PPeer) TableName() string

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 models.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(runResults <-chan pipeline.RunWithResults, pipelineRunner pipeline.Runner, done chan struct{}, jobID int32) *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 models.PeerID
	Peer   peer
	// contains filtered or unexported fields
}

SingletonPeerWrapper manages all libocr peers for the application

func NewSingletonPeerWrapper added in v0.9.9

func NewSingletonPeerWrapper(keyStore *KeyStore, config *orm.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() (err 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() (err error)

type Transmitter

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

func NewTransmitter

func NewTransmitter(sqldb *sql.DB, fromAddress gethCommon.Address, gasLimit, maxUnconfirmedTransactions uint64) Transmitter

NewTransmitter creates a new eth transmitter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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