addressed PR comments

pull/1319/head
Dennis Won 5 years ago
parent a9bbcf6ae8
commit 5df2131bad
  1. 9
      cmd/client/wallet_stress_test/main.go
  2. 22
      core/types/transaction.go
  3. 5
      node/node.go
  4. 2
      node/worker/worker.go

@ -242,7 +242,7 @@ func processStressTestCommand() {
var receiverState *AccountState
var retry uint32
for i := 0; i < 10; i++ {
for i := 0; ; i++ {
for retry = 0; retry < 10; retry++ {
shardIDToAccountStateSender = FetchBalance(senderAddress)
shardIDToAccountStateReceiver = FetchBalance(receiverAddress)
@ -268,11 +268,16 @@ func processStressTestCommand() {
receiverBalance := receiverState.balance
// amount 1/10th of the balance
amountBigInt := senderBalance.Div(senderBalance, big.NewInt(10))
amountBigInt := senderBalance.Div(senderBalance, big.NewInt(1))
fmt.Printf("\nsender: balance (shard %d: %s, nonce: %v)\n", shardID, convertBalanceIntoReadableFormat(senderBalance), senderState.nonce)
fmt.Printf("receiver balance (shard %d: %s, nonce: %v)\n", shardID, convertBalanceIntoReadableFormat(receiverBalance), receiverState.nonce)
// stop stress testing here after printing out the final balance
if i == 10 {
break
}
tx := types.NewTransaction(
senderState.nonce, receiverAddress, uint32(shardID), amountBigInt,
gasLimit, gasPriceBigInt, data)

@ -19,6 +19,7 @@ package types
import (
"container/heap"
"errors"
"fmt"
"io"
"math/big"
"sync/atomic"
@ -27,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
common2 "github.com/harmony-one/harmony/internal/common"
)
// no go:generate gencodec -type txdata -field-override txdataMarshaling -out gen_tx_json.go
@ -489,6 +491,26 @@ func (m Message) CheckNonce() bool {
// RecentTxsStats is a recent transactions stats map tracking stats like BlockTxsCounts.
type RecentTxsStats map[uint64]BlockTxsCounts
// String returns the string formatted representation of RecentTxsStats
func (rts RecentTxsStats) String() string {
ret := "{ "
for blockNum, blockTxsCounts := range rts {
ret += fmt.Sprintf("blockNum:%d=%s", blockNum, blockTxsCounts.String())
}
ret += " }"
return ret
}
// BlockTxsCounts is a transactions counts map of
// the number of transactions made by each account in a block on this node.
type BlockTxsCounts map[common.Address]uint64
// String returns the string formatted representation of BlockTxsCounts
func (btc BlockTxsCounts) String() string {
ret := "{ "
for sender, numTxs := range btc {
ret += fmt.Sprintf("%s:%d,", common2.MustAddressToBech32(sender), numTxs)
}
ret += " }"
return ret
}

@ -265,10 +265,9 @@ func (node *Node) getTransactionsForNewBlock(coinbase common.Address) types.Tran
newBlockNum := node.Blockchain().CurrentBlock().NumberU64() + 1
// remove old (> txsThrottleConfigRecentTxDuration) blockNum keys from recentTxsStats and initiailize for the new block
recentTxsBlockNumGap := uint64(txsThrottleConfig.RecentTxDuration / node.BlockPeriod)
for blockNum := range node.recentTxsStats {
blockNumHourAgo := uint64(txsThrottleConfig.RecentTxDuration / node.BlockPeriod)
if blockNumHourAgo < newBlockNum-blockNum {
if recentTxsBlockNumGap < newBlockNum-blockNum {
delete(node.recentTxsStats, blockNum)
}
}

@ -69,7 +69,7 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
utils.GetLogInstance().Info("Throttling tx with max amount limit",
"tx Id", tx.Hash().Hex(),
"MaxTxAmountLimit", txsThrottleConfig.MaxTxAmountLimit.Uint64(),
"Tx amount", tx.Value().Uint64())
"Tx amount", tx.Value())
return sender, shardingconfig.TxInvalid
}

Loading…
Cancel
Save