feat: Add AccountSlots flag for TxPool (#4071)

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

@ -220,4 +220,13 @@ func init() {
confTree.Set("Version", "2.5.0")
return confTree
}
migrations["2.5.0"] = func(confTree *toml.Tree) *toml.Tree {
if confTree.Get("TxPool.AccountSlots") == nil {
confTree.Set("TxPool.AccountSlots", defaultConfig.TxPool.AccountSlots)
}
confTree.Set("Version", "2.5.1")
return confTree
}
}

@ -5,7 +5,7 @@ import (
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
)
const tomlConfigVersion = "2.5.0"
const tomlConfigVersion = "2.5.1" // bump from 2.5.0 for AccountSlots
const (
defNetworkType = nodeconfig.Mainnet
@ -65,6 +65,7 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt",
RosettaFixFile: "",
AccountSlots: 16,
},
Sync: getDefaultSyncConfig(defNetworkType),
Pprof: harmonyconfig.PprofConfig{

@ -123,6 +123,7 @@ var (
}
txPoolFlags = []cli.Flag{
tpAccountSlotsFlag,
rosettaFixFileFlag,
tpBlacklistFileFlag,
legacyTPBlacklistFileFlag,
@ -977,6 +978,11 @@ func applyConsensusFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig
// transaction pool flags
var (
tpAccountSlotsFlag = cli.IntFlag{
Name: "txpool.accountslots",
Usage: "number of executable transaction slots guaranteed per account",
DefValue: int(defaultConfig.TxPool.AccountSlots),
}
tpBlacklistFileFlag = cli.StringFlag{
Name: "txpool.blacklist",
Usage: "file of blacklisted wallet addresses",
@ -999,7 +1005,13 @@ func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
if cli.IsFlagChanged(cmd, rosettaFixFileFlag) {
config.TxPool.RosettaFixFile = cli.GetStringFlagValue(cmd, rosettaFixFileFlag)
}
if cli.IsFlagChanged(cmd, tpAccountSlotsFlag) {
value := cli.GetIntFlagValue(cmd, tpAccountSlotsFlag) // int, so fits in uint64 when positive
if value <= 0 {
panic("Must provide positive for txpool.accountslots")
}
config.TxPool.AccountSlots = uint64(cli.GetIntFlagValue(cmd, tpAccountSlotsFlag))
}
if cli.IsFlagChanged(cmd, tpBlacklistFileFlag) {
config.TxPool.BlacklistFile = cli.GetStringFlagValue(cmd, tpBlacklistFileFlag)
} else if cli.IsFlagChanged(cmd, legacyTPBlacklistFileFlag) {

@ -102,6 +102,7 @@ func TestHarmonyFlags(t *testing.T) {
TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt",
RosettaFixFile: "",
AccountSlots: 16,
},
Pprof: harmonyconfig.PprofConfig{
Enabled: false,
@ -780,6 +781,7 @@ func TestTxPoolFlags(t *testing.T) {
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
},
},
{
@ -787,6 +789,7 @@ func TestTxPoolFlags(t *testing.T) {
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: "blacklist.file",
RosettaFixFile: "rosettafix.file",
AccountSlots: 16, // default
},
},
{
@ -794,6 +797,15 @@ func TestTxPoolFlags(t *testing.T) {
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: "blacklist.file",
RosettaFixFile: "rosettafix.file",
AccountSlots: 16, // default
},
},
{
args: []string{"--txpool.accountslots", "5", "--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file"},
expConfig: harmonyconfig.TxPoolConfig{
AccountSlots: 5,
BlacklistFile: "blacklist.file",
RosettaFixFile: "rosettafix.file",
},
},
}

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

@ -88,6 +88,7 @@ type BlsConfig struct {
type TxPoolConfig struct {
BlacklistFile string
RosettaFixFile string
AccountSlots uint64
}
type PprofConfig struct {

@ -1034,6 +1034,9 @@ func New(
txPoolConfig.PriceLimit = 1e9
txPoolConfig.PriceBump = 10
}
if harmonyconfig != nil {
txPoolConfig.AccountSlots = harmonyconfig.TxPool.AccountSlots
}
txPoolConfig.Blacklist = blacklist
txPoolConfig.Journal = fmt.Sprintf("%v/%v", node.NodeConfig.DBDir, txPoolConfig.Journal)

@ -1,4 +1,4 @@
Version = "2.5.0"
Version = "2.5.1"
[BLSKeys]
KMSConfigFile = ""
@ -90,6 +90,7 @@ Version = "2.5.0"
[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
RosettaFixFile = "./rosetta_local_fix.csv"
AccountSlots = 16
[WS]
AuthPort = 9801

@ -1,4 +1,4 @@
Version = "2.5.0"
Version = "2.5.1"
[BLSKeys]
KMSConfigFile = ""
@ -89,6 +89,7 @@ Version = "2.5.0"
[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
AccountSlots = 16
[WS]
AuthPort = 9801

Loading…
Cancel
Save