chainlink

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: 80 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSecrets = errors.New("invalid secrets")

Functions

This section is empty.

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
	GetConfig() GeneralConfig
	SetLogLevel(lvl zapcore.Level) error
	GetKeyStore() keystore.Master
	GetEventBroadcaster() pg.EventBroadcaster
	WakeSessionReaper()
	GetWebAuthnConfiguration() sessions.WebAuthnConfiguration

	GetExternalInitiatorManager() webhook.ExternalInitiatorManager
	GetChains() Chains

	GetLoopRegistry() *plugins.LoopRegistry

	// V2 Jobs (TOML specified)
	JobSpawner() job.Spawner
	JobORM() job.ORM
	EVMORM() evmtypes.Configs
	PipelineORM() pipeline.ORM
	BridgeORM() bridges.ORM
	SessionORM() sessions.ORM
	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 pipeline.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
	EventBroadcaster         pg.EventBroadcaster
	MailMon                  *utils.MailboxMonitor
	SqlxDB                   *sqlx.DB
	KeyStore                 keystore.Master
	Chains                   Chains
	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
}

type ChainlinkApplication

type ChainlinkApplication struct {
	Chains           Chains
	EventBroadcaster pg.EventBroadcaster

	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) 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

func (*ChainlinkApplication) GetAuditLogger

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

func (*ChainlinkApplication) GetChains

func (app *ChainlinkApplication) GetChains() Chains

GetChains returns Chains.

func (*ChainlinkApplication) GetConfig

func (app *ChainlinkApplication) GetConfig() GeneralConfig

func (*ChainlinkApplication) GetEventBroadcaster

func (app *ChainlinkApplication) GetEventBroadcaster() pg.EventBroadcaster

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) GetLoopRegistry added in v2.2.0

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

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 pipeline.JSONSerializable) (int64, error)

func (*ChainlinkApplication) SecretGenerator

func (app *ChainlinkApplication) SecretGenerator() SecretGenerator

func (*ChainlinkApplication) SessionORM

func (app *ChainlinkApplication) SessionORM() sessions.ORM

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 Chains

type Chains struct {
	EVM      evm.ChainSet
	Cosmos   cosmos.ChainSet // nil if disabled
	Solana   loop.Relayer    // nil if disabled
	StarkNet loop.Relayer    // nil if disabled
}

Chains holds a ChainSet for each type of chain.

type Config

type Config struct {
	toml.Core

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

	Cosmos cosmos.CosmosConfigs `toml:",omitempty"`

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

	Starknet starknet.StarknetConfigs `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 utils.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 models.Duration, models.URL, utils.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

type FilePersistedSecretGenerator

type FilePersistedSecretGenerator struct{}

func (FilePersistedSecretGenerator) Generate

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

type GeneralConfig

type GeneralConfig interface {
	config.AppConfig
	toml.HasEVMConfigs
	CosmosConfigs() cosmos.CosmosConfigs
	SolanaConfigs() solana.SolanaConfigs
	StarknetConfigs() starknet.StarknetConfigs
	// 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 coreconfig.GeneralConfig for the given options.

func (*GeneralConfigOpts) Setup added in v2.4.0

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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