From 78d5ace75426d4bdcc4c9ee14165b819eccd131d Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 17 Apr 2019 18:03:58 -0700 Subject: [PATCH] Refactor multinode-demo/ scripts to avoid shipping fullnode-x.sh (#3835) --- book/src/testnet-participation.md | 45 ++++++--- ci/localnet-sanity.sh | 2 +- ci/publish-tarball.sh | 8 +- multinode-demo/clear-fullnode-config.sh | 17 ++++ multinode-demo/common.sh | 86 +++-------------- multinode-demo/fullnode-x.sh | 2 +- multinode-demo/fullnode.sh | 117 ++++++++++++++++-------- multinode-demo/leader.sh | 1 - multinode-demo/setup.sh | 89 +++++------------- multinode-demo/validator-x.sh | 1 - multinode-demo/validator.sh | 1 - net/remote/remote-node.sh | 4 +- 12 files changed, 171 insertions(+), 202 deletions(-) create mode 100755 multinode-demo/clear-fullnode-config.sh delete mode 120000 multinode-demo/leader.sh delete mode 120000 multinode-demo/validator-x.sh delete mode 120000 multinode-demo/validator.sh diff --git a/book/src/testnet-participation.md b/book/src/testnet-participation.md index 8cffdc4e4b..dc10056029 100644 --- a/book/src/testnet-participation.md +++ b/book/src/testnet-participation.md @@ -91,7 +91,6 @@ $ export PATH=$PWD/bin:$PATH ``` ### Starting The Validator - Sanity check that you are able to interact with the cluster by receiving a small airdrop of lamports from the testnet drone: ```bash @@ -103,34 +102,52 @@ Then the following command will start a new validator node. If this is a `solana-install`-installation: ```bash -$ fullnode-x.sh --public-address --poll-for-new-genesis-block beta.testnet.solana.com +$ clear-fullnode-config.sh +$ fullnode.sh --public-address --poll-for-new-genesis-block beta.testnet.solana.com ``` Alternatively, the `solana-install run` command can be used to run the validator node while periodically checking for and applying software updates: ```bash -$ solana-install run fullnode-x.sh -- --public-address --poll-for-new-genesis-block beta.testnet.solana.com +$ solana-install run fullnode.sh -- --public-address --poll-for-new-genesis-block beta.testnet.solana.com ``` -When not using `solana-install`: +If you built from source: ```bash -$ USE_INSTALL=1 ./multinode-demo/fullnode-x.sh --public-address --poll-for-new-genesis-block beta.testnet.solana.com +$ USE_INSTALL=1 ./multinode-demo/clear-fullnode-config.sh +$ USE_INSTALL=1 ./multinode-demo/fullnode.sh --public-address --poll-for-new-genesis-block edge.testnet.solana.com ``` -Then from another console, confirm the IP address if your node is now visible in -the gossip network by running: -```bash -$ solana-gossip --network beta.testnet.solana.com:8001 -``` - -Congratulations, you're now participating in the testnet cluster! - #### Controlling local network port allocation By default the validator will dynamically select available network ports in the 8000-10000 range, and may be overridden with `--dynamic-port-range`. For -example, `fullnode-x.sh --dynamic-port-range 11000-11010 ...` will restrict the +example, `fullnode.sh --dynamic-port-range 11000-11010 ...` will restrict the validator to ports 11000-11011. +### Validator Monitoring +From another console, confirm the IP address of your validator is visible in the +gossip network by running: +```bash +solana-gossip --network edge.testnet.solana.com:8001 +``` + +When `fullnode.sh` starts, it will output a fullnode configuration that looks +similar to: +```bash +======================[ Fullnode configuration ]====================== +node id: 4ceWXsL3UJvn7NYZiRkw7NsryMpviaKBDYr8GK7J61Dm +vote id: 2ozWvfaXQd1X6uKh8jERoRGApDqSqcEy6fF1oN13LL2G +ledger: ... +accounts: ... +====================================================================== +``` + +Provide the **vote id** pubkey to the `solana-wallet show-vote-account` command to view +the recent voting activity from your validator: +```bash +$ solana-wallet -n beta.testnet.solana.com show-vote-account 2ozWvfaXQd1X6uKh8jERoRGApDqSqcEy6fF1oN13LL2G +``` + ### Sharing Metrics From Your Validator If you'd like to share metrics perform the following steps before starting the validator node: diff --git a/ci/localnet-sanity.sh b/ci/localnet-sanity.sh index 14a0b61d60..2d3e7bdf00 100755 --- a/ci/localnet-sanity.sh +++ b/ci/localnet-sanity.sh @@ -90,7 +90,7 @@ nodes=( for i in $(seq 1 $extraNodes); do nodes+=( "multinode-demo/fullnode.sh \ - -X dyn$i \ + --label dyn$i \ --init-complete-file init-complete-node$((2 + i)).log \ $maybeNoLeaderRotation" ) diff --git a/ci/publish-tarball.sh b/ci/publish-tarball.sh index 021a4429cc..355da0d63b 100755 --- a/ci/publish-tarball.sh +++ b/ci/publish-tarball.sh @@ -77,16 +77,16 @@ exec multinode-demo/fullnode.sh "$@" EOF chmod +x solana-release/bin/fullnode.sh - # Add a wrapper script for fullnode-x.sh + # Add a wrapper script for clear-fullnode-config.sh # TODO: Remove multinode/... from tarball - cat > solana-release/bin/fullnode-x.sh <<'EOF' + cat > solana-release/bin/clear-fullnode-config.sh <<'EOF' #!/usr/bin/env bash set -e cd "$(dirname "$0")"/.. export USE_INSTALL=1 -exec multinode-demo/fullnode-x.sh "$@" +exec multinode-demo/clear-fullnode-config.sh "$@" EOF - chmod +x solana-release/bin/fullnode-x.sh + chmod +x solana-release/bin/clear-fullnode-config.sh tar jvcf solana-release-$TARGET.tar.bz2 solana-release/ cp solana-release/bin/solana-install solana-install-$TARGET diff --git a/multinode-demo/clear-fullnode-config.sh b/multinode-demo/clear-fullnode-config.sh new file mode 100755 index 0000000000..413465cc42 --- /dev/null +++ b/multinode-demo/clear-fullnode-config.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# Clear the current cluster configuration +# + +here=$(dirname "$0") +# shellcheck source=multinode-demo/common.sh +source "$here"/common.sh + +set -e + +for i in "$SOLANA_RSYNC_CONFIG_DIR" "$SOLANA_CONFIG_DIR"; do + echo "Cleaning $i" + rm -rvf "$i" + mkdir -p "$i" +done + diff --git a/multinode-demo/common.sh b/multinode-demo/common.sh index adb5db1ab2..c7885285a6 100644 --- a/multinode-demo/common.sh +++ b/multinode-demo/common.sh @@ -7,7 +7,7 @@ # shellcheck disable=2034 # -solana_root="$(dirname "${BASH_SOURCE[0]}")/.." +SOLANA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. || exit 1; pwd)" rsync=rsync bootstrap_leader_logger="tee bootstrap-leader.log" @@ -23,8 +23,7 @@ if [[ $(uname) != Linux ]]; then fi fi - -if [[ -n $USE_INSTALL || ! -f "$solana_root"/Cargo.toml ]]; then +if [[ -n $USE_INSTALL || ! -f "$SOLANA_ROOT"/Cargo.toml ]]; then solana_program() { declare program="$1" printf "solana-%s" "$program" @@ -38,17 +37,17 @@ else features+="cuda," fi - if [[ -r "$solana_root"/"$program"/Cargo.toml ]]; then + if [[ -r "$SOLANA_ROOT/$program"/Cargo.toml ]]; then maybe_package="--package solana-$program" fi if [[ -n $NDEBUG ]]; then maybe_release=--release fi - declare manifest_path="--manifest-path=$solana_root/$program/Cargo.toml" + declare manifest_path="--manifest-path=$SOLANA_ROOT/$program/Cargo.toml" printf "cargo run $manifest_path $maybe_release $maybe_package --bin solana-%s %s -- " "$program" "$features" } # shellcheck disable=2154 # 'here' is referenced but not assigned - LD_LIBRARY_PATH=$(cd "$here/../target/perf-libs" && pwd):$LD_LIBRARY_PATH + LD_LIBRARY_PATH=$(cd "$SOLANA_ROOT/target/perf-libs" && pwd):$LD_LIBRARY_PATH export LD_LIBRARY_PATH fi @@ -66,14 +65,14 @@ export RUST_LOG=${RUST_LOG:-solana=info} # if RUST_LOG is unset, default to info export RUST_BACKTRACE=1 # shellcheck source=scripts/configure-metrics.sh -source "$solana_root"/scripts/configure-metrics.sh +source "$SOLANA_ROOT"/scripts/configure-metrics.sh tune_system() { # Skip in CI [[ -z $CI ]] || return 0 # shellcheck source=scripts/ulimit-n.sh - source "$solana_root"/scripts/ulimit-n.sh + source "$SOLANA_ROOT"/scripts/ulimit-n.sh # Reference: https://medium.com/@CameronSparr/increase-os-udp-buffers-to-improve-performance-51d167bb1360 if [[ $(uname) = Linux ]]; then @@ -107,76 +106,20 @@ tune_system() { fi } -airdrop() { - declare keypair_file=$1 - declare host=$2 - declare amount=$3 - - declare address - address=$($solana_wallet --keypair "$keypair_file" address) - - # TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved - # a fullnode needs N lamports as its vote account gets re-created on every - # node restart, costing it lamports - declare retries=5 - - while ! $solana_wallet --keypair "$keypair_file" --host "$host" airdrop "$amount"; do - - # TODO: Consider moving this retry logic into `solana-wallet airdrop` - # itself, currently it does not retry on "Connection refused" errors. - ((retries--)) - if [[ $retries -le 0 ]]; then - echo "Airdrop to $address failed." - return 1 - fi - echo "Airdrop to $address failed. Remaining retries: $retries" - sleep 1 - done - - return 0 -} - -setup_vote_account() { - declare drone_address=$1 - declare node_id_path=$2 - declare vote_id_path=$3 - declare stake=$4 - - declare node_id - node_id=$($solana_wallet --keypair "$node_id_path" address) - - declare vote_id - vote_id=$($solana_wallet --keypair "$vote_id_path" address) - - if [[ -f "$vote_id_path".configured ]]; then - echo "Vote account has already been configured" - else - airdrop "$node_id_path" "$drone_address" "$stake" || return $? - - # Fund the vote account from the node, with the node as the node_id - $solana_wallet --keypair "$node_id_path" --host "$drone_address" \ - create-vote-account "$vote_id" "$node_id" $((stake - 1)) || return $? - fi - - $solana_wallet --keypair "$node_id_path" --host "$drone_address" show-vote-account "$vote_id" - return 0 -} - fullnode_usage() { if [[ -n $1 ]]; then echo "$*" echo fi cat <&1) ]]; then echo "############## New genesis detected, restarting fullnode ##############" - rm -rf "$ledger_config_dir" kill "$pid" || true wait "$pid" || true + rm -rf "$ledger_config_dir" "$accounts_config_dir" "$vote_id_path".configured break fi fi diff --git a/multinode-demo/leader.sh b/multinode-demo/leader.sh deleted file mode 120000 index 86bcd2c1e4..0000000000 --- a/multinode-demo/leader.sh +++ /dev/null @@ -1 +0,0 @@ -bootstrap-leader.sh \ No newline at end of file diff --git a/multinode-demo/setup.sh b/multinode-demo/setup.sh index 5a38c1d1e1..ffa2f3cc2e 100755 --- a/multinode-demo/setup.sh +++ b/multinode-demo/setup.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -# -# Creates a fullnode configuration -# here=$(dirname "$0") # shellcheck source=multinode-demo/common.sh source "$here"/common.sh +lamports=1000000000 +bootstrap_leader_lamports= + usage () { exitcode=0 if [[ -n "$1" ]]; then @@ -14,25 +14,18 @@ usage () { echo "Error: $*" fi cat < drone.log 2>&1 & @@ -122,7 +122,7 @@ local|tar) set -x if [[ $skipSetup != true ]]; then - ./multinode-demo/setup.sh -t fullnode + ./multinode-demo/clear-fullnode-config.sh fi if [[ $nodeType = blockstreamer ]]; then