[pool] make GlobalSlots configurable (#4236)

pull/4241/head
Max 2 years ago committed by GitHub
parent 32493f5b41
commit 18ba697870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      cmd/harmony/config_migrations.go
  2. 3
      cmd/harmony/default.go
  3. 15
      cmd/harmony/flags.go
  4. 21
      cmd/harmony/flags_test.go
  5. 7
      core/tx_pool.go
  6. 1
      internal/configs/harmony/harmony.go
  7. 1
      node/node.go
  8. 3
      rosetta/infra/harmony-mainnet.conf
  9. 1
      rosetta/infra/harmony-pstn.conf

@ -266,5 +266,12 @@ func init() {
confTree.Set("Version", "2.5.4")
return confTree
}
migrations["2.5.4"] = func(confTree *toml.Tree) *toml.Tree {
if confTree.Get("TxPool.GlobalSlots") == nil {
confTree.Set("TxPool.GlobalSlots", defaultConfig.TxPool.GlobalSlots)
}
confTree.Set("Version", "2.5.5")
return confTree
}
}

@ -5,7 +5,7 @@ import (
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
)
const tomlConfigVersion = "2.5.4" // bump from 2.5.2 for rpc filters
const tomlConfigVersion = "2.5.5"
const (
defNetworkType = nodeconfig.Mainnet
@ -74,6 +74,7 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
RosettaFixFile: "",
AccountSlots: 16,
LocalAccountsFile: "./.hmy/locals.txt",
GlobalSlots: 5120,
},
Sync: getDefaultSyncConfig(defNetworkType),
Pprof: harmonyconfig.PprofConfig{

@ -136,6 +136,7 @@ var (
legacyTPBlacklistFileFlag,
localAccountsFileFlag,
allowedTxsFileFlag,
tpGlobalSlotsFlag,
}
pprofFlags = []cli.Flag{
@ -1086,6 +1087,11 @@ var (
Usage: "file of allowed transactions",
DefValue: defaultConfig.TxPool.AllowedTxsFile,
}
tpGlobalSlotsFlag = cli.IntFlag{
Name: "txpool.globalslots",
Usage: "maximum global number of non-executable transactions in the pool",
DefValue: int(defaultConfig.TxPool.GlobalSlots),
}
)
func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
@ -1097,7 +1103,14 @@ func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
if value <= 0 {
panic("Must provide positive for txpool.accountslots")
}
config.TxPool.AccountSlots = uint64(cli.GetIntFlagValue(cmd, tpAccountSlotsFlag))
config.TxPool.AccountSlots = uint64(value)
}
if cli.IsFlagChanged(cmd, tpGlobalSlotsFlag) {
value := cli.GetIntFlagValue(cmd, tpGlobalSlotsFlag)
if value <= 0 {
panic("Must provide positive value for txpool.globalslots")
}
config.TxPool.GlobalSlots = uint64(value)
}
if cli.IsFlagChanged(cmd, tpBlacklistFileFlag) {
config.TxPool.BlacklistFile = cli.GetStringFlagValue(cmd, tpBlacklistFileFlag)

@ -109,6 +109,7 @@ func TestHarmonyFlags(t *testing.T) {
AllowedTxsFile: "./.hmy/allowedtxs.txt",
RosettaFixFile: "",
AccountSlots: 16,
GlobalSlots: 5120,
LocalAccountsFile: "./.hmy/locals.txt",
},
Pprof: harmonyconfig.PprofConfig{
@ -880,6 +881,7 @@ func TestTxPoolFlags(t *testing.T) {
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
GlobalSlots: defaultConfig.TxPool.GlobalSlots,
},
},
{
@ -888,7 +890,8 @@ func TestTxPoolFlags(t *testing.T) {
BlacklistFile: "blacklist.file",
AllowedTxsFile: "allowedtxs.txt",
RosettaFixFile: "rosettafix.file",
AccountSlots: 16, // default
AccountSlots: defaultConfig.TxPool.AccountSlots,
GlobalSlots: defaultConfig.TxPool.GlobalSlots,
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
},
},
@ -898,7 +901,8 @@ func TestTxPoolFlags(t *testing.T) {
BlacklistFile: "blacklist.file",
RosettaFixFile: "rosettafix.file",
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
AccountSlots: 16, // default
AccountSlots: defaultConfig.TxPool.AccountSlots,
GlobalSlots: defaultConfig.TxPool.GlobalSlots,
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
},
},
@ -910,6 +914,7 @@ func TestTxPoolFlags(t *testing.T) {
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: "rosettafix.file",
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
GlobalSlots: defaultConfig.TxPool.GlobalSlots,
},
},
{
@ -920,6 +925,18 @@ func TestTxPoolFlags(t *testing.T) {
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
LocalAccountsFile: "locals.txt",
GlobalSlots: defaultConfig.TxPool.GlobalSlots,
},
},
{
args: []string{"--txpool.globalslots", "10240"},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
GlobalSlots: 10240,
},
},
}

@ -234,6 +234,13 @@ func (config *TxPoolConfig) sanitize() TxPoolConfig {
Msg("Sanitizing invalid txpool account slots")
conf.AccountSlots = DefaultTxPoolConfig.AccountSlots
}
if conf.GlobalSlots == 0 {
utils.Logger().Warn().
Uint64("provided", conf.GlobalSlots).
Uint64("updated", DefaultTxPoolConfig.GlobalSlots).
Msg("Sanitizing invalid txpool global slots")
conf.GlobalSlots = DefaultTxPoolConfig.GlobalSlots
}
return conf
}

@ -102,6 +102,7 @@ type TxPoolConfig struct {
RosettaFixFile string
AccountSlots uint64
LocalAccountsFile string
GlobalSlots uint64
}
type PprofConfig struct {

@ -1028,6 +1028,7 @@ func New(
}
if harmonyconfig != nil {
txPoolConfig.AccountSlots = harmonyconfig.TxPool.AccountSlots
txPoolConfig.GlobalSlots = harmonyconfig.TxPool.GlobalSlots
txPoolConfig.Locals = append(txPoolConfig.Locals, localAccounts...)
}

@ -1,4 +1,4 @@
Version = "2.5.4"
Version = "2.5.5"
[BLSKeys]
KMSConfigFile = ""
@ -108,6 +108,7 @@ Version = "2.5.4"
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
RosettaFixFile = "./rosetta_local_fix.csv"
GlobalSlots = 5120
[WS]
AuthPort = 9801

@ -108,6 +108,7 @@ Version = "2.5.4"
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
RosettaFixFile = ""
GlobalSlots = 5120
[WS]
AuthPort = 9801

Loading…
Cancel
Save