bootstrap-validator.sh 4.6 KB

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