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
|
2021-09-15 16:05:10 -07:00
|
|
|
script_dir="$(readlink -f "$(dirname "$0")")"
|
|
|
|
if [[ "$script_dir" =~ /scripts$ ]]; then
|
|
|
|
cd "$script_dir/.."
|
|
|
|
else
|
|
|
|
cd "$script_dir"
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
2020-11-12 12:44:37 -08:00
|
|
|
export RUST_LOG=${RUST_LOG:-solana=info,solana_runtime::message_processor=debug} # 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-11-16 08:45:04 -08:00
|
|
|
if ! solana address; then
|
|
|
|
echo Generating default keypair
|
|
|
|
solana-keygen new --no-passphrase
|
|
|
|
fi
|
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
|
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 \
|
|
|
|
--faucet-lamports 500000000000000000 \
|
2020-03-04 23:42:01 -08:00
|
|
|
--bootstrap-validator \
|
2021-03-06 09:29:02 -08:00
|
|
|
"$validator_identity" \
|
|
|
|
"$validator_vote_account" \
|
|
|
|
"$validator_stake_account" \
|
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-11-16 08:45:04 -08:00
|
|
|
solana-faucet &
|
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=(
|
2021-03-06 09:29:02 -08:00
|
|
|
--identity "$validator_identity"
|
|
|
|
--vote-account "$validator_vote_account"
|
2019-05-31 16:51:09 -07:00
|
|
|
--ledger "$ledgerDir"
|
2019-05-23 14:50:23 -07:00
|
|
|
--gossip-port 8001
|
2022-02-11 03:38:32 -08:00
|
|
|
--full-rpc-api
|
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 -
|
2020-03-23 10:25:39 -07:00
|
|
|
--enable-rpc-transaction-history
|
2022-03-22 15:17:05 -07:00
|
|
|
--enable-extended-tx-metadata-storage
|
2019-11-15 22:56:29 -08:00
|
|
|
--init-complete-file "$dataDir"/init-completed
|
2020-11-30 17:16:50 -08:00
|
|
|
--snapshot-compression none
|
2020-09-18 22:03:54 -07:00
|
|
|
--require-tower
|
2021-03-25 18:54:51 -07:00
|
|
|
--no-wait-for-vote-to-start-leader
|
2022-02-14 07:48:30 -08:00
|
|
|
--no-os-network-limits-test
|
2019-02-16 10:16:27 -08:00
|
|
|
)
|
2020-12-28 11:38:59 -08:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
solana-validator "${args[@]}" $SOLANA_RUN_SH_VALIDATOR_ARGS &
|
2019-05-23 15:06:01 -07:00
|
|
|
validator=$!
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-05-23 15:06:01 -07:00
|
|
|
wait "$validator"
|