From a71ebcc9f3df50874ed983d816d9dda4b744c907 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 21 Sep 2021 15:59:48 +0000 Subject: [PATCH] demote `./run.sh` (backport #19679) (#20052) * move `./run.sh` into `./scripts` (cherry picked from commit 92e343da264282d432f09a22d25fd6e3a8617950) * add some guidance in place of `./run.sh` (cherry picked from commit 33de7b856fbb22cc6022fdbe0024f0c46973fb7c) Co-authored-by: Trent Nelson --- README.md | 5 -- ci/run-sanity.sh | 2 +- run.sh | 116 ++++--------------------------------- scripts/run.sh | 114 ++++++++++++++++++++++++++++++++++++ sdk/docker-solana/build.sh | 2 +- 5 files changed, 126 insertions(+), 113 deletions(-) mode change 100755 => 100644 run.sh create mode 100755 scripts/run.sh diff --git a/README.md b/README.md index 4d75a8573b..a8e3cbbf8a 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,6 @@ $ cd solana $ cargo build ``` -## **4. Run a minimal local cluster.** -```bash -$ ./run.sh -``` - # Testing **Run the test suite:** diff --git a/ci/run-sanity.sh b/ci/run-sanity.sh index d7b5ac35c5..1c74499b18 100755 --- a/ci/run-sanity.sh +++ b/ci/run-sanity.sh @@ -7,7 +7,7 @@ source multinode-demo/common.sh rm -rf config/run/init-completed config/ledger config/snapshot-ledger -SOLANA_RUN_SH_VALIDATOR_ARGS="--snapshot-interval-slots 200" timeout 120 ./run.sh & +SOLANA_RUN_SH_VALIDATOR_ARGS="--snapshot-interval-slots 200" timeout 120 ./scripts/run.sh & pid=$! attempts=20 diff --git a/run.sh b/run.sh old mode 100755 new mode 100644 index 917e5fcd6f..809893e880 --- a/run.sh +++ b/run.sh @@ -1,114 +1,18 @@ #!/usr/bin/env bash -# -# 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 -# -set -e -# Prefer possible `cargo build` binaries over PATH binaries -cd "$(dirname "$0")/" +cat <<'EOF' -profile=debug -if [[ -n $NDEBUG ]]; then - profile=release -fi -PATH=$PWD/target/$profile:$PATH + WARNING! LEGACY SHELL SCRIPT -ok=true -for program in solana-{faucet,genesis,keygen,validator}; do - $program -V || ok=false -done -$ok || { - echo - echo "Unable to locate required programs. Try building them first with:" - echo - echo " $ cargo build --all" - echo - exit 1 -} + You almost certainly do not want to run this script! -export RUST_LOG=${RUST_LOG:-solana=info,solana_runtime::message_processor=debug} # if RUST_LOG is unset, default to info -export RUST_BACKTRACE=1 -dataDir=$PWD/config/"$(basename "$0" .sh)" -ledgerDir=$PWD/config/ledger + If you are a dapp developer and looking for a way to run a local validator, please + see https://docs.solana.com/developing/test-validator -SOLANA_RUN_SH_CLUSTER_TYPE=${SOLANA_RUN_SH_CLUSTER_TYPE:-development} + If you are a prospective validator, please see https://docs.solana.com/running-validator -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 you are a core developer, many apologies for what you're about to endure, but + you may be in the right place. This script is now located at `./scripts/run.sh`. + Please update whatever docs lead you here to reflect this change -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 - kill "$faucet" "$validator" - wait "$validator" -} -trap abort INT TERM EXIT - -solana-faucet & -faucet=$! - -args=( - --identity "$validator_identity" - --vote-account "$validator_vote_account" - --ledger "$ledgerDir" - --gossip-port 8001 - --rpc-port 8899 - --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 - --require-tower - --no-wait-for-vote-to-start-leader -) -# shellcheck disable=SC2086 -solana-validator "${args[@]}" $SOLANA_RUN_SH_VALIDATOR_ARGS & -validator=$! - -wait "$validator" +EOF diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000000..1754a9ad8c --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# +# 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 +# +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 + +ok=true +for program in solana-{faucet,genesis,keygen,validator}; do + $program -V || ok=false +done +$ok || { + echo + echo "Unable to locate required programs. Try building them first with:" + echo + echo " $ cargo build --all" + echo + 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 +dataDir=$PWD/config/"$(basename "$0" .sh)" +ledgerDir=$PWD/config/ledger + +SOLANA_RUN_SH_CLUSTER_TYPE=${SOLANA_RUN_SH_CLUSTER_TYPE:-development} + +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 + kill "$faucet" "$validator" + wait "$validator" +} +trap abort INT TERM EXIT + +solana-faucet & +faucet=$! + +args=( + --identity "$validator_identity" + --vote-account "$validator_vote_account" + --ledger "$ledgerDir" + --gossip-port 8001 + --rpc-port 8899 + --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 + --require-tower + --no-wait-for-vote-to-start-leader +) +# shellcheck disable=SC2086 +solana-validator "${args[@]}" $SOLANA_RUN_SH_VALIDATOR_ARGS & +validator=$! + +wait "$validator" diff --git a/sdk/docker-solana/build.sh b/sdk/docker-solana/build.sh index 08fdb255d7..77160d73ed 100755 --- a/sdk/docker-solana/build.sh +++ b/sdk/docker-solana/build.sh @@ -23,7 +23,7 @@ rm -rf usr/ ../../ci/docker-run.sh "$rust_stable_docker_image" \ scripts/cargo-install-all.sh sdk/docker-solana/usr -cp -f ../../run.sh usr/bin/solana-run.sh +cp -f ../../scripts/run.sh usr/bin/solana-run.sh cp -f ../../fetch-spl.sh usr/bin/ ( cd usr/bin