You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.7 KiB

  1. #!/bin/bash
  2. DATA=$GOPATH/src/github.com/tendermint/tendermint/benchmarks/blockchain/data
  3. if [ ! -d $DATA ]; then
  4. echo "no data found, generating a chain... (this only has to happen once)"
  5. tendermint init --home $DATA
  6. cp $DATA/config.toml $DATA/config2.toml
  7. echo "
  8. [consensus]
  9. timeout_commit = 0
  10. " >> $DATA/config.toml
  11. echo "starting node"
  12. tendermint node \
  13. --home $DATA \
  14. --proxy_app dummy \
  15. --p2p.laddr tcp://127.0.0.1:56656 \
  16. --rpc.laddr tcp://127.0.0.1:56657 \
  17. --log_level error &
  18. echo "making blocks for 60s"
  19. sleep 60
  20. mv $DATA/config2.toml $DATA/config.toml
  21. kill %1
  22. echo "done generating chain."
  23. fi
  24. # validator node
  25. HOME1=$TMPDIR$RANDOM$RANDOM
  26. cp -R $DATA $HOME1
  27. echo "starting validator node"
  28. tendermint node \
  29. --home $HOME1 \
  30. --proxy_app dummy \
  31. --p2p.laddr tcp://127.0.0.1:56656 \
  32. --rpc.laddr tcp://127.0.0.1:56657 \
  33. --log_level error &
  34. sleep 1
  35. # downloader node
  36. HOME2=$TMPDIR$RANDOM$RANDOM
  37. tendermint init --home $HOME2
  38. cp $HOME1/genesis.json $HOME2
  39. printf "starting downloader node"
  40. tendermint node \
  41. --home $HOME2 \
  42. --proxy_app dummy \
  43. --p2p.laddr tcp://127.0.0.1:56666 \
  44. --rpc.laddr tcp://127.0.0.1:56667 \
  45. --p2p.seeds 127.0.0.1:56656 \
  46. --log_level error &
  47. # wait for node to start up so we only count time where we are actually syncing
  48. sleep 0.5
  49. while curl localhost:56667/status 2> /dev/null | grep "\"latest_block_height\": 0," > /dev/null
  50. do
  51. printf '.'
  52. sleep 0.2
  53. done
  54. echo
  55. echo "syncing blockchain for 10s"
  56. for i in {1..10}
  57. do
  58. sleep 1
  59. HEIGHT="$(curl localhost:56667/status 2> /dev/null \
  60. | grep 'latest_block_height' \
  61. | grep -o ' [0-9]*' \
  62. | xargs)"
  63. let 'RATE = HEIGHT / i'
  64. echo "height: $HEIGHT, blocks/sec: $RATE"
  65. done
  66. kill %1
  67. kill %2
  68. rm -rf $HOME1 $HOME2