| 
									
										
										
										
											2018-11-11 08:19:04 -08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | set -e | 
					
						
							| 
									
										
										
										
											2018-09-04 23:24:33 -07:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2019-10-21 21:21:21 -06:00
										 |  |  | # This script is to be run on the bootstrap validator | 
					
						
							| 
									
										
										
										
											2018-09-04 23:24:33 -07:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 09:21:03 -07:00
										 |  |  | cd "$(dirname "$0")"/../.. | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  | sanityTargetIp="$1" | 
					
						
							| 
									
										
										
										
											2019-06-05 12:06:54 -07:00
										 |  |  | shift | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 09:21:03 -07:00
										 |  |  | deployMethod= | 
					
						
							| 
									
										
										
										
											2018-09-04 22:21:58 -07:00
										 |  |  | entrypointIp= | 
					
						
							| 
									
										
										
										
											2018-09-04 09:21:03 -07:00
										 |  |  | numNodes= | 
					
						
							| 
									
										
										
										
											2019-04-29 21:38:03 -07:00
										 |  |  | failOnValidatorBootupFailure= | 
					
						
							| 
									
										
										
										
											2019-06-17 18:15:22 -07:00
										 |  |  | airdropsEnabled=true | 
					
						
							| 
									
										
										
										
											2018-09-04 22:21:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | [[ -r deployConfig ]] || { | 
					
						
							|  |  |  |   echo deployConfig missing | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | # shellcheck source=/dev/null # deployConfig is written by remote-node.sh | 
					
						
							| 
									
										
										
										
											2018-09-04 09:21:03 -07:00
										 |  |  | source deployConfig | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 08:46:20 -07:00
										 |  |  | missing() { | 
					
						
							|  |  |  |   echo "Error: $1 not specified" | 
					
						
							| 
									
										
										
										
											2018-09-04 09:21:03 -07:00
										 |  |  |   exit 1 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  | [[ -n $sanityTargetIp ]] || missing sanityTargetIp | 
					
						
							| 
									
										
										
										
											2018-12-05 17:33:32 -08:00
										 |  |  | [[ -n $deployMethod ]]   || missing deployMethod | 
					
						
							|  |  |  | [[ -n $entrypointIp ]]   || missing entrypointIp | 
					
						
							|  |  |  | [[ -n $numNodes ]]       || missing numNodes | 
					
						
							| 
									
										
										
										
											2019-04-29 21:38:03 -07:00
										 |  |  | [[ -n $failOnValidatorBootupFailure ]] || missing failOnValidatorBootupFailure | 
					
						
							| 
									
										
										
										
											2018-09-07 08:46:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-05 15:31:29 -07:00
										 |  |  | installCheck=true | 
					
						
							| 
									
										
										
										
											2018-09-11 20:00:49 -07:00
										 |  |  | rejectExtraNodes=false | 
					
						
							| 
									
										
										
										
											2018-09-04 22:21:58 -07:00
										 |  |  | while [[ $1 = -o ]]; do | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   opt="$2" | 
					
						
							|  |  |  |   shift 2 | 
					
						
							|  |  |  |   case $opt in | 
					
						
							| 
									
										
										
										
											2019-06-05 15:31:29 -07:00
										 |  |  |   noInstallCheck) | 
					
						
							|  |  |  |     installCheck=false | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2018-09-11 20:00:49 -07:00
										 |  |  |   rejectExtraNodes) | 
					
						
							|  |  |  |     rejectExtraNodes=true | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   *) | 
					
						
							|  |  |  |     echo "Error: unknown option: $opt" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |   esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-31 10:13:30 -07:00
										 |  |  | if [[ -n $1 ]]; then | 
					
						
							|  |  |  |   export RUST_LOG="$1" | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-01-09 12:57:00 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | source net/common.sh | 
					
						
							|  |  |  | loadConfigFile | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | case $deployMethod in | 
					
						
							| 
									
										
										
										
											2019-07-22 21:38:26 -07:00
										 |  |  | local|tar|skip) | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   PATH="$HOME"/.cargo/bin:"$PATH" | 
					
						
							|  |  |  |   export USE_INSTALL=1 | 
					
						
							| 
									
										
										
										
											2019-10-15 07:47:45 -07:00
										 |  |  |   solana_cli=solana | 
					
						
							| 
									
										
										
										
											2019-04-01 17:43:07 -06:00
										 |  |  |   solana_gossip=solana-gossip | 
					
						
							| 
									
										
										
										
											2019-05-26 11:17:07 -07:00
										 |  |  |   solana_install=solana-install | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   ;; | 
					
						
							|  |  |  | *) | 
					
						
							|  |  |  |   echo "Unknown deployment method: $deployMethod" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | esac | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-29 21:38:03 -07:00
										 |  |  | if $failOnValidatorBootupFailure; then | 
					
						
							| 
									
										
										
										
											2019-04-30 08:56:53 -07:00
										 |  |  |   numSanityNodes="$numNodes" | 
					
						
							|  |  |  | else | 
					
						
							| 
									
										
										
										
											2019-04-29 21:38:03 -07:00
										 |  |  |   numSanityNodes=1 | 
					
						
							|  |  |  |   if $rejectExtraNodes; then | 
					
						
							|  |  |  |     echo "rejectExtraNodes cannot be used with failOnValidatorBootupFailure" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-11 11:54:49 -07:00
										 |  |  | echo "--- $sanityTargetIp: validators" | 
					
						
							| 
									
										
										
										
											2019-10-09 09:46:25 +09:00
										 |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2020-01-20 23:06:47 -07:00
										 |  |  |   $solana_cli --url http://"$sanityTargetIp":8899 validators | 
					
						
							| 
									
										
										
										
											2019-10-09 09:46:25 +09:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-11 11:54:49 -07:00
										 |  |  | echo "--- $sanityTargetIp: node count ($numSanityNodes expected)" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2018-09-11 20:00:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 00:53:54 -06:00
										 |  |  |   nodeArg="num-nodes" | 
					
						
							| 
									
										
										
										
											2018-09-11 20:00:49 -07:00
										 |  |  |   if $rejectExtraNodes; then | 
					
						
							| 
									
										
										
										
											2019-04-04 00:53:54 -06:00
										 |  |  |     nodeArg="num-nodes-exactly" | 
					
						
							| 
									
										
										
										
											2018-09-11 20:00:49 -07:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-17 11:36:24 -05:00
										 |  |  |   $solana_gossip spy --entrypoint "$sanityTargetIp:8001" \
 | 
					
						
							|  |  |  |     --$nodeArg "$numSanityNodes" --timeout 60 \
 | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  | echo "--- $sanityTargetIp: RPC API: getTransactionCount" | 
					
						
							| 
									
										
										
										
											2019-01-09 12:39:27 -07:00
										 |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							|  |  |  |   curl --retry 5 --retry-delay 2 --retry-connrefused \
 | 
					
						
							|  |  |  |     -X POST -H 'Content-Type: application/json' \
 | 
					
						
							|  |  |  |     -d '{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}' \
 | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  |     http://"$sanityTargetIp":8899 | 
					
						
							| 
									
										
										
										
											2019-01-09 12:39:27 -07:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-17 18:15:22 -07:00
										 |  |  | if [[ "$airdropsEnabled" = true ]]; then | 
					
						
							|  |  |  |   echo "--- $sanityTargetIp: wallet sanity" | 
					
						
							|  |  |  |   ( | 
					
						
							|  |  |  |     set -x | 
					
						
							|  |  |  |     scripts/wallet-sanity.sh --url http://"$sanityTargetIp":8899 | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   echo "^^^ +++" | 
					
						
							|  |  |  |   echo "Note: wallet sanity is disabled as airdrops are disabled" | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-01-09 12:39:27 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-05 15:31:29 -07:00
										 |  |  | if $installCheck && [[ -r update_manifest_keypair.json ]]; then | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  |   echo "--- $sanityTargetIp: solana-install test" | 
					
						
							| 
									
										
										
										
											2019-05-26 11:17:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   ( | 
					
						
							|  |  |  |     set -x | 
					
						
							|  |  |  |     rm -rf install-data-dir | 
					
						
							|  |  |  |     $solana_install init \
 | 
					
						
							|  |  |  |       --no-modify-path \
 | 
					
						
							|  |  |  |       --data-dir install-data-dir \
 | 
					
						
							| 
									
										
										
										
											2019-06-04 22:46:48 -07:00
										 |  |  |       --url http://"$sanityTargetIp":8899 \
 | 
					
						
							| 
									
										
										
										
											2019-05-26 11:17:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     $solana_install info | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-08 14:12:32 -07:00
										 |  |  | echo --- Pass |