bootstrap-validator.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #!/usr/bin/env bash
  2. #
  3. # Start the bootstrap validator node
  4. #
  5. set -e
  6. here=$(dirname "$0")
  7. # shellcheck source=multinode-demo/common.sh
  8. source "$here"/common.sh
  9. if [[ "$SOLANA_GPU_MISSING" -eq 1 ]]; then
  10. echo "Testnet requires GPUs, but none were found! Aborting..."
  11. exit 1
  12. fi
  13. if [[ -n $SOLANA_CUDA ]]; then
  14. program=$agave_validator_cuda
  15. else
  16. program=$agave_validator
  17. fi
  18. no_restart=0
  19. maybeRequireTower=true
  20. args=()
  21. while [[ -n $1 ]]; do
  22. if [[ ${1:0:1} = - ]]; then
  23. if [[ $1 = --init-complete-file ]]; then
  24. args+=("$1" "$2")
  25. shift 2
  26. elif [[ $1 = --bind-address ]]; then
  27. args+=("$1" "$2")
  28. shift 2
  29. elif [[ $1 = --gossip-port ]]; then
  30. args+=("$1" "$2")
  31. shift 2
  32. elif [[ $1 = --dev-halt-at-slot ]]; then
  33. args+=("$1" "$2")
  34. shift 2
  35. elif [[ $1 = --dynamic-port-range ]]; then
  36. args+=("$1" "$2")
  37. shift 2
  38. elif [[ $1 = --limit-ledger-size ]]; then
  39. args+=("$1" "$2")
  40. shift 2
  41. elif [[ $1 = --no-rocksdb-compaction ]]; then
  42. args+=("$1")
  43. shift
  44. elif [[ $1 = --enable-rpc-transaction-history ]]; then
  45. args+=("$1")
  46. shift
  47. elif [[ $1 = --rpc-pubsub-enable-block-subscription ]]; then
  48. args+=("$1")
  49. shift
  50. elif [[ $1 = --enable-extended-tx-metadata-storage ]]; then
  51. args+=("$1")
  52. shift
  53. elif [[ $1 = --enable-rpc-bigtable-ledger-storage ]]; then
  54. args+=("$1")
  55. shift
  56. elif [[ $1 = --tpu-disable-quic ]]; then
  57. args+=("$1")
  58. shift
  59. elif [[ $1 = --tpu-enable-udp ]]; then
  60. args+=("$1")
  61. shift
  62. elif [[ $1 = --rpc-send-batch-ms ]]; then
  63. args+=("$1" "$2")
  64. shift 2
  65. elif [[ $1 = --rpc-send-batch-size ]]; then
  66. args+=("$1" "$2")
  67. shift 2
  68. elif [[ $1 = --skip-poh-verify ]]; then
  69. args+=("$1")
  70. shift
  71. elif [[ $1 = --log ]]; then
  72. args+=("$1" "$2")
  73. shift 2
  74. elif [[ $1 = --no-restart ]]; then
  75. no_restart=1
  76. shift
  77. elif [[ $1 == --wait-for-supermajority ]]; then
  78. args+=("$1" "$2")
  79. shift 2
  80. elif [[ $1 == --expected-bank-hash ]]; then
  81. args+=("$1" "$2")
  82. shift 2
  83. elif [[ $1 == --expected-shred-version ]]; then
  84. args+=("$1" "$2")
  85. shift 2
  86. elif [[ $1 == --accounts ]]; then
  87. args+=("$1" "$2")
  88. shift 2
  89. elif [[ $1 == --maximum-snapshots-to-retain ]]; then
  90. args+=("$1" "$2")
  91. shift 2
  92. elif [[ $1 == --no-snapshot-fetch ]]; then
  93. args+=("$1")
  94. shift
  95. elif [[ $1 == --accounts-db-skip-shrink ]]; then
  96. args+=("$1")
  97. shift
  98. elif [[ $1 == --skip-require-tower ]]; then
  99. maybeRequireTower=false
  100. shift
  101. elif [[ $1 = --log-messages-bytes-limit ]]; then
  102. args+=("$1" "$2")
  103. shift 2
  104. elif [[ $1 == --block-production-method ]]; then
  105. args+=("$1" "$2")
  106. shift 2
  107. elif [[ $1 == --transaction-structure ]]; then
  108. args+=("$1" "$2")
  109. shift 2
  110. elif [[ $1 == --wen-restart ]]; then
  111. args+=("$1" "$2")
  112. shift 2
  113. elif [[ $1 == --wen-restart-coordinator ]]; then
  114. args+=("$1" "$2")
  115. shift 2
  116. else
  117. echo "Unknown argument: $1"
  118. $program --help
  119. exit 1
  120. fi
  121. else
  122. echo "Unknown argument: $1"
  123. $program --help
  124. exit 1
  125. fi
  126. done
  127. # These keypairs are created by ./setup.sh and included in the genesis config
  128. identity=$SOLANA_CONFIG_DIR/bootstrap-validator/identity.json
  129. vote_account="$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json
  130. ledger_dir="$SOLANA_CONFIG_DIR"/bootstrap-validator
  131. [[ -d "$ledger_dir" ]] || {
  132. echo "$ledger_dir does not exist"
  133. echo
  134. echo "Please run: $here/setup.sh"
  135. exit 1
  136. }
  137. if [[ $maybeRequireTower = true ]]; then
  138. args+=(--require-tower)
  139. fi
  140. args+=(
  141. --ledger "$ledger_dir"
  142. --rpc-port 8899
  143. --snapshot-interval-slots 200
  144. --no-incremental-snapshots
  145. --identity "$identity"
  146. --vote-account "$vote_account"
  147. --rpc-faucet-address 127.0.0.1:9900
  148. --no-poh-speed-test
  149. --no-os-network-limits-test
  150. --no-wait-for-vote-to-start-leader
  151. --full-rpc-api
  152. --allow-private-addr
  153. )
  154. default_arg --gossip-port 8001
  155. default_arg --log -
  156. pid=
  157. kill_node() {
  158. # Note: do not echo anything from this function to ensure $pid is actually
  159. # killed when stdout/stderr are redirected
  160. set +ex
  161. if [[ -n $pid ]]; then
  162. declare _pid=$pid
  163. pid=
  164. kill "$_pid" || true
  165. wait "$_pid" || true
  166. fi
  167. }
  168. kill_node_and_exit() {
  169. kill_node
  170. exit
  171. }
  172. trap 'kill_node_and_exit' INT TERM ERR
  173. while true; do
  174. echo "$program ${args[*]}"
  175. $program "${args[@]}" &
  176. pid=$!
  177. echo "pid: $pid"
  178. if ((no_restart)); then
  179. wait "$pid"
  180. exit $?
  181. fi
  182. while true; do
  183. if [[ -z $pid ]] || ! kill -0 "$pid"; then
  184. echo "############## validator exited, restarting ##############"
  185. break
  186. fi
  187. sleep 1
  188. done
  189. kill_node
  190. done