-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# |source| me | ||
|
||
upload_ci_artifact() { | ||
echo "--- artifact: $1" | ||
if [[ -r "$1" ]]; then | ||
ls -l "$1" | ||
if ${BUILDKITE:-false}; then | ||
( | ||
set -x | ||
buildkite-agent artifact upload "$1" | ||
) | ||
fi | ||
else | ||
echo ^^^ +++ | ||
echo "$1 not found" | ||
fi | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/bin/bash | ||
# | ||
# Runs a node | ||
# | ||
|
||
here="$(dirname "$0")" | ||
|
||
usage() { | ||
if [[ -n "$1" ]]; then | ||
echo "$*" | ||
fi | ||
|
||
cat <<EOF | ||
Usage: $0 [mode] [public_address] [leader_address]" | ||
mode Select operation mode: | ||
leader - Run a leader | ||
leader-cuda - Run a leader with CUDA | ||
validator - Run a validator | ||
validator-cuda - Run a validator with CUDA | ||
drone - Run a drone | ||
public_address Public IP address of this node | ||
(hint: run |${here}/myip.sh| to help determine this value). | ||
leader_address Address of the leader node to connect with. | ||
Only required when mode=validator,validator-cuda,drone | ||
EOF | ||
exit 1 | ||
} | ||
|
||
|
||
MODE= | ||
if [[ -n "$1" ]]; then | ||
MODE="$1" | ||
elif [[ -d $SNAP ]]; then # Running as a Linux Snap? | ||
MODE="$(snapctl get mode)" | ||
fi | ||
[[ -n "$MODE" ]] || usage "Error: mode not specified" | ||
|
||
PUBLIC_ADDRESS= | ||
if [[ -n "$2" ]]; then | ||
PUBLIC_ADDRESS="$2" | ||
elif [[ -d $SNAP ]]; then # Running as a Linux Snap? | ||
PUBLIC_ADDRESS="$(snapctl get public-address)" | ||
fi | ||
[[ -n "$PUBLIC_ADDRESS" ]] || usage "Error: public_address not specified" | ||
|
||
LEADER_ADDRESS=testnet.solana.com | ||
if [[ -n "$3" ]]; then | ||
LEADER_ADDRESS="$3" | ||
elif [[ -d $SNAP ]]; then # Running as a Linux Snap? | ||
LEADER_ADDRESS="$(snapctl get leader-address)" | ||
fi | ||
|
||
PROGRAM=solana-fullnode | ||
if [[ "$MODE" =~ .*cuda ]]; then | ||
if [[ -z $SNAP ]]; then | ||
echo "Note: -cuda suffix ignored, use --features=cuda when running locally" | ||
else | ||
PROGRAM=solana-fullnode-cuda | ||
fi | ||
elif [[ "$MODE" = "drone" ]]; then | ||
PROGRAM=solana-drone | ||
fi | ||
|
||
if [[ -z $SNAP ]]; then | ||
PROGRAM="cargo run --release --bin $PROGRAM --" | ||
fi | ||
|
||
DATA_DIR=${SNAP_DATA:-$PWD}/config | ||
|
||
export RUST_LOG=${RUST_LOG:-solana=info} # if RUST_LOG is unset, default to info | ||
export RUST_BACKTRACE=1 | ||
[[ $(uname) = Linux ]] && sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null | ||
|
||
case $MODE in | ||
leader-cuda|leader) | ||
echo "Starting $MODE" | ||
set -x | ||
# shellcheck disable=SC2086 # $PROGRAM should not be quoted | ||
exec $PROGRAM \ | ||
-l "$DATA_DIR/leader.json" \ | ||
< "$DATA_DIR/genesis.log" "$DATA_DIR"/tx-*.log \ | ||
> "$DATA_DIR"/tx-"$(date -u +%Y%m%d%H%M%S%N)".log | ||
;; | ||
|
||
validator-cuda|validator) | ||
[[ -n "$LEADER_ADDRESS" ]] || usage "Error: leader_address not specified" | ||
|
||
echo "Fetching configuration from $LEADER_ADDRESS:" | ||
( | ||
set -x | ||
rm -rf "${DATA_DIR:?}/$LEADER_ADDRESS" | ||
mkdir -p "$DATA_DIR/$LEADER_ADDRESS" | ||
rsync -vrPz \ | ||
"rsync://$LEADER_ADDRESS"/solana/config/ \ | ||
"$DATA_DIR/$LEADER_ADDRESS/" | ||
) || exit $? | ||
|
||
echo "Starting $MODE, connecting to the leader at address: $LEADER_ADDRESS" | ||
set -x | ||
# shellcheck disable=SC2086 # $PROGRAM should not be quoted | ||
exec $PROGRAM \ | ||
-l "$DATA_DIR/validator.json" -t "$DATA_DIR/$LEADER_ADDRESS/leader.json" \ | ||
< "$DATA_DIR/$LEADER_ADDRESS/genesis.log" "$DATA_DIR/$LEADER_ADDRESS"/tx-*.log | ||
;; | ||
|
||
drone) | ||
[[ -n "$LEADER_ADDRESS" ]] || usage "Error: leader_address not specified" | ||
|
||
echo "Fetching configuration from $LEADER_ADDRESS:" | ||
( | ||
set -x | ||
rm -rf "${DATA_DIR:?}/$LEADER_ADDRESS" | ||
mkdir -p "$DATA_DIR/$LEADER_ADDRESS" | ||
rsync -vrPz \ | ||
rsync://"$LEADER_ADDRESS"/solana/config/leader.json \ | ||
"$DATA_DIR/$LEADER_ADDRESS/" | ||
rsync -vrPz \ | ||
rsync://"$LEADER_ADDRESS"/solana/config/mint-demo.json \ | ||
"$DATA_DIR/$LEADER_ADDRESS/" | ||
) || exit $? | ||
|
||
echo "Starting $MODE, connecting to the leader at address: $LEADER_ADDRESS" | ||
set -x | ||
# shellcheck disable=SC2086 # $PROGRAM should not be quoted | ||
exec $PROGRAM \ | ||
-l "$DATA_DIR/$LEADER_ADDRESS"/leader.json \ | ||
< "$DATA_DIR/$LEADER_ADDRESS"/mint-demo.json | ||
;; | ||
|
||
|
||
*) | ||
echo "Error: Unknown mode: $MODE" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash -e | ||
# | ||
# TODO: Merge this file with ../../../multinode-demo/setup.sh | ||
# | ||
|
||
if [[ -d "$SNAP" ]]; then # Running as a Linux Snap? | ||
# Setup aliases to the normal solana command to make the reset of configure more | ||
# readable. | ||
shopt -s expand_aliases | ||
export SNAP SNAP_LIBRARY_PATH | ||
alias solana-mint-demo="$SNAP"/command-mint-demo.wrapper | ||
alias solana-genesis-demo="$SNAP"/command-genesis-demo.wrapper | ||
alias solana-fullnode-config="$SNAP"/command-fullnode-config.wrapper | ||
|
||
echo Stopping daemon | ||
snapctl stop --disable solana.daemon-node | ||
if [[ -z "$(snapctl get mode)" ]]; then | ||
exit 0 | ||
fi | ||
|
||
NUM_TOKENS="$(snapctl get num-tokens)" | ||
else | ||
NUM_TOKENS="$1" | ||
fi | ||
|
||
: ${NUM_TOKENS:=1000000000} | ||
|
||
DATA_DIR="${SNAP_DATA:-$PWD}"/config | ||
echo "Cleaning $DATA_DIR" | ||
|
||
rm -rvf "$DATA_DIR" | ||
mkdir -p "$DATA_DIR" | ||
|
||
echo "Creating $DATA_DIR/mint-demo.json with $NUM_TOKENS tokens" | ||
solana-mint-demo <<<"$NUM_TOKENS" > "$DATA_DIR"/mint-demo.json | ||
|
||
echo "Creating $DATA_DIR/genesis.log" | ||
solana-genesis-demo < "$DATA_DIR"/mint-demo.json > "$DATA_DIR"/genesis.log | ||
|
||
echo "Creating $DATA_DIR/leader.json" | ||
solana-fullnode-config -d > "$DATA_DIR"/leader.json | ||
|
||
echo "Creating $DATA_DIR/validator.json" | ||
solana-fullnode-config -d -b 9000 > "$DATA_DIR"/validator.json | ||
|
||
if [[ -d "$SNAP" ]]; then | ||
echo Starting daemon | ||
snapctl start --enable solana.daemon-node | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters