config

package
v1.96.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 17 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init should be called at the beginning of execution to load base configuration and generate dependent configuration files. The defaults for the config package will be loaded from values defined in defaults.yaml in this package, then overridden the corresponding environment variables.

func InitBifrost

func InitBifrost()

func InitThornode

func InitThornode(ctx context.Context)

Types

type Bifrost

type Bifrost struct {
	Signer    BifrostSignerConfiguration                 `mapstructure:"signer"`
	Thorchain BifrostClientConfiguration                 `mapstructure:"thorchain"`
	Metrics   BifrostMetricsConfiguration                `mapstructure:"metrics"`
	Chains    map[common.Chain]BifrostChainConfiguration `mapstructure:"chains"`
	TSS       BifrostTSSConfiguration                    `mapstructure:"tss"`
	BackOff   BifrostBackOff                             `mapstructure:"back_off"`
}

func GetBifrost

func GetBifrost() Bifrost

GetBifrost returns the global thornode configuration.

type BifrostBackOff

type BifrostBackOff struct {
	InitialInterval     time.Duration `mapstructure:"initial_interval"`
	RandomizationFactor float64       `mapstructure:"randomization_factor"`
	Multiplier          float64       `mapstructure:"multiplier"`
	MaxInterval         time.Duration `mapstructure:"max_interval"`
	MaxElapsedTime      time.Duration `mapstructure:"max_elapsed_time"`
}

type BifrostBlockScannerConfiguration

type BifrostBlockScannerConfiguration struct {
	RPCHost                    string        `mapstructure:"rpc_host"`
	CosmosGRPCHost             string        `mapstructure:"cosmos_grpc_host"`
	CosmosGRPCTLS              bool          `mapstructure:"cosmos_grpc_tls"`
	StartBlockHeight           int64         `mapstructure:"start_block_height"`
	BlockScanProcessors        int           `mapstructure:"block_scan_processors"`
	HTTPRequestTimeout         time.Duration `mapstructure:"http_request_timeout"`
	HTTPRequestReadTimeout     time.Duration `mapstructure:"http_request_read_timeout"`
	HTTPRequestWriteTimeout    time.Duration `mapstructure:"http_request_write_timeout"`
	MaxHTTPRequestRetry        int           `mapstructure:"max_http_request_retry"`
	BlockHeightDiscoverBackoff time.Duration `mapstructure:"block_height_discover_back_off"`
	BlockRetryInterval         time.Duration `mapstructure:"block_retry_interval"`
	EnforceBlockHeight         bool          `mapstructure:"enforce_block_height"`
	DBPath                     string        `mapstructure:"db_path"`
	ChainID                    common.Chain  `mapstructure:"chain_id"`
	SuggestedFeeVersion        int           `mapstructure:"suggested_fee_version"`
	GasCacheSize               int           `mapstructure:"gas_cache_size"`
	Concurrency                int64         `mapstructure:"concurrency"`
}

func (*BifrostBlockScannerConfiguration) Validate

func (b *BifrostBlockScannerConfiguration) Validate()

type BifrostChainConfiguration

type BifrostChainConfiguration struct {
	ChainID             common.Chain                     `mapstructure:"chain_id"`
	ChainHost           string                           `mapstructure:"chain_host"`
	ChainNetwork        string                           `mapstructure:"chain_network"`
	UserName            string                           `mapstructure:"username"`
	Password            string                           `mapstructure:"password"`
	RPCHost             string                           `mapstructure:"rpc_host"`
	CosmosGRPCHost      string                           `mapstructure:"cosmos_grpc_host"`
	CosmosGRPCTLS       bool                             `mapstructure:"cosmos_grpc_tls"`
	HTTPostMode         bool                             `mapstructure:"http_post_mode"` // Bitcoin core only supports HTTP POST mode
	DisableTLS          bool                             `mapstructure:"disable_tls"`    // Bitcoin core does not provide TLS by default
	BlockScanner        BifrostBlockScannerConfiguration `mapstructure:"block_scanner"`
	BackOff             BifrostBackOff                   `mapstructure:"back_off"`
	OptToRetire         bool                             `mapstructure:"opt_to_retire"` // don't emit support for this chain during keygen process
	ParallelMempoolScan int                              `mapstructure:"parallel_mempool_scan"`
	Disabled            bool                             `mapstructure:"disabled"`
}

func (*BifrostChainConfiguration) Validate

func (b *BifrostChainConfiguration) Validate()

type BifrostClientConfiguration

type BifrostClientConfiguration struct {
	ChainID         common.Chain `mapstructure:"chain_id" `
	ChainHost       string       `mapstructure:"chain_host"`
	ChainRPC        string       `mapstructure:"chain_rpc"`
	ChainHomeFolder string       `mapstructure:"chain_home_folder"`
	SignerName      string       `mapstructure:"signer_name"`
	SignerPasswd    string
	BackOff         BifrostBackOff `mapstructure:"back_off"`
}

type BifrostMetricsConfiguration

type BifrostMetricsConfiguration struct {
	Enabled      bool           `mapstructure:"enabled"`
	PprofEnabled bool           `mapstructure:"pprof_enabled"`
	ListenPort   int            `mapstructure:"listen_port"`
	ReadTimeout  time.Duration  `mapstructure:"read_timeout"`
	WriteTimeout time.Duration  `mapstructure:"write_timeout"`
	Chains       []common.Chain `mapstructure:"chains"`
}

type BifrostSignerConfiguration

type BifrostSignerConfiguration struct {
	SignerDbPath  string                           `mapstructure:"signer_db_path"`
	BlockScanner  BifrostBlockScannerConfiguration `mapstructure:"block_scanner"`
	RetryInterval time.Duration                    `mapstructure:"retry_interval"`
}

type BifrostTSSConfiguration

type BifrostTSSConfiguration struct {
	BootstrapPeers []string `mapstructure:"bootstrap_peers"`
	Rendezvous     string   `mapstructure:"rendezvous"`
	P2PPort        int      `mapstructure:"p2p_port"`
	InfoAddress    string   `mapstructure:"info_address"`
	ExternalIP     string   `mapstructure:"external_ip"`
}

func (BifrostTSSConfiguration) GetBootstrapPeers

func (c BifrostTSSConfiguration) GetBootstrapPeers() ([]maddr.Multiaddr, error)

GetBootstrapPeers return the internal bootstrap peers in a slice of maddr.Multiaddr

type Config

type Config struct {
	Thornode Thornode `mapstructure:"thor"`
	Bifrost  Bifrost  `mapstructure:"bifrost"`
}

type Thornode

type Thornode struct {
	AutoStateSync struct {
		Enabled bool `mapstructure:"enabled"`

		// BlockBuffer is the number of blocks in the past we will automatically reference
		// for the trust state from one of the configured RPC endpoints.
		BlockBuffer int64 `mapstructure:"block_buffer"`

		// Peers will be used to template the persistent peers in the Tendermint P2P config
		// on the first launch. These peers are static and typically provided by benevolent
		// community members, since the statesync snapshot creation is very expensive and
		// cannot be enabled on nodes unless they are willing to fall behind for a few hours
		// while the snapshots create. Once the initial snapshot is recovered, subsequent
		// restarts will unset the fixed persistent peers to free up peer slots on nodes
		// that are known statesync providers.
		Peers []string `mapstructure:"peers"`
	} `mapstructure:"auto_state_sync"`

	API struct {
		LimitCount    float64       `mapstructure:"limit_count"`
		LimitDuration time.Duration `mapstructure:"limit_duration"`
	} `mapstructure:"api"`

	// Cosmos contains values used in templating the Cosmos app.toml.
	Cosmos struct {
		Pruning         string `mapstructure:"pruning"`
		HaltHeight      int64  `mapstructure:"halt_height"`
		MinRetainBlocks int64  `mapstructure:"min_retain_blocks"`

		Telemetry struct {
			Enabled                 bool  `mapstructure:"enabled"`
			PrometheusRetentionTime int64 `mapstructure:"prometheus_retention_time"`
		} `mapstructure:"telemetry"`

		API struct {
			Enable            bool `mapstructure:"enable"`
			EnabledUnsafeCORS bool `mapstructure:"enabled_unsafe_cors"`
		} `mapstructure:"api"`

		StateSync struct {
			SnapshotInterval   int64 `mapstructure:"snapshot_interval"`
			SnapshotKeepRecent int64 `mapstructure:"snapshot_keep_recent"`
		} `mapstructure:"state_sync"`
	} `mapstructure:"cosmos"`

	// Tendermint contains values used in templating the Tendermint config.toml.
	Tendermint struct {
		Consensus struct {
			TimeoutCommit time.Duration `mapstructure:"timeout_commit"`
		} `mapstructure:"consensus"`

		Log struct {
			Level  string `mapstructure:"level"`
			Format string `mapstructure:"format"`
		} `mapstructure:"log"`

		RPC struct {
			ListenAddress     string `mapstructure:"listen_address"`
			CORSAllowedOrigin string `mapstructure:"cors_allowed_origin"`
		} `mapstructure:"rpc"`

		P2P struct {
			ExternalAddress     string `mapstructure:"external_address"`
			ListenAddress       string `mapstructure:"listen_address"`
			PersistentPeers     string `mapstructure:"persistent_peers"`
			AddrBookStrict      bool   `mapstructure:"addr_book_strict"`
			MaxNumInboundPeers  int64  `mapstructure:"max_num_inbound_peers"`
			MaxNumOutboundPeers int64  `mapstructure:"max_num_outbound_peers"`
			AllowDuplicateIP    bool   `mapstructure:"allow_duplicate_ip"`
			Seeds               string `mapstructure:"seeds"`
		} `mapstructure:"p2p"`

		StateSync struct {
			Enable      bool   `mapstructure:"enable"`
			RPCServers  string `mapstructure:"rpc_servers"`
			TrustHeight int64  `mapstructure:"trust_height"`
			TrustHash   string `mapstructure:"trust_hash"`
			TrustPeriod string `mapstructure:"trust_period"`
		} `mapstructure:"state_sync"`

		Instrumentation struct {
			Prometheus bool `mapstructure:"prometheus"`
		} `mapstructure:"instrumentation"`
	} `mapstructure:"tendermint"`
}

func GetThornode

func GetThornode() Thornode

GetThornode returns the global thornode configuration.

Jump to

Keyboard shortcuts

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