Renamed the prev MaxNumTxsPerBlockLimit to tx pool size limit and added another config value MaxNumTxsPerBlockLimit separately

pull/1319/head
Dennis Won 5 years ago
parent 24a87fdcc3
commit dffe6652a7
  1. 2
      core/types/transaction.go
  2. 11
      internal/configs/sharding/fixedschedule.go
  3. 14
      internal/configs/sharding/localnet.go
  4. 14
      internal/configs/sharding/mainnet.go
  5. 14
      internal/configs/sharding/shardingconfig.go
  6. 14
      internal/configs/sharding/testnet.go
  7. 2
      node/node.go
  8. 16
      node/worker/worker.go

@ -295,6 +295,8 @@ func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int) {
// Transactions is a Transaction slice type for basic sorting.
type Transactions []*Transaction
// TODO: put these temp custom txs data structures into other places to keep Transaction type code clean.
// RecentTxsStats is a recent transactions stats map tracking stats like BlockTxsCounts.
type RecentTxsStats map[uint64]BlockTxsCounts

@ -44,15 +44,20 @@ func (s fixedSchedule) MaxNumRecentTxsPerAccountLimit() uint64 {
return mainnetMaxNumRecentTxsPerAccountLimit
}
func (s fixedSchedule) MaxTxsPerBlockLimit() int {
return mainnetMaxTxsPerBlockLimit
func (s fixedSchedule) MaxTxPoolSizeLimit() int {
return mainnetMaxTxPoolSizeLimit
}
func (s fixedSchedule) MaxNumTxsPerBlockLimit() int {
return mainnetMaxNumTxsPerBlockLimit
}
func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: s.MaxTxAmountLimit(),
MaxNumRecentTxsPerAccountLimit: s.MaxNumRecentTxsPerAccountLimit(),
MaxTxsPerBlockLimit: s.MaxTxsPerBlockLimit(),
MaxTxPoolSizeLimit: s.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: s.MaxNumTxsPerBlockLimit(),
}
}

@ -22,7 +22,8 @@ const (
localnetMaxTxAmountLimit = 1e2 // unit is in One
localnetMaxNumRecentTxsPerAccountLimit = 2
localnetMaxTxsPerBlockLimit = 8000
localnetMaxTxPoolSizeLimit = 8000
localnetMaxNumTxsPerBlockLimit = 1000
)
func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
@ -72,15 +73,20 @@ func (ls localnetSchedule) MaxNumRecentTxsPerAccountLimit() uint64 {
return localnetMaxNumRecentTxsPerAccountLimit
}
func (ls localnetSchedule) MaxTxsPerBlockLimit() int {
return localnetMaxTxsPerBlockLimit
func (ls localnetSchedule) MaxTxPoolSizeLimit() int {
return localnetMaxTxPoolSizeLimit
}
func (ls localnetSchedule) MaxNumTxsPerBlockLimit() int {
return localnetMaxNumTxsPerBlockLimit
}
func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ls.MaxTxAmountLimit(),
MaxNumRecentTxsPerAccountLimit: ls.MaxNumRecentTxsPerAccountLimit(),
MaxTxsPerBlockLimit: ls.MaxTxsPerBlockLimit(),
MaxTxPoolSizeLimit: ls.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ls.MaxNumTxsPerBlockLimit(),
}
}

@ -15,7 +15,8 @@ const (
mainnetMaxTxAmountLimit = 1e3 // unit is in One
mainnetMaxNumRecentTxsPerAccountLimit = 10
mainnetMaxTxsPerBlockLimit = 8000
mainnetMaxTxPoolSizeLimit = 8000
mainnetMaxNumTxsPerBlockLimit = 1000
)
// MainnetSchedule is the mainnet sharding configuration schedule.
@ -72,15 +73,20 @@ func (ms mainnetSchedule) MaxNumRecentTxsPerAccountLimit() uint64 {
return mainnetMaxNumRecentTxsPerAccountLimit
}
func (ms mainnetSchedule) MaxTxsPerBlockLimit() int {
return mainnetMaxTxsPerBlockLimit
func (ms mainnetSchedule) MaxTxPoolSizeLimit() int {
return mainnetMaxTxPoolSizeLimit
}
func (ms mainnetSchedule) MaxNumTxsPerBlockLimit() int {
return mainnetMaxNumTxsPerBlockLimit
}
func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ms.MaxTxAmountLimit(),
MaxNumRecentTxsPerAccountLimit: ms.MaxNumRecentTxsPerAccountLimit(),
MaxTxsPerBlockLimit: ms.MaxTxsPerBlockLimit(),
MaxTxPoolSizeLimit: ms.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ms.MaxNumTxsPerBlockLimit(),
}
}

@ -28,8 +28,11 @@ type Schedule interface {
// Max number of transactions of a particular account per block level
MaxNumRecentTxsPerAccountLimit() uint64
// Max total number of transactions in a block
MaxTxsPerBlockLimit() int
// Max total number of transactions allowed as pending transactions in transaction pool
MaxTxPoolSizeLimit() int
// Max total number of transactions allowed to be processed per block
MaxNumTxsPerBlockLimit() int
// configuration for throttling pending transactions
TxsThrottleConfig() *TxsThrottleConfig
@ -92,6 +95,9 @@ type TxsThrottleConfig struct {
// Max number of transactions of a particular account for the past hour
MaxNumRecentTxsPerAccountLimit uint64
// Max total number of transactions in a block
MaxTxsPerBlockLimit int
// Max total number of transactions allowed as pending transactions in transaction pool
MaxTxPoolSizeLimit int
// Max total number of transactions allowed to be processed per block
MaxNumTxsPerBlockLimit int
}

@ -22,7 +22,8 @@ const (
testnetMaxTxAmountLimit = 1e3 // unit is in One
testnetMaxNumRecentTxsPerAccountLimit = 10
testnetMaxTxsPerBlockLimit = 8000
testnetMaxTxPoolSizeLimit = 8000
testnetMaxNumTxsPerBlockLimit = 1000
)
func (testnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
@ -73,15 +74,20 @@ func (ts testnetSchedule) MaxNumRecentTxsPerAccountLimit() uint64 {
return testnetMaxNumRecentTxsPerAccountLimit
}
func (ts testnetSchedule) MaxTxsPerBlockLimit() int {
return testnetMaxTxsPerBlockLimit
func (ts testnetSchedule) MaxTxPoolSizeLimit() int {
return testnetMaxTxPoolSizeLimit
}
func (ts testnetSchedule) MaxNumTxsPerBlockLimit() int {
return testnetMaxNumTxsPerBlockLimit
}
func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ts.MaxTxAmountLimit(),
MaxNumRecentTxsPerAccountLimit: ts.MaxNumRecentTxsPerAccountLimit(),
MaxTxsPerBlockLimit: ts.MaxTxsPerBlockLimit(),
MaxTxPoolSizeLimit: ts.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ts.MaxNumTxsPerBlockLimit(),
}
}

@ -226,7 +226,7 @@ func (node *Node) Beaconchain() *core.BlockChain {
}
func (node *Node) reducePendingTransactions() {
txPoolLimit := core.ShardingSchedule.MaxTxsPerBlockLimit()
txPoolLimit := core.ShardingSchedule.MaxTxPoolSizeLimit()
curLen := len(node.pendingTransactions)
// If length of pendingTransactions is greater than TxPoolLimit then by greedy take the TxPoolLimit recent transactions.

@ -66,10 +66,10 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
}
// already selected max num txs
if len(selected) > txsThrottleConfig.MaxTxsPerBlockLimit {
utils.GetLogInstance().Info("Throttling tx with max txs per block limit",
if len(selected) > txsThrottleConfig.MaxNumTxsPerBlockLimit {
utils.GetLogInstance().Info("Throttling tx with max num txs per block limit",
"tx Id", tx.Hash().Hex(),
"MaxTxsPerBlockLimit", txsThrottleConfig.MaxTxsPerBlockLimit)
"MaxNumTxsPerBlockLimit", txsThrottleConfig.MaxNumTxsPerBlockLimit)
return sender, shardingconfig.TxUnselect
}
@ -143,7 +143,17 @@ func (w *Worker) SelectTransactionsForNewBlock(newBlockNum uint64, txs types.Tra
"Transaction Id", tx.Hash().Hex(),
"txThrottleFlag", flag.String())
}
utils.GetLogInstance().Info("Transaction gas limit info",
"Transaction Id", tx.Hash().Hex(),
"tx gas limit", tx.Gas())
}
utils.GetLogInstance().Info("Block gas limit and usage info",
"newBlockNum", newBlockNum,
"block gas limit", w.current.header.GasLimit,
"block gas used", w.current.header.GasUsed)
return selected, unselected, invalid
}

Loading…
Cancel
Save