types

package
v0.1.7-0...-cf52d4c Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidType              = InvalidArgumentError("invalid type")
	ErrInvalidConfig            = InvalidArgumentError("invalid configuration")
	ErrChainReaderConfigMissing = UnimplementedError("ChainReader entry missing from RelayConfig")
	ErrInternal                 = InternalError("internal error")
	ErrNotFound                 = NotFoundError("not found")
)

Errors exposed to product plugins

View Source
const (
	ErrFieldNotFound   = InvalidArgumentError("field not found")
	ErrInvalidEncoding = InvalidArgumentError("invalid encoding")
	ErrSliceWrongLen   = InvalidArgumentError("slice is wrong length")
	ErrNotASlice       = InvalidArgumentError("element is not a slice")
)
View Source
const (
	NetworkEVM      = "evm"
	NetworkCosmos   = "cosmos"
	NetworkSolana   = "solana"
	NetworkStarkNet = "starknet"
)

Variables

View Source
var SupportedRelays = map[string]struct{}{
	NetworkEVM:      {},
	NetworkCosmos:   {},
	NetworkSolana:   {},
	NetworkStarkNet: {},
}

Functions

This section is empty.

Types

type AutomationProvider

type AutomationProvider interface {
	PluginProvider
	Registry() automation.Registry
	Encoder() automation.Encoder
	TransmitEventProvider() automation.EventProvider
	BlockSubscriber() automation.BlockSubscriber
	PayloadBuilder() automation.PayloadBuilder
	UpkeepStateStore() automation.UpkeepStateStore
	LogEventProvider() automation.LogEventProvider
	LogRecoverer() automation.LogRecoverer
	UpkeepProvider() automation.ConditionalUpkeepProvider
}

AutomationProvider provides components needed for the automation OCR2 plugin.

type BoundContract

type BoundContract struct {
	Address string
	Name    string
	Pending bool
}

func (BoundContract) Key

func (bc BoundContract) Key() string

type CCIPCommitFactoryGenerator

type CCIPCommitFactoryGenerator interface {
	NewCommitFactory(ctx context.Context, provider CCIPCommitProvider) (ReportingPluginFactory, error)
}

type CCIPCommitProvider

type CCIPCommitProvider interface {
	PluginProvider

	NewCommitStoreReader(ctx context.Context, addr ccip.Address) (ccip.CommitStoreReader, error)
	NewOffRampReader(ctx context.Context, addr ccip.Address) (ccip.OffRampReader, error)
	NewOnRampReader(ctx context.Context, addr ccip.Address) (ccip.OnRampReader, error)
	NewPriceGetter(ctx context.Context) (ccip.PriceGetter, error)
	NewPriceRegistryReader(ctx context.Context, addr ccip.Address) (ccip.PriceRegistryReader, error)
	SourceNativeToken(ctx context.Context) (ccip.Address, error)
}

type CCIPExecProvider

type CCIPExecProvider interface {
	PluginProvider

	NewCommitStoreReader(ctx context.Context, addr ccip.Address) (ccip.CommitStoreReader, error)
	NewOffRampReader(ctx context.Context, addr ccip.Address) (ccip.OffRampReader, error)
	NewOnRampReader(ctx context.Context, addr ccip.Address) (ccip.OnRampReader, error)
	NewPriceRegistryReader(ctx context.Context, addr ccip.Address) (ccip.PriceRegistryReader, error)
	NewTokenDataReader(ctx context.Context, tokenAddress ccip.Address) (ccip.TokenDataReader, error)
	NewTokenPoolBatchedReader(ctx context.Context) (ccip.TokenPoolBatchedReader, error)
	SourceNativeToken(ctx context.Context) (ccip.Address, error)
}

type CCIPExecutionFactoryGenerator

type CCIPExecutionFactoryGenerator interface {
	NewExecutionFactory(ctx context.Context, provider CCIPExecProvider) (ReportingPluginFactory, error)
}

type ChainReader

type ChainReader interface {
	// GetLatestValue gets the latest value....
	// The params argument can be any object which maps a set of generic parameters into chain specific parameters defined in RelayConfig.
	// It must encode as an object via [json.Marshal] and [github.com/fxamacker/cbor/v2.Marshal].
	// Typically, would be either a struct with field names mapping to arguments, or anonymous map such as `map[string]any{"baz": 42, "test": true}}`
	//
	// returnVal must [json.Unmarshal] and and [github.com/fxamacker/cbor/v2.Marshal] as an object.
	//
	// Example use:
	//  type ProductParams struct {
	// 		ID int `json:"id"`
	//  }
	//  type ProductReturn struct {
	// 		Foo string `json:"foo"`
	// 		Bar *big.Int `json:"bar"`
	//  }
	//  func do(ctx context.Context, cr ChainReader) (resp ProductReturn, err error) {
	// 		err = cr.GetLatestValue(ctx, "FooContract", "GetProduct", ProductParams{ID:1}, &resp)
	// 		return
	//  }
	//
	// Note that implementations should ignore extra fields in params that are not expected in the call to allow easier
	// use across chains and contract versions.
	// Similarly, when using a struct for returnVal, fields in the return value that are not on-chain will not be set.
	GetLatestValue(ctx context.Context, contractName, method string, params, returnVal any) error

	// Bind will override current bindings for the same contract, if one has been set and will return an error if the
	// contract is not known by the ChainReader, or if the Address is invalid
	// TODO: (BCF-3139) can't handle log poller filters,explore handling this through chain reader config.
	Bind(ctx context.Context, bindings []BoundContract) error

	// QueryKey provides fetching chain agnostic events (Sequence) with general querying capability.
	// TODO: (BCF-3174) find a way to abstract EVM Log Poller IndexedLogsWithSigsExcluding, should be possible by adding a new filter.
	QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]Sequence, error)
}

type ChainService

type ChainService interface {
	Service

	GetChainStatus(ctx context.Context) (ChainStatus, error)
	ListNodeStatuses(ctx context.Context, pageSize int32, pageToken string) (stats []NodeStatus, nextPageToken string, total int, err error)
	Transact(ctx context.Context, from, to string, amount *big.Int, balanceCheck bool) error
}

ChainService is a sub-interface of [loop.Relayer] that encapsulates the explicit interactions with a chain

type ChainStatus

type ChainStatus struct {
	ID      string
	Enabled bool
	Config  string // TOML
}

type Codec

type Codec interface {
	Encoder
	Decoder
}

type ConfigProvider

type ConfigProvider interface {
	Service
	OffchainConfigDigester() ocrtypes.OffchainConfigDigester
	ContractConfigTracker() ocrtypes.ContractConfigTracker
}

The bootstrap jobs only watch config.

type ContractTypeProvider

type ContractTypeProvider interface {
	CreateContractType(contractName, itemType string, forEncoding bool) (any, error)
}

type Decoder

type Decoder interface {
	Decode(ctx context.Context, raw []byte, into any, itemType string) error
	// GetMaxDecodingSize returns the max size in bytes if n elements are supplied for all top level dynamically sized elements.
	// If no elements are dynamically sized, the returned value will be the same for all n.
	// If there are multiple levels of dynamically sized elements, or itemType cannot be found,
	// ErrInvalidType will be returned.
	GetMaxDecodingSize(ctx context.Context, n int, itemType string) (int, error)
}

type Encoder

type Encoder interface {
	Encode(ctx context.Context, item any, itemType string) ([]byte, error)
	// GetMaxEncodingSize returns the max size in bytes if n elements are supplied for all top level dynamically sized elements.
	// If no elements are dynamically sized, the returned value will be the same for all n.
	// If there are multiple levels of dynamically sized elements, or itemType cannot be found,
	// ErrInvalidType will be returned.
	GetMaxEncodingSize(ctx context.Context, n int, itemType string) (int, error)
}

type FunctionsEvents

type FunctionsEvents interface {
	Service
	LatestEvents() ([]OracleRequest, []OracleResponse, error)
}

An on-chain event source, which understands router proxy contracts.

type FunctionsProvider

type FunctionsProvider interface {
	PluginProvider
	FunctionsEvents() FunctionsEvents
}
type Head struct {
	Identifier string
	Hash       []byte
	Timestamp  uint64
}

type InternalError

type InternalError string

func (InternalError) Error

func (e InternalError) Error() string

func (InternalError) GRPCStatus

func (e InternalError) GRPCStatus() *status.Status

func (InternalError) Is

func (e InternalError) Is(target error) bool

type InvalidArgumentError

type InvalidArgumentError string

func (InvalidArgumentError) Error

func (e InvalidArgumentError) Error() string

func (InvalidArgumentError) GRPCStatus

func (e InvalidArgumentError) GRPCStatus() *status.Status

func (InvalidArgumentError) Is

func (e InvalidArgumentError) Is(target error) bool

type LLOProvider

type LLOProvider interface {
	ConfigProvider
	ContractTransmitter() llo.Transmitter
	ChannelDefinitionCache() llo.ChannelDefinitionCache
}

type MedianProvider

type MedianProvider interface {
	PluginProvider
	ReportCodec() median.ReportCodec
	MedianContract() median.MedianContract
	OnchainConfigCodec() median.OnchainConfigCodec
}

MedianProvider provides all components needed for a median OCR2 plugin.

type MercuryCredentials

type MercuryCredentials struct {
	LegacyURL string
	URL       string
	Username  string
	Password  string
}

type MercuryPluginFactory

type MercuryPluginFactory interface {
	Service
	ocr3types.MercuryPluginFactory
}

type MercuryProvider

type MercuryProvider interface {
	PluginProvider

	ReportCodecV1() v1.ReportCodec
	ReportCodecV2() v2.ReportCodec
	ReportCodecV3() v3.ReportCodec
	OnchainConfigCodec() mercury.OnchainConfigCodec
	MercuryServerFetcher() mercury.ServerFetcher
	MercuryChainReader() mercury.ChainReader
}

MercuryProvider provides components needed for a mercury OCR2 plugin. Mercury requires config tracking but does not transmit on-chain.

type NodeStatus

type NodeStatus struct {
	ChainID string
	Name    string
	Config  string // TOML
	State   string
}

type NotFoundError

type NotFoundError string

func (NotFoundError) Error

func (e NotFoundError) Error() string

func (NotFoundError) GRPCStatus

func (e NotFoundError) GRPCStatus() *status.Status

func (NotFoundError) Is

func (e NotFoundError) Is(target error) bool

type OCR2PluginType

type OCR2PluginType string

OCR2PluginType defines supported OCR2 plugin types.

const (
	Median  OCR2PluginType = "median"
	DKG     OCR2PluginType = "dkg"
	OCR2VRF OCR2PluginType = "ocr2vrf"

	// TODO: sc-55296 to rename ocr2keeper to ocr2automation in code
	OCR2Keeper     OCR2PluginType = "ocr2automation"
	Functions      OCR2PluginType = "functions"
	Mercury        OCR2PluginType = "mercury"
	LLO            OCR2PluginType = "llo"
	GenericPlugin  OCR2PluginType = "plugin"
	OCR3Capability OCR2PluginType = "ocr3-capability"

	CCIPCommit    OCR2PluginType = "ccip-commit"
	CCIPExecution OCR2PluginType = "ccip-execution"
)

type OCR3CapabilityProvider

type OCR3CapabilityProvider interface {
	PluginProvider
	OCR3ContractTransmitter
}

type OCR3ContractTransmitter

type OCR3ContractTransmitter interface {
	OCR3ContractTransmitter() ocr3types.ContractTransmitter[[]byte]
}

type OracleRequest

type OracleRequest struct {
	RequestID          [32]byte
	RequestingContract ocrtypes.Account
	RequestInitiator   ocrtypes.Account
	//nolint:revive
	SubscriptionId      uint64
	SubscriptionOwner   ocrtypes.Account
	Data                []byte
	DataVersion         uint16
	Flags               [32]byte
	CallbackGasLimit    uint64
	TxHash              []byte
	CoordinatorContract ocrtypes.Account
	OnchainMetadata     []byte
}

type OracleResponse

type OracleResponse struct {
	RequestID [32]byte
}

type Plugin

type Plugin = PluginProvider

Plugin is an alias for PluginProvider, for compatibility. Deprecated

type PluginArgs

type PluginArgs struct {
	TransmitterID string
	PluginConfig  []byte
}

PluginArgs are the args required to create any OCR2 plugin components. It's possible that the plugin config might actually be different per relay type, so we pass the config directly through.

type PluginMercury

type PluginMercury interface {
	NewMercuryV1Factory(ctx context.Context, provider MercuryProvider, dataSource v1.DataSource) (MercuryPluginFactory, error)
	NewMercuryV2Factory(ctx context.Context, provider MercuryProvider, dataSource v2.DataSource) (MercuryPluginFactory, error)
	NewMercuryV3Factory(ctx context.Context, provider MercuryProvider, dataSource v3.DataSource) (MercuryPluginFactory, error)
}

type PluginProvider

type PluginProvider interface {
	ConfigProvider
	ContractTransmitter() ocrtypes.ContractTransmitter
	ChainReader() ChainReader
	Codec() Codec
}

PluginProvider provides common components for any OCR2 plugin. It watches config and is able to transmit.

type RelayArgs

type RelayArgs struct {
	ExternalJobID      uuid.UUID
	JobID              int32
	ContractID         string
	New                bool // Whether this is a first time job add.
	RelayConfig        []byte
	ProviderType       string
	MercuryCredentials *MercuryCredentials
}

type RelayID

type RelayID struct {
	Network string
	ChainID string
}

func NewRelayID

func NewRelayID(n string, c string) RelayID

func (*RelayID) Name

func (i *RelayID) Name() string

ID uniquely identifies a relayer by network and chain id

func (*RelayID) String

func (i *RelayID) String() string

func (*RelayID) UnmarshalString

func (i *RelayID) UnmarshalString(s string) error

type Relayer deprecated

type Relayer interface {
	Service
	NewConfigProvider(rargs RelayArgs) (ConfigProvider, error)
	NewMedianProvider(rargs RelayArgs, pargs PluginArgs) (MedianProvider, error)
	NewMercuryProvider(rargs RelayArgs, pargs PluginArgs) (MercuryProvider, error)
	NewFunctionsProvider(rargs RelayArgs, pargs PluginArgs) (FunctionsProvider, error)
	NewAutomationProvider(rargs RelayArgs, pargs PluginArgs) (AutomationProvider, error)
	NewLLOProvider(rargs RelayArgs, pargs PluginArgs) (LLOProvider, error)
	NewPluginProvider(rargs RelayArgs, pargs PluginArgs) (PluginProvider, error)
	NewOCR3CapabilityProvider(rargs RelayArgs, pargs PluginArgs) (OCR3CapabilityProvider, error)
}

Deprecated: use loop.Relayer, which includes context.Context.

type RemoteCodec

type RemoteCodec interface {
	Codec
	TypeProvider
}

type ReportingPluginFactory

type ReportingPluginFactory interface {
	Service
	libocr.ReportingPluginFactory
}

type Sequence

type Sequence struct {
	// This way we can retrieve past/future sequences (EVM log events) very granularly, but still hide the chain detail.
	Cursor string
	Head
	Data any
}

type Service deprecated

type Service interface {
	Name() string
	Start(context.Context) error
	Close() error
	Ready() error
	HealthReport() map[string]error
}

Deprecated: use services.Service

type TypeProvider

type TypeProvider interface {
	CreateType(itemType string, forEncoding bool) (any, error)
}

type UnimplementedError

type UnimplementedError string

func (UnimplementedError) Error

func (e UnimplementedError) Error() string

func (UnimplementedError) GRPCStatus

func (e UnimplementedError) GRPCStatus() *status.Status

func (UnimplementedError) Is

func (e UnimplementedError) Is(target error) bool

Directories

Path Synopsis
v1
v2
v3

Jump to

Keyboard shortcuts

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