diff --git a/internal/configs/sharding/fixedschedule.go b/internal/configs/sharding/fixedschedule.go index 8f2b8d198..da63e28b3 100644 --- a/internal/configs/sharding/fixedschedule.go +++ b/internal/configs/sharding/fixedschedule.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(), } } diff --git a/internal/configs/sharding/localnet.go b/internal/configs/sharding/localnet.go index a47562cce..967ea70b1 100644 --- a/internal/configs/sharding/localnet.go +++ b/internal/configs/sharding/localnet.go @@ -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(), } } diff --git a/internal/configs/sharding/mainnet.go b/internal/configs/sharding/mainnet.go index b35252234..d7e78d541 100644 --- a/internal/configs/sharding/mainnet.go +++ b/internal/configs/sharding/mainnet.go @@ -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(), } } diff --git a/internal/configs/sharding/shardingconfig.go b/internal/configs/sharding/shardingconfig.go index 5ecec75ff..cbc8cb05f 100644 --- a/internal/configs/sharding/shardingconfig.go +++ b/internal/configs/sharding/shardingconfig.go @@ -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 diff --git a/internal/configs/sharding/testnet.go b/internal/configs/sharding/testnet.go index de8710c44..80b37c14f 100644 --- a/internal/configs/sharding/testnet.go +++ b/internal/configs/sharding/testnet.go @@ -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(), } } diff --git a/node/worker/worker.go b/node/worker/worker.go index 76032387d..d3c6ab9bc 100644 --- a/node/worker/worker.go +++ b/node/worker/worker.go @@ -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 }