diff --git a/aws-code/transaction_generator.go b/aws-code/transaction_generator.go index 31bf14788..4c4783b3a 100644 --- a/aws-code/transaction_generator.go +++ b/aws-code/transaction_generator.go @@ -2,19 +2,19 @@ package main import ( "bufio" + "encoding/hex" "flag" "fmt" "harmony-benchmark/blockchain" + "harmony-benchmark/consensus" "harmony-benchmark/log" "harmony-benchmark/node" "harmony-benchmark/p2p" "math/rand" "os" + "strconv" "strings" "time" - "harmony-benchmark/consensus" - "encoding/hex" - "strconv" ) // Get numTxs number of Fake transactions based on the existing UtxoPool. @@ -50,7 +50,7 @@ func getNewFakeTransactions(dataNode *node.Node, numTxs int) []*blockchain.Trans for index, value := range utxoMap { countAll++ if rand.Intn(100) <= 20 { // 20% sample rate to select UTXO to use for new transactions - // Spend the money of current UTXO to a random address in [1 - 1000] + // Spend the money of current UTXO to a random address in [1 - 1000] txin := blockchain.TXInput{txId, index, address} txout := blockchain.TXOutput{value, strconv.Itoa(rand.Intn(1000))} tx := blockchain.Transaction{[32]byte{}, []blockchain.TXInput{txin}, []blockchain.TXOutput{txout}} diff --git a/aws-scripts/preprocess_peerlist.py b/aws-scripts/preprocess_peerlist.py new file mode 100644 index 000000000..eda1e7fe3 --- /dev/null +++ b/aws-scripts/preprocess_peerlist.py @@ -0,0 +1,21 @@ +import requests +amazon_ipv4_url = "http://169.254.169.254/latest/meta-data/public-ipv4" +if __name__ == "__main__": + current_ip = requests.get(amazon_ipv4_url).text + f = open("global_nodes.txt","r") + peerList = [] + for myline in f: + mylist = myline.split(" ") + ip = mylist[0] + node = mylist[2] + if node != "transaction": + peerList.append(myline) + else: + h = open("isTransaction.txt","w") + h.write("I am just a transaction generator node") + h.close() + f.close() + g = open("global_peerlist.txt","w") + for myline in peerList: + g.write(myline) + g.close() diff --git a/aws-scripts/run_instances.sh b/aws-scripts/run_instances.sh index bd4b7f59f..fd79e6d26 100755 --- a/aws-scripts/run_instances.sh +++ b/aws-scripts/run_instances.sh @@ -1,3 +1,3 @@ #!/bin/bash -x cd /home/ec2-user/projects/src/harmony-benchmark -./deploy_linux.sh local_config2.txt \ No newline at end of file +./deploy_one_instance.sh global_nodes.txt \ No newline at end of file diff --git a/deploy_one_instance.sh b/deploy_one_instance.sh new file mode 100755 index 000000000..fd5131045 --- /dev/null +++ b/deploy_one_instance.sh @@ -0,0 +1,20 @@ +#!/bin/bash -x +##The commented suffix is for linux +##Reference: https://github.com/Zilliqa/Zilliqa/blob/master/tests/Node/test_node_simple.sh +sudo sysctl net.core.somaxconn=1024 +sudo sysctl net.core.netdev_max_backlog=65536; +sudo sysctl net.ipv4.tcp_tw_reuse=1; +sudo sysctl -w net.ipv4.tcp_rmem='65536 873800 1534217728'; +sudo sysctl -w net.ipv4.tcp_wmem='65536 873800 1534217728'; +sudo sysctl -w net.ipv4.tcp_mem='65536 873800 1534217728'; + +./kill_node.sh +source ~/.bash_profile +python aws-scripts/preprocess_peerlist.py +FILE='isTransaction.txt' +config=$1 +if [ -f $FILE ]; then + go run ./aws-code/transaction_generator.go -config_file $config +else + go run ./benchmark_main.go -config_file $config& +fi \ No newline at end of file diff --git a/global_nodes.txt b/global_nodes.txt new file mode 100644 index 000000000..4a6a3c34e --- /dev/null +++ b/global_nodes.txt @@ -0,0 +1,3 @@ +34.219.57.67 9000 validator 0 +52.43.81.62 9000 leader 0 +54.201.72.153 9000 transaction 0 \ No newline at end of file