handler

package
v0.0.0-...-8d415c1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 94 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConditionTrigger uint8 = iota
	LogTrigger
)
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 (
	ApplicationJson     = "application/json"
	BlockNumber         = "blockNumber" // valid for v0.2
	FeedIDs             = "feedIDs"     // valid for v0.3
	FeedIdHex           = "feedIdHex"   // valid for v0.2
	HeaderAuthorization = "Authorization"
	HeaderContentType   = "Content-Type"
	HeaderTimestamp     = "X-Authorization-Timestamp"
	HeaderSignature     = "X-Authorization-Signature-SHA256"
	HeaderUpkeepId      = "X-Authorization-Upkeep-Id"
	MercuryPathV2       = "/client?"              // only used to access mercury v0.2 server
	MercuryBatchPathV3  = "/api/v1/reports/bulk?" // only used to access mercury v0.3 server
	RetryDelay          = 500 * time.Millisecond
	Timestamp           = "timestamp" // valid for v0.3
	TotalAttempt        = 3
	UserId              = "userId"
)
View Source
const (
	// upkeep failure onchain reasons
	UpkeepFailureReasonNone                    UpkeepFailureReason = 0
	UpkeepFailureReasonUpkeepCancelled         UpkeepFailureReason = 1
	UpkeepFailureReasonUpkeepPaused            UpkeepFailureReason = 2
	UpkeepFailureReasonTargetCheckReverted     UpkeepFailureReason = 3
	UpkeepFailureReasonUpkeepNotNeeded         UpkeepFailureReason = 4
	UpkeepFailureReasonPerformDataExceedsLimit UpkeepFailureReason = 5
	UpkeepFailureReasonInsufficientBalance     UpkeepFailureReason = 6
	UpkeepFailureReasonMercuryCallbackReverted UpkeepFailureReason = 7
	UpkeepFailureReasonRevertDataExceedsLimit  UpkeepFailureReason = 8
	UpkeepFailureReasonRegistryPaused          UpkeepFailureReason = 9
	// leaving a gap here for more onchain failure reasons in the future
	// upkeep failure offchain reasons
	UpkeepFailureReasonMercuryAccessNotAllowed UpkeepFailureReason = 32
	UpkeepFailureReasonTxHashNoLongerExists    UpkeepFailureReason = 33
	UpkeepFailureReasonInvalidRevertDataInput  UpkeepFailureReason = 34
	UpkeepFailureReasonSimulationFailed        UpkeepFailureReason = 35
	UpkeepFailureReasonTxHashReorged           UpkeepFailureReason = 36

	// pipeline execution error
	NoPipelineError        PipelineExecutionState = 0
	CheckBlockTooOld       PipelineExecutionState = 1
	CheckBlockInvalid      PipelineExecutionState = 2
	RpcFlakyFailure        PipelineExecutionState = 3
	MercuryFlakyFailure    PipelineExecutionState = 4
	PackUnpackDecodeFailed PipelineExecutionState = 5
	MercuryUnmarshalError  PipelineExecutionState = 6
	InvalidMercuryRequest  PipelineExecutionState = 7
	InvalidMercuryResponse PipelineExecutionState = 8 // this will only happen if Mercury server sends bad responses
	UpkeepNotAuthorized    PipelineExecutionState = 9
)

Variables

This section is empty.

Functions

func JSONMarshalWithoutEscape

func JSONMarshalWithoutEscape(t interface{}) ([]byte, error)

func NewBaseHandler

func NewBaseHandler(cfg *config.Config) *baseHandler

NewBaseHandler is the constructor of baseHandler

func OCR2AutomationReports

func OCR2AutomationReports(hdlr *baseHandler, txs []string) error

func OCR2GetConfig

func OCR2GetConfig(hdlr *baseHandler, registry_addr string) error

Types

type BaseOCR2Tx

type BaseOCR2Tx struct {
	types.Transaction
	// contains filtered or unexported fields
}

func NewBaseOCR2Tx

func NewBaseOCR2Tx(tx *types.Transaction) (*BaseOCR2Tx, error)

func (*BaseOCR2Tx) DataMap

func (tx *BaseOCR2Tx) DataMap() (map[string]interface{}, error)

func (*BaseOCR2Tx) Method

func (tx *BaseOCR2Tx) Method() (*abi.Method, error)

type CSAKeyInfo

type CSAKeyInfo struct {
	NodeName    string `json:"nodeName"`
	NodeAddress string `json:"nodeAddress"`
	PublicKey   string `json:"publicKey"`
}

func (*CSAKeyInfo) Equals

func (ci *CSAKeyInfo) Equals(ci2 *CSAKeyInfo) bool

type HttpClient

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

type JsonError

type JsonError interface {
	Error() string
	// ErrorCode() int
	ErrorData() interface{}
}

JsonError is a rpc.jsonError interface

type Keeper

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

Keeper is the keepers commands handler

func NewKeeper

func NewKeeper(cfg *config.Config) *Keeper

NewKeeper creates new instance of Keeper

func (*Keeper) CreateJob

func (k *Keeper) CreateJob(ctx context.Context)

func (*Keeper) Debug

func (k *Keeper) Debug(ctx context.Context, args []string)

func (*Keeper) DeployKeepers

func (k *Keeper) DeployKeepers(ctx context.Context)

DeployKeepers contains a logic to deploy keepers.

func (*Keeper) DeployRegistry

func (k *Keeper) DeployRegistry(ctx context.Context, verify bool)

DeployRegistry deploys a new keeper registry.

func (*Keeper) GetVerifiableLoadStats

func (k *Keeper) GetVerifiableLoadStats(ctx context.Context, csv bool)

func (*Keeper) LaunchAndTest

func (k *Keeper) LaunchAndTest(ctx context.Context, withdraw, printLogs, force, bootstrap bool)

LaunchAndTest launches keeper registry, chainlink nodes, upkeeps and start performing. 1. launch chainlink node using docker image 2. get keeper registry instance, deploy if needed 3. deploy upkeeps 4. create keeper jobs 5. fund nodes if needed 6. set keepers in the registry 7. withdraw funds after tests are done -> TODO: wait until tests are done instead of cancel manually

func (*Keeper) PrintLogs

func (k *Keeper) PrintLogs(ctx context.Context, pattern string, grep, vgrep []string)

func (Keeper) RevertReason

func (h Keeper) RevertReason(hash string)

RevertReason attempts to fetch more info on failed TX

func (Keeper) ScrapeNodes

func (h Keeper) ScrapeNodes()

func (Keeper) StartBootstrapNode

func (h Keeper) StartBootstrapNode(ctx context.Context, addr string, uiPort, p2pv2Port int, force bool) string

StartBootstrapNode starts the ocr2 bootstrap node with the given contract address, returns the tcp address of the node

func (*Keeper) UpdateRegistry

func (k *Keeper) UpdateRegistry(ctx context.Context)

UpdateRegistry attaches to an existing registry and possibly updates registry config

func (*Keeper) UpkeepCounterEvents

func (k *Keeper) UpkeepCounterEvents(ctx context.Context, hexAddr string, fromBlock, toBlock uint64)

UpkeepCounterEvents print out emitted events and write to csv file

func (*Keeper) UpkeepHistory

func (k *Keeper) UpkeepHistory(ctx context.Context, upkeepId *big.Int, from, to, gasPrice uint64)

UpkeepHistory prints the checkUpkeep status and keeper responsibility for a given upkeep in a set block range

func (*Keeper) VerifyContract

func (k *Keeper) VerifyContract(params ...string)

func (*Keeper) Withdraw

func (k *Keeper) Withdraw(ctx context.Context, hexAddr string)

Withdraw takes a keeper registry address, cancels all upkeeps and withdraws the funds

type MercuryCredentials

type MercuryCredentials struct {
	LegacyURL string
	URL       string
	ClientID  string
	ClientKey string
}

func (*MercuryCredentials) Validate

func (mc *MercuryCredentials) Validate() bool

type MercuryData

type MercuryData struct {
	Index     int
	Error     error
	Retryable bool
	Bytes     [][]byte
	State     PipelineExecutionState
}

type MercuryLookupHandler

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

MercuryLookupHandler is responsible for initiating the calls to the Mercury server to determine whether the upkeeps are eligible

func NewMercuryLookupHandler

func NewMercuryLookupHandler(
	credentials *MercuryCredentials,
	rpcClient *rpc.Client,
) *MercuryLookupHandler

func (*MercuryLookupHandler) CheckCallback

func (mlh *MercuryLookupHandler) CheckCallback(ctx context.Context, values [][]byte, lookup *StreamsLookup, registryABI ethabi.ABI, registryAddress common.Address) (hexutil.Bytes, error)

type MercuryV02Response

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

MercuryV02Response represents a JSON structure used by Mercury v0.2

type MercuryV03Report

type MercuryV03Report struct {
	FeedID                string `json:"feedID"` // feed id in hex encoded
	ValidFromTimestamp    uint32 `json:"validFromTimestamp"`
	ObservationsTimestamp uint32 `json:"observationsTimestamp"`
	FullReport            string `json:"fullReport"` // the actual hex encoded mercury report of this feed, can be sent to verifier
}

type MercuryV03Response

type MercuryV03Response struct {
	Reports []MercuryV03Report `json:"reports"`
}

MercuryV03Response represents a JSON structure used by Mercury v0.3

type MercuryVersion

type MercuryVersion string

type NodeInfo

type NodeInfo struct {
	AdminAddress          common.Address `json:"adminAddress"`
	CSAKeys               []*CSAKeyInfo  `json:"csaKeys"`
	DisplayName           string         `json:"displayName"`
	Ocr2ConfigPublicKey   []string       `json:"ocr2ConfigPublicKey"`
	Ocr2Id                []string       `json:"ocr2Id"`
	Ocr2OffchainPublicKey []string       `json:"ocr2OffchainPublicKey"`
	Ocr2OnchainPublicKey  []string       `json:"ocr2OnchainPublicKey"`
	NodeAddress           []string       `json:"ocrNodeAddress"`
	OcrSigningAddress     []string       `json:"ocrSigningAddress"`
	PayeeAddress          common.Address `json:"payeeAddress"`
	PeerId                []string       `json:"peerId"`
	Status                string         `json:"status"`
}

func (NodeInfo) Equals

func (node NodeInfo) Equals(ni NodeInfo, log logger.Logger) bool

type OCR2ReportDataElem

type OCR2ReportDataElem struct {
	Err                string
	From               string
	To                 string
	ChainID            string
	BlockNumber        string
	PerformKeys        string
	PerformBlockChecks string
}

type OCR2SetConfigTx

type OCR2SetConfigTx struct {
	BaseOCR2Tx
}

func NewOCR2SetConfigTx

func NewOCR2SetConfigTx(tx *types.Transaction) (*OCR2SetConfigTx, error)

func (*OCR2SetConfigTx) Config

func (tx *OCR2SetConfigTx) Config() (ocrtypes.ContractConfig, error)

type OCR2Transaction

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

func NewOCR2Transaction

func NewOCR2Transaction(raw map[string]interface{}) (*OCR2Transaction, error)

func (*OCR2Transaction) BlockNumber

func (t *OCR2Transaction) BlockNumber() (uint64, error)

func (*OCR2Transaction) ChainId

func (t *OCR2Transaction) ChainId() *big.Int

func (*OCR2Transaction) DecodeError

func (t *OCR2Transaction) DecodeError(b []byte) string

func (*OCR2Transaction) From

func (t *OCR2Transaction) From() (common.Address, error)

func (*OCR2Transaction) Method

func (t *OCR2Transaction) Method() (*abi.Method, error)

func (*OCR2Transaction) To

func (t *OCR2Transaction) To() *common.Address

func (*OCR2Transaction) TransactionHash

func (t *OCR2Transaction) TransactionHash() common.Hash

type OCR2TransmitTx

type OCR2TransmitTx struct {
	OCR2Transaction
}

func NewOCR2TransmitTx

func NewOCR2TransmitTx(raw map[string]interface{}) (*OCR2TransmitTx, error)

func (*OCR2TransmitTx) BatchElem

func (t *OCR2TransmitTx) BatchElem() (rpc.BatchElem, error)

func (*OCR2TransmitTx) SetStaticValues

func (t *OCR2TransmitTx) SetStaticValues(elem *OCR2ReportDataElem)

func (*OCR2TransmitTx) UpkeepsInTransmit

func (t *OCR2TransmitTx) UpkeepsInTransmit() ([]ocr2keepers20.UpkeepResult, error)

type PipelineExecutionState

type PipelineExecutionState uint8

type StreamsLookup

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

type TenderlyAPIResponse

type TenderlyAPIResponse struct {
	Simulation struct {
		Id string
	}
}

type UpkeepFailureReason

type UpkeepFailureReason uint8

type UpkeepPrivilegeConfig

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

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

Jump to

Keyboard shortcuts

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