rename tx throttline configuration key name to MaxNumTxsPerAccountPastHourLimit

pull/1319/head
Dennis Won 5 years ago
parent b4c4f76546
commit 987306a9f8
  1. 6
      internal/configs/sharding/fixedschedule.go
  2. 8
      internal/configs/sharding/localnet.go
  3. 8
      internal/configs/sharding/mainnet.go
  4. 6
      internal/configs/sharding/shardingconfig.go
  5. 8
      internal/configs/sharding/testnet.go
  6. 4
      node/worker/worker.go

@ -40,8 +40,8 @@ func (s fixedSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt
}
func (s fixedSchedule) MaxTxsPerAccountInBlockLimit() uint64 {
return mainnetMaxTxsPerAccountInBlockLimit
func (s fixedSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return mainnetMaxNumTxsPerAccountPastHourLimit
}
func (s fixedSchedule) MaxTxsPerBlockLimit() int {
@ -51,7 +51,7 @@ func (s fixedSchedule) MaxTxsPerBlockLimit() int {
func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: s.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: s.MaxTxsPerAccountInBlockLimit(),
MaxNumTxsPerAccountPastHourLimit: s.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: s.MaxTxsPerBlockLimit(),
}
}

@ -21,7 +21,7 @@ const (
twoOne = 5
localnetMaxTxAmountLimit = 1e2 // unit is in One
localnetMaxTxsPerAccountInBlockLimit = 2
localnetMaxNumTxsPerAccountPastHourLimit = 2
localnetMaxTxsPerBlockLimit = 8000
)
@ -68,8 +68,8 @@ func (ls localnetSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt
}
func (ls localnetSchedule) MaxTxsPerAccountInBlockLimit() uint64 {
return localnetMaxTxsPerAccountInBlockLimit
func (ls localnetSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return localnetMaxNumTxsPerAccountPastHourLimit
}
func (ls localnetSchedule) MaxTxsPerBlockLimit() int {
@ -79,7 +79,7 @@ func (ls localnetSchedule) MaxTxsPerBlockLimit() int {
func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ls.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ls.MaxTxsPerAccountInBlockLimit(),
MaxNumTxsPerAccountPastHourLimit: ls.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ls.MaxTxsPerBlockLimit(),
}
}

@ -14,7 +14,7 @@ const (
mainnetV2Epoch = 5
mainnetMaxTxAmountLimit = 1e3 // unit is in One
mainnetMaxTxsPerAccountInBlockLimit = 10
mainnetMaxNumTxsPerAccountPastHourLimit = 10
mainnetMaxTxsPerBlockLimit = 8000
)
@ -68,8 +68,8 @@ func (ms mainnetSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt
}
func (ms mainnetSchedule) MaxTxsPerAccountInBlockLimit() uint64 {
return mainnetMaxTxsPerAccountInBlockLimit
func (ms mainnetSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return mainnetMaxNumTxsPerAccountPastHourLimit
}
func (ms mainnetSchedule) MaxTxsPerBlockLimit() int {
@ -79,7 +79,7 @@ func (ms mainnetSchedule) MaxTxsPerBlockLimit() int {
func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ms.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ms.MaxTxsPerAccountInBlockLimit(),
MaxNumTxsPerAccountPastHourLimit: ms.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ms.MaxTxsPerBlockLimit(),
}
}

@ -26,7 +26,7 @@ type Schedule interface {
MaxTxAmountLimit() *big.Int
// Max number of transactions of a particular account per block level
MaxTxsPerAccountInBlockLimit() uint64
MaxNumTxsPerAccountPastHourLimit() uint64
// Max total number of transactions in a block
MaxTxsPerBlockLimit() int
@ -87,8 +87,8 @@ type TxsThrottleConfig struct {
// Max amount limit for a valid transaction
MaxTxAmountLimit *big.Int
// Max number of transactions of a particular account per block level
MaxTxsPerAccountInBlockLimit uint64
// Max number of transactions of a particular account for the past hour
MaxNumTxsPerAccountPastHourLimit uint64
// Max total number of transactions in a block
MaxTxsPerBlockLimit int

@ -21,7 +21,7 @@ const (
threeOne = 111
testnetMaxTxAmountLimit = 1e3 // unit is in One
testnetMaxTxsPerAccountInBlockLimit = 10
testnetMaxNumTxsPerAccountPastHourLimit = 10
testnetMaxTxsPerBlockLimit = 8000
)
@ -69,8 +69,8 @@ func (ts testnetSchedule) MaxTxAmountLimit() *big.Int {
return amountBigInt
}
func (ts testnetSchedule) MaxTxsPerAccountInBlockLimit() uint64 {
return testnetMaxTxsPerAccountInBlockLimit
func (ts testnetSchedule) MaxNumTxsPerAccountPastHourLimit() uint64 {
return testnetMaxNumTxsPerAccountPastHourLimit
}
func (ts testnetSchedule) MaxTxsPerBlockLimit() int {
@ -80,7 +80,7 @@ func (ts testnetSchedule) MaxTxsPerBlockLimit() int {
func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ts.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ts.MaxTxsPerAccountInBlockLimit(),
MaxNumTxsPerAccountPastHourLimit: ts.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ts.MaxTxsPerBlockLimit(),
}
}

@ -86,9 +86,9 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
for _, blockTxsCounts := range recentTxsStats {
numTxsPastHour += blockTxsCounts[sender]
}
if numTxsPastHour >= (*txsThrottleConfig).MaxTxsPerAccountInBlockLimit {
if numTxsPastHour >= (*txsThrottleConfig).MaxNumTxsPerAccountPastHourLimit {
utils.Logger().Debug().
Uint64("MaxTxsPerAccountInBlockLimit", (*txsThrottleConfig).MaxTxsPerAccountInBlockLimit).
Uint64("MaxNumTxsPerAccountPastHourLimit", (*txsThrottleConfig).MaxNumTxsPerAccountPastHourLimit).
Msg("Throttling tx with max txs per account in a single block limit")
return sender, shardingconfig.Unselect
}

Loading…
Cancel
Save