2018-11-11 08:19:04 -08:00
|
|
|
#!/usr/bin/env bash
|
2019-02-16 09:48:51 -08:00
|
|
|
#
|
|
|
|
# Run a minimal Solana cluster. Ctrl-C to exit.
|
|
|
|
#
|
|
|
|
# Before running this script ensure standard Solana programs are available
|
2019-09-19 20:50:34 -07:00
|
|
|
# in the PATH, or that `cargo build` ran successfully
|
2019-02-16 09:48:51 -08:00
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
2019-09-19 20:50:34 -07:00
|
|
|
# Prefer possible `cargo build` binaries over PATH binaries
|
2019-05-18 14:01:36 -07:00
|
|
|
cd "$(dirname "$0")/"
|
2019-11-15 22:56:29 -08:00
|
|
|
|
|
|
|
profile=debug
|
|
|
|
if [[ -n $NDEBUG ]]; then
|
|
|
|
profile=release
|
|
|
|
fi
|
|
|
|
PATH=$PWD/target/$profile:$PATH
|
2019-02-16 09:48:51 -08:00
|
|
|
|
|
|
|
ok=true
|
2019-12-16 13:05:17 -08:00
|
|
|
for program in solana-{faucet,genesis,keygen,validator}; do
|
2019-02-16 09:48:51 -08:00
|
|
|
$program -V || ok=false
|
|
|
|
done
|
|
|
|
$ok || {
|
|
|
|
echo
|
2019-02-16 09:58:28 -08:00
|
|
|
echo "Unable to locate required programs. Try building them first with:"
|
|
|
|
echo
|
|
|
|
echo " $ cargo build --all"
|
|
|
|
echo
|
2019-02-16 09:48:51 -08:00
|
|
|
exit 1
|
|
|
|
}
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2018-10-14 11:48:10 -07:00
|
|
|
export RUST_LOG=${RUST_LOG:-solana=info} # if RUST_LOG is unset, default to info
|
2018-10-02 17:34:47 -07:00
|
|
|
export RUST_BACKTRACE=1
|
2019-07-30 22:43:47 -07:00
|
|
|
dataDir=$PWD/config/"$(basename "$0" .sh)"
|
2019-05-31 16:51:09 -07:00
|
|
|
ledgerDir=$PWD/config/ledger
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2020-10-03 08:30:26 -07:00
|
|
|
SOLANA_RUN_SH_CLUSTER_TYPE=${SOLANA_RUN_SH_CLUSTER_TYPE:-development}
|
|
|
|
|
2019-02-16 09:48:51 -08:00
|
|
|
set -x
|
2020-03-15 13:19:55 -07:00
|
|
|
validator_identity="$dataDir/validator-identity.json"
|
|
|
|
if [[ -e $validator_identity ]]; then
|
|
|
|
echo "Use existing validator keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
else
|
2020-03-15 13:19:55 -07:00
|
|
|
solana-keygen new --no-passphrase -so "$validator_identity"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2020-03-15 13:19:55 -07:00
|
|
|
validator_vote_account="$dataDir/validator-vote-account.json"
|
|
|
|
if [[ -e $validator_vote_account ]]; then
|
|
|
|
echo "Use existing validator vote account keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
else
|
2020-03-15 13:19:55 -07:00
|
|
|
solana-keygen new --no-passphrase -so "$validator_vote_account"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2020-03-15 13:19:55 -07:00
|
|
|
validator_stake_account="$dataDir/validator-stake-account.json"
|
|
|
|
if [[ -e $validator_stake_account ]]; then
|
|
|
|
echo "Use existing validator stake account keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
else
|
2020-03-15 13:19:55 -07:00
|
|
|
solana-keygen new --no-passphrase -so "$validator_stake_account"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2020-03-15 13:19:55 -07:00
|
|
|
faucet="$dataDir"/faucet.json
|
|
|
|
if [[ -e $faucet ]]; then
|
2019-11-15 22:56:29 -08:00
|
|
|
echo "Use existing faucet keypair"
|
|
|
|
else
|
2020-03-15 13:19:55 -07:00
|
|
|
solana-keygen new --no-passphrase -fso "$faucet"
|
2019-11-15 22:56:29 -08:00
|
|
|
fi
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2020-03-25 02:46:41 -07:00
|
|
|
if [[ -e "$ledgerDir"/genesis.bin || -e "$ledgerDir"/genesis.tar.bz2 ]]; then
|
2020-01-15 21:34:36 -08:00
|
|
|
echo "Use existing genesis"
|
|
|
|
else
|
2020-07-29 11:05:19 -07:00
|
|
|
./fetch-spl.sh
|
|
|
|
if [[ -r spl-genesis-args.sh ]]; then
|
|
|
|
SPL_GENESIS_ARGS=$(cat spl-genesis-args.sh)
|
|
|
|
fi
|
|
|
|
|
2020-04-23 22:48:53 -07:00
|
|
|
# shellcheck disable=SC2086
|
2020-01-15 21:34:36 -08:00
|
|
|
solana-genesis \
|
|
|
|
--hashes-per-tick sleep \
|
2020-03-14 16:49:28 -07:00
|
|
|
--faucet-pubkey "$dataDir"/faucet.json \
|
2020-01-15 21:34:36 -08:00
|
|
|
--faucet-lamports 500000000000000000 \
|
2020-03-04 23:42:01 -08:00
|
|
|
--bootstrap-validator \
|
2020-03-15 13:19:55 -07:00
|
|
|
"$dataDir"/validator-identity.json \
|
|
|
|
"$dataDir"/validator-vote-account.json \
|
|
|
|
"$dataDir"/validator-stake-account.json \
|
2020-01-15 21:34:36 -08:00
|
|
|
--ledger "$ledgerDir" \
|
2020-10-03 08:30:26 -07:00
|
|
|
--cluster-type "$SOLANA_RUN_SH_CLUSTER_TYPE" \
|
2020-07-29 11:05:19 -07:00
|
|
|
$SPL_GENESIS_ARGS \
|
2020-04-23 22:48:53 -07:00
|
|
|
$SOLANA_RUN_SH_GENESIS_ARGS
|
2020-01-15 21:34:36 -08:00
|
|
|
fi
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-05-31 16:51:09 -07:00
|
|
|
abort() {
|
|
|
|
set +e
|
2019-12-16 13:05:17 -08:00
|
|
|
kill "$faucet" "$validator"
|
2019-11-15 22:56:29 -08:00
|
|
|
wait "$validator"
|
2019-05-31 16:51:09 -07:00
|
|
|
}
|
|
|
|
trap abort INT TERM EXIT
|
|
|
|
|
2020-03-16 04:44:54 -07:00
|
|
|
solana-faucet --keypair "$dataDir"/faucet.json &
|
2019-12-16 13:05:17 -08:00
|
|
|
faucet=$!
|
2018-12-07 16:04:34 -08:00
|
|
|
|
2019-02-16 10:16:27 -08:00
|
|
|
args=(
|
2020-03-15 13:19:55 -07:00
|
|
|
--identity "$dataDir"/validator-identity.json
|
|
|
|
--vote-account "$dataDir"/validator-vote-account.json
|
2019-05-31 16:51:09 -07:00
|
|
|
--ledger "$ledgerDir"
|
2019-05-23 14:50:23 -07:00
|
|
|
--gossip-port 8001
|
2019-02-16 10:16:27 -08:00
|
|
|
--rpc-port 8899
|
2019-12-16 13:05:17 -08:00
|
|
|
--rpc-faucet-address 127.0.0.1:9900
|
2019-11-08 11:30:19 -08:00
|
|
|
--log -
|
2019-11-15 22:56:29 -08:00
|
|
|
--enable-rpc-exit
|
2020-03-23 10:25:39 -07:00
|
|
|
--enable-rpc-transaction-history
|
2019-11-15 22:56:29 -08:00
|
|
|
--init-complete-file "$dataDir"/init-completed
|
2020-09-18 22:03:54 -07:00
|
|
|
--require-tower
|
2019-02-16 10:16:27 -08:00
|
|
|
)
|
2019-05-23 15:06:01 -07:00
|
|
|
solana-validator "${args[@]}" &
|
|
|
|
validator=$!
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-05-23 15:06:01 -07:00
|
|
|
wait "$validator"
|