mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
Update default cli config (#323)
* update the default cli config * fix: handle maxpeers flag override, added tests * add: no-snapshot flag, handle snapshot disable * fix: update default flags * add: update the sealer.GasPrice default to 30 gewi * fix: remove snapshot flag, rely on no-snapshot only
This commit is contained in:
parent
388b68cd05
commit
597037df30
3 changed files with 51 additions and 20 deletions
|
|
@ -58,8 +58,8 @@ type Config struct {
|
||||||
// GcMode selects the garbage collection mode for the trie
|
// GcMode selects the garbage collection mode for the trie
|
||||||
GcMode string `hcl:"gc-mode,optional"`
|
GcMode string `hcl:"gc-mode,optional"`
|
||||||
|
|
||||||
// XXX
|
// NoSnapshot disbales the snapshot database mode
|
||||||
Snapshot bool `hcl:"snapshot,optional"`
|
NoSnapshot bool `hcl:"no-snapshot,optional"`
|
||||||
|
|
||||||
// Ethstats is the address of the ethstats server to send telemetry
|
// Ethstats is the address of the ethstats server to send telemetry
|
||||||
Ethstats string `hcl:"ethstats,optional"`
|
Ethstats string `hcl:"ethstats,optional"`
|
||||||
|
|
@ -406,27 +406,27 @@ func DefaultConfig() *Config {
|
||||||
URL: "http://localhost:1317",
|
URL: "http://localhost:1317",
|
||||||
Without: false,
|
Without: false,
|
||||||
},
|
},
|
||||||
SyncMode: "full",
|
SyncMode: "full",
|
||||||
GcMode: "full",
|
GcMode: "full",
|
||||||
Snapshot: true,
|
NoSnapshot: false,
|
||||||
TxPool: &TxPoolConfig{
|
TxPool: &TxPoolConfig{
|
||||||
Locals: []string{},
|
Locals: []string{},
|
||||||
NoLocals: false,
|
NoLocals: false,
|
||||||
Journal: "",
|
Journal: "",
|
||||||
Rejournal: time.Duration(1 * time.Hour),
|
Rejournal: time.Duration(1 * time.Hour),
|
||||||
PriceLimit: 1,
|
PriceLimit: 30000000000,
|
||||||
PriceBump: 10,
|
PriceBump: 10,
|
||||||
AccountSlots: 16,
|
AccountSlots: 16,
|
||||||
GlobalSlots: 4096,
|
GlobalSlots: 32768,
|
||||||
AccountQueue: 64,
|
AccountQueue: 16,
|
||||||
GlobalQueue: 1024,
|
GlobalQueue: 32768,
|
||||||
LifeTime: time.Duration(3 * time.Hour),
|
LifeTime: time.Duration(3 * time.Hour),
|
||||||
},
|
},
|
||||||
Sealer: &SealerConfig{
|
Sealer: &SealerConfig{
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
Etherbase: "",
|
Etherbase: "",
|
||||||
GasCeil: 8000000,
|
GasCeil: 8000000,
|
||||||
GasPrice: big.NewInt(params.GWei),
|
GasPrice: big.NewInt(30 * params.GWei),
|
||||||
ExtraData: "",
|
ExtraData: "",
|
||||||
},
|
},
|
||||||
Gpo: &GpoConfig{
|
Gpo: &GpoConfig{
|
||||||
|
|
@ -443,11 +443,11 @@ func DefaultConfig() *Config {
|
||||||
GasCap: ethconfig.Defaults.RPCGasCap,
|
GasCap: ethconfig.Defaults.RPCGasCap,
|
||||||
TxFeeCap: ethconfig.Defaults.RPCTxFeeCap,
|
TxFeeCap: ethconfig.Defaults.RPCTxFeeCap,
|
||||||
Http: &APIConfig{
|
Http: &APIConfig{
|
||||||
Enabled: true,
|
Enabled: false,
|
||||||
Port: 8545,
|
Port: 8545,
|
||||||
Prefix: "",
|
Prefix: "",
|
||||||
Host: "localhost",
|
Host: "localhost",
|
||||||
Modules: []string{"eth", "web3", "net"},
|
Modules: []string{"eth", "net", "web3", "txpool", "bor"},
|
||||||
},
|
},
|
||||||
Ws: &APIConfig{
|
Ws: &APIConfig{
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
|
|
@ -805,7 +805,7 @@ func (c *Config) buildEth(stack *node.Node) (*ethconfig.Config, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// snapshot disable check
|
// snapshot disable check
|
||||||
if c.Snapshot {
|
if c.NoSnapshot {
|
||||||
if n.SyncMode == downloader.SnapSync {
|
if n.SyncMode == downloader.SnapSync {
|
||||||
log.Info("Snap sync requested, enabling --snapshot")
|
log.Info("Snap sync requested, enabling --snapshot")
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -867,6 +867,10 @@ func (c *Config) buildNode() (*node.Config, error) {
|
||||||
cfg.P2P.ListenAddr = ""
|
cfg.P2P.ListenAddr = ""
|
||||||
cfg.P2P.NoDial = true
|
cfg.P2P.NoDial = true
|
||||||
cfg.P2P.DiscoveryV5 = false
|
cfg.P2P.DiscoveryV5 = false
|
||||||
|
|
||||||
|
// enable JsonRPC HTTP API
|
||||||
|
c.JsonRPC.Http.Enabled = true
|
||||||
|
cfg.HTTPModules = []string{"admin", "debug", "eth", "miner", "net", "personal", "txpool", "web3", "bor"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable jsonrpc endpoints
|
// enable jsonrpc endpoints
|
||||||
|
|
@ -922,6 +926,11 @@ func (c *Config) Merge(cc ...*Config) error {
|
||||||
if err := mergo.Merge(c, elem, mergo.WithOverride, mergo.WithAppendSlice); err != nil {
|
if err := mergo.Merge(c, elem, mergo.WithOverride, mergo.WithAppendSlice); err != nil {
|
||||||
return fmt.Errorf("failed to merge configurations: %v", err)
|
return fmt.Errorf("failed to merge configurations: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override max peers
|
||||||
|
if elem.P2P.MaxPeers == 0 {
|
||||||
|
c.P2P.MaxPeers = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ func TestConfigDefault(t *testing.T) {
|
||||||
|
|
||||||
func TestConfigMerge(t *testing.T) {
|
func TestConfigMerge(t *testing.T) {
|
||||||
c0 := &Config{
|
c0 := &Config{
|
||||||
Chain: "0",
|
Chain: "0",
|
||||||
Snapshot: true,
|
NoSnapshot: true,
|
||||||
Whitelist: map[string]string{
|
Whitelist: map[string]string{
|
||||||
"a": "b",
|
"a": "b",
|
||||||
},
|
},
|
||||||
|
|
@ -53,8 +53,8 @@ func TestConfigMerge(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected := &Config{
|
expected := &Config{
|
||||||
Chain: "1",
|
Chain: "1",
|
||||||
Snapshot: true,
|
NoSnapshot: true,
|
||||||
Whitelist: map[string]string{
|
Whitelist: map[string]string{
|
||||||
"a": "b",
|
"a": "b",
|
||||||
"b": "c",
|
"b": "c",
|
||||||
|
|
@ -76,6 +76,28 @@ func TestConfigMerge(t *testing.T) {
|
||||||
assert.Equal(t, c0, expected)
|
assert.Equal(t, c0, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDefaultDatatypeOverride(t *testing.T) {
|
||||||
|
// This test is specific to `maxpeers` flag (for now) to check
|
||||||
|
// if default datatype value (0 in case of uint64) is overridden.
|
||||||
|
c0 := &Config{
|
||||||
|
P2P: &P2PConfig{
|
||||||
|
MaxPeers: 30,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
c1 := &Config{
|
||||||
|
P2P: &P2PConfig{
|
||||||
|
MaxPeers: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expected := &Config{
|
||||||
|
P2P: &P2PConfig{
|
||||||
|
MaxPeers: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.NoError(t, c0.Merge(c1))
|
||||||
|
assert.Equal(t, c0, expected)
|
||||||
|
}
|
||||||
|
|
||||||
func TestConfigLoadFile(t *testing.T) {
|
func TestConfigLoadFile(t *testing.T) {
|
||||||
readFile := func(path string) {
|
readFile := func(path string) {
|
||||||
config, err := readConfigFile(path)
|
config, err := readConfigFile(path)
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ func (c *Command) Flags() *flagset.Flagset {
|
||||||
Value: &c.cliConfig.Whitelist,
|
Value: &c.cliConfig.Whitelist,
|
||||||
})
|
})
|
||||||
f.BoolFlag(&flagset.BoolFlag{
|
f.BoolFlag(&flagset.BoolFlag{
|
||||||
Name: "snapshot",
|
Name: "no-snapshot",
|
||||||
Usage: `Enables snapshot-database mode (default = enable)`,
|
Usage: `Disables the snapshot-database mode (default = false)`,
|
||||||
Value: &c.cliConfig.Snapshot,
|
Value: &c.cliConfig.NoSnapshot,
|
||||||
})
|
})
|
||||||
|
|
||||||
// heimdall
|
// heimdall
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue