Documentation ¶
Overview ¶
Package config enables config file parsing.
Index ¶
- Variables
- type AggregateStatsConfig
- type AnalysisConfig
- type AnalyzersList
- type ArchiveConfig
- type BlockBasedAnalyzerConfig
- type BlockRange
- type CacheConfig
- type Config
- type CustomChainConfig
- type EVMContractVerifierConfig
- type EvmAbiAnalyzerConfig
- type EvmContractCodeAnalyzerConfig
- type EvmTokensAnalyzerConfig
- type FastSyncConfig
- type History
- func (h *History) CurrentRecord() *Record
- func (h *History) EarliestRecord() *Record
- func (h *History) RecordForChainContext(chainContext string) (*Record, error)
- func (h *History) RecordForHeight(height int64) (*Record, error)
- func (h *History) RecordForRuntimeRound(runtime common.Runtime, round uint64) (*Record, error)
- type IPFSConfig
- type ItemBasedAnalyzerConfig
- type LogConfig
- type MetadataRegistryConfig
- type MetricsConfig
- type NodeConfig
- type NodeStatsConfig
- type Record
- type ServerConfig
- type SourceConfig
- type StorageBackend
- type StorageConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultChains = map[common.ChainName]*History{ common.ChainNameMainnet: { Records: []*Record{ { ArchiveName: "eden", GenesisHeight: 16817956, RuntimeStartRounds: map[common.Runtime]uint64{ common.RuntimeCipher: 44054, common.RuntimeEmerald: 7875129, common.RuntimeSapphire: 1357486, }, ChainContext: "bb3d748def55bdfb797a2ac53ee6ee141e54cd2ab2dc2375f4a0703a178e6e55", }, { 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: "2023-10-12", GenesisHeight: 17751681, ChainContext: "0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76", RuntimeStartRounds: map[common.Runtime]uint64{ common.RuntimeCipher: 1730319, common.RuntimeEmerald: 2627790, common.RuntimeSapphire: 2995927, }, }, { 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 ¶
This section is empty.
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"` EmeraldEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_emerald"` SapphireEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_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"` EmeraldContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_emerald"` SapphireContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_sapphire"` EmeraldAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_emerald"` SapphireAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_sapphire"` MetadataRegistry *MetadataRegistryConfig `koanf:"metadata_registry"` NodeStats *NodeStatsConfig `koanf:"node_stats"` AggregateStats *AggregateStatsConfig `koanf:"aggregate_stats"` }
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"` // If present, the analyzer will run in fast sync mode for // an initial range of blocks, and then switch to slow sync. // If absent, the analyzer will only run in "slow", sequential mode. // // If fast sync mode is enabled: // - DB checks and foreign keys are disabled. // - Multiple analyzers run in parallel and process blocks out of order. // - Analyzers do not perform dead reckoning on state (notably, transfers). // After all analyzers finish the fast sync range: // - DB checks and foreign keys are re-enabled. // - State that would normally be dead-reckoned is fetched directly from the node // via the StateToGenesis() RPC, or recalculated from the relevant DB entries. // - A single "slow mode" analyzer (per runtime/consensus) is started, and resumes // to process blocks sequentially, with dead reckoning enabled. FastSync *FastSyncConfig `koanf:"fast_sync"` // To is the (inclusive) ending block for this analyzer. // Omitting this parameter or setting it to 0 means this analyzer will // continue processing new blocks forever. 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) FastSyncRange ¶ added in v0.1.11
func (blockCfg BlockBasedAnalyzerConfig) FastSyncRange() *BlockRange
func (BlockBasedAnalyzerConfig) SlowSyncRange ¶ added in v0.1.11
func (blockCfg BlockBasedAnalyzerConfig) SlowSyncRange() BlockRange
func (BlockBasedAnalyzerConfig) Validate ¶
func (blockCfg BlockBasedAnalyzerConfig) Validate() error
type BlockRange ¶ added in v0.1.11
func (BlockRange) Validate ¶ added in v0.1.11
func (r BlockRange) Validate() error
type CacheConfig ¶
type CacheConfig struct { // CacheDir is the directory where the cache data is stored CacheDir string `koanf:"cache_dir"` }
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 ¶
InitConfig initializes configuration from file.
type CustomChainConfig ¶
type EVMContractVerifierConfig ¶ added in v0.1.13
type EVMContractVerifierConfig struct { ItemBasedAnalyzerConfig `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"` }
EVMContractVerifierConfig is the configuration for the EVM contracts verifier analyzer.
func (*EVMContractVerifierConfig) Validate ¶ added in v0.1.13
func (cfg *EVMContractVerifierConfig) Validate() error
Validate validates the evm contracts verifier config.
type EvmAbiAnalyzerConfig ¶ added in v0.1.26
type EvmAbiAnalyzerConfig struct {
ItemBasedAnalyzerConfig `koanf:",squash"`
}
type EvmContractCodeAnalyzerConfig ¶
type EvmContractCodeAnalyzerConfig struct {
ItemBasedAnalyzerConfig `koanf:",squash"`
}
type EvmTokensAnalyzerConfig ¶
type EvmTokensAnalyzerConfig struct {
ItemBasedAnalyzerConfig `koanf:",squash"`
}
type FastSyncConfig ¶ added in v0.1.11
type FastSyncConfig struct { // To is the block (inclusive) to which the analyzer // will run in fast sync mode. From this block onwards (exclusive), // the analyzer will run in slow mode. To uint64 `koanf:"to"` // The number of parallel analyzers to run in fast sync mode. Parallelism int `koanf:"parallelism"` }
type History ¶
type History struct {
Records []*Record `koanf:"records"`
}
func (*History) CurrentRecord ¶
func (*History) EarliestRecord ¶
func (*History) RecordForChainContext ¶
type IPFSConfig ¶ added in v0.1.16
type IPFSConfig struct { // Gateway is the URL prefix of an IPFS HTTP gateway. Do not include a // trailing slash, e.g. `https://ipfs.io`. Something like // `/ipfs/xxxx/n.json` will be appended. Gateway string `koanf:"gateway"` }
IPFSConfig is information about accessing IPFS.
type ItemBasedAnalyzerConfig ¶ added in v0.1.13
type ItemBasedAnalyzerConfig struct { // BatchSize determines the maximum number of items the item analyzer // processes per batch. This is relevant only when the analyzer // work queue is sufficiently long, most often when the analyzer is first enabled after // the block analyzers have been running for some time. // // Optimal value depends on the item processing speed. Ideally, it should // be set to the number of items that can be processed within 60 seconds. // Note that for some items, the processor will request information from out-of-band // sources such as Sourcify/Github. Care should be taken not to flood them // with too many requests. // // Uses default value of 20 if unset/set to 0. BatchSize uint64 `koanf:"batch_size"` // If StopOnEmptyQueue is true, the analyzer will exit the main processing loop when // there are no items left in the work queue. This is useful during testing when // 1) The number of items in the queue is determinate // 2) We want the analyzer to naturally terminate after processing all available work items. // // Defaults to false. StopOnEmptyQueue bool `koanf:"stop_on_empty_queue"` // If Interval is set, the analyzer will process batches at a fixed cadence specified by Interval. // Otherwise, the analyzer will use an adaptive backoff to determine the delay between // batches. Note that the backoff will attempt to run as fast as possible. Interval time.Duration `koanf:"interval"` // InterItemDelay determines the length of time the analyzer waits between spawning // new goroutines to process items within a batch. This is useful for cases where // processItem() makes out of band requests to rate limited resources. InterItemDelay time.Duration `koanf:"inter_item_delay"` }
type LogConfig ¶
type LogConfig struct { Format string `koanf:"format"` Level string `koanf:"level"` File string `koanf:"file"` }
LogConfig contains the logging configuration.
type MetadataRegistryConfig ¶
type MetadataRegistryConfig struct {
ItemBasedAnalyzerConfig `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 NodeStatsConfig ¶ added in v0.1.11
type NodeStatsConfig struct {
ItemBasedAnalyzerConfig `koanf:",squash"`
}
NodeStatsConfig is the configuration for the node stats analyzer.
func (*NodeStatsConfig) Validate ¶ added in v0.1.11
func (cfg *NodeStatsConfig) Validate() error
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", "damask" and "eden". Nodes map[string]*ArchiveConfig `koanf:"nodes"` // IPFS holds the configuration for accessing IPFS. IPFS *IPFSConfig `koanf:"ipfs"` // 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 (*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.