config

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config enables config file parsing.

Index

Constants

This section is empty.

Variables

View Source
var DefaultChains = map[common.ChainName]*History{
	common.ChainNameMainnet: {
		Records: []*Record{
			{

				ArchiveName:   "damask",
				GenesisHeight: 8048956,
				RuntimeStartRounds: map[common.Runtime]uint64{
					common.RuntimeCipher:   8284,
					common.RuntimeEmerald:  1003298,
					common.RuntimeSapphire: 0,
				},
				ChainContext: "b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535",
			},
			{

				ArchiveName:   "cobalt",
				GenesisHeight: 3027601,
				RuntimeStartRounds: map[common.Runtime]uint64{
					common.RuntimeCipher:  0,
					common.RuntimeEmerald: 0,
				},
				ChainContext: "53852332637bacb61b91b6411ab4095168ba02a50be4c3f82448438826f23898",
			},
			{

				ArchiveName:   "mainnet",
				GenesisHeight: 702000,
				ChainContext:  "a4dc2c4537992d6d2908c9779927ccfee105830250d903fd1abdfaf42cb45631",
			},
			{

				ArchiveName:   "beta",
				GenesisHeight: 1,
				ChainContext:  "a245619497e580dd3bc1aa3256c07f68b8dcc13f92da115eadc3b231b083d3c4",
			},
		},
	},
	common.ChainNameTestnet: {
		Records: []*Record{
			{

				ArchiveName:   "2022-03-03",
				GenesisHeight: 8535081,
				ChainContext:  "50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a",
				RuntimeStartRounds: map[common.Runtime]uint64{
					common.RuntimeCipher:   1675996,
					common.RuntimeEmerald:  398623,
					common.RuntimeSapphire: 0,
				},
			},
			{

				ArchiveName:   "2021-04-13",
				GenesisHeight: 3398334,
				ChainContext:  "5ba68bc5e01e06f755c4c044dd11ec508e4c17f1faf40c0e67874388437a9e55",
				RuntimeStartRounds: map[common.Runtime]uint64{
					common.RuntimeCipher:  0,
					common.RuntimeEmerald: 0,
				},
			},
			{

				ArchiveName:   "2021-03-24",
				GenesisHeight: 3076800,
				ChainContext:  "TODO-UNKNOWN",
			},
			{

				ArchiveName:   "2021-02-03",
				GenesisHeight: 2284801,
				ChainContext:  "TODO-UNKNOWN",
			},
			{

				ArchiveName:   "2020-11-04",
				GenesisHeight: 811055,
				ChainContext:  "TODO-UNKNOWN",
			},
			{

				ArchiveName:   "2020-09-15",
				GenesisHeight: 1,
				ChainContext:  "TODO-UNKNOWN",
			},
		},
	},
}

Functions

func SingleNetworkLookup

func SingleNetworkLookup(rpc string) map[string]*ArchiveConfig

Types

type AggregateStatsConfig

type AggregateStatsConfig struct{}

AggregateStatsConfig is the configuration for the aggregate stats analyzer.

func (*AggregateStatsConfig) Validate

func (cfg *AggregateStatsConfig) Validate() error

type AnalysisConfig

type AnalysisConfig struct {
	// Source is the configuration for accessing oasis-node(s).
	Source SourceConfig `koanf:"source"`

	// Analyzers is the analyzer configs.
	Analyzers AnalyzersList `koanf:"analyzers"`

	Storage *StorageConfig `koanf:"storage"`
}

AnalysisConfig is the configuration for chain analyzers.

func (*AnalysisConfig) Validate

func (cfg *AnalysisConfig) Validate() error

Validate validates the analysis configuration.

type AnalyzersList

type AnalyzersList struct {
	Consensus *BlockBasedAnalyzerConfig `koanf:"consensus"`
	Emerald   *BlockBasedAnalyzerConfig `koanf:"emerald"`
	Sapphire  *BlockBasedAnalyzerConfig `koanf:"sapphire"`
	Cipher    *BlockBasedAnalyzerConfig `koanf:"cipher"`

	EmeraldEvmTokens         *EvmTokensAnalyzerConfig       `koanf:"evm_tokens_emerald"`
	SapphireEvmTokens        *EvmTokensAnalyzerConfig       `koanf:"evm_tokens_sapphire"`
	EmeraldEvmTokenBalances  *EvmTokensAnalyzerConfig       `koanf:"evm_token_balances_emerald"`
	SapphireEvmTokenBalances *EvmTokensAnalyzerConfig       `koanf:"evm_token_balances_sapphire"`
	EmeraldContractCode      *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_emerald"`
	SapphireContractCode     *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_sapphire"`

	MetadataRegistry     *MetadataRegistryConfig     `koanf:"metadata_registry"`
	AggregateStats       *AggregateStatsConfig       `koanf:"aggregate_stats"`
	EVMContractsVerifier *EVMContractsVerifierConfig `koanf:"evm_contracts_verifier"`
}

type ArchiveConfig

type ArchiveConfig struct {
	// DefaultNode is information about the node to get data from by default.
	DefaultNode *NodeConfig `koanf:"default"`
	// ConsensusNode is information about the node to get consensus data from,
	// instead of the default node.
	ConsensusNode *NodeConfig `koanf:"consensus"`
	// RuntimeNodes is the information about the nodes to get runtime data
	// from, instead of the default node.
	RuntimeNodes map[common.Runtime]*NodeConfig `koanf:"runtimes"`
}

ArchiveConfig is information about the nodes for a network.

func (*ArchiveConfig) ResolvedConsensusNode

func (ac *ArchiveConfig) ResolvedConsensusNode() *NodeConfig

func (*ArchiveConfig) ResolvedRuntimeNode

func (ac *ArchiveConfig) ResolvedRuntimeNode(runtime common.Runtime) *NodeConfig

type BlockBasedAnalyzerConfig

type BlockBasedAnalyzerConfig struct {
	// From is the (inclusive) starting block for this analyzer.
	From uint64 `koanf:"from"`

	// To is the (inclusive) ending block for this analyzer.
	// Omitting this parameter means this analyzer will
	// continue processing new blocks until the next breaking
	// upgrade.
	To uint64 `koanf:"to"`

	// BatchSize determines the maximum number of blocks the block analyzer
	// processes per batch. This is relevant only when the analyzer is
	// still catching up to the latest block.
	// Optimal value depends on block processing speed. Ideally, it should
	// be set to the number of blocks processed within 30-60 seconds.
	//
	// Uses default value of 1000 if unset/set to 0.
	BatchSize uint64 `koanf:"batch_size"`
}

func (*BlockBasedAnalyzerConfig) Validate

func (cfg *BlockBasedAnalyzerConfig) Validate() error

Validate validates the range configuration.

type CacheConfig

type CacheConfig struct {
	// CacheDir is the directory where the cache data is stored
	CacheDir string `koanf:"cache_dir"`

	// If set, the analyzer will query the node upon any cache
	// misses.
	QueryOnCacheMiss bool `koanf:"query_on_cache_miss"`
}

func (*CacheConfig) Validate

func (cfg *CacheConfig) Validate() error

type Config

type Config struct {
	Analysis *AnalysisConfig `koanf:"analysis"`
	Server   *ServerConfig   `koanf:"server"`
	Log      *LogConfig      `koanf:"log"`
	Metrics  *MetricsConfig  `koanf:"metrics"`
}

Config contains the CLI configuration.

func InitConfig

func InitConfig(f string) (*Config, error)

InitConfig initializes configuration from file.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate performs config validation.

type CustomChainConfig

type CustomChainConfig struct {
	// History is the sequence of networks in the chain.
	History *History `koanf:"history"`
	// SDKNetwork is the oasis-sdk Network configuration of the latest
	// network in the chain.
	SDKNetwork *sdkConfig.Network `koanf:"sdk_network"`
}

type EVMContractsVerifierConfig

type EVMContractsVerifierConfig struct {
	IntervalBasedAnalyzerConfig `koanf:",squash"`

	// ChainName is the name of the chain (e.g. mainnet/testnet).
	// The analyzer only supports testnet/mainnet chains.
	ChainName common.ChainName `koanf:"chain_name"`

	// SourcifyServerUrl is the base URL of the Sourcify server.
	SourcifyServerUrl string `koanf:"sourcify_server_url"`
}

EVMContractsVerifierConfig is the configuration for the EVM contracts verifier analyzer.

func (*EVMContractsVerifierConfig) Validate

func (cfg *EVMContractsVerifierConfig) Validate() error

Validate validates the evm contracts verifier config.

type EvmContractCodeAnalyzerConfig

type EvmContractCodeAnalyzerConfig struct{}

type EvmTokensAnalyzerConfig

type EvmTokensAnalyzerConfig struct{}

type History

type History struct {
	Records []*Record `koanf:"records"`
}

func SingleRecordHistory

func SingleRecordHistory(chainContext string) *History

func (*History) CurrentRecord

func (h *History) CurrentRecord() *Record

func (*History) EarliestRecord

func (h *History) EarliestRecord() *Record

func (*History) RecordForChainContext

func (h *History) RecordForChainContext(chainContext string) (*Record, error)

func (*History) RecordForHeight

func (h *History) RecordForHeight(height int64) (*Record, error)

func (*History) RecordForRuntimeRound

func (h *History) RecordForRuntimeRound(runtime common.Runtime, round uint64) (*Record, error)

type IntervalBasedAnalyzerConfig

type IntervalBasedAnalyzerConfig struct {
	// Interval is the time interval at which to run the analyzer.
	Interval time.Duration `koanf:"interval"`
}

type LogConfig

type LogConfig struct {
	Format string `koanf:"format"`
	Level  string `koanf:"level"`
	File   string `koanf:"file"`
}

LogConfig contains the logging configuration.

func (*LogConfig) Validate

func (cfg *LogConfig) Validate() error

Validate validates the logging configuration.

type MetadataRegistryConfig

type MetadataRegistryConfig struct {
	IntervalBasedAnalyzerConfig `koanf:",squash"`
}

MetadataRegistryConfig is the configuration for the metadata registry analyzer.

func (*MetadataRegistryConfig) Validate

func (cfg *MetadataRegistryConfig) Validate() error

Validate validates the configuration.

type MetricsConfig

type MetricsConfig struct {
	PullEndpoint string `koanf:"pull_endpoint"`
}

MetricsConfig contains the metrics configuration.

func (*MetricsConfig) Validate

func (cfg *MetricsConfig) Validate() error

Validate validates the metrics configuration.

type NodeConfig

type NodeConfig struct {
	// RPC is the node endpoint.
	RPC string `koanf:"rpc"`
}

NodeConfig is information about one oasis-node to connect to.

type Record

type Record struct {
	ArchiveName   string `koanf:"archive_name"`
	GenesisHeight int64  `koanf:"genesis_height"`
	// RuntimeStartRounds has entries for runtimes that already exist at the
	// genesis of this network. Look these up in the genesis document's
	// .roothash.runtime_states[runtime_id_hex].round. For clarity, add an
	// entry stating round 0 in the first network where a runtime is available
	// (although code does not differentiate between the presence or absence
	// of a zero entry).
	RuntimeStartRounds map[common.Runtime]uint64 `koanf:"runtime_start_rounds"`
	ChainContext       string                    `koanf:"chain_context"`
}

type ServerConfig

type ServerConfig struct {
	// ChainName is the name of the chain (i.e. mainnet/testnet). Custom/local nets are not supported.
	// This is only used for the runtime status endpoint.
	ChainName common.ChainName `koanf:"chain_name"`

	// Endpoint is the service endpoint from which to serve the API.
	Endpoint string `koanf:"endpoint"`

	Storage *StorageConfig `koanf:"storage"`
}

ServerConfig contains the API server configuration.

func (*ServerConfig) Validate

func (cfg *ServerConfig) Validate() error

Validate validates the server configuration.

type SourceConfig

type SourceConfig struct {
	// Cache holds the configuration for a file-based caching backend.
	Cache *CacheConfig `koanf:"cache"`

	// ChainName is the name of the chain (e.g. mainnet/testnet). Set
	// this to use one of the default chains.
	ChainName common.ChainName `koanf:"chain_name"`
	// CustomChain is information about a custom chain. Set this to use a
	// chain other than the default chains, e.g. a local testnet.
	CustomChain *CustomChainConfig `koanf:"custom_chain"`

	// Nodes describe the oasis-node(s) to connect to. Keys are "archive
	// names," which are named after mainnet releases, in lowercase e.g.
	// "cobalt" and "damask."
	Nodes map[string]*ArchiveConfig `koanf:"nodes"`

	// If set, the analyzer will skip some initial checks, e.g. that
	// `rpc` really serves the chain with the chain context we expect.
	// NOT RECOMMENDED in production; intended for faster testing.
	FastStartup bool `koanf:"fast_startup"`
}

SourceConfig has some controls about what chain we're analyzing and how to connect.

func CustomSingleNetworkSourceConfig

func CustomSingleNetworkSourceConfig(rpc string, chainContext string) *SourceConfig

func (*SourceConfig) History

func (sc *SourceConfig) History() *History

func (*SourceConfig) SDKNetwork

func (sc *SourceConfig) SDKNetwork() *sdkConfig.Network

func (*SourceConfig) SDKParaTime

func (sc *SourceConfig) SDKParaTime(runtime common.Runtime) *sdkConfig.ParaTime

type StorageBackend

type StorageBackend uint

StorageBackend is a storage backend.

const (
	// BackendCockroach is the CockroachDB storage backend.
	BackendCockroach StorageBackend = iota
	// BackendPostgres is the PostgreSQL storage backend.
	BackendPostgres
	// BackendInMemory is the in-memory storage backend.
	BackendInMemory
)

func (*StorageBackend) Set

func (sb *StorageBackend) Set(s string) error

Set sets the StorageBackend to the value specified by the provided string.

func (*StorageBackend) String

func (sb *StorageBackend) String() string

String returns the string representation of a StorageBackend.

func (*StorageBackend) Type

func (sb *StorageBackend) Type() string

Type returns the list of supported StorageBackends.

type StorageConfig

type StorageConfig struct {
	// Endpoint is the storage endpoint from which to read/write indexed data.
	Endpoint string `koanf:"endpoint"`

	// Backend is the storage backend to select.
	Backend string `koanf:"backend"`

	// Migrations is the directory containing schema migrations.
	Migrations string `koanf:"migrations"`

	// If true, we'll first delete all tables in the DB to
	// force a full re-index of the blockchain.
	WipeStorage bool `koanf:"DANGER__WIPE_STORAGE_ON_STARTUP"`
}

StorageConfig contains the storage layer configuration.

func (*StorageConfig) Validate

func (cfg *StorageConfig) Validate(requireMigrations bool) error

Validate validates the storage configuration.

Jump to

Keyboard shortcuts

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