stress test script updates

pull/1319/head
Dennis Won 5 years ago
parent 6bcbde5a3a
commit a9bbcf6ae8
  1. 77
      cmd/client/wallet_stress_test/main.go
  2. 2
      internal/configs/sharding/localnet.go
  3. 11
      node/worker/worker.go

@ -33,10 +33,11 @@ import (
) )
var ( var (
version string version string
builtBy string builtBy string
builtAt string builtAt string
commit string commit string
nextNonce uint64
) )
func printVersion(me string) { func printVersion(me string) {
@ -213,18 +214,14 @@ func processStressTestCommand() {
*/ */
fmt.Println("Creating wallet node")
walletNode := createWalletNode()
senderAddress := common2.ParseAddr("one1uyshu2jgv8w465yc8kkny36thlt2wvel89tcmg") senderAddress := common2.ParseAddr("one1uyshu2jgv8w465yc8kkny36thlt2wvel89tcmg")
receiverAddress := common2.ParseAddr("one1spshr72utf6rwxseaz339j09ed8p6f8ke370zj") receiverAddress := common2.ParseAddr("one1spshr72utf6rwxseaz339j09ed8p6f8ke370zj")
shardID := 1 shardID := 1
walletNode := createWalletNode() fmt.Printf("Sender account: %s:\n", common2.MustAddressToBech32(senderAddress))
shardIDToAccountState := FetchBalance(senderAddress)
state := shardIDToAccountState[shardID]
balance := state.balance
// amount 1/10th of the balance
amountBigInt := balance.Div(balance, big.NewInt(10))
// default inputData // default inputData
data := make([]byte, 0) data := make([]byte, 0)
@ -235,12 +232,49 @@ func processStressTestCommand() {
gasPriceBigInt := big.NewInt(int64(gasPrice)) gasPriceBigInt := big.NewInt(int64(gasPrice))
gasPriceBigInt = gasPriceBigInt.Mul(gasPriceBigInt, big.NewInt(denominations.Nano)) gasPriceBigInt = gasPriceBigInt.Mul(gasPriceBigInt, big.NewInt(denominations.Nano))
fmt.Printf("gas limit: %d, gas price: %d", gasLimit, gasPriceBigInt.Uint64())
senderPass := "" senderPass := ""
for i := 0; i < 4; i++ { var shardIDToAccountStateSender []*AccountState
currNonce := state.nonce var shardIDToAccountStateReceiver []*AccountState
var senderState *AccountState
var receiverState *AccountState
var retry uint32
for i := 0; i < 10; i++ {
for retry = 0; retry < 10; retry++ {
shardIDToAccountStateSender = FetchBalance(senderAddress)
shardIDToAccountStateReceiver = FetchBalance(receiverAddress)
senderState = shardIDToAccountStateSender[shardID]
receiverState = shardIDToAccountStateReceiver[shardID]
if senderState.nonce == nextNonce {
break
}
time.Sleep(3 * time.Second)
fmt.Printf(".")
}
if retry == 10 {
fmt.Printf("\nRetry expired. Num txs made: %d\n", i)
break
}
nextNonce++
senderBalance := senderState.balance
receiverBalance := receiverState.balance
// amount 1/10th of the balance
amountBigInt := senderBalance.Div(senderBalance, big.NewInt(10))
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)
tx := types.NewTransaction( tx := types.NewTransaction(
currNonce, receiverAddress, uint32(shardID), amountBigInt, senderState.nonce, receiverAddress, uint32(shardID), amountBigInt,
gasLimit, gasPriceBigInt, data) gasLimit, gasPriceBigInt, data)
account, _ := ks.Find(accounts.Account{Address: senderAddress}) account, _ := ks.Find(accounts.Account{Address: senderAddress})
@ -253,21 +287,10 @@ func processStressTestCommand() {
fmt.Println(ctxerror.New("submitTransaction failed", fmt.Println(ctxerror.New("submitTransaction failed",
"tx", tx, "shardID", shardID).WithCause(err)) "tx", tx, "shardID", shardID).WithCause(err))
} }
for retry := 0; retry < 10; retry++ {
accountStates := FetchBalance(senderAddress)
state = accountStates[shardID]
fmt.Println("state.nonce", state.nonce)
if state.nonce == currNonce+1 {
break
}
time.Sleep(3 * time.Second)
}
} }
fmt.Printf("Sender Account: %s:\n", common2.MustAddressToBech32(senderAddress))
for shardID, balanceNonce := range FetchBalance(senderAddress) { for shardID, balanceNonce := range FetchBalance(senderAddress) {
fmt.Printf(" Balance in Shard %d: %s, nonce: %v \n", shardID, convertBalanceIntoReadableFormat(balanceNonce.balance), balanceNonce.nonce) fmt.Printf(" Final: Balance in Shard %d: %s, nonce: %v \n", shardID, convertBalanceIntoReadableFormat(balanceNonce.balance), balanceNonce.nonce)
} }
} }

@ -25,7 +25,7 @@ const (
localnetMaxNumRecentTxsPerAccountLimit = 2 localnetMaxNumRecentTxsPerAccountLimit = 2
localnetMaxTxPoolSizeLimit = 8000 localnetMaxTxPoolSizeLimit = 8000
localnetMaxNumTxsPerBlockLimit = 1000 localnetMaxNumTxsPerBlockLimit = 1000
localnetRecentTxDuration = 100 * time.Second localnetRecentTxDuration = 10 * time.Second
) )
func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance { func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {

@ -47,17 +47,8 @@ type Worker struct {
// the second is the throttling result enum for the transaction of interest. // the second is the throttling result enum for the transaction of interest.
// Throttling happens based on the amount, frequency, etc. // Throttling happens based on the amount, frequency, etc.
func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.RecentTxsStats, txsThrottleConfig *shardingconfig.TxsThrottleConfig, tx *types.Transaction) (common.Address, shardingconfig.TxThrottleFlag) { func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.RecentTxsStats, txsThrottleConfig *shardingconfig.TxsThrottleConfig, tx *types.Transaction) (common.Address, shardingconfig.TxThrottleFlag) {
chainID := tx.ChainID()
// Depending on the presence of the chain ID, sign with EIP155 or homestead
var s types.Signer
if chainID != nil {
s = types.NewEIP155Signer(chainID)
} else {
s = types.HomesteadSigner{}
}
var sender common.Address var sender common.Address
msg, err := tx.AsMessage(s) msg, err := tx.AsMessage(types.MakeSigner(w.config, w.chain.CurrentBlock().Number()))
if err != nil { if err != nil {
utils.GetLogInstance().Error("Error when parsing tx into message", utils.GetLogInstance().Error("Error when parsing tx into message",
"tx Id", tx.Hash().Hex(), "err", err) "tx Id", tx.Hash().Hex(), "err", err)

Loading…
Cancel
Save