solana/net/remote/remote-node.sh

167 lines
4.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-09-03 21:15:55 -07:00
2018-09-04 09:21:03 -07:00
cd "$(dirname "$0")"/../..
set -x
2018-09-03 21:15:55 -07:00
deployMethod="$1"
nodeType="$2"
publicNetwork="$3"
entrypointIp="$4"
numNodes="$5"
2018-09-04 09:21:03 -07:00
RUST_LOG="$6"
skipSetup="$7"
2018-12-05 17:33:32 -08:00
leaderRotation="$8"
set +x
export RUST_LOG
2018-09-04 09:21:03 -07:00
# Use a very large stake (relative to the default multinode-demo/ stake of 43)
# for the testnet fullnodes setup by net/. This make it less likely that
# low-staked ephemeral validator a random user may attach to testnet will cause
# trouble
#
# Ref: https://github.com/solana-labs/solana/issues/3798
stake=424243
2018-09-07 08:46:20 -07:00
missing() {
echo "Error: $1 not specified"
exit 1
}
[[ -n $deployMethod ]] || missing deployMethod
[[ -n $nodeType ]] || missing nodeType
[[ -n $publicNetwork ]] || missing publicNetwork
[[ -n $entrypointIp ]] || missing entrypointIp
[[ -n $numNodes ]] || missing numNodes
[[ -n $skipSetup ]] || missing skipSetup
2018-12-05 17:33:32 -08:00
[[ -n $leaderRotation ]] || missing leaderRotation
2018-09-04 09:21:03 -07:00
cat > deployConfig <<EOF
deployMethod="$deployMethod"
entrypointIp="$entrypointIp"
2018-09-04 09:21:03 -07:00
numNodes="$numNodes"
2018-12-05 17:33:32 -08:00
leaderRotation=$leaderRotation
2018-09-04 09:21:03 -07:00
EOF
2018-09-03 21:15:55 -07:00
source net/common.sh
loadConfigFile
case $deployMethod in
local|tar)
2018-09-03 21:15:55 -07:00
PATH="$HOME"/.cargo/bin:"$PATH"
export USE_INSTALL=1
export SOLANA_METRICS_DISPLAY_HOSTNAME=1
2018-09-03 21:15:55 -07:00
# Setup `/var/snap/solana/current` symlink so rsyncing the genesis
# ledger works (reference: `net/scripts/install-rsync.sh`)
sudo rm -rf /var/snap/solana/current
sudo mkdir -p /var/snap/solana
sudo ln -sT /home/solana/solana /var/snap/solana/current
2018-09-03 21:15:55 -07:00
./fetch-perf-libs.sh
2018-11-12 17:50:16 -08:00
# shellcheck source=/dev/null
source ./target/perf-libs/env.sh
2018-12-23 22:12:58 -08:00
(
sudo scripts/oom-monitor.sh
) > oom-monitor.log 2>&1 &
echo $! > oom-monitor.pid
scripts/net-stats.sh > net-stats.log 2>&1 &
echo $! > net-stats.pid
2018-09-03 21:15:55 -07:00
case $nodeType in
bootstrap-leader)
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-fullnode-cuda ]]; then
echo Selecting solana-fullnode-cuda
export SOLANA_CUDA=1
fi
2019-01-09 09:50:43 -08:00
set -x
if [[ $skipSetup != true ]]; then
./multinode-demo/setup.sh -b $stake
fi
2018-09-03 21:15:55 -07:00
./multinode-demo/drone.sh > drone.log 2>&1 &
2019-02-17 11:43:36 -08:00
args=()
2019-03-04 14:27:06 -08:00
if $publicNetwork; then
args+=(--public-address)
2019-03-04 14:27:06 -08:00
fi
args+=(--enable-rpc-exit)
2019-03-04 14:27:06 -08:00
./multinode-demo/bootstrap-leader.sh "${args[@]}" > bootstrap-leader.log 2>&1 &
ln -sTf bootstrap-leader.log fullnode.log
2018-09-03 21:15:55 -07:00
;;
fullnode|blockstreamer)
net/scripts/rsync-retry.sh -vPrc "$entrypointIp":~/.cargo/bin/ ~/.cargo/bin/
2018-09-03 21:15:55 -07:00
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-fullnode-cuda ]]; then
echo Selecting solana-fullnode-cuda
export SOLANA_CUDA=1
fi
2019-02-17 11:43:36 -08:00
args=()
2019-03-04 14:27:06 -08:00
if $publicNetwork; then
args+=("--public-address")
fi
if [[ $nodeType = blockstreamer ]]; then
args+=(
2019-02-21 15:16:09 -08:00
--blockstream /tmp/solana-blockstream.sock
--no-voting
--stake 0
)
else
if $leaderRotation; then
args+=("--stake" "$stake")
else
args+=("--stake" 0)
fi
fi
2019-03-13 10:49:40 -07:00
args+=(
--enable-rpc-exit
--gossip-port 8001
2019-03-13 10:49:40 -07:00
--rpc-port 8899
)
2019-01-09 09:50:43 -08:00
set -x
if [[ $skipSetup != true ]]; then
./multinode-demo/clear-fullnode-config.sh
fi
if [[ $nodeType = blockstreamer ]]; then
2019-03-21 21:09:03 -07:00
# Sneak the mint-id.json from the bootstrap leader and run another drone
# with it on the blockstreamer node. Typically the blockstreamer node has
# a static IP/DNS name for hosting the blockexplorer web app, and is
# a location that somebody would expect to be able to airdrop from
scp "$entrypointIp":~/solana/config-local/mint-id.json config-local/
./multinode-demo/drone.sh > drone.log 2>&1 &
npm install @solana/blockexplorer@1
npx solana-blockexplorer > blockexplorer.log 2>&1 &
2019-03-13 09:57:35 -07:00
# Confirm the blockexplorer is accessible
curl --head --retry 3 --retry-connrefused http://localhost:5000/
# Redirect port 80 to port 5000
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 5000 -j ACCEPT
sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 5000
# Confirm the blockexplorer is now globally accessible
curl --head "$(curl ifconfig.io)"
fi
args+=("$entrypointIp":~/solana "$entrypointIp:8001")
./multinode-demo/fullnode.sh "${args[@]}" > fullnode.log 2>&1 &
2018-09-03 21:15:55 -07:00
;;
*)
echo "Error: unknown node type: $nodeType"
exit 1
;;
esac
disown
2018-09-03 21:15:55 -07:00
;;
*)
echo "Unknown deployment method: $deployMethod"
exit 1
esac