Refactor multinode-demo/ scripts to avoid shipping fullnode-x.sh (#3835)

This commit is contained in:
Michael Vines
2019-04-17 18:03:58 -07:00
committed by GitHub
parent 2b3218b5f2
commit 78d5ace754
12 changed files with 171 additions and 202 deletions

View File

@ -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 <<EOF
usage: $0 [-x] [--blockstream PATH] [--init-complete-file FILE] [--stake LAMPORTS] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
usage: $0 [--blockstream PATH] [--init-complete-file FILE] [--label LABEL] [--stake LAMPORTS] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
Start a full node on the specified network
Start a full node
-x - start a new, dynamically-configured full node. Does not apply to the bootstrap leader
-X [label] - start or restart a dynamically-configured full node with
the specified label. Does not apply to the bootstrap leader
--blockstream PATH - open blockstream at this unix domain socket location
--init-complete-file FILE - create this file, if it doesn't already exist, once node initialization is complete
--label LABEL - Append the given label to the fullnode configuration files, useful when running
multiple fullnodes from the same filesystem location
--stake LAMPORTS - Number of lamports to stake
--public-address - advertise public machine address in gossip. By default the local machine address is advertised
--no-voting - start node without vote signer
@ -186,9 +129,8 @@ EOF
exit 1
}
# The directory on the bootstrap leader that is rsynced by other full nodes as
# they boot (TODO: Eventually this should go away)
SOLANA_RSYNC_CONFIG_DIR=$PWD/config
# The directory on the cluster entrypoint that is rsynced by other full nodes
SOLANA_RSYNC_CONFIG_DIR=$SOLANA_ROOT/config
# Configuration that remains local
SOLANA_CONFIG_DIR=$PWD/config-local
SOLANA_CONFIG_DIR=$SOLANA_ROOT/config-local