Eject bootstrap-leader support from fullnode.sh (#5301)

This commit is contained in:
Michael Vines 2019-07-29 21:25:28 -07:00 committed by GitHub
parent 50a991fdf9
commit 2214d2dbb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 150 additions and 136 deletions

View File

@ -74,8 +74,6 @@ source scripts/configure-metrics.sh
nodes=(
"multinode-demo/drone.sh"
"multinode-demo/bootstrap-leader.sh \
--enable-rpc-exit \
--no-restart \
--init-complete-file init-complete-node1.log"
"multinode-demo/validator.sh \
--enable-rpc-exit \

View File

@ -2,6 +2,77 @@
#
# Start the bootstrap leader node
#
set -e
here=$(dirname "$0")
exec "$here"/fullnode.sh --bootstrap-leader "$@"
# shellcheck source=multinode-demo/common.sh
source "$here"/common.sh
if [[ -n $SOLANA_CUDA ]]; then
program=$solana_validator_cuda
else
program=$solana_validator
fi
args=()
while [[ -n $1 ]]; do
if [[ ${1:0:1} = - ]]; then
if [[ $1 = --init-complete-file ]]; then
args+=("$1" "$2")
shift 2
else
echo "Unknown argument: $1"
$program --help
exit 1
fi
else
echo "Unknown argument: $1"
$program --help
exit 1
fi
done
if [[ ! -d "$SOLANA_RSYNC_CONFIG_DIR"/ledger ]]; then
echo "$SOLANA_RSYNC_CONFIG_DIR/ledger does not exist"
echo
echo "Please run: $here/setup.sh"
exit 1
fi
if [[ -z $CI ]]; then # Skip in CI
# shellcheck source=scripts/tune-system.sh
source "$here"/../scripts/tune-system.sh
fi
setup_secondary_mount
# These keypairs are created by ./setup.sh and included in the genesis block
identity_keypair=$SOLANA_CONFIG_DIR/bootstrap-leader-keypair.json
vote_keypair="$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-keypair.json
storage_keypair=$SOLANA_CONFIG_DIR/bootstrap-leader-storage-keypair.json
ledger_config_dir="$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
[[ -d "$ledger_config_dir" ]] || (
set -x
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger/ "$ledger_config_dir"
)
args+=(
--accounts "$SOLANA_CONFIG_DIR"/bootstrap-leader-accounts
--enable-rpc-exit
--gossip-port 8001
--identity "$identity_keypair"
--ledger "$ledger_config_dir"
--rpc-port 8899
--snapshot-path "$SOLANA_CONFIG_DIR"/bootstrap-leader-snapshots
--storage-keypair "$storage_keypair"
--voting-keypair "$vote_keypair"
--rpc-drone-address 127.0.0.1:9900
)
identity_pubkey=$($solana_keygen pubkey "$identity_keypair")
export SOLANA_METRICS_HOST_ID="$identity_pubkey"
set -x
# shellcheck disable=SC2086 # Don't want to double quote $program
exec $program "${args[@]}"

View File

@ -1,15 +1,11 @@
#!/usr/bin/env bash
#
# Start a fullnode
# Start a validator
#
here=$(dirname "$0")
# shellcheck source=multinode-demo/common.sh
source "$here"/common.sh
# shellcheck source=scripts/oom-score-adj.sh
source "$here"/../scripts/oom-score-adj.sh
fullnode_usage() {
if [[ -n $1 ]]; then
echo "$*"
@ -136,15 +132,7 @@ setup_validator_accounts() {
return 0
}
ledger_not_setup() {
echo "Error: $*"
echo
echo "Please run: ${here}/setup.sh"
exit 1
}
args=()
node_type=validator
node_lamports=424242 # number of lamports to assign the node for transaction fees
stake_lamports=42 # number of lamports to assign as stake
poll_for_new_genesis_block=0
@ -166,19 +154,12 @@ while [[ -n $1 ]]; do
elif [[ $1 = --no-restart ]]; then
no_restart=1
shift
elif [[ $1 = --bootstrap-leader ]]; then
node_type=bootstrap_leader
generate_snapshots=1
shift
elif [[ $1 = --generate-snapshots ]]; then
generate_snapshots=1
shift
elif [[ $1 = --no-snapshot ]]; then
boot_from_snapshot=0
shift
elif [[ $1 = --validator ]]; then
node_type=validator
shift
elif [[ $1 = --poll-for-new-genesis-block ]]; then
poll_for_new_genesis_block=1
shift
@ -263,34 +244,6 @@ fi
setup_secondary_mount
if [[ $node_type = bootstrap_leader ]]; then
if [[ ${#positional_args[@]} -ne 0 ]]; then
fullnode_usage "Unknown argument: ${positional_args[0]}"
fi
[[ -f "$SOLANA_CONFIG_DIR"/bootstrap-leader-keypair.json ]] ||
ledger_not_setup "$SOLANA_CONFIG_DIR/bootstrap-leader-keypair.json not found"
$solana_ledger_tool --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger verify
# These four keypairs are created by ./setup.sh and encoded into the genesis
# block
identity_keypair_path=$SOLANA_CONFIG_DIR/bootstrap-leader-keypair.json
voting_keypair_path="$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-keypair.json
stake_keypair_path=$SOLANA_CONFIG_DIR/bootstrap-leader-stake-keypair.json
storage_keypair_path=$SOLANA_CONFIG_DIR/bootstrap-leader-storage-keypair.json
ledger_config_dir="$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
state_dir="$SOLANA_CONFIG_DIR"/bootstrap-leader-state
configured_flag=$SOLANA_CONFIG_DIR/bootstrap-leader.configured
default_arg --rpc-port 8899
if ((airdrops_enabled)); then
default_arg --rpc-drone-address 127.0.0.1:9900
fi
default_arg --gossip-port 8001
elif [[ $node_type = validator ]]; then
if [[ ${#positional_args[@]} -gt 2 ]]; then
fullnode_usage "$@"
fi
@ -322,10 +275,6 @@ elif [[ $node_type = validator ]]; then
fi
rsync_entrypoint_url=$(rsync_url "$entrypoint")
else
echo "Error: Unknown node_type: $node_type"
exit 1
fi
identity_pubkey=$($solana_keygen pubkey "$identity_keypair_path")
export SOLANA_METRICS_HOST_ID="$identity_pubkey"
@ -393,7 +342,7 @@ if ((reset_ledger)); then
fi
while true; do
if [[ $node_type != bootstrap_leader ]] && new_genesis_block; then
if new_genesis_block; then
# If the genesis block has changed remove the now stale ledger and start all
# over again
(
@ -402,12 +351,7 @@ while true; do
)
fi
if [[ $node_type = bootstrap_leader && ! -d "$SOLANA_RSYNC_CONFIG_DIR"/ledger ]]; then
ledger_not_setup "$SOLANA_RSYNC_CONFIG_DIR/ledger does not exist"
fi
if [[ ! -d "$ledger_config_dir" ]]; then
if [[ $node_type = validator ]]; then
(
cd "$SOLANA_RSYNC_CONFIG_DIR"
@ -438,8 +382,6 @@ while true; do
echo "Extracted snapshot in $SECONDS seconds"
fi
)
fi
(
set -x
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger/ "$ledger_config_dir"
@ -450,14 +392,14 @@ while true; do
stake_pubkey=$($solana_keygen pubkey "$stake_keypair_path")
storage_pubkey=$($solana_keygen pubkey "$storage_keypair_path")
if [[ $node_type = validator ]] && ((stake_lamports)); then
if ((stake_lamports)); then
setup_validator_accounts "${entrypoint_address%:*}" \
"$node_lamports" \
"$stake_lamports"
fi
cat <<EOF
======================[ $node_type configuration ]======================
======================[ validator configuration ]======================
identity pubkey: $identity_pubkey
vote pubkey: $vote_pubkey
stake pubkey: $stake_pubkey
@ -473,7 +415,6 @@ EOF
$program "${args[@]}" &
pid=$!
echo "pid: $pid"
oom_score_adj "$pid" 1000
if ((no_restart)); then
wait "$pid"
@ -485,7 +426,7 @@ EOF
while true; do
if [[ -z $pid ]] || ! kill -0 "$pid"; then
[[ -z $pid ]] || wait "$pid"
echo "############## $node_type exited, restarting ##############"
echo "############## validator exited, restarting ##############"
break
fi
@ -521,7 +462,7 @@ EOF
if ((poll_for_new_genesis_block && --secs_to_next_genesis_poll == 0)); then
echo "Polling for new genesis block..."
if new_genesis_block; then
echo "############## New genesis detected, restarting $node_type ##############"
echo "############## New genesis detected, restarting ##############"
break
fi
secs_to_next_genesis_poll=60

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
here=$(dirname "$0")
exec "$here"/fullnode.sh --validator "$@"
exec "$here"/fullnode.sh "$@"

View File

@ -58,6 +58,7 @@ genesisOptions="$genesisOptions"
airdropsEnabled=$airdropsEnabled
EOF
source scripts/oom-score-adj.sh
source net/common.sh
loadConfigFile
@ -164,21 +165,20 @@ local|tar|skip)
args+=($genesisOptions)
./multinode-demo/setup.sh "${args[@]}"
fi
if [[ $airdropsEnabled = true ]]; then
./multinode-demo/drone.sh > drone.log 2>&1 &
fi
args=(
--enable-rpc-exit
--gossip-port "$entrypointIp":8001
--init-complete-file "$initCompleteFile"
)
if [[ $airdropsEnabled != true ]]; then
args+=(--no-airdrop)
if [[ $airdropsEnabled = true ]]; then
./multinode-demo/drone.sh > drone.log 2>&1 &
fi
args+=(--init-complete-file "$initCompleteFile")
# shellcheck disable=SC2206 # Don't want to double quote $extraNodeArgs
args+=($extraNodeArgs)
nohup ./multinode-demo/validator.sh --bootstrap-leader "${args[@]}" > fullnode.log 2>&1 &
pid=$!
oom_score_adj "$pid" 1000
waitForNodeToInit
;;
validator|blockstreamer)
@ -265,6 +265,8 @@ local|tar|skip)
# shellcheck disable=SC2206 # Don't want to double quote $extraNodeArgs
args+=($extraNodeArgs)
nohup ./multinode-demo/validator.sh "${args[@]}" > fullnode.log 2>&1 &
pid=$!
oom_score_adj "$pid" 1000
waitForNodeToInit
;;
replicator)
@ -284,6 +286,8 @@ local|tar|skip)
fi
nohup ./multinode-demo/replicator.sh "${args[@]}" > fullnode.log 2>&1 &
pid=$!
oom_score_adj "$pid" 1000
sleep 1
;;
*)

View File

@ -23,7 +23,7 @@ sysctl_write() {
fi
echo "$ $cmd"
$cmd
$cmd || true
# Some versions of sysctl exit with 0 on permission denied errors
current_value=$(sysctl -n "$name")