rename tx throttline configuration key name to MaxNumTxsPerAccountPastHourLimit

pull/1319/head
Dennis Won 5 years ago
parent b4c4f76546
commit 987306a9f8
  1. 10
      internal/configs/sharding/fixedschedule.go
  2. 16
      internal/configs/sharding/localnet.go
  3. 16
      internal/configs/sharding/mainnet.go
  4. 6
      internal/configs/sharding/shardingconfig.go
  5. 16
      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 {
@ -50,9 +50,9 @@ func (s fixedSchedule) MaxTxsPerBlockLimit() int {
func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: s.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: s.MaxTxsPerAccountInBlockLimit(),
MaxTxsPerBlockLimit: s.MaxTxsPerBlockLimit(),
MaxTxAmountLimit: s.MaxTxAmountLimit(),
MaxNumTxsPerAccountPastHourLimit: s.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: s.MaxTxsPerBlockLimit(),
}
}

@ -20,9 +20,9 @@ const (
localnetEpochBlock1 = 20
twoOne = 5
localnetMaxTxAmountLimit = 1e2 // unit is in One
localnetMaxTxsPerAccountInBlockLimit = 2
localnetMaxTxsPerBlockLimit = 8000
localnetMaxTxAmountLimit = 1e2 // unit is in One
localnetMaxNumTxsPerAccountPastHourLimit = 2
localnetMaxTxsPerBlockLimit = 8000
)
func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
@ -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 {
@ -78,9 +78,9 @@ func (ls localnetSchedule) MaxTxsPerBlockLimit() int {
func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ls.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ls.MaxTxsPerAccountInBlockLimit(),
MaxTxsPerBlockLimit: ls.MaxTxsPerBlockLimit(),
MaxTxAmountLimit: ls.MaxTxAmountLimit(),
MaxNumTxsPerAccountPastHourLimit: ls.MaxNumTxsPerAccountPastHourLimit(),
MaxTxsPerBlockLimit: ls.MaxTxsPerBlockLimit(),
}
}

@ -13,9 +13,9 @@ const (
mainnetV1Epoch = 1
mainnetV2Epoch = 5
mainnetMaxTxAmountLimit = 1e3 // unit is in One
mainnetMaxTxsPerAccountInBlockLimit = 10
mainnetMaxTxsPerBlockLimit = 8000
mainnetMaxTxAmountLimit = 1e3 // unit is in One
mainnetMaxNumTxsPerAccountPastHourLimit = 10
mainnetMaxTxsPerBlockLimit = 8000
)
// MainnetSchedule is the mainnet sharding configuration schedule.
@ -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 {
@ -78,9 +78,9 @@ func (ms mainnetSchedule) MaxTxsPerBlockLimit() int {
func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ms.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ms.MaxTxsPerAccountInBlockLimit(),
MaxTxsPerBlockLimit: ms.MaxTxsPerBlockLimit(),
MaxTxAmountLimit: ms.MaxTxAmountLimit(),
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

@ -20,9 +20,9 @@ const (
testnetEpochBlock1 = 78
threeOne = 111
testnetMaxTxAmountLimit = 1e3 // unit is in One
testnetMaxTxsPerAccountInBlockLimit = 10
testnetMaxTxsPerBlockLimit = 8000
testnetMaxTxAmountLimit = 1e3 // unit is in One
testnetMaxNumTxsPerAccountPastHourLimit = 10
testnetMaxTxsPerBlockLimit = 8000
)
func (testnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
@ -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 {
@ -79,9 +79,9 @@ func (ts testnetSchedule) MaxTxsPerBlockLimit() int {
func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ts.MaxTxAmountLimit(),
MaxTxsPerAccountInBlockLimit: ts.MaxTxsPerAccountInBlockLimit(),
MaxTxsPerBlockLimit: ts.MaxTxsPerBlockLimit(),
MaxTxAmountLimit: ts.MaxTxAmountLimit(),
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