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.

50 lines
1.2 KiB

  1. #! /bin/bash
  2. set -eu
  3. IPV=$1
  4. NUM_OF_PEERS=$2
  5. # how many attempts for each peer to catch up by height
  6. MAX_ATTEMPTS_TO_CATCH_UP=120
  7. echo "Waiting for nodes to come online"
  8. set +e
  9. for i in $(seq 1 "$NUM_OF_PEERS"); do
  10. addr=$(test/p2p/address.sh $IPV $i 26657)
  11. curl -s "$addr/status" > /dev/null
  12. ERR=$?
  13. while [ "$ERR" != 0 ]; do
  14. sleep 1
  15. curl -s "$addr/status" > /dev/null
  16. ERR=$?
  17. done
  18. echo "... node $i is up"
  19. done
  20. set -e
  21. # get the first peer's height
  22. addr=$(test/p2p/address.sh $IPV 1 26657)
  23. h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g")
  24. echo "1st peer is on height $h1"
  25. echo "Waiting until other peers reporting a height higher than the 1st one"
  26. for i in $(seq 2 "$NUM_OF_PEERS"); do
  27. attempt=1
  28. hi=0
  29. while [[ $hi -le $h1 ]] ; do
  30. addr=$(test/p2p/address.sh $IPV $i 26657)
  31. hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g")
  32. echo "... peer $i is on height $hi"
  33. ((attempt++))
  34. if [ "$attempt" -ge $MAX_ATTEMPTS_TO_CATCH_UP ] ; then
  35. echo "$attempt unsuccessful attempts were made to catch up"
  36. curl -s "$addr/dump_consensus_state" | jq .result
  37. exit 1
  38. fi
  39. sleep 1
  40. done
  41. done