github.com/MetalBlockchain/metalgo@v1.11.9/node/config.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package node 5 6 import ( 7 "crypto/tls" 8 "net/netip" 9 "time" 10 11 "github.com/MetalBlockchain/metalgo/api/server" 12 "github.com/MetalBlockchain/metalgo/chains" 13 "github.com/MetalBlockchain/metalgo/genesis" 14 "github.com/MetalBlockchain/metalgo/ids" 15 "github.com/MetalBlockchain/metalgo/network" 16 "github.com/MetalBlockchain/metalgo/snow/networking/benchlist" 17 "github.com/MetalBlockchain/metalgo/snow/networking/router" 18 "github.com/MetalBlockchain/metalgo/snow/networking/tracker" 19 "github.com/MetalBlockchain/metalgo/subnets" 20 "github.com/MetalBlockchain/metalgo/trace" 21 "github.com/MetalBlockchain/metalgo/utils/crypto/bls" 22 "github.com/MetalBlockchain/metalgo/utils/logging" 23 "github.com/MetalBlockchain/metalgo/utils/profiler" 24 "github.com/MetalBlockchain/metalgo/utils/set" 25 "github.com/MetalBlockchain/metalgo/utils/timer" 26 "github.com/MetalBlockchain/metalgo/vms/platformvm/txs/fee" 27 ) 28 29 type APIIndexerConfig struct { 30 IndexAPIEnabled bool `json:"indexAPIEnabled"` 31 IndexAllowIncomplete bool `json:"indexAllowIncomplete"` 32 } 33 34 type HTTPConfig struct { 35 server.HTTPConfig 36 APIConfig `json:"apiConfig"` 37 HTTPHost string `json:"httpHost"` 38 HTTPPort uint16 `json:"httpPort"` 39 40 HTTPSEnabled bool `json:"httpsEnabled"` 41 HTTPSKey []byte `json:"-"` 42 HTTPSCert []byte `json:"-"` 43 44 HTTPAllowedOrigins []string `json:"httpAllowedOrigins"` 45 HTTPAllowedHosts []string `json:"httpAllowedHosts"` 46 47 ShutdownTimeout time.Duration `json:"shutdownTimeout"` 48 ShutdownWait time.Duration `json:"shutdownWait"` 49 } 50 51 type APIConfig struct { 52 APIIndexerConfig `json:"indexerConfig"` 53 54 // Enable/Disable APIs 55 AdminAPIEnabled bool `json:"adminAPIEnabled"` 56 InfoAPIEnabled bool `json:"infoAPIEnabled"` 57 KeystoreAPIEnabled bool `json:"keystoreAPIEnabled"` 58 MetricsAPIEnabled bool `json:"metricsAPIEnabled"` 59 HealthAPIEnabled bool `json:"healthAPIEnabled"` 60 } 61 62 type IPConfig struct { 63 PublicIP string `json:"publicIP"` 64 PublicIPResolutionService string `json:"publicIPResolutionService"` 65 PublicIPResolutionFreq time.Duration `json:"publicIPResolutionFreq"` 66 // The host portion of the address to listen on. The port to 67 // listen on will be sourced from IPPort. 68 // 69 // - If empty, listen on all interfaces (both ipv4 and ipv6). 70 // - If populated, listen only on the specified address. 71 ListenHost string `json:"listenHost"` 72 ListenPort uint16 `json:"listenPort"` 73 } 74 75 type StakingConfig struct { 76 genesis.StakingConfig 77 SybilProtectionEnabled bool `json:"sybilProtectionEnabled"` 78 PartialSyncPrimaryNetwork bool `json:"partialSyncPrimaryNetwork"` 79 StakingTLSCert tls.Certificate `json:"-"` 80 StakingSigningKey *bls.SecretKey `json:"-"` 81 SybilProtectionDisabledWeight uint64 `json:"sybilProtectionDisabledWeight"` 82 StakingKeyPath string `json:"stakingKeyPath"` 83 StakingCertPath string `json:"stakingCertPath"` 84 StakingSignerPath string `json:"stakingSignerPath"` 85 } 86 87 type StateSyncConfig struct { 88 StateSyncIDs []ids.NodeID `json:"stateSyncIDs"` 89 StateSyncIPs []netip.AddrPort `json:"stateSyncIPs"` 90 } 91 92 type BootstrapConfig struct { 93 // Timeout before emitting a warn log when connecting to bootstrapping beacons 94 BootstrapBeaconConnectionTimeout time.Duration `json:"bootstrapBeaconConnectionTimeout"` 95 96 // Max number of containers in an ancestors message sent by this node. 97 BootstrapAncestorsMaxContainersSent int `json:"bootstrapAncestorsMaxContainersSent"` 98 99 // This node will only consider the first [AncestorsMaxContainersReceived] 100 // containers in an ancestors message it receives. 101 BootstrapAncestorsMaxContainersReceived int `json:"bootstrapAncestorsMaxContainersReceived"` 102 103 // Max time to spend fetching a container and its 104 // ancestors while responding to a GetAncestors message 105 BootstrapMaxTimeGetAncestors time.Duration `json:"bootstrapMaxTimeGetAncestors"` 106 107 Bootstrappers []genesis.Bootstrapper `json:"bootstrappers"` 108 } 109 110 type DatabaseConfig struct { 111 // If true, all writes are to memory and are discarded at node shutdown. 112 ReadOnly bool `json:"readOnly"` 113 114 // Path to database 115 Path string `json:"path"` 116 117 // Name of the database type to use 118 Name string `json:"name"` 119 120 // Path to config file 121 Config []byte `json:"-"` 122 } 123 124 // Config contains all of the configurations of an Avalanche node. 125 type Config struct { 126 HTTPConfig `json:"httpConfig"` 127 IPConfig `json:"ipConfig"` 128 StakingConfig `json:"stakingConfig"` 129 fee.StaticConfig `json:"txFeeConfig"` 130 StateSyncConfig `json:"stateSyncConfig"` 131 BootstrapConfig `json:"bootstrapConfig"` 132 DatabaseConfig `json:"databaseConfig"` 133 134 // Genesis information 135 GenesisBytes []byte `json:"-"` 136 AvaxAssetID ids.ID `json:"avaxAssetID"` 137 138 // ID of the network this node should connect to 139 NetworkID uint32 `json:"networkID"` 140 141 // Health 142 HealthCheckFreq time.Duration `json:"healthCheckFreq"` 143 144 // Network configuration 145 NetworkConfig network.Config `json:"networkConfig"` 146 147 AdaptiveTimeoutConfig timer.AdaptiveTimeoutConfig `json:"adaptiveTimeoutConfig"` 148 149 BenchlistConfig benchlist.Config `json:"benchlistConfig"` 150 151 ProfilerConfig profiler.Config `json:"profilerConfig"` 152 153 LoggingConfig logging.Config `json:"loggingConfig"` 154 155 PluginDir string `json:"pluginDir"` 156 157 // File Descriptor Limit 158 FdLimit uint64 `json:"fdLimit"` 159 160 // Metrics 161 MeterVMEnabled bool `json:"meterVMEnabled"` 162 163 RouterHealthConfig router.HealthConfig `json:"routerHealthConfig"` 164 ConsensusShutdownTimeout time.Duration `json:"consensusShutdownTimeout"` 165 // Poll for new frontiers every [FrontierPollFrequency] 166 FrontierPollFrequency time.Duration `json:"consensusGossipFreq"` 167 // ConsensusAppConcurrency defines the maximum number of goroutines to 168 // handle App messages per chain. 169 ConsensusAppConcurrency int `json:"consensusAppConcurrency"` 170 171 TrackedSubnets set.Set[ids.ID] `json:"trackedSubnets"` 172 173 SubnetConfigs map[ids.ID]subnets.Config `json:"subnetConfigs"` 174 175 ChainConfigs map[string]chains.ChainConfig `json:"-"` 176 ChainAliases map[ids.ID][]string `json:"chainAliases"` 177 178 VMAliases map[ids.ID][]string `json:"vmAliases"` 179 180 // Halflife to use for the processing requests tracker. 181 // Larger halflife --> usage metrics change more slowly. 182 SystemTrackerProcessingHalflife time.Duration `json:"systemTrackerProcessingHalflife"` 183 184 // Frequency to check the real resource usage of tracked processes. 185 // More frequent checks --> usage metrics are more accurate, but more 186 // expensive to track 187 SystemTrackerFrequency time.Duration `json:"systemTrackerFrequency"` 188 189 // Halflife to use for the cpu tracker. 190 // Larger halflife --> cpu usage metrics change more slowly. 191 SystemTrackerCPUHalflife time.Duration `json:"systemTrackerCPUHalflife"` 192 193 // Halflife to use for the disk tracker. 194 // Larger halflife --> disk usage metrics change more slowly. 195 SystemTrackerDiskHalflife time.Duration `json:"systemTrackerDiskHalflife"` 196 197 CPUTargeterConfig tracker.TargeterConfig `json:"cpuTargeterConfig"` 198 199 DiskTargeterConfig tracker.TargeterConfig `json:"diskTargeterConfig"` 200 201 RequiredAvailableDiskSpace uint64 `json:"requiredAvailableDiskSpace"` 202 WarningThresholdAvailableDiskSpace uint64 `json:"warningThresholdAvailableDiskSpace"` 203 204 TraceConfig trace.Config `json:"traceConfig"` 205 206 // See comment on [UseCurrentHeight] in platformvm.Config 207 UseCurrentHeight bool `json:"useCurrentHeight"` 208 209 // ProvidedFlags contains all the flags set by the user 210 ProvidedFlags map[string]interface{} `json:"-"` 211 212 // ChainDataDir is the root path for per-chain directories where VMs can 213 // write arbitrary data. 214 ChainDataDir string `json:"chainDataDir"` 215 216 // Path to write process context to (including PID, API URI, and 217 // staking address). 218 ProcessContextFilePath string `json:"processContextFilePath"` 219 }