Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Refactor multinode-demo/ scripts to avoid shipping fullnode-x.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Apr 17, 2019
1 parent 8d1fd29 commit fd97fed
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 203 deletions.
45 changes: 31 additions & 14 deletions book/src/testnet-participation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```

When not using `solana-install`:
```bash
$ USE_INSTALL=1 ./multinode-demo/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
```

Then from another console, confirm the IP address if your node is now visible in
the gossip network by running:
If you built from source:
```bash
$ solana-gossip --network beta.testnet.solana.com:8001
$ 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
```

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:
Expand Down
2 changes: 1 addition & 1 deletion ci/localnet-sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
8 changes: 4 additions & 4 deletions ci/publish-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions multinode-demo/clear-fullnode-config.sh
Original file line number Diff line number Diff line change
@@ -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

86 changes: 14 additions & 72 deletions multinode-demo/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion multinode-demo/fullnode-x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

here=$(dirname "$0")

exec "$here"/fullnode.sh -x "$@"
exec "$here"/fullnode.sh --label x$$ "$@"
Loading

0 comments on commit fd97fed

Please sign in to comment.