config

package
v0.0.79 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config contains the config for different kinds of agents

Index

Constants

This section is empty.

Variables

View Source
var AllSignerTypes []SignerType

AllSignerTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.

View Source
var ErrInvalidChainType error

ErrInvalidChainType indicates chain type was invalid.

View Source
var ErrInvalidDomainID = errors.New("domain ID invalid")

ErrInvalidDomainID indicates domain id is invalid.

View Source
var ErrRequiredField = errors.New("field is required")

ErrRequiredField indicates a required field was left blank.

View Source
var ErrUnsupportedSignerType = errors.New("unsupported signer type")

ErrUnsupportedSignerType indicates the signer type being used is unsupported.

Functions

func SignerFromConfig

func SignerFromConfig(config SignerConfig) (signer.Signer, error)

SignerFromConfig creates a new signer from a signer config. TODO: this needs to be moved to some kind of common package. in the old code configs were split into responsible packages. Maybe something like that works here?

Types

type Config

type Config struct {
	// Domains stores all domains
	Domains DomainConfigs `toml:"Domains"`
	// Signer contains the signer config for agents
	Signer SignerConfig `toml:"Signer"`
	// DbConfig is the database config
	Database DBConfig `toml:"Database"`
}

Config is used for configuring the application. It stores the configurations defined in each module.

func (*Config) IsValid

func (c *Config) IsValid(ctx context.Context) (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type DBConfig

type DBConfig struct {
	// Type of the database to use for sql. This does not affect hte pebble db
	Type string `toml:"Type"`
	// DBPath is the db path used for the pebble db
	DBPath string `toml:"DBPath"`
	// ConnString is the connection string used for mysql
	ConnString string `toml:"ConnString"`
}

DBConfig is used for configuring the.

func (*DBConfig) IsValid

func (d *DBConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid asserts the database connection is valid.

type DomainConfig

type DomainConfig struct {
	// DomainID is the domain of the chain
	DomainID uint32 `toml:"Domain"`
	// Type of the chain (e.g. evm)
	Type string `toml:"Type"`
	// RequiredConfirmations is the number of confirmations to way
	RequiredConfirmations uint32 `toml:"ConfirmationsThreshold"`
	// OriginAddress gets origin contract address
	OriginAddress string `toml:"OriginAddress"`
	// AttestationCollectorAddress contains the attestation collector address (if present)
	AttestationCollectorAddress string `toml:"AttestationCollectorAddress"`
	// DestinationAddress gets destination contract address
	DestinationAddress string `toml:"DestinationAddress"`
	// RPCUrl to use for the chain
	RPCUrl string `toml:"RPCURL"`
	// Minimum start height
	StartHeight uint32 `toml:"StartHeight"`
}

DomainConfig defines the config for a specific domain.

func (DomainConfig) IsValid

func (d DomainConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid validates the domain config.

type DomainConfigs

type DomainConfigs map[string]DomainConfig

DomainConfigs contains a map of name->domain config.

func (DomainConfigs) IsValid

func (d DomainConfigs) IsValid(ctx context.Context) (ok bool, err error)

IsValid validates the domain configs by asserting no two domains appear twice it also calls IsValid on each individual DomainConfig.

type GuardConfig added in v0.0.68

type GuardConfig struct {
	// OriginDomains stores all origin domains
	OriginDomains DomainConfigs `toml:"OriginDomains"`
	// AttestationDomain stores the attestaion domain
	AttestationDomain DomainConfig `toml:"AttestationDomain"`
	// DestinationDomains stores all destination domains
	DestinationDomains DomainConfigs `toml:"DestinationDomains"`
	// UnbondedSigner contains the unbonded signer config for agents
	// (this is signer used to submit transactions)
	UnbondedSigner SignerConfig `toml:"UnbondedSigner"`
	// BondedSigner contains the bonded signer config for agents
	BondedSigner SignerConfig `toml:"BondedSigner"`
	// DbConfig is the database config
	Database DBConfig `toml:"Database"`
	// RefreshIntervalInSeconds is how long to wait before refreshing the Notary state
	RefreshIntervalInSeconds int64 `toml:"RefreshIntervalInSeconds"`
}

GuardConfig is used for configuring the guard.

func (*GuardConfig) IsValid added in v0.0.68

func (c *GuardConfig) IsValid(ctx context.Context) (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type NotaryConfig added in v0.0.58

type NotaryConfig struct {
	// OriginDomains stores all origin domains
	OriginDomains DomainConfigs `toml:"OriginDomains"`
	// AttestationDomain stores the attestaion domain
	AttestationDomain DomainConfig `toml:"AttestationDomain"`
	// DestinationDomain stores  the destination domain
	DestinationDomain DomainConfig `toml:"DestinationDomain"`
	// UnbondedSigner contains the unbonded signer config for agents
	// (this is signer used to submit transactions)
	UnbondedSigner SignerConfig `toml:"UnbondedSigner"`
	// BondedSigner contains the bonded signer config for agents
	BondedSigner SignerConfig `toml:"BondedSigner"`
	// DbConfig is the database config
	Database DBConfig `toml:"Database"`
	// RefreshIntervalInSeconds is how long to wait before refreshing the Notary state
	RefreshIntervalInSeconds int64 `toml:"RefreshIntervalInSeconds"`
}

NotaryConfig is used for configuring the notary.

func (*NotaryConfig) IsValid added in v0.0.58

func (c *NotaryConfig) IsValid(ctx context.Context) (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type SignerConfig

type SignerConfig struct {
	// Type is the driver used for the signer
	Type string
	// File is the file used for the key.
	File string
}

SignerConfig contains a signer config. Currently this config only supports local based signers due to a lack of isomorphic types when we parse yaml.

func (SignerConfig) IsValid

func (s SignerConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid determines if the config is valid.

type SignerType

type SignerType int

SignerType is the signer type

const (
	// FileType is a file-based signer.
	FileType SignerType = 0 // File
	// KMSType is a non-file based signer.
	KMSType SignerType = iota // KMS
)

func (SignerType) String

func (i SignerType) String() string

Jump to

Keyboard shortcuts

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