Documentation
¶
Index ¶
- type BlockHistory
- type BlockKey
- type BlockNumber
- type BlockSubscriber
- type CheckResult
- type ConditionalUpkeepProvider
- type CoordinatedBlockProposal
- type Encoder
- type EventProvider
- type LogEventProvider
- type LogEventProviderConfig
- type LogRecoverer
- type LogTriggerExtension
- type PayloadBuilder
- type RecoverableProvider
- type Registry
- type ReportedUpkeep
- type TransmitEvent
- type TransmitEventType
- type Trigger
- type UpkeepIdentifier
- type UpkeepPayload
- type UpkeepState
- type UpkeepStateReader
- type UpkeepStateStore
- type UpkeepStateUpdater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockHistory ¶
type BlockHistory []BlockKey
BlockHistory is a list of block keys
func (BlockHistory) Latest ¶
func (bh BlockHistory) Latest() (BlockKey, error)
type BlockKey ¶
type BlockKey struct {
Number BlockNumber
Hash [32]byte
}
BlockKey represent a block (number and hash) NOTE: This struct is sent on the p2p network as part of observations to get quorum Any change here should be backwards compatible and should keep validation and quorum requirements in mind. Please ensure to get a proper review along with an upgrade plan before changing this
type BlockNumber ¶
type BlockNumber uint64
type BlockSubscriber ¶
type BlockSubscriber interface {
// Subscribe provides an identifier integer, a new channel, and potentially an error
Subscribe() (int, chan BlockHistory, error)
// Unsubscribe requires an identifier integer and indicates the provided channel should be closed
Unsubscribe(int) error
Start(context.Context) error
Close() error
}
type CheckResult ¶
type CheckResult struct {
// zero if success, else indicates an error code
PipelineExecutionState uint8
// if PipelineExecutionState is non zero, then retryable indicates that the same
// payload can be processed again in order to get a successful execution
Retryable bool
// Rest of these fields are only applicable if PipelineExecutionState is zero
// Eligible indicates whether this result is eligible to be performed
Eligible bool
// If result is not eligible then the reason it failed. Should be 0 if eligible
IneligibilityReason uint8
// Upkeep is all the information that identifies the upkeep
UpkeepID UpkeepIdentifier
// Trigger is the event that triggered the upkeep to be checked
Trigger Trigger
// WorkID represents the unit of work for the check result
// Exploratory: Make workID an internal field and an external WorkID() function which generates WID
WorkID string
// GasAllocated is the gas to provide an upkeep in a report
GasAllocated uint64
// PerformData is the raw data returned when simulating an upkeep perform
PerformData []byte
// FastGasWei is the fast gas price in wei when performing this upkeep
FastGasWei *big.Int
// Link to native ratio to be used when performing this upkeep
LinkNative *big.Int
// RetryInterval is the time interval after which the same payload can be retried.
// This field is used is special cases (such as mercury lookup), where we want to
// have a different retry interval than the default one (30s)
// NOTE: this field is not encoded in JSON and is only used internally
RetryInterval time.Duration
}
NOTE: This struct is sent on the p2p network as part of observations to get quorum Any change here should be backwards compatible and should keep validation and quorum requirements in mind. Any field that is needed to be encoded should be added as well to checkResultMsg struct, and to be encoded/decoded in the MarshalJSON and UnmarshalJSON functions. Please ensure to get a proper review along with an upgrade plan before changing this.
func (CheckResult) MarshalJSON ¶
func (r CheckResult) MarshalJSON() ([]byte, error)
func (CheckResult) String ¶
func (r CheckResult) String() string
NOTE: this function is used for debugging purposes only. for encoding check results, please use the Encoder interface
func (CheckResult) UniqueID ¶
func (r CheckResult) UniqueID() string
UniqueID returns a unique identifier for the check result. It is used to achieve quorum on results before being sent within a report.
func (*CheckResult) UnmarshalJSON ¶
func (r *CheckResult) UnmarshalJSON(data []byte) error
type ConditionalUpkeepProvider ¶
type ConditionalUpkeepProvider interface {
GetActiveUpkeeps(context.Context) ([]UpkeepPayload, error)
}
type CoordinatedBlockProposal ¶
type CoordinatedBlockProposal struct {
// UpkeepID is the id of the proposed upkeep
UpkeepID UpkeepIdentifier
// Trigger represents the event that triggered the upkeep to be checked
Trigger Trigger
// WorkID represents the unit of work for the coordinated proposal
WorkID string
}
CoordinatedBlockProposal is used to represent a unit of work that can be performed after a check block has been coordinated between nodes. NOTE: This struct is sent on the p2p network as part of observations to get quorum Any change here should be backwards compatible and should keep validation and quorum requirements in mind. Please ensure to get a proper review along with an upgrade plan before changing this NOTE: Only the trigger.BlockHash and trigger.BlockNumber are coordinated across the network to get a quorum. WorkID is guaranteed to be correctly generated. Rest of the fields here SHOULD NOT BE TRUSTED as they can be manipulated by a single malicious node.
type Encoder ¶
type Encoder interface {
Encode(...CheckResult) ([]byte, error)
Extract([]byte) ([]ReportedUpkeep, error)
}
type EventProvider ¶
type LogEventProvider ¶
type LogEventProvider interface {
GetLatestPayloads(context.Context) ([]UpkeepPayload, error)
SetConfig(LogEventProviderConfig)
Start(context.Context) error
Close() error
}
type LogEventProviderConfig ¶
type LogRecoverer ¶
type LogTriggerExtension ¶
type LogTriggerExtension struct {
// LogTxHash is the transaction hash of the log event
TxHash [32]byte
// Index is the index of the log event in the transaction
Index uint32
// BlockHash is the block hash in which the event occurred
BlockHash [32]byte
// BlockNumber is the block number in which the event occurred
// NOTE: This field might be empty. If relying on this field check
// it is non empty, if it's empty derive from BlockHash
BlockNumber BlockNumber
}
LogTriggerExtension is the extension used for log triggers, It contains information of the log event that was triggered. NOTE: This struct is sent on the p2p network as part of observations to get quorum Any change here should be backwards compatible and should keep validation and quorum requirements in mind. Please ensure to get a proper review along with an upgrade plan before changing this
func (LogTriggerExtension) LogIdentifier ¶
func (e LogTriggerExtension) LogIdentifier() []byte
LogIdentifier returns a unique identifier for the log event, composed of the transaction hash and the log index bytes.
func (LogTriggerExtension) String ¶
func (e LogTriggerExtension) String() string
type PayloadBuilder ¶
type PayloadBuilder interface {
// Can get payloads for a subset of proposals along with an error
BuildPayloads(context.Context, ...CoordinatedBlockProposal) ([]UpkeepPayload, error)
}
type RecoverableProvider ¶
type RecoverableProvider interface {
GetRecoveryProposals(context.Context) ([]UpkeepPayload, error)
}
type ReportedUpkeep ¶
type ReportedUpkeep struct {
// UpkeepID id of the underlying upkeep
UpkeepID UpkeepIdentifier
// Trigger data for the upkeep
Trigger Trigger
// WorkID represents the unit of work for the reported upkeep
WorkID string
}
ReportedUpkeep contains details of an upkeep for which a report was generated.
type TransmitEvent ¶
type TransmitEvent struct {
// Type describes the type of event
Type TransmitEventType
// TransmitBlock is the block height of the transmit event
TransmitBlock BlockNumber
// Confirmations is the block height behind latest
Confirmations int64
// TransactionHash is the hash for the transaction where the event originated
TransactionHash [32]byte
// UpkeepID uniquely identifies the upkeep in the registry
UpkeepID UpkeepIdentifier
// WorkID uniquely identifies the unit of work for the specified upkeep
WorkID string
// CheckBlock is the block value that the upkeep was originally checked at
CheckBlock BlockNumber
}
type TransmitEventType ¶
type TransmitEventType int
const ( UnknownEvent TransmitEventType = iota PerformEvent StaleReportEvent ReorgReportEvent InsufficientFundsReportEvent )
type Trigger ¶
type Trigger struct {
// BlockNumber is the block number in which the trigger was checked
BlockNumber BlockNumber
// BlockHash is the block hash in which the trigger was checked
BlockHash [32]byte
// LogTriggerExtension is the extension for log triggers
LogTriggerExtension *LogTriggerExtension
}
Trigger represents a trigger for an upkeep. It contains an extension per trigger type, and the block number + hash in which the trigger was checked. NOTE: This struct is sent on the p2p network as part of observations to get quorum Any change here should be backwards compatible and should keep validation and quorum requirements in mind. Please ensure to get a proper review along with an upgrade plan before changing this
func NewLogTrigger ¶
func NewLogTrigger(blockNumber BlockNumber, blockHash [32]byte, logTriggerExtension *LogTriggerExtension) Trigger
func NewTrigger ¶
func NewTrigger(blockNumber BlockNumber, blockHash [32]byte) Trigger
NewTrigger returns a new basic trigger w/o extension
type UpkeepIdentifier ¶
type UpkeepIdentifier [32]byte
UpkeepIdentifier is a unique identifier for the upkeep, represented as uint256 in the contract.
func (UpkeepIdentifier) BigInt ¶
func (u UpkeepIdentifier) BigInt() *big.Int
func (*UpkeepIdentifier) FromBigInt ¶
func (u *UpkeepIdentifier) FromBigInt(i *big.Int) bool
FromBigInt sets the upkeep identifier from a big.Int, returning true if the big.Int is valid and false otherwise. in case of an invalid big.Int the upkeep identifier is set to 32 zeros.
func (UpkeepIdentifier) String ¶
func (u UpkeepIdentifier) String() string
String returns a base 10 numerical string representation of the upkeep identifier.
type UpkeepPayload ¶
type UpkeepPayload struct {
// Upkeep is all the information that identifies the upkeep
UpkeepID UpkeepIdentifier
// Trigger is the event that triggered the upkeep to be checked
Trigger Trigger
// WorkID uniquely identifies the unit of work for the specified upkeep
WorkID string
// CheckData is the data used to check the upkeep
CheckData []byte
}
func (UpkeepPayload) IsEmpty ¶
func (p UpkeepPayload) IsEmpty() bool
Determines whether the payload is empty, used within filtering
type UpkeepState ¶
type UpkeepState uint8
UpkeepState is a final state of some unit of work.
const ( UnknownState UpkeepState = iota // Performed means the upkeep was performed Performed // Ineligible means the upkeep was not eligible to be performed Ineligible )
type UpkeepStateReader ¶
type UpkeepStateReader interface {
SelectByWorkIDs(ctx context.Context, workIDs ...string) ([]UpkeepState, error)
}
UpkeepStateReader is the interface for reading the current state of upkeeps.
type UpkeepStateStore ¶
type UpkeepStateStore interface {
UpkeepStateUpdater
UpkeepStateReader
Start(context.Context) error
io.Closer
}
UpkeepStateStore is the interface for managing upkeeps final state in a local store.
type UpkeepStateUpdater ¶
type UpkeepStateUpdater interface {
SetUpkeepState(context.Context, CheckResult, UpkeepState) error
}