| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | args+=( | 
					
						
							|  |  |  |   --enable-rpc-exit | 
					
						
							| 
									
										
										
										
											2020-03-06 17:03:10 -07:00
										 |  |  |   --enable-rpc-set-log-filter | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											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 |