Use -X for dynamic fullnodes, to ensure keypair remains constant during iterations

This commit is contained in:
Michael Vines
2019-01-21 18:40:16 -08:00
committed by Grimes
parent d666ebc558
commit dca0ba6a5d
2 changed files with 39 additions and 30 deletions

View File

@ -68,8 +68,8 @@ nodes=(
"multinode-demo/fullnode.sh $maybeNoLeaderRotation --rpc-port 18899" "multinode-demo/fullnode.sh $maybeNoLeaderRotation --rpc-port 18899"
) )
for _ in $(seq 1 $extraNodes); do for i in $(seq 1 $extraNodes); do
nodes+=("multinode-demo/fullnode-x.sh $maybeNoLeaderRotation") nodes+=("multinode-demo/fullnode.sh -X dyn$i $maybeNoLeaderRotation")
done done
numNodes=$((2 + extraNodes)) numNodes=$((2 + extraNodes))

View File

@ -20,14 +20,18 @@ usage() {
echo "$*" echo "$*"
echo echo
fi fi
echo "usage: $0 [-x] [--no-leader-rotation] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]" cat <<EOF
echo usage: $0 [-x] [--no-leader-rotation] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
echo " Start a full node on the specified network"
echo Start a full node on the specified network
echo " -x: runs a new, dynamically-configured full node"
echo " --no-leader-rotation: disable leader rotation" -x - start a new, dynamically-configured full node
echo " --rpc-port port: custom RPC port for this node" -X [label] - start or restart a dynamically-configured full node with
echo the specified label
--no-leader-rotation - disable leader rotation
--rpc-port port - custom RPC port for this node
EOF
exit 1 exit 1
} }
@ -35,8 +39,13 @@ if [[ $1 = -h ]]; then
usage usage
fi fi
if [[ $1 = -x ]]; then if [[ $1 = -X ]]; then
self_setup=1 self_setup=1
self_setup_label=$2
shift 2
elif [[ $1 = -x ]]; then
self_setup=1
self_setup_label=$$
shift shift
else else
self_setup=0 self_setup=0
@ -134,28 +143,28 @@ if ((!self_setup)); then
ledger_config_dir=$SOLANA_CONFIG_DIR/fullnode-ledger ledger_config_dir=$SOLANA_CONFIG_DIR/fullnode-ledger
else else
mkdir -p "$SOLANA_CONFIG_DIR" mkdir -p "$SOLANA_CONFIG_DIR"
fullnode_id_path=$SOLANA_CONFIG_DIR/fullnode-id-x$$.json fullnode_id_path=$SOLANA_CONFIG_DIR/fullnode-id-x$self_setup_label.json
$solana_keygen -o "$fullnode_id_path" [[ -f "$fullnode_id_path" ]] || $solana_keygen -o "$fullnode_id_path"
mkdir -p "$SOLANA_CONFIG_DIR" mkdir -p "$SOLANA_CONFIG_DIR"
fullnode_json_path=$SOLANA_CONFIG_DIR/fullnode-x$$.json fullnode_json_path=$SOLANA_CONFIG_DIR/fullnode-x$self_setup_label.json
[[ -f "$fullnode_json_path" ]] || {
echo "Finding a port.."
# Find an available port in the range 9100-9899
(( port = 9100 + ($$ % 800) ))
while true; do
(( port = port >= 9900 ? 9100 : ++port ))
echo "Testing $port"
if ! nc -w 10 -z 127.0.0.1 $port; then
echo "Selected port $port"
break;
fi
echo "Port $port is in use"
done
$solana_fullnode_config --keypair="$fullnode_id_path" -l -b "$port" > "$fullnode_json_path"
}
echo "Finding a port.." ledger_config_dir=$SOLANA_CONFIG_DIR/fullnode-ledger-x$self_setup_label
# Find an available port in the range 9100-9899
(( port = 9100 + ($$ % 800) ))
while true; do
(( port = port >= 9900 ? 9100 : ++port ))
echo "Testing $port"
if ! nc -w 10 -z 127.0.0.1 $port; then
echo "Selected port $port"
break;
fi
echo "Port $port is in use"
done
$solana_fullnode_config --keypair="$fullnode_id_path" -l -b "$port" > "$fullnode_json_path"
ledger_config_dir=$SOLANA_CONFIG_DIR/fullnode-ledger-x$$
fi fi
[[ -r $fullnode_id_path ]] || { [[ -r $fullnode_id_path ]] || {