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
|
|
|
|
2019-02-21 15:16:09 -08:00
|
|
|
blockstreamSocket=/tmp/solana-blockstream.sock # Default to location used by the block explorer
|
2019-02-16 10:16:27 -08:00
|
|
|
while [[ -n $1 ]]; do
|
2019-02-21 15:16:09 -08:00
|
|
|
if [[ $1 = --blockstream ]]; then
|
|
|
|
blockstreamSocket=$2
|
2019-02-16 10:16:27 -08:00
|
|
|
shift 2
|
|
|
|
else
|
|
|
|
echo "Unknown argument: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
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
|
|
|
|
2019-02-16 09:48:51 -08:00
|
|
|
set -x
|
2019-05-31 16:51:09 -07:00
|
|
|
leader_keypair="$dataDir/leader-keypair.json"
|
2019-05-30 21:31:35 -07:00
|
|
|
if [[ -e $leader_keypair ]]; then
|
|
|
|
echo "Use existing leader keypair"
|
|
|
|
else
|
2019-11-25 20:33:15 -08:00
|
|
|
solana-keygen new --no-passphrase -so "$leader_keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2019-05-31 16:51:09 -07:00
|
|
|
leader_vote_account_keypair="$dataDir/leader-vote-account-keypair.json"
|
2019-05-30 21:31:35 -07:00
|
|
|
if [[ -e $leader_vote_account_keypair ]]; then
|
|
|
|
echo "Use existing leader vote account keypair"
|
|
|
|
else
|
2019-11-25 20:33:15 -08:00
|
|
|
solana-keygen new --no-passphrase -so "$leader_vote_account_keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2019-05-31 16:51:09 -07:00
|
|
|
leader_stake_account_keypair="$dataDir/leader-stake-account-keypair.json"
|
2019-05-30 21:31:35 -07:00
|
|
|
if [[ -e $leader_stake_account_keypair ]]; then
|
|
|
|
echo "Use existing leader stake account keypair"
|
|
|
|
else
|
2019-11-25 20:33:15 -08:00
|
|
|
solana-keygen new --no-passphrase -so "$leader_stake_account_keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2019-11-15 22:56:29 -08:00
|
|
|
faucet_keypair="$dataDir"/faucet-keypair.json
|
|
|
|
if [[ -e $faucet_keypair ]]; then
|
|
|
|
echo "Use existing faucet keypair"
|
|
|
|
else
|
2019-11-25 20:33:15 -08:00
|
|
|
solana-keygen new --no-passphrase -fso "$faucet_keypair"
|
2019-11-15 22:56:29 -08:00
|
|
|
fi
|
|
|
|
leader_storage_account_keypair="$dataDir"/leader-storage-account-keypair.json
|
|
|
|
if [[ -e $leader_storage_account_keypair ]]; then
|
|
|
|
echo "Use existing leader storage account keypair"
|
|
|
|
else
|
2019-11-25 20:33:15 -08:00
|
|
|
solana-keygen new --no-passphrase -fso "$leader_storage_account_keypair"
|
2019-11-15 22:56:29 -08:00
|
|
|
fi
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2020-01-15 21:34:36 -08:00
|
|
|
if [[ -e "$ledgerDir"/genesis.bin ]]; then
|
|
|
|
echo "Use existing genesis"
|
|
|
|
else
|
|
|
|
solana-genesis \
|
|
|
|
--hashes-per-tick sleep \
|
|
|
|
--faucet-pubkey "$dataDir"/faucet-keypair.json \
|
|
|
|
--faucet-lamports 500000000000000000 \
|
2020-01-22 08:22:09 -08:00
|
|
|
--bootstrap-validator-pubkey "$dataDir"/leader-keypair.json \
|
2020-01-15 21:34:36 -08:00
|
|
|
--bootstrap-vote-pubkey "$dataDir"/leader-vote-account-keypair.json \
|
|
|
|
--bootstrap-stake-pubkey "$dataDir"/leader-stake-account-keypair.json \
|
|
|
|
--bootstrap-storage-pubkey "$dataDir"/leader-storage-account-keypair.json \
|
|
|
|
--ledger "$ledgerDir" \
|
|
|
|
--operating-mode development
|
|
|
|
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
|
|
|
|
|
2019-12-16 13:05:17 -08:00
|
|
|
solana-faucet --keypair "$dataDir"/faucet-keypair.json &
|
|
|
|
faucet=$!
|
2018-12-07 16:04:34 -08:00
|
|
|
|
2019-02-16 10:16:27 -08:00
|
|
|
args=(
|
2019-11-22 07:20:40 -08:00
|
|
|
--identity-keypair "$dataDir"/leader-keypair.json
|
2019-05-31 16:51:09 -07:00
|
|
|
--storage-keypair "$dataDir"/leader-storage-account-keypair.json
|
|
|
|
--voting-keypair "$dataDir"/leader-vote-account-keypair.json
|
|
|
|
--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-05-30 21:31:35 -07:00
|
|
|
--accounts "$dataDir"/accounts
|
2019-11-08 11:30:19 -08:00
|
|
|
--log -
|
2019-11-15 22:56:29 -08:00
|
|
|
--enable-rpc-exit
|
|
|
|
--init-complete-file "$dataDir"/init-completed
|
2019-02-16 10:16:27 -08:00
|
|
|
)
|
2019-02-21 15:16:09 -08:00
|
|
|
if [[ -n $blockstreamSocket ]]; then
|
|
|
|
args+=(--blockstream "$blockstreamSocket")
|
2019-02-16 10:16:27 -08:00
|
|
|
fi
|
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"
|