evm

package
v2.4.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UPKEEP_FAILURE_REASON_NONE = iota
	UPKEEP_FAILURE_REASON_UPKEEP_CANCELLED
	UPKEEP_FAILURE_REASON_UPKEEP_PAUSED
	UPKEEP_FAILURE_REASON_TARGET_CHECK_REVERTED
	UPKEEP_FAILURE_REASON_UPKEEP_NOT_NEEDED
	UPKEEP_FAILURE_REASON_PERFORM_DATA_EXCEEDS_LIMIT
	UPKEEP_FAILURE_REASON_INSUFFICIENT_BALANCE
	UPKEEP_FAILURE_REASON_MERCURY_CALLBACK_REVERTED
	UPKEEP_FAILURE_REASON_REVERT_DATA_EXCEEDS_LIMIT
	UPKEEP_FAILURE_REASON_REGISTRY_PAUSED

	// Start of offchain failure types. All onchain failure reasons from
	// contract should be put above
	UPKEEP_FAILURE_REASON_MERCURY_ACCESS_NOT_ALLOWED
)

enum UpkeepFailureReason is defined by https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/dev/automation/2_1/interfaces/AutomationRegistryInterface2_1.sol#L97 make sure failure reasons are in sync between contract and offchain enum

View Source
const (
	// PollLogInterval is the interval to query log poller
	PollLogInterval = time.Second
	// CleanUpInterval is the interval for cleaning up block maps
	CleanUpInterval = 15 * time.Minute
	// ChannelSize represents the channel size for head broadcaster
	ChannelSize = 20
)
View Source
const (
	BlockNumber        = "blockNumber" // valid for v0.2
	FeedId             = "feedId"      // valid for v0.3
	FeedIdHex          = "feedIdHex"   // valid for v0.2
	MercuryPathV2      = "/client?"
	MercuryPathV3      = "/v1/reports?"
	MercuryBatchPathV3 = "/v1/reports/bulk?"
	RetryDelay         = 500 * time.Millisecond
	Timestamp          = "timestamp" // valid for v0.3
	TotalAttempt       = 3
	UserId             = "userId"
	MercuryV02         = MercuryVersion("v0.2")
	MercuryV03         = MercuryVersion("v0.3")
)
View Source
const (
	// DefaultAllowListExpiration decides how long an upkeep's allow list info will be valid for.
	DefaultAllowListExpiration = 20 * time.Minute
	// CleanupInterval decides when the expired items in cache will be deleted.
	CleanupInterval = 25 * time.Minute
)
View Source
const BlockKeySeparator = "|"

Variables

View Source
var (
	ErrLogReadFailure                = fmt.Errorf("failure reading logs")
	ErrHeadNotAvailable              = fmt.Errorf("head not available")
	ErrRegistryCallFailure           = fmt.Errorf("registry chain call failure")
	ErrBlockKeyNotParsable           = fmt.Errorf("block identifier not parsable")
	ErrUpkeepKeyNotParsable          = fmt.Errorf("upkeep key not parsable")
	ErrInitializationFailure         = fmt.Errorf("failed to initialize registry")
	ErrContextCancelled              = fmt.Errorf("context was cancelled")
	ErrABINotParsable                = fmt.Errorf("error parsing abi")
	ActiveUpkeepIDBatchSize    int64 = 1000
	FetchUpkeepConfigBatchSize       = 10
)
View Source
var (
	ErrEmptyResults = fmt.Errorf("empty results; cannot encode")
)

Functions

func NewEvmRegistryPackerV2_1

func NewEvmRegistryPackerV2_1(abi abi.ABI, utilsAbi abi.ABI) *evmRegistryPackerV2_1

func TransmitEventProviderFilterName added in v2.4.0

func TransmitEventProviderFilterName(addr common.Address) string

func UpkeepFilterName

func UpkeepFilterName(addr common.Address) string

func UpkeepTriggerID added in v2.4.0

func UpkeepTriggerID(id *big.Int, trigger []byte) (string, error)

UpkeepTriggerID returns the identifier using the given upkeepID and trigger. It follows the same logic as the contract, but performs it locally.

Types

type AdminOffchainConfig

type AdminOffchainConfig struct {
	MercuryEnabled bool `json:"mercuryEnabled"`
}

AdminOffchainConfig represents the administrative offchain config for each upkeep. It can be set by s_upkeepManager role on the registry. Upkeeps allowed to use Mercury server will have this set to true.

type BlockKey added in v2.4.0

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

type BlockKeyHelper

type BlockKeyHelper[T uint32 | int64] struct {
}

func (BlockKeyHelper[T]) MakeBlockKey

func (kh BlockKeyHelper[T]) MakeBlockKey(b T) ocr2keepers.BlockKey

type BlockSubscriber added in v2.4.0

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

func NewBlockSubscriber added in v2.4.0

func NewBlockSubscriber(hb httypes.HeadBroadcaster, lp logpoller.LogPoller, blockHistorySize int64, lggr logger.Logger) *BlockSubscriber

func (*BlockSubscriber) Close added in v2.4.0

func (hw *BlockSubscriber) Close() error

func (*BlockSubscriber) Start added in v2.4.0

func (hw *BlockSubscriber) Start(_ context.Context) error

func (*BlockSubscriber) Subscribe added in v2.4.0

func (hw *BlockSubscriber) Subscribe() (int, chan ocr2keepers.BlockHistory, error)

func (*BlockSubscriber) Unsubscribe added in v2.4.0

func (hw *BlockSubscriber) Unsubscribe(subId int) error

type EVMAutomationEncoder21

type EVMAutomationEncoder21 struct {
	encoding.BasicEncoder
	// contains filtered or unexported fields
}

func (EVMAutomationEncoder21) Encode added in v2.4.0

func (enc EVMAutomationEncoder21) Encode(results ...ocr2keepers.CheckResult) ([]byte, error)

func (EVMAutomationEncoder21) Extract added in v2.4.0

Extract the plugin will call this function to accept/transmit reports

type EVMAutomationResultExtension21 added in v2.4.0

type EVMAutomationResultExtension21 struct {
	FastGasWei    *big.Int
	LinkNative    *big.Int
	FailureReason uint8 // this is not encoded, only pass along for the purpose of pipeline run
}

type EVMAutomationUpkeepResult21

type EVMAutomationUpkeepResult21 struct {
	// Block is the block number used to build an UpkeepKey for this result
	Block uint32
	// ID is the unique identifier for the upkeep
	ID            *big.Int
	Eligible      bool
	FailureReason uint8
	GasUsed       *big.Int
	PerformData   []byte
	FastGasWei    *big.Int
	LinkNative    *big.Int
	// CheckBlockNumber is the block number that the contract indicates the
	// upkeep was checked on
	CheckBlockNumber uint32
	CheckBlockHash   [32]byte
	ExecuteGas       uint32
	Retryable        bool
}

type EvmRegistry

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

func NewEVMRegistryService

func NewEVMRegistryService(addr common.Address, client evm.Chain, mc *models.MercuryCredentials, lggr logger.Logger) (*EvmRegistry, error)

func (*EvmRegistry) CheckUpkeeps added in v2.4.0

func (r *EvmRegistry) CheckUpkeeps(ctx context.Context, keys ...ocr2keepers.UpkeepPayload) ([]ocr2keepers.CheckResult, error)

func (*EvmRegistry) Close

func (r *EvmRegistry) Close() error

func (*EvmRegistry) GetActiveUpkeepIDs

func (r *EvmRegistry) GetActiveUpkeepIDs(ctx context.Context) ([]ocr2keepers.UpkeepIdentifier, error)

GetActiveUpkeepIDs uses the latest head and map of all active upkeeps to build a slice of upkeep keys.

func (*EvmRegistry) GetActiveUpkeepIDsByType

func (r *EvmRegistry) GetActiveUpkeepIDsByType(ctx context.Context, triggers ...uint8) ([]ocr2keepers.UpkeepIdentifier, error)

GetActiveUpkeepIDsByType returns all active upkeeps of the given trigger types.

func (*EvmRegistry) HealthReport

func (r *EvmRegistry) HealthReport() map[string]error

func (*EvmRegistry) LogEventProvider added in v2.4.0

func (r *EvmRegistry) LogEventProvider() logprovider.LogEventProvider

func (*EvmRegistry) Name

func (r *EvmRegistry) Name() string

func (*EvmRegistry) Ready

func (r *EvmRegistry) Ready() error

func (*EvmRegistry) Start

func (r *EvmRegistry) Start(ctx context.Context) error

type FeedLookup

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

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type LatestBlockGetter

type LatestBlockGetter interface {
	LatestBlock() int64
}

type MercuryBytes

type MercuryBytes struct {
	Index     int
	Error     error
	Retryable bool
	Bytes     []byte
}

type MercuryConfig

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

type MercuryResponse

type MercuryResponse struct {
	ChainlinkBlob string `json:"chainlinkBlob"`
}

MercuryResponse is used in both single feed endpoint and bulk endpoint because bulk endpoint will return ONE chainlinkBlob which contains multiple reports instead of multiple blobs.

type MercuryVersion

type MercuryVersion string

type Registry

type Registry interface {
	GetUpkeep(opts *bind.CallOpts, id *big.Int) (UpkeepInfo, error)
	GetState(opts *bind.CallOpts) (iregistry21.GetState, error)
	GetActiveUpkeepIDs(opts *bind.CallOpts, startIndex *big.Int, maxCount *big.Int) ([]*big.Int, error)
	GetAdminPrivilegeConfig(opts *bind.CallOpts, admin common.Address) ([]byte, error)
	GetUpkeepTriggerConfig(opts *bind.CallOpts, upkeepId *big.Int) ([]byte, error)
	CheckCallback(opts *bind.TransactOpts, id *big.Int, values [][]byte, extraData []byte) (*coreTypes.Transaction, error)
	ParseLog(log coreTypes.Log) (generated.AbigenLog, error)
}

type TransmitEventProvider added in v2.4.0

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

func NewTransmitEventProvider added in v2.4.0

func NewTransmitEventProvider(
	logger logger.Logger,
	logPoller logpoller.LogPoller,
	registryAddress common.Address,
	client evmclient.Client,
	lookbackBlocks int64,
) (*TransmitEventProvider, error)

func (*TransmitEventProvider) Close added in v2.4.0

func (c *TransmitEventProvider) Close() error

func (*TransmitEventProvider) Events added in v2.4.0

func (*TransmitEventProvider) HealthReport added in v2.4.0

func (c *TransmitEventProvider) HealthReport() map[string]error

func (*TransmitEventProvider) Name added in v2.4.0

func (c *TransmitEventProvider) Name() string

func (*TransmitEventProvider) Ready added in v2.4.0

func (c *TransmitEventProvider) Ready() error

func (*TransmitEventProvider) Start added in v2.4.0

type UpkeepKeyHelper

type UpkeepKeyHelper[T uint32 | int64] struct {
}

func (UpkeepKeyHelper[T]) MakeUpkeepKey

func (kh UpkeepKeyHelper[T]) MakeUpkeepKey(b T, id *big.Int) ocr2keepers.UpkeepKey

type UpkeepState added in v2.4.0

type UpkeepState uint8

TODO: use the same type defined in keeper plugin after a new release is cut

const (
	Performed UpkeepState = iota
	Eligible
)

type UpkeepStateReader added in v2.4.0

type UpkeepStateReader interface {
	// SelectByUpkeepIDsAndBlockRange retrieves upkeep states for provided upkeep ids and block range, the result is currently not in particular order
	SelectByUpkeepIDsAndBlockRange(upkeepIds []*big.Int, start, end int64) ([]*ocr2keepers.UpkeepPayload, []*UpkeepState, error)
}

type UpkeepStateStore added in v2.4.0

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

func NewUpkeepStateStore added in v2.4.0

func NewUpkeepStateStore(lggr logger.Logger) *UpkeepStateStore

NewUpkeepStateStore creates a new state store. This is an initial version of this store. More improvements to come: TODO: AUTO-4027

func (*UpkeepStateStore) SelectByUpkeepIDsAndBlockRange added in v2.4.0

func (u *UpkeepStateStore) SelectByUpkeepIDsAndBlockRange(upkeepIds []*big.Int, start, end int64) ([]*ocr2keepers.UpkeepPayload, []*UpkeepState, error)

func (*UpkeepStateStore) SetUpkeepState added in v2.4.0

func (u *UpkeepStateStore) SetUpkeepState(pl ocr2keepers.UpkeepPayload, us UpkeepState) error

type UpkeepStateUpdater added in v2.4.0

type UpkeepStateUpdater interface {
	SetUpkeepState(ocr2keepers.UpkeepPayload, UpkeepState) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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