chainlink

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 100 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllRelayers = func(id relay.ID) bool {
	return true
}
View Source
var ErrInvalidSecrets = errors.New("invalid secrets")
View Source
var ErrNoSuchRelayer = errors.New("relayer does not exist")

Functions

func FilterRelayersByType added in v2.5.0

func FilterRelayersByType(network relay.Network) func(id relay.ID) bool

Returns true if the given network matches id.Network

Types

type Application

type Application interface {
	Start(ctx context.Context) error
	Stop() error
	GetLogger() logger.SugaredLogger
	GetAuditLogger() audit.AuditLogger
	GetHealthChecker() services.Checker
	GetSqlxDB() *sqlx.DB // Deprecated: use GetDB
	GetDB() sqlutil.DataSource
	GetConfig() GeneralConfig
	SetLogLevel(lvl zapcore.Level) error
	GetKeyStore() keystore.Master
	WakeSessionReaper()
	GetWebAuthnConfiguration() sessions.WebAuthnConfiguration

	GetExternalInitiatorManager() webhook.ExternalInitiatorManager
	GetRelayers() RelayerChainInteroperators
	GetLoopRegistry() *plugins.LoopRegistry
	GetLoopRegistrarConfig() plugins.RegistrarConfig

	// V2 Jobs (TOML specified)
	JobSpawner() job.Spawner
	JobORM() job.ORM
	EVMORM() evmtypes.Configs
	PipelineORM() pipeline.ORM
	BridgeORM() bridges.ORM
	BasicAdminUsersORM() sessions.BasicAdminUsersORM
	AuthenticationProvider() sessions.AuthenticationProvider
	TxmStorageService() txmgr.EvmTxStore
	AddJobV2(ctx context.Context, job *job.Job) error
	DeleteJob(ctx context.Context, jobID int32) error
	RunWebhookJobV2(ctx context.Context, jobUUID uuid.UUID, requestBody string, meta jsonserializable.JSONSerializable) (int64, error)
	ResumeJobV2(ctx context.Context, taskID uuid.UUID, result pipeline.Result) error
	// Testing only
	RunJobV2(ctx context.Context, jobID int32, meta map[string]interface{}) (int64, error)

	// Feeds
	GetFeedsService() feeds.Service

	// ReplayFromBlock replays logs from on or after the given block number. If forceBroadcast is
	// set to true, consumers will reprocess data even if it has already been processed.
	ReplayFromBlock(chainID *big.Int, number uint64, forceBroadcast bool) error

	// ID is unique to this particular application instance
	ID() uuid.UUID

	SecretGenerator() SecretGenerator
}

Application implements the common functions used in the core node.

func NewApplication

func NewApplication(opts ApplicationOpts) (Application, error)

NewApplication initializes a new store if one is not already present at the configured root directory (default: ~/.chainlink), the logger at the same directory and returns the Application to be used by the node. TODO: Inject more dependencies here to save booting up useless stuff in tests

type ApplicationOpts

type ApplicationOpts struct {
	Config                     GeneralConfig
	Logger                     logger.Logger
	MailMon                    *mailbox.Monitor
	SqlxDB                     *sqlx.DB // Deprecated: use DB instead
	DB                         sqlutil.DataSource
	KeyStore                   keystore.Master
	RelayerChainInteroperators *CoreRelayerChainInteroperators
	AuditLogger                audit.AuditLogger
	CloseLogger                func() error
	ExternalInitiatorManager   webhook.ExternalInitiatorManager
	Version                    string
	RestrictedHTTPClient       *http.Client
	UnrestrictedHTTPClient     *http.Client
	SecretGenerator            SecretGenerator
	LoopRegistry               *plugins.LoopRegistry
	GRPCOpts                   loop.GRPCOpts
	MercuryPool                wsrpc.Pool
}

type ChainStatuser added in v2.5.0

type ChainStatuser interface {
	ChainStatus(ctx context.Context, id relay.ID) (types.ChainStatus, error)
	ChainStatuses(ctx context.Context, offset, limit int) ([]types.ChainStatus, int, error)
}

type ChainlinkApplication

type ChainlinkApplication struct {
	FeedsService feeds.Service

	Config                   GeneralConfig
	KeyStore                 keystore.Master
	ExternalInitiatorManager webhook.ExternalInitiatorManager
	SessionReaper            *utils.SleeperTask

	HealthChecker services.Checker
	Nurse         *services.Nurse

	AuditLogger audit.AuditLogger
	// contains filtered or unexported fields
}

ChainlinkApplication contains fields for the JobSubscriber, Scheduler, and Store. The JobSubscriber and Scheduler are also available in the services package, but the Store has its own package.

func (*ChainlinkApplication) AddJobV2

func (app *ChainlinkApplication) AddJobV2(ctx context.Context, j *job.Job) error

func (*ChainlinkApplication) AuthenticationProvider added in v2.8.0

func (app *ChainlinkApplication) AuthenticationProvider() sessions.AuthenticationProvider

func (*ChainlinkApplication) BasicAdminUsersORM added in v2.8.0

func (app *ChainlinkApplication) BasicAdminUsersORM() sessions.BasicAdminUsersORM

func (*ChainlinkApplication) BridgeORM

func (app *ChainlinkApplication) BridgeORM() bridges.ORM

func (*ChainlinkApplication) DeleteJob

func (app *ChainlinkApplication) DeleteJob(ctx context.Context, jobID int32) error

func (*ChainlinkApplication) EVMORM

func (app *ChainlinkApplication) EVMORM() evmtypes.Configs

TODO BCF-2516 remove this all together remove EVM specifics

func (*ChainlinkApplication) GetAuditLogger

func (app *ChainlinkApplication) GetAuditLogger() audit.AuditLogger

func (*ChainlinkApplication) GetConfig

func (app *ChainlinkApplication) GetConfig() GeneralConfig

func (*ChainlinkApplication) GetDB added in v2.11.0

func (*ChainlinkApplication) GetExternalInitiatorManager

func (app *ChainlinkApplication) GetExternalInitiatorManager() webhook.ExternalInitiatorManager

func (*ChainlinkApplication) GetFeedsService

func (app *ChainlinkApplication) GetFeedsService() feeds.Service

func (*ChainlinkApplication) GetHealthChecker

func (app *ChainlinkApplication) GetHealthChecker() services.Checker

func (*ChainlinkApplication) GetKeyStore

func (app *ChainlinkApplication) GetKeyStore() keystore.Master

func (*ChainlinkApplication) GetLogger

func (app *ChainlinkApplication) GetLogger() logger.SugaredLogger

func (*ChainlinkApplication) GetLoopRegistrarConfig added in v2.11.0

func (app *ChainlinkApplication) GetLoopRegistrarConfig() plugins.RegistrarConfig

func (*ChainlinkApplication) GetLoopRegistry added in v2.2.0

func (app *ChainlinkApplication) GetLoopRegistry() *plugins.LoopRegistry

func (*ChainlinkApplication) GetRelayers added in v2.5.0

func (*ChainlinkApplication) GetSqlxDB

func (app *ChainlinkApplication) GetSqlxDB() *sqlx.DB

func (*ChainlinkApplication) GetWebAuthnConfiguration

func (app *ChainlinkApplication) GetWebAuthnConfiguration() sessions.WebAuthnConfiguration

Returns the configuration to use for creating and authenticating new WebAuthn credentials

func (*ChainlinkApplication) ID

func (app *ChainlinkApplication) ID() uuid.UUID

func (*ChainlinkApplication) JobORM

func (app *ChainlinkApplication) JobORM() job.ORM

func (*ChainlinkApplication) JobSpawner

func (app *ChainlinkApplication) JobSpawner() job.Spawner

func (*ChainlinkApplication) PipelineORM

func (app *ChainlinkApplication) PipelineORM() pipeline.ORM

func (*ChainlinkApplication) ReplayFromBlock

func (app *ChainlinkApplication) ReplayFromBlock(chainID *big.Int, number uint64, forceBroadcast bool) error

ReplayFromBlock implements the Application interface.

func (*ChainlinkApplication) ResumeJobV2

func (app *ChainlinkApplication) ResumeJobV2(
	ctx context.Context,
	taskID uuid.UUID,
	result pipeline.Result,
) error

func (*ChainlinkApplication) RunJobV2

func (app *ChainlinkApplication) RunJobV2(
	ctx context.Context,
	jobID int32,
	meta map[string]interface{},
) (int64, error)

Only used for local testing, not supported by the UI.

func (*ChainlinkApplication) RunWebhookJobV2

func (app *ChainlinkApplication) RunWebhookJobV2(ctx context.Context, jobUUID uuid.UUID, requestBody string, meta jsonserializable.JSONSerializable) (int64, error)

func (*ChainlinkApplication) SecretGenerator

func (app *ChainlinkApplication) SecretGenerator() SecretGenerator

func (*ChainlinkApplication) SetLogLevel

func (app *ChainlinkApplication) SetLogLevel(lvl zapcore.Level) error

func (*ChainlinkApplication) Start

func (app *ChainlinkApplication) Start(ctx context.Context) error

Start all necessary services. If successful, nil will be returned. Start sequence is aborted if the context gets cancelled.

func (*ChainlinkApplication) Stop

func (app *ChainlinkApplication) Stop() error

Stop allows the application to exit by halting schedules, closing logs, and closing the DB connection.

func (*ChainlinkApplication) StopIfStarted

func (app *ChainlinkApplication) StopIfStarted() error

func (*ChainlinkApplication) TxmStorageService added in v2.1.0

func (app *ChainlinkApplication) TxmStorageService() txmgr.EvmTxStore

func (*ChainlinkApplication) WakeSessionReaper

func (app *ChainlinkApplication) WakeSessionReaper()

WakeSessionReaper wakes up the reaper to do its reaping.

type ChainsNodesStatuser added in v2.5.0

type ChainsNodesStatuser interface {
	ChainStatuser
	NodesStatuser
}

ChainsNodesStatuser report statuses about chains and nodes

type Config

type Config struct {
	toml.Core

	EVM evmcfg.EVMConfigs `toml:",omitempty"`

	Cosmos coscfg.TOMLConfigs `toml:",omitempty"`

	Solana solana.TOMLConfigs `toml:",omitempty"`

	Starknet stkcfg.TOMLConfigs `toml:",omitempty"`
}

Config is the root type used for TOML configuration.

See docs at /docs/CONFIG.md generated via config.GenerateDocs from /internal/config/docs.toml

When adding a new field:

  • consider including a unit suffix with the field name
  • TOML is limited to int64/float64, so fields requiring greater range/precision must use non-standard types implementing encoding.TextMarshaler/TextUnmarshaler, like big.Big and decimal.Decimal
  • std lib types that don't implement encoding.TextMarshaler/TextUnmarshaler (time.Duration, url.URL, big.Int) won't work as expected, and require wrapper types. See commonconfig.Duration, commonconfig.URL, big.Big.

func (*Config) SetFrom

func (c *Config) SetFrom(f *Config) (err error)

func (*Config) TOMLString

func (c *Config) TOMLString() (string, error)

TOMLString returns a TOML encoded string.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if the Config is not valid for use, as-is. This is typically used after defaults have been applied.

type CoreRelayerChainInitFunc added in v2.5.0

type CoreRelayerChainInitFunc func(op *CoreRelayerChainInteroperators) error

CoreRelayerChainInitFunc is a hook in the constructor to create relayers from a factory.

func InitCosmos added in v2.5.0

InitCosmos is a option for instantiating Cosmos relayers

func InitEVM added in v2.5.0

InitEVM is a option for instantiating evm relayers

func InitSolana added in v2.5.0

InitSolana is a option for instantiating Solana relayers

func InitStarknet added in v2.5.0

InitStarknet is a option for instantiating Starknet relayers

type CoreRelayerChainInteroperators added in v2.5.0

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

CoreRelayerChainInteroperators implements RelayerChainInteroperators as needed for the core chainlink.Application

func NewCoreRelayerChainInteroperators added in v2.5.0

func NewCoreRelayerChainInteroperators(initFuncs ...CoreRelayerChainInitFunc) (*CoreRelayerChainInteroperators, error)

func (*CoreRelayerChainInteroperators) ChainStatus added in v2.5.0

ChainStatus gets [types.ChainStatus]

func (*CoreRelayerChainInteroperators) ChainStatuses added in v2.5.0

func (rs *CoreRelayerChainInteroperators) ChainStatuses(ctx context.Context, offset, limit int) ([]types.ChainStatus, int, error)

func (*CoreRelayerChainInteroperators) Get added in v2.5.0

Get a loop.Relayer by id

func (*CoreRelayerChainInteroperators) LegacyCosmosChains added in v2.5.0

func (rs *CoreRelayerChainInteroperators) LegacyCosmosChains() LegacyCosmosContainer

LegacyCosmosChains returns a container with all the cosmos chains TODO BCF-2511

func (*CoreRelayerChainInteroperators) LegacyEVMChains added in v2.5.0

LegacyEVMChains returns a container with all the evm chains TODO BCF-2511

func (*CoreRelayerChainInteroperators) List added in v2.5.0

List returns all the RelayerChainInteroperators that match the FilterFn. A typical usage pattern to use [List] with [FilterByType] to obtain a set of RelayerChainInteroperators for a given chain

func (*CoreRelayerChainInteroperators) Node added in v2.5.0

func (*CoreRelayerChainInteroperators) NodeStatuses added in v2.5.0

func (rs *CoreRelayerChainInteroperators) NodeStatuses(ctx context.Context, offset, limit int, relayerIDs ...relay.ID) (nodes []types.NodeStatus, count int, err error)

ids must be a string representation of relay.Identifier ids are a filter; if none are specified, all are returned.

func (*CoreRelayerChainInteroperators) Services added in v2.5.0

func (rs *CoreRelayerChainInteroperators) Services() (s []services.ServiceCtx)

func (*CoreRelayerChainInteroperators) Slice added in v2.5.0

Returns a slice of loop.Relayer. A typically usage pattern to is use [List(criteria)].Slice() for range based operations

type CosmosFactoryConfig added in v2.5.0

type CosmosFactoryConfig struct {
	Keystore keystore.Cosmos
	coscfg.TOMLConfigs
	*sqlx.DB
	pg.QConfig
}

func (CosmosFactoryConfig) Validate added in v2.6.0

func (c CosmosFactoryConfig) Validate() error

type CosmosLoopRelayerChain added in v2.8.0

type CosmosLoopRelayerChain struct {
	loop.Relayer
	// contains filtered or unexported fields
}

func NewCosmosLoopRelayerChain added in v2.8.0

func NewCosmosLoopRelayerChain(r *cosmos.Relayer, s adapters.Chain) *CosmosLoopRelayerChain

func (*CosmosLoopRelayerChain) Chain added in v2.8.0

type CosmosLoopRelayerChainer added in v2.8.0

type CosmosLoopRelayerChainer interface {
	loop.Relayer
	Chain() adapters.Chain
}

type EVMFactoryConfig added in v2.5.0

type EVMFactoryConfig struct {
	legacyevm.ChainOpts
	evmrelay.CSAETHKeystore
}

type FilePersistedSecretGenerator

type FilePersistedSecretGenerator struct{}

func (FilePersistedSecretGenerator) Generate

func (f FilePersistedSecretGenerator) Generate(rootDir string) ([]byte, error)

type FilterFn added in v2.5.0

type FilterFn func(id relay.ID) bool

type GeneralConfig

type GeneralConfig interface {
	config.AppConfig
	toml.HasEVMConfigs
	CosmosConfigs() coscfg.TOMLConfigs
	SolanaConfigs() solana.TOMLConfigs
	StarknetConfigs() stkcfg.TOMLConfigs
	// ConfigTOML returns both the user provided and effective configuration as TOML.
	ConfigTOML() (user, effective string)
}

type GeneralConfigOpts

type GeneralConfigOpts struct {
	ConfigStrings  []string
	SecretsStrings []string

	Config
	Secrets

	// OverrideFn is a *test-only* hook to override effective values.
	OverrideFn func(*Config, *Secrets)

	SkipEnv bool
}

GeneralConfigOpts holds configuration options for creating a coreconfig.GeneralConfig via New().

See ParseTOML to initilialize Config and Secrets from TOML.

func (GeneralConfigOpts) New

New returns a GeneralConfig for the given options.

func (*GeneralConfigOpts) Setup added in v2.4.0

func (o *GeneralConfigOpts) Setup(configFiles []string, secretsFiles []string) error

type LegacyChainer added in v2.5.0

type LegacyChainer interface {
	LegacyEVMChains() legacyevm.LegacyChainContainer
	LegacyCosmosChains() LegacyCosmosContainer
}

LegacyChainer is an interface for getting legacy chains This will be deprecated/removed when products depend only on the relayer interface.

type LegacyCosmos added in v2.8.0

type LegacyCosmos = chains.ChainsKV[adapters.Chain]

func NewLegacyCosmos added in v2.8.0

func NewLegacyCosmos(m map[string]adapters.Chain) *LegacyCosmos

type LegacyCosmosContainer added in v2.8.0

type LegacyCosmosContainer interface {
	Get(id string) (adapters.Chain, error)
	Len() int
	List(ids ...string) ([]adapters.Chain, error)
	Slice() []adapters.Chain
}

LegacyCosmosContainer is container interface for Cosmos chains

type LoopRelayerStorer added in v2.5.0

type LoopRelayerStorer interface {
	ocr2.RelayGetter
	Slice() []loop.Relayer
}

LoopRelayerStorer is key-value like interface for storing and retrieving loop.Relayer

type NodesStatuser added in v2.6.0

type NodesStatuser interface {
	NodeStatuses(ctx context.Context, offset, limit int, relayIDs ...relay.ID) (nodes []types.NodeStatus, count int, err error)
}

NodesStatuser is an interface for node configuration and state. TODO BCF-2440, BCF-2511 may need Node(ctx,name) to get a node status by name

type RelayerChainInteroperators added in v2.5.0

type RelayerChainInteroperators interface {
	Services() []services.ServiceCtx

	List(filter FilterFn) RelayerChainInteroperators

	LoopRelayerStorer
	LegacyChainer
	ChainsNodesStatuser
}

RelayerChainInteroperators encapsulates relayers and chains and is the primary entry point for the node to access relayers, get legacy chains associated to a relayer and get status about the chains and nodes

type RelayerFactory added in v2.5.0

type RelayerFactory struct {
	logger.Logger
	*plugins.LoopRegistry
	loop.GRPCOpts
	MercuryPool wsrpc.Pool
}

func (*RelayerFactory) NewCosmos added in v2.5.0

func (*RelayerFactory) NewEVM added in v2.5.0

func (*RelayerFactory) NewSolana added in v2.5.0

func (r *RelayerFactory) NewSolana(ks keystore.Solana, chainCfgs solana.TOMLConfigs) (map[relay.ID]loop.Relayer, error)

func (*RelayerFactory) NewStarkNet added in v2.5.0

func (r *RelayerFactory) NewStarkNet(ks keystore.StarkNet, chainCfgs config.TOMLConfigs) (map[relay.ID]loop.Relayer, error)

TODO BCF-2606 consider consolidating the driving logic with that of NewSolana above via generics perhaps when we implement a Cosmos LOOP

type SecretGenerator

type SecretGenerator interface {
	Generate(string) ([]byte, error)
}

SecretGenerator is the interface for objects that generate a secret used to sign or encrypt.

type Secrets

type Secrets struct {
	toml.Secrets
}

func (*Secrets) SetFrom added in v2.4.0

func (s *Secrets) SetFrom(f *Secrets) (err error)

func (*Secrets) TOMLString

func (s *Secrets) TOMLString() (string, error)

TOMLString returns a TOML encoded string with secret values redacted.

func (*Secrets) Validate

func (s *Secrets) Validate() error

Validate validates every consitutent secret and return an accumulated error

func (*Secrets) ValidateDB added in v2.2.0

func (s *Secrets) ValidateDB() error

ValidateDB only validates the encompassed DatabaseSecret

type SolanaFactoryConfig added in v2.5.0

type SolanaFactoryConfig struct {
	Keystore keystore.Solana
	solana.TOMLConfigs
}

type StarkNetFactoryConfig added in v2.5.0

type StarkNetFactoryConfig struct {
	Keystore keystore.StarkNet
	config.TOMLConfigs
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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