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
|
|
|
|
# in the PATH, or that `cargo build --all` ran successfully
|
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Prefer possible `cargo build --all` binaries over PATH binaries
|
2019-02-16 10:16:27 -08:00
|
|
|
PATH=$PWD/target/debug:$PATH
|
2019-02-16 09:48:51 -08:00
|
|
|
|
|
|
|
ok=true
|
2019-03-05 12:44:27 -08:00
|
|
|
for program in solana-{genesis,keygen,fullnode}; 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-02-16 09:48:51 -08:00
|
|
|
dataDir=$PWD/target/"$(basename "$0" .sh)"
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-02-16 09:48:51 -08:00
|
|
|
set -x
|
|
|
|
solana-keygen -o "$dataDir"/config/leader-keypair.json
|
2019-04-11 14:52:56 -07:00
|
|
|
solana-keygen -o "$dataDir"/config/leader-vote-account-keypair.json
|
2019-02-16 09:48:51 -08:00
|
|
|
solana-keygen -o "$dataDir"/config/drone-keypair.json
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-04-11 14:52:56 -07:00
|
|
|
leaderVoteAccountPubkey=$(\
|
2019-03-21 08:54:13 -07:00
|
|
|
solana-wallet \
|
2019-04-11 14:52:56 -07:00
|
|
|
--keypair "$dataDir"/config/leader-vote-account-keypair.json \
|
2019-03-21 08:54:13 -07:00
|
|
|
address \
|
|
|
|
)
|
|
|
|
|
2018-12-07 16:04:34 -08:00
|
|
|
solana-genesis \
|
2019-03-05 17:01:57 -08:00
|
|
|
--lamports 1000000000 \
|
2019-02-16 09:48:51 -08:00
|
|
|
--mint "$dataDir"/config/drone-keypair.json \
|
|
|
|
--bootstrap-leader-keypair "$dataDir"/config/leader-keypair.json \
|
2019-04-11 14:52:56 -07:00
|
|
|
--bootstrap-vote-keypair "$dataDir"/config/leader-vote-account-keypair.json \
|
2019-02-16 09:48:51 -08:00
|
|
|
--ledger "$dataDir"/ledger
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-02-16 09:48:51 -08:00
|
|
|
solana-drone --keypair "$dataDir"/config/drone-keypair.json &
|
2018-10-02 17:34:47 -07:00
|
|
|
drone=$!
|
2018-12-07 16:04:34 -08:00
|
|
|
|
2019-02-16 10:16:27 -08:00
|
|
|
args=(
|
2019-03-04 14:27:06 -08:00
|
|
|
--identity "$dataDir"/config/leader-keypair.json
|
2019-04-11 14:52:56 -07:00
|
|
|
--voting-keypair "$dataDir"/config/leader-vote-account-keypair.json
|
|
|
|
--vote-account "$leaderVoteAccountPubkey"
|
2019-02-16 10:16:27 -08:00
|
|
|
--ledger "$dataDir"/ledger/
|
|
|
|
--rpc-port 8899
|
2019-03-06 09:26:12 -08:00
|
|
|
--rpc-drone-address 127.0.0.1:9900
|
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
|
|
|
|
solana-fullnode "${args[@]}" &
|
2018-10-02 17:34:47 -07:00
|
|
|
fullnode=$!
|
|
|
|
|
|
|
|
abort() {
|
2019-03-21 08:54:13 -07:00
|
|
|
set +e
|
2018-10-02 17:34:47 -07:00
|
|
|
kill "$drone" "$fullnode"
|
|
|
|
}
|
2019-03-21 08:54:13 -07:00
|
|
|
trap abort INT TERM EXIT
|
|
|
|
|
2018-10-02 17:34:47 -07:00
|
|
|
wait "$fullnode"
|