The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/cmd/harmony/default.go

314 lines
8.6 KiB

package main
import (
harmonyconfig "github.com/harmony-one/harmony/internal/configs/harmony"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
)
const tomlConfigVersion = "2.5.12"
const (
defNetworkType = nodeconfig.Mainnet
)
var defaultConfig = harmonyconfig.HarmonyConfig{
Version: tomlConfigVersion,
General: harmonyconfig.GeneralConfig{
NodeType: "validator",
NoStaking: false,
ShardID: -1,
IsArchival: false,
IsBeaconArchival: false,
IsOffline: false,
DataDir: "./",
TraceEnable: false,
TriesInMemory: 128,
},
Network: getDefaultNetworkConfig(defNetworkType),
P2P: harmonyconfig.P2pConfig{
Port: nodeconfig.DefaultP2PPort,
IP: nodeconfig.DefaultPublicListenIP,
KeyFile: "./.hmykey",
DiscConcurrency: nodeconfig.DefaultP2PConcurrency,
MaxConnsPerIP: nodeconfig.DefaultMaxConnPerIP,
DisablePrivateIPScan: false,
MaxPeers: nodeconfig.DefaultMaxPeers,
ConnManagerLowWatermark: nodeconfig.DefaultConnManagerLowWatermark,
ConnManagerHighWatermark: nodeconfig.DefaultConnManagerHighWatermark,
WaitForEachPeerToConnect: nodeconfig.DefaultWaitForEachPeerToConnect,
},
HTTP: harmonyconfig.HttpConfig{
Enabled: true,
RosettaEnabled: false,
IP: "127.0.0.1",
Port: nodeconfig.DefaultRPCPort,
3 years ago
AuthPort: nodeconfig.DefaultAuthRPCPort,
RosettaPort: nodeconfig.DefaultRosettaPort,
},
WS: harmonyconfig.WsConfig{
Enabled: true,
IP: "127.0.0.1",
Port: nodeconfig.DefaultWSPort,
AuthPort: nodeconfig.DefaultAuthWSPort,
},
RPCOpt: harmonyconfig.RpcOptConfig{
DebugEnabled: false,
EthRPCsEnabled: true,
StakingRPCsEnabled: true,
LegacyRPCsEnabled: true,
RpcFilterFile: "./.hmy/rpc_filter.txt",
RateLimterEnabled: true,
RequestsPerSecond: nodeconfig.DefaultRPCRateLimit,
},
BLSKeys: harmonyconfig.BlsConfig{
KeyDir: "./.hmy/blskeys",
KeyFiles: []string{},
MaxKeys: 10,
PassEnabled: true,
PassSrcType: blsPassTypeAuto,
PassFile: "",
SavePassphrase: false,
KMSEnabled: false,
KMSConfigSrcType: kmsConfigTypeShared,
KMSConfigFile: "",
},
TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt",
AllowedTxsFile: "./.hmy/allowedtxs.txt",
RosettaFixFile: "",
AccountSlots: 16,
LocalAccountsFile: "./.hmy/locals.txt",
GlobalSlots: 5120,
},
Sync: getDefaultSyncConfig(defNetworkType),
Pprof: harmonyconfig.PprofConfig{
Enabled: false,
ListenAddr: "127.0.0.1:6060",
Folder: "./profiles",
ProfileNames: []string{},
ProfileIntervals: []int{600},
ProfileDebugValues: []int{0},
},
Log: harmonyconfig.LogConfig{
Console: false,
Folder: "./latest",
FileName: "harmony.log",
RotateSize: 100,
RotateCount: 0,
RotateMaxAge: 0,
Verbosity: 3,
VerbosePrints: harmonyconfig.LogVerbosePrints{
Config: true,
},
},
Config 2.0.0 Fixes regarding config V2.0.0 The following fixes and improvements have been applied - Added timeout to config update prompt. Prompt logic has been moved to a separate func - When updating config file, the original is saved to <config>.backup - Added semantic version validation for the version found in config. Error is returned if version is missing, not a valid sematic version or not found in the migrations map - Flags related to DNSSync has been moved to dnsSyncFlags flag array. Also moved tests related to DNSSync flags to separate test func - Added dns.server and dns.client flags and tests for them - Added migration tests with dumps of versions 1.0.2, 1.0.3, 1.0.4 Inital commit Removed lint warning Fixed names, that have changed in dnsSync Fixed some lint errors Some functions were exported although no need to be and some test variables were also renamed Fixed 1.0.4 migration - Tests in config_test.go expected wrong version since it was migrated to 2.0.0 - getDefaultHmyConfigCopy did not get DNSSync defaults - Key for DNSPort for version prior to 1.0.4 was wrong - DNSSyncPort Added default for DNSSync when creating default Config Fixed empty string user input crash Inputing empty string was causing out of bounds index to be read from readStr Fixed flags_test to work with config version 2.0.0 Changed DNSSync fields names It seems that Enabled was not a good name, considering that actually did the opposite. Also kept LegacyClient and LegacyServer names Removed Legacy prefix from dnsSync fields It seems Legacy prefix is obsolite since moving the fields to dsnSync Fixes regarding config V2.0.0 The following fixes and improvements have been applied - Added timeout to config update prompt. Prompt logic has been moved to a separate func - When updating config file, the original is saved to <config>.backup - Added semantic version validation for the version found in config. Error is returned if version is missing, not a valid sematic version or not found in the migrations map - Flags related to DNSSync has been moved to dnsSyncFlags flag array. Also moved tests related to DNSSync flags to separate test func - Added dns.server and dns.client flags and tests for them - Added migration tests with dumps of versions 1.0.2, 1.0.3, 1.0.4 Fix for config_migrations_test Added default value to serverPort during migration
4 years ago
DNSSync: getDefaultDNSSyncConfig(defNetworkType),
3 years ago
ShardData: harmonyconfig.ShardDataConfig{
EnableShardData: false,
DiskCount: 8,
ShardCount: 4,
CacheTime: 10,
CacheSize: 512,
3 years ago
},
}
var defaultSysConfig = harmonyconfig.SysConfig{
NtpServer: "1.pool.ntp.org",
}
var defaultDevnetConfig = harmonyconfig.DevnetConfig{
NumShards: 2,
ShardSize: 10,
HmyNodeSize: 10,
SlotsLimit: 0, // 0 means no limit
}
var defaultRevertConfig = harmonyconfig.RevertConfig{
RevertBeacon: false,
RevertBefore: 0,
RevertTo: 0,
}
var defaultLogContext = harmonyconfig.LogContext{
IP: "127.0.0.1",
Port: 9000,
}
var defaultConsensusConfig = harmonyconfig.ConsensusConfig{
MinPeers: 6,
AggregateSig: true,
}
var defaultPrometheusConfig = harmonyconfig.PrometheusConfig{
Enabled: true,
IP: "0.0.0.0",
Port: 9900,
EnablePush: false,
Gateway: "https://gateway.harmony.one",
}
var defaultStagedSyncConfig = harmonyconfig.StagedSyncConfig{
TurboMode: true,
DoubleCheckBlockHashes: false,
MaxBlocksPerSyncCycle: 512, // sync new blocks in each cycle, if set to zero means all blocks in one full cycle
MaxBackgroundBlocks: 512, // max blocks to be downloaded at background process in turbo mode
InsertChainBatchSize: 128, // number of blocks to build a batch and insert to chain in staged sync
VerifyAllSig: false, // whether it should verify signatures for all blocks
VerifyHeaderBatchSize: 100, // batch size to verify block header before insert to chain
MaxMemSyncCycleSize: 1024, // max number of blocks to use a single transaction for staged sync
UseMemDB: true, // it uses memory by default. set it to false to use disk
LogProgress: false, // log the full sync progress in console
}
var (
defaultMainnetSyncConfig = harmonyconfig.SyncConfig{
Enabled: false,
Downloader: false,
StagedSync: false,
StagedSyncCfg: defaultStagedSyncConfig,
Concurrency: 6,
MinPeers: 6,
InitStreams: 8,
MaxAdvertiseWaitTime: 60, //minutes
DiscSoftLowCap: 8,
DiscHardLowCap: 6,
DiscHighCap: 128,
DiscBatch: 8,
}
defaultTestNetSyncConfig = harmonyconfig.SyncConfig{
Enabled: true,
Downloader: false,
StagedSync: false,
StagedSyncCfg: defaultStagedSyncConfig,
Concurrency: 2,
MinPeers: 2,
InitStreams: 2,
MaxAdvertiseWaitTime: 5, //minutes
DiscSoftLowCap: 2,
DiscHardLowCap: 2,
DiscHighCap: 1024,
DiscBatch: 3,
}
defaultLocalNetSyncConfig = harmonyconfig.SyncConfig{
Enabled: true,
Downloader: true,
StagedSync: true,
StagedSyncCfg: defaultStagedSyncConfig,
Concurrency: 4,
MinPeers: 4,
InitStreams: 4,
MaxAdvertiseWaitTime: 5, //minutes
DiscSoftLowCap: 4,
DiscHardLowCap: 4,
DiscHighCap: 1024,
DiscBatch: 8,
}
defaultPartnerSyncConfig = harmonyconfig.SyncConfig{
Enabled: true,
Downloader: true,
StagedSync: false,
StagedSyncCfg: defaultStagedSyncConfig,
Concurrency: 4,
MinPeers: 2,
InitStreams: 2,
MaxAdvertiseWaitTime: 2, //minutes
DiscSoftLowCap: 2,
DiscHardLowCap: 2,
DiscHighCap: 1024,
DiscBatch: 4,
}
defaultElseSyncConfig = harmonyconfig.SyncConfig{
Enabled: true,
Downloader: true,
StagedSync: false,
StagedSyncCfg: defaultStagedSyncConfig,
Concurrency: 4,
MinPeers: 4,
InitStreams: 4,
MaxAdvertiseWaitTime: 2, //minutes
DiscSoftLowCap: 4,
DiscHardLowCap: 4,
DiscHighCap: 1024,
DiscBatch: 8,
}
)
const (
defaultBroadcastInvalidTx = false
)
func getDefaultHmyConfigCopy(nt nodeconfig.NetworkType) harmonyconfig.HarmonyConfig {
config := defaultConfig
config.Network = getDefaultNetworkConfig(nt)
if nt == nodeconfig.Devnet {
devnet := getDefaultDevnetConfigCopy()
config.Devnet = &devnet
}
config.Sync = getDefaultSyncConfig(nt)
Config 2.0.0 Fixes regarding config V2.0.0 The following fixes and improvements have been applied - Added timeout to config update prompt. Prompt logic has been moved to a separate func - When updating config file, the original is saved to <config>.backup - Added semantic version validation for the version found in config. Error is returned if version is missing, not a valid sematic version or not found in the migrations map - Flags related to DNSSync has been moved to dnsSyncFlags flag array. Also moved tests related to DNSSync flags to separate test func - Added dns.server and dns.client flags and tests for them - Added migration tests with dumps of versions 1.0.2, 1.0.3, 1.0.4 Inital commit Removed lint warning Fixed names, that have changed in dnsSync Fixed some lint errors Some functions were exported although no need to be and some test variables were also renamed Fixed 1.0.4 migration - Tests in config_test.go expected wrong version since it was migrated to 2.0.0 - getDefaultHmyConfigCopy did not get DNSSync defaults - Key for DNSPort for version prior to 1.0.4 was wrong - DNSSyncPort Added default for DNSSync when creating default Config Fixed empty string user input crash Inputing empty string was causing out of bounds index to be read from readStr Fixed flags_test to work with config version 2.0.0 Changed DNSSync fields names It seems that Enabled was not a good name, considering that actually did the opposite. Also kept LegacyClient and LegacyServer names Removed Legacy prefix from dnsSync fields It seems Legacy prefix is obsolite since moving the fields to dsnSync Fixes regarding config V2.0.0 The following fixes and improvements have been applied - Added timeout to config update prompt. Prompt logic has been moved to a separate func - When updating config file, the original is saved to <config>.backup - Added semantic version validation for the version found in config. Error is returned if version is missing, not a valid sematic version or not found in the migrations map - Flags related to DNSSync has been moved to dnsSyncFlags flag array. Also moved tests related to DNSSync flags to separate test func - Added dns.server and dns.client flags and tests for them - Added migration tests with dumps of versions 1.0.2, 1.0.3, 1.0.4 Fix for config_migrations_test Added default value to serverPort during migration
4 years ago
config.DNSSync = getDefaultDNSSyncConfig(nt)
return config
}
func getDefaultSysConfigCopy() harmonyconfig.SysConfig {
config := defaultSysConfig
return config
}
func getDefaultDevnetConfigCopy() harmonyconfig.DevnetConfig {
config := defaultDevnetConfig
return config
}
func getDefaultRevertConfigCopy() harmonyconfig.RevertConfig {
config := defaultRevertConfig
return config
}
func getDefaultLogContextCopy() harmonyconfig.LogContext {
config := defaultLogContext
return config
}
func getDefaultConsensusConfigCopy() harmonyconfig.ConsensusConfig {
config := defaultConsensusConfig
return config
}
func getDefaultPrometheusConfigCopy() harmonyconfig.PrometheusConfig {
config := defaultPrometheusConfig
return config
}
const (
nodeTypeValidator = "validator"
nodeTypeExplorer = "explorer"
)
const (
blsPassTypeAuto = "auto"
blsPassTypeFile = "file"
blsPassTypePrompt = "prompt"
kmsConfigTypeShared = "shared"
kmsConfigTypePrompt = "prompt"
kmsConfigTypeFile = "file"
legacyBLSPassTypeDefault = "default"
legacyBLSPassTypeStdin = "stdin"
legacyBLSPassTypeDynamic = "no-prompt"
legacyBLSPassTypePrompt = "prompt"
legacyBLSPassTypeStatic = "file"
legacyBLSPassTypeNone = "none"
legacyBLSKmsTypeDefault = "default"
legacyBLSKmsTypePrompt = "prompt"
legacyBLSKmsTypeFile = "file"
legacyBLSKmsTypeNone = "none"
)