| 
									
										
										
										
											2018-12-07 10:00:35 -08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2020-01-22 09:22:09 -07:00
										 |  |  | # Start the bootstrap validator node | 
					
						
							| 
									
										
										
										
											2018-12-07 10:00:35 -08:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | set -e | 
					
						
							| 
									
										
										
										
											2018-12-07 10:00:35 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | here=$(dirname "$0") | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | # shellcheck source=multinode-demo/common.sh | 
					
						
							|  |  |  | source "$here"/common.sh | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-14 10:33:32 -06:00
										 |  |  | if [[ "$SOLANA_GPU_MISSING" -eq 1 ]]; then | 
					
						
							|  |  |  |   echo "Testnet requires GPUs, but none were found!  Aborting..." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | if [[ -n $SOLANA_CUDA ]]; then | 
					
						
							|  |  |  |   program=$solana_validator_cuda | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   program=$solana_validator | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-22 09:44:16 -07:00
										 |  |  | no_restart=0 | 
					
						
							| 
									
										
										
										
											2021-08-18 23:02:28 -06:00
										 |  |  | maybeRequireTower=true | 
					
						
							| 
									
										
										
										
											2019-11-22 09:44:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | args=() | 
					
						
							|  |  |  | while [[ -n $1 ]]; do | 
					
						
							|  |  |  |   if [[ ${1:0:1} = - ]]; then | 
					
						
							|  |  |  |     if [[ $1 = --init-complete-file ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2019-11-20 16:57:24 -07:00
										 |  |  |     elif [[ $1 = --gossip-host ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2019-07-30 15:53:03 -07:00
										 |  |  |     elif [[ $1 = --gossip-port ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2020-06-08 19:01:44 -06:00
										 |  |  |     elif [[ $1 = --dev-halt-at-slot ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2019-08-01 14:37:59 -07:00
										 |  |  |     elif [[ $1 = --dynamic-port-range ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2019-09-17 10:05:41 -07:00
										 |  |  |     elif [[ $1 = --limit-ledger-size ]]; then | 
					
						
							| 
									
										
										
										
											2020-03-23 08:42:32 -07:00
										 |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							|  |  |  |     elif [[ $1 = --no-rocksdb-compaction ]]; then | 
					
						
							| 
									
										
										
										
											2019-09-17 10:05:41 -07:00
										 |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2020-03-23 11:25:39 -06:00
										 |  |  |     elif [[ $1 = --enable-rpc-transaction-history ]]; then | 
					
						
							| 
									
										
										
										
											2020-02-12 17:08:27 -07:00
										 |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2022-01-14 21:53:34 -05:00
										 |  |  |     elif [[ $1 = --rpc-pubsub-enable-block-subscription ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2021-02-01 14:00:51 -07:00
										 |  |  |     elif [[ $1 = --enable-cpi-and-log-storage ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2022-03-22 23:17:05 +01:00
										 |  |  |     elif [[ $1 = --enable-extended-tx-metadata-storage ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2020-07-23 09:54:57 -07:00
										 |  |  |     elif [[ $1 = --enable-rpc-bigtable-ledger-storage ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2019-11-04 22:14:55 -07:00
										 |  |  |     elif [[ $1 = --skip-poh-verify ]]; then | 
					
						
							| 
									
										
										
										
											2019-10-21 10:21:43 -07:00
										 |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2019-11-06 12:47:34 -07:00
										 |  |  |     elif [[ $1 = --log ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2019-11-22 09:44:16 -07:00
										 |  |  |     elif [[ $1 = --no-restart ]]; then | 
					
						
							|  |  |  |       no_restart=1 | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2020-06-15 19:52:44 -06:00
										 |  |  |     elif [[ $1 == --wait-for-supermajority ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2020-06-03 18:50:57 -06:00
										 |  |  |     elif [[ $1 == --expected-bank-hash ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2021-01-05 21:01:57 -07:00
										 |  |  |     elif [[ $1 == --accounts ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2021-05-12 10:32:27 -07:00
										 |  |  |     elif [[ $1 == --maximum-snapshots-to-retain ]]; then | 
					
						
							|  |  |  |       args+=("$1" "$2") | 
					
						
							|  |  |  |       shift 2 | 
					
						
							| 
									
										
										
										
											2021-06-04 15:55:16 -07:00
										 |  |  |     elif [[ $1 == --no-snapshot-fetch ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2021-07-29 19:04:45 +00:00
										 |  |  |     elif [[ $1 == --allow-private-addr ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2021-08-18 16:28:06 -06:00
										 |  |  |     elif [[ $1 == --accounts-db-skip-shrink ]]; then | 
					
						
							|  |  |  |       args+=("$1") | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2021-08-18 23:02:28 -06:00
										 |  |  |     elif [[ $1 == --skip-require-tower ]]; then | 
					
						
							|  |  |  |       maybeRequireTower=false | 
					
						
							|  |  |  |       shift | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  |     else | 
					
						
							|  |  |  |       echo "Unknown argument: $1" | 
					
						
							|  |  |  |       $program --help | 
					
						
							|  |  |  |       exit 1 | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     echo "Unknown argument: $1" | 
					
						
							|  |  |  |     $program --help | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-08 23:56:57 -05:00
										 |  |  | # These keypairs are created by ./setup.sh and included in the genesis config | 
					
						
							| 
									
										
										
										
											2020-03-13 11:41:18 -07:00
										 |  |  | identity=$SOLANA_CONFIG_DIR/bootstrap-validator/identity.json | 
					
						
							|  |  |  | vote_account="$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-22 09:22:09 -07:00
										 |  |  | ledger_dir="$SOLANA_CONFIG_DIR"/bootstrap-validator | 
					
						
							| 
									
										
										
										
											2019-07-30 22:43:47 -07:00
										 |  |  | [[ -d "$ledger_dir" ]] || { | 
					
						
							|  |  |  |   echo "$ledger_dir does not exist" | 
					
						
							|  |  |  |   echo | 
					
						
							|  |  |  |   echo "Please run: $here/setup.sh" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-18 23:02:28 -06:00
										 |  |  | if [[ $maybeRequireTower = true ]]; then | 
					
						
							|  |  |  |   args+=(--require-tower) | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | args+=( | 
					
						
							| 
									
										
										
										
											2019-07-30 22:43:47 -07:00
										 |  |  |   --ledger "$ledger_dir" | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  |   --rpc-port 8899 | 
					
						
							| 
									
										
										
										
											2020-04-22 13:25:15 -06:00
										 |  |  |   --snapshot-interval-slots 200 | 
					
						
							| 
									
										
										
										
											2022-02-09 13:26:35 -06:00
										 |  |  |   --no-incremental-snapshots | 
					
						
							| 
									
										
										
										
											2020-03-13 11:41:18 -07:00
										 |  |  |   --identity "$identity" | 
					
						
							|  |  |  |   --vote-account "$vote_account" | 
					
						
							| 
									
										
										
										
											2019-12-16 14:05:17 -07:00
										 |  |  |   --rpc-faucet-address 127.0.0.1:9900 | 
					
						
							| 
									
										
										
										
											2021-02-28 13:03:56 -08:00
										 |  |  |   --no-poh-speed-test | 
					
						
							| 
									
										
										
										
											2021-10-25 18:25:55 -07:00
										 |  |  |   --no-os-network-limits-test | 
					
						
							| 
									
										
										
										
											2021-03-25 18:54:51 -07:00
										 |  |  |   --no-wait-for-vote-to-start-leader | 
					
						
							| 
									
										
										
										
											2022-01-28 19:00:18 -07:00
										 |  |  |   --full-rpc-api | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2019-07-30 15:53:03 -07:00
										 |  |  | default_arg --gossip-port 8001 | 
					
						
							| 
									
										
										
										
											2019-11-06 12:47:34 -07:00
										 |  |  | default_arg --log - | 
					
						
							| 
									
										
										
										
											2019-07-29 21:25:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-22 09:44:16 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | pid= | 
					
						
							|  |  |  | kill_node() { | 
					
						
							|  |  |  |   # Note: do not echo anything from this function to ensure $pid is actually | 
					
						
							|  |  |  |   # killed when stdout/stderr are redirected | 
					
						
							|  |  |  |   set +ex | 
					
						
							|  |  |  |   if [[ -n $pid ]]; then | 
					
						
							|  |  |  |     declare _pid=$pid | 
					
						
							|  |  |  |     pid= | 
					
						
							|  |  |  |     kill "$_pid" || true | 
					
						
							|  |  |  |     wait "$_pid" || true | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | kill_node_and_exit() { | 
					
						
							|  |  |  |   kill_node | 
					
						
							|  |  |  |   exit | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | trap 'kill_node_and_exit' INT TERM ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | while true; do | 
					
						
							|  |  |  |   echo "$program ${args[*]}" | 
					
						
							|  |  |  |   $program "${args[@]}" & | 
					
						
							|  |  |  |   pid=$! | 
					
						
							|  |  |  |   echo "pid: $pid" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if ((no_restart)); then | 
					
						
							|  |  |  |     wait "$pid" | 
					
						
							|  |  |  |     exit $? | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   while true; do | 
					
						
							|  |  |  |     if [[ -z $pid ]] || ! kill -0 "$pid"; then | 
					
						
							|  |  |  |       echo "############## validator exited, restarting ##############" | 
					
						
							|  |  |  |       break | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     sleep 1 | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   kill_node | 
					
						
							|  |  |  | done |