Merge branch 'r3_txs_throttle' into txr3

pull/1319/head
Dennis JongHyuck Won 5 years ago committed by GitHub
commit 4690a3e29f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 68
      cmd/client/wallet/generated_wallet.ini.go
  2. 1
      cmd/client/wallet_stress_test/generated_wallet.ini.go
  3. 7
      cmd/client/wallet_stress_test/main.go
  4. 22
      core/types/transaction.go
  5. 1
      internal/configs/sharding/mainnet.go
  6. 5
      node/node.go
  7. 2
      node/worker/worker.go

@ -4,83 +4,45 @@ const (
defaultWalletIni = `[default]
bootnode = /ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
shards = 4
[default.shard0.rpc]
rpc = l0.t.hmny.io:14555
rpc = s0.t.hmny.io:14555
[default.shard1.rpc]
rpc = l1.t.hmny.io:14555
rpc = s1.t.hmny.io:14555
[default.shard2.rpc]
rpc = l2.t.hmny.io:14555
rpc = s2.t.hmny.io:14555
[default.shard3.rpc]
rpc = l3.t.hmny.io:14555
rpc = s3.t.hmny.io:14555
[local]
bootnode = /ip4/127.0.0.1/tcp/19876/p2p/Qmc1V6W7BwX8Ugb42Ti8RnXF1rY5PF7nnZ6bKBryCgi6cv
shards = 2
[local.shard0.rpc]
rpc = 127.0.0.1:14555
rpc = 127.0.0.1:14557
rpc = 127.0.0.1:14559
[local.shard1.rpc]
rpc = 127.0.0.1:14556
rpc = 127.0.0.1:14558
rpc = 127.0.0.1:14560
[beta]
bootnode = /ip4/54.213.43.194/tcp/9868/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/100.26.90.187/tcp/9868/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/13.113.101.219/tcp/12018/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
shards = 4
[beta.shard0.rpc]
rpc = l0.b.hmny.io:14555
rpc = s0.b.hmny.io:14555
[beta.shard1.rpc]
rpc = l1.b.hmny.io:14555
rpc = s1.b.hmny.io:14555
[beta.shard2.rpc]
rpc = l2.b.hmny.io:14555
rpc = s2.b.hmny.io:14555
[beta.shard3.rpc]
rpc = l3.b.hmny.io:14555
rpc = s3.b.hmny.io:14555
[pangaea]
bootnode = /ip4/100.26.90.187/tcp/9867/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9867/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/13.113.101.219/tcp/9867/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
bootnode = /ip4/99.81.170.167/tcp/9867/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
[devnet]
bootnode = /ip4/100.26.90.187/tcp/9871/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9871/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
shards = 4
[pangaea.shard0.rpc]
rpc = l0.p.hmny.io:14555
rpc = s0.p.hmny.io:14555
[pangaea.shard1.rpc]
rpc = l1.p.hmny.io:14555
rpc = s1.p.hmny.io:14555
[pangaea.shard2.rpc]
rpc = l2.p.hmny.io:14555
rpc = s2.p.hmny.io:14555
[pangaea.shard3.rpc]
rpc = l3.p.hmny.io:14555
rpc = s3.p.hmny.io:14555
[devnet.shard0.rpc]
rpc = l0.t1.hmny.io:14555
rpc = s0.t1.hmny.io:14555
[devnet.shard1.rpc]
rpc = l1.t1.hmny.io:14555
rpc = s1.t1.hmny.io:14555
[devnet.shard2.rpc]
rpc = l2.t1.hmny.io:14555
rpc = s2.t1.hmny.io:14555
[devnet.shard3.rpc]
rpc = l3.t1.hmny.io:14555
rpc = s3.t1.hmny.io:14555
`
)

@ -4,6 +4,7 @@ const (
defaultWalletIni = `[default]
bootnode = /ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
shards = 4

@ -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)
@ -273,6 +273,11 @@ func processStressTestCommand() {
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
}

@ -11,6 +11,7 @@ import (
const (
mainnetEpochBlock1 = 344064 // 21 * 2^14
blocksPerShard = 16384 // 2^14
mainnetV0_1Epoch = 1
mainnetV0_2Epoch = 5
mainnetV0_3Epoch = 8

@ -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