solana/run.sh

115 lines
2.9 KiB
Bash
Raw Normal View History

#!/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` ran successfully
2019-02-16 09:48:51 -08:00
#
set -e
# Prefer possible `cargo build` binaries over PATH binaries
cd "$(dirname "$0")/"
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
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
}
export RUST_LOG=${RUST_LOG:-solana=info,solana_runtime::message_processor=debug} # if RUST_LOG is unset, default to info
export RUST_BACKTRACE=1
2019-07-30 22:43:47 -07:00
dataDir=$PWD/config/"$(basename "$0" .sh)"
ledgerDir=$PWD/config/ledger
SOLANA_RUN_SH_CLUSTER_TYPE=${SOLANA_RUN_SH_CLUSTER_TYPE:-development}
2019-02-16 09:48:51 -08:00
set -x
if ! solana address; then
echo Generating default keypair
solana-keygen new --no-passphrase
fi
validator_identity="$dataDir/validator-identity.json"
if [[ -e $validator_identity ]]; then
echo "Use existing validator keypair"
else
solana-keygen new --no-passphrase -so "$validator_identity"
fi
validator_vote_account="$dataDir/validator-vote-account.json"
if [[ -e $validator_vote_account ]]; then
echo "Use existing validator vote account keypair"
else
solana-keygen new --no-passphrase -so "$validator_vote_account"
fi
validator_stake_account="$dataDir/validator-stake-account.json"
if [[ -e $validator_stake_account ]]; then
echo "Use existing validator stake account keypair"
else
solana-keygen new --no-passphrase -so "$validator_stake_account"
fi
if [[ -e "$ledgerDir"/genesis.bin || -e "$ledgerDir"/genesis.tar.bz2 ]]; then
echo "Use existing genesis"
else
./fetch-spl.sh
if [[ -r spl-genesis-args.sh ]]; then
SPL_GENESIS_ARGS=$(cat spl-genesis-args.sh)
fi
# shellcheck disable=SC2086
solana-genesis \
--hashes-per-tick sleep \
--faucet-lamports 500000000000000000 \
--bootstrap-validator \
"$validator_identity" \
"$validator_vote_account" \
"$validator_stake_account" \
--ledger "$ledgerDir" \
--cluster-type "$SOLANA_RUN_SH_CLUSTER_TYPE" \
$SPL_GENESIS_ARGS \
$SOLANA_RUN_SH_GENESIS_ARGS
fi
abort() {
set +e
2019-12-16 13:05:17 -08:00
kill "$faucet" "$validator"
wait "$validator"
}
trap abort INT TERM EXIT
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=(
--identity "$validator_identity"
--vote-account "$validator_vote_account"
--ledger "$ledgerDir"
--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
--log -
--enable-rpc-transaction-history
--enable-cpi-and-log-storage
--init-complete-file "$dataDir"/init-completed
--snapshot-compression none
Persistent tower (#10718) * Save/restore Tower * Avoid unwrap() * Rebase cleanups * Forcibly pass test * Correct reconcilation of votes after validator resume * d b g * Add more tests * fsync and fix test * Add test * Fix fmt * Debug * Fix tests... * save * Clarify error message and code cleaning around it * Move most of code out of tower save hot codepath * Proper comment for the lack of fsync on tower * Clean up * Clean up * Simpler type alias * Manage tower-restored ancestor slots without banks * Add comment * Extract long code blocks... * Add comment * Simplify returned tuple... * Tweak too aggresive log * Fix typo... * Add test * Update comment * Improve test to require non-empty stray restored slots * Measure tower save and dump all tower contents * Log adjust and add threshold related assertions * cleanup adjust * Properly lower stray restored slots priority... * Rust fmt * Fix test.... * Clarify comments a bit and add TowerError::TooNew * Further clean-up arround TowerError * Truly create ancestors by excluding last vote slot * Add comment for stray_restored_slots * Add comment for stray_restored_slots * Use BTreeSet * Consider root_slot into post-replay adjustment * Tweak logging * Add test for stray_restored_ancestors * Reorder some code * Better names for unit tests * Add frozen_abi to SavedTower * Fold long lines * Tweak stray ancestors and too old slot history * Re-adjust error conditon of too old slot history * Test normal ancestors is checked before stray ones * Fix conflict, update tests, adjust behavior a bit * Fix test * Address review comments * Last touch! * Immediately after creating cleaning pr * Revert stray slots * Revert comment... * Report error as metrics * Revert not to panic! and ignore unfixable test... * Normalize lockouts.root_slot more strictly * Add comments for panic! and more assertions * Proper initialize root without vote account * Clarify code and comments based on review feedback * Fix rebase * Further simplify based on assured tower root * Reorder code for more readability Co-authored-by: Michael Vines <mvines@gmail.com>
2020-09-18 22:03:54 -07:00
--require-tower
--no-wait-for-vote-to-start-leader
2019-02-16 10:16:27 -08:00
)
# shellcheck disable=SC2086
solana-validator "${args[@]}" $SOLANA_RUN_SH_VALIDATOR_ARGS &
validator=$!
wait "$validator"