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-05-18 14:01:36 -07:00
|
|
|
cd "$(dirname "$0")/"
|
2019-02-16 10:16:27 -08:00
|
|
|
PATH=$PWD/target/debug:$PATH
|
2019-02-16 09:48:51 -08:00
|
|
|
|
|
|
|
ok=true
|
2019-05-23 15:06:01 -07:00
|
|
|
for program in solana-{drone,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-05-31 16:51:09 -07:00
|
|
|
dataDir=$PWD/config-local/"$(basename "$0" .sh)"
|
|
|
|
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-06-07 17:54:54 -07:00
|
|
|
solana-keygen new -o "$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-06-07 17:54:54 -07:00
|
|
|
solana-keygen new -o "$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-06-07 17:54:54 -07:00
|
|
|
solana-keygen new -o "$leader_stake_account_keypair"
|
2019-05-30 21:31:35 -07:00
|
|
|
fi
|
2019-06-07 22:18:55 -07:00
|
|
|
solana-keygen new -f -o "$dataDir"/drone-keypair.json
|
|
|
|
solana-keygen new -f -o "$dataDir"/leader-storage-account-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-05-31 16:51:09 -07:00
|
|
|
--keypair "$dataDir"/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-05-07 20:28:41 -07:00
|
|
|
--bootstrap-leader-lamports 10000000 \
|
2019-06-10 22:18:32 -07:00
|
|
|
--target-lamports-per-signature 42 \
|
|
|
|
--target-signatures-per-slot 42 \
|
2019-05-18 14:01:36 -07:00
|
|
|
--hashes-per-tick sleep \
|
2019-05-31 16:51:09 -07:00
|
|
|
--mint "$dataDir"/drone-keypair.json \
|
|
|
|
--bootstrap-leader-keypair "$dataDir"/leader-keypair.json \
|
|
|
|
--bootstrap-vote-keypair "$dataDir"/leader-vote-account-keypair.json \
|
|
|
|
--bootstrap-stake-keypair "$dataDir"/leader-stake-account-keypair.json \
|
|
|
|
--bootstrap-storage-keypair "$dataDir"/leader-storage-account-keypair.json \
|
|
|
|
--ledger "$ledgerDir"
|
2018-10-02 17:34:47 -07:00
|
|
|
|
2019-05-31 16:51:09 -07:00
|
|
|
abort() {
|
|
|
|
set +e
|
|
|
|
kill "$drone" "$validator"
|
|
|
|
}
|
|
|
|
trap abort INT TERM EXIT
|
|
|
|
|
|
|
|
solana-drone --keypair "$dataDir"/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-05-31 16:51:09 -07:00
|
|
|
--identity "$dataDir"/leader-keypair.json
|
|
|
|
--storage-keypair "$dataDir"/leader-storage-account-keypair.json
|
|
|
|
--voting-keypair "$dataDir"/leader-vote-account-keypair.json
|
2019-04-11 14:52:56 -07:00
|
|
|
--vote-account "$leaderVoteAccountPubkey"
|
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-03-06 09:26:12 -08:00
|
|
|
--rpc-drone-address 127.0.0.1:9900
|
2019-05-30 21:31:35 -07:00
|
|
|
--accounts "$dataDir"/accounts
|
|
|
|
--snapshot-path "$dataDir"/snapshots
|
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"
|