| 
									
										
										
										
											2018-11-11 08:19:04 -08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | set -e | 
					
						
							| 
									
										
										
										
											2018-09-04 23:24:33 -07:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2018-12-05 16:40:08 -08:00
										 |  |  | # This script is to be run on the bootstrap full node | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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= | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | ledgerVerify=true | 
					
						
							|  |  |  | validatorSanity=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 | 
					
						
							|  |  |  |   noLedgerVerify) | 
					
						
							|  |  |  |     ledgerVerify=false | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |   noValidatorSanity) | 
					
						
							|  |  |  |     validatorSanity=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-01-09 12:57:00 -07:00
										 |  |  | RUST_LOG="$1" | 
					
						
							|  |  |  | export RUST_LOG=${RUST_LOG:-solana=info} # if RUST_LOG is unset, default to info | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | source net/common.sh | 
					
						
							|  |  |  | loadConfigFile | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | case $deployMethod in | 
					
						
							| 
									
										
										
										
											2018-10-30 18:05:38 -07:00
										 |  |  | local|tar) | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   PATH="$HOME"/.cargo/bin:"$PATH" | 
					
						
							|  |  |  |   export USE_INSTALL=1 | 
					
						
							| 
									
										
										
										
											2018-11-14 19:19:27 -08:00
										 |  |  |   if [[ -r target/perf-libs/env.sh ]]; then | 
					
						
							|  |  |  |     # shellcheck source=/dev/null | 
					
						
							|  |  |  |     source target/perf-libs/env.sh | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 07:56:26 -07:00
										 |  |  |   entrypointRsyncUrl="$entrypointIp:~/solana" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-01 17:43:07 -06:00
										 |  |  |   solana_gossip=solana-gossip | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   solana_ledger_tool=solana-ledger-tool | 
					
						
							| 
									
										
										
										
											2018-09-08 07:07:10 +09:00
										 |  |  |   solana_keygen=solana-keygen | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-07 11:00:21 -08:00
										 |  |  |   ledger=config-local/bootstrap-leader-ledger | 
					
						
							| 
									
										
										
										
											2019-03-21 15:10:01 -07:00
										 |  |  |   client_id=config-local/client-id.json | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "+++ $entrypointIp: node count ($numSanityNodes expected)" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2018-09-08 14:12:32 -07:00
										 |  |  |   $solana_keygen -o "$client_id" | 
					
						
							| 
									
										
										
										
											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-05-03 15:00:19 -07:00
										 |  |  |   timeout 2m $solana_gossip --entrypoint "$entrypointIp:8001" \
 | 
					
						
							| 
									
										
										
										
											2019-04-29 21:38:03 -07:00
										 |  |  |     spy --$nodeArg "$numSanityNodes" \
 | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 12:39:27 -07:00
										 |  |  | echo "--- RPC API: getTransactionCount" | 
					
						
							|  |  |  | ( | 
					
						
							|  |  |  |   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"}' \
 | 
					
						
							|  |  |  |     http://"$entrypointIp":8899 | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "--- $entrypointIp: wallet sanity" | 
					
						
							|  |  |  | ( | 
					
						
							|  |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2019-05-06 07:38:26 -07:00
										 |  |  |   scripts/wallet-sanity.sh --url http://"$entrypointIp":8899 | 
					
						
							| 
									
										
										
										
											2019-01-09 12:39:27 -07:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 22:21:58 -07:00
										 |  |  | echo "--- $entrypointIp: verify ledger" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | if $ledgerVerify; then | 
					
						
							|  |  |  |   if [[ -d $ledger ]]; then | 
					
						
							|  |  |  |     ( | 
					
						
							|  |  |  |       set -x | 
					
						
							|  |  |  |       rm -rf /var/tmp/ledger-verify | 
					
						
							| 
									
										
										
										
											2018-09-07 12:36:19 -07:00
										 |  |  |       du -hs "$ledger" | 
					
						
							|  |  |  |       time cp -r "$ledger" /var/tmp/ledger-verify | 
					
						
							|  |  |  |       time $solana_ledger_tool --ledger /var/tmp/ledger-verify verify | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |     ) | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     echo "^^^ +++" | 
					
						
							| 
									
										
										
										
											2018-09-08 14:10:09 -07:00
										 |  |  |     echo "Ledger verify skipped: directory does not exist: $ledger" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   fi | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   echo "^^^ +++" | 
					
						
							| 
									
										
										
										
											2018-09-08 14:10:09 -07:00
										 |  |  |   echo "Note: ledger verify disabled" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 22:21:58 -07:00
										 |  |  | echo "--- $entrypointIp: validator sanity" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | if $validatorSanity; then | 
					
						
							|  |  |  |   ( | 
					
						
							| 
									
										
										
										
											2018-12-05 10:33:10 -08:00
										 |  |  |     set -x -o pipefail | 
					
						
							| 
									
										
										
										
											2019-04-16 13:03:01 -07:00
										 |  |  |     timeout 10s ./multinode-demo/fullnode-x.sh --stake 0 \
 | 
					
						
							| 
									
										
										
										
											2018-12-07 11:00:21 -08:00
										 |  |  |       "$entrypointRsyncUrl" \
 | 
					
						
							|  |  |  |       "$entrypointIp:8001" 2>&1 | tee validator-sanity.log | 
					
						
							| 
									
										
										
										
											2018-09-04 15:16:25 -07:00
										 |  |  |   ) || { | 
					
						
							|  |  |  |     exitcode=$? | 
					
						
							|  |  |  |     [[ $exitcode -eq 124 ]] || exit $exitcode | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-12-05 16:40:08 -08:00
										 |  |  |   wc -l validator-sanity.log | 
					
						
							|  |  |  |   if grep -C100 panic validator-sanity.log; then | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |     echo "^^^ +++" | 
					
						
							|  |  |  |     echo "Panic observed" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  |   else | 
					
						
							| 
									
										
										
										
											2018-12-05 16:40:08 -08:00
										 |  |  |     echo "Validator sanity log looks ok" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  |   fi | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   echo "^^^ +++" | 
					
						
							| 
									
										
										
										
											2018-09-08 14:10:09 -07:00
										 |  |  |   echo "Note: validator sanity disabled" | 
					
						
							| 
									
										
										
										
											2018-09-03 19:33:40 -10:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2018-09-08 14:12:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | echo --- Pass |