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

241 lines
5.4 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.2.0"
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: "./",
},
Network: getDefaultNetworkConfig(defNetworkType),
P2P: harmonyconfig.P2pConfig{
Port: nodeconfig.DefaultP2PPort,
IP: nodeconfig.DefaultPublicListenIP,
KeyFile: "./.hmykey",
},
HTTP: harmonyconfig.HttpConfig{
Enabled: true,
RosettaEnabled: false,
IP: "127.0.0.1",
Port: nodeconfig.DefaultRPCPort,
RosettaPort: nodeconfig.DefaultRosettaPort,
},
WS: harmonyconfig.WsConfig{
Enabled: true,
IP: "127.0.0.1",
Port: nodeconfig.DefaultWSPort,
},
RPCOpt: harmonyconfig.RpcOptConfig{
DebugEnabled: false,
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",
},
Sync: getDefaultSyncConfig(defNetworkType),
Pprof: harmonyconfig.PprofConfig{
Enabled: false,
ListenAddr: "127.0.0.1:6060",
Folder: "./profiles",
ProfileNames: []string{},
},
Log: harmonyconfig.LogConfig{
Folder: "./latest",
FileName: "harmony.log",
RotateSize: 100,
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),
}
var defaultSysConfig = harmonyconfig.SysConfig{
NtpServer: "1.pool.ntp.org",
}
var defaultDevnetConfig = harmonyconfig.DevnetConfig{
NumShards: 2,
ShardSize: 10,
HmyNodeSize: 10,
}
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 (
defaultMainnetSyncConfig = harmonyconfig.SyncConfig{
Enabled: false,
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
Downloader: false,
Concurrency: 6,
MinPeers: 6,
InitStreams: 8,
DiscSoftLowCap: 8,
DiscHardLowCap: 6,
DiscHighCap: 128,
DiscBatch: 8,
}
defaultTestNetSyncConfig = harmonyconfig.SyncConfig{
Enabled: 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
Downloader: false,
Concurrency: 4,
MinPeers: 4,
InitStreams: 4,
DiscSoftLowCap: 4,
DiscHardLowCap: 4,
DiscHighCap: 1024,
DiscBatch: 8,
}
defaultLocalNetSyncConfig = harmonyconfig.SyncConfig{
Enabled: 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
Downloader: false,
Concurrency: 4,
MinPeers: 4,
InitStreams: 4,
DiscSoftLowCap: 4,
DiscHardLowCap: 4,
DiscHighCap: 1024,
DiscBatch: 8,
}
defaultElseSyncConfig = harmonyconfig.SyncConfig{
Enabled: 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
Downloader: true,
Concurrency: 4,
MinPeers: 4,
InitStreams: 4,
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"
)