Disable throttling for txns

pull/1772/head
Rongjian Lan 5 years ago
parent 58e05eea5e
commit 06f8594aa2
  1. 2
      cmd/client/wallet/main.go
  2. 2
      internal/configs/sharding/localnet.go
  3. 2
      internal/configs/sharding/mainnet.go
  4. 2
      internal/configs/sharding/testnet.go
  5. 10
      node/worker/worker.go

@ -976,6 +976,8 @@ func submitTransaction(tx *types.Transaction, walletNode *node.Node, shardID uin
return err
}
fmt.Printf("Transaction Id for shard %d: %s\n", int(shardID), tx.Hash().Hex())
json, err := tx.MarshalJSON()
fmt.Printf("Transaction Submitted for shard %d: %s\n", int(shardID), string(json))
// FIXME (leo): how to we know the tx was successful sent to the network
// this is a hacky way to wait for sometime
time.Sleep(3 * time.Second)

@ -32,7 +32,7 @@ const (
localnetMaxTxPoolSizeLimit = 8000
localnetMaxNumTxsPerBlockLimit = 1000
localnetRecentTxDuration = time.Hour
localnetEnableTxnThrottling = true
localnetEnableTxnThrottling = false
)
func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {

@ -34,7 +34,7 @@ const (
mainnetMaxTxPoolSizeLimit = 8000
mainnetMaxNumTxsPerBlockLimit = 1000
mainnetRecentTxDuration = time.Hour
mainnetEnableTxnThrottling = true
mainnetEnableTxnThrottling = false
// MainNetHTTPPattern is the http pattern for mainnet.
MainNetHTTPPattern = "https://api.s%d.t.hmny.io"

@ -28,7 +28,7 @@ const (
testnetMaxTxPoolSizeLimit = 8000
testnetMaxNumTxsPerBlockLimit = 1000
testnetRecentTxDuration = time.Hour
testnetEnableTxnThrottling = true
testnetEnableTxnThrottling = false
// TestNetHTTPPattern is the http pattern for testnet.
TestNetHTTPPattern = "https://api.s%d.b.hmny.io"

@ -62,17 +62,17 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
sender = msg.From()
}
// do not throttle transactions if disabled
if !txsThrottleConfig.EnableTxnThrottling {
return sender, shardingconfig.TxSelect
}
// already selected max num txs
if len(selected) > txsThrottleConfig.MaxNumTxsPerBlockLimit {
utils.Logger().Info().Str("txId", tx.Hash().Hex()).Int("MaxNumTxsPerBlockLimit", txsThrottleConfig.MaxNumTxsPerBlockLimit).Msg("Throttling tx with max num txs per block limit")
return sender, shardingconfig.TxUnselect
}
// do not throttle transactions if disabled
if !txsThrottleConfig.EnableTxnThrottling {
return sender, shardingconfig.TxSelect
}
// throttle a single sender sending too many transactions in one block
if tx.Value().Cmp(txsThrottleConfig.MaxTxAmountLimit) > 0 {
utils.Logger().Info().Str("txId", tx.Hash().Hex()).Uint64("MaxTxAmountLimit", txsThrottleConfig.MaxTxAmountLimit.Uint64()).Uint64("txAmount", tx.Value().Uint64()).Msg("Throttling tx with max amount limit")

Loading…
Cancel
Save