Skip to content

Commit

Permalink
Update commands
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwu committed Oct 21, 2023
1 parent 4d6ea3f commit 3f2c847
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
36 changes: 36 additions & 0 deletions .devnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,42 @@ This script starts snarkOS on the EC2 instances.

This script monitors the EC2 instances.

#### Switch Nodes (forward)

To toggle to the next node in a local devnet, run:
```
Ctrl+b n
```

#### Switch Nodes (backwards)

To toggle to the previous node in a local devnet, run:
```
Ctrl+b p
```

#### Select a Node (choose-tree)

To select a node in a local devnet, run:
```
Ctrl+b w
```

#### Select a Node (manually)

To select a node manually in a local devnet, run:
```
Ctrl+b :select-window -t {NODE_ID}
```

#### Exit (But Keeps the Devnet Running)

To exit the monitor, run:
```
Ctrl+b :kill-session
```
Then, press `Enter`.

## 6. `stop.sh`

This script stops snarkOS on the EC2 instances.
2 changes: 1 addition & 1 deletion .devnet/monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tmux attach-session -t "devnet-aws"
#read -p "Enter the node ID (default: 0): " NODE_ID
#NODE_ID="${NODE_ID:-0}"
#
## SSH into the node and attach to the SnarkOS tmux session
## SSH into the node and attach to the snarkOS tmux session
##ssh -o StrictHostKeyChecking=no aws-n$NODE_ID << EOF
## # Commands to run on the remote instance
## sudo -i # Switch to root user
Expand Down
16 changes: 8 additions & 8 deletions .devnet/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ NUM_INSTANCES="${NUM_INSTANCES:-16}"
# Get the IP address of NODE 0 from the SSH config for aws-n0
NODE_0_IP=$(awk '/Host aws-n0/{f=1} f&&/HostName/{print $2; exit}' ~/.ssh/config)

# Define a function to start SnarkOS in a tmux session on a node
# Define a function to start snarkOS in a tmux session on a node
start_snarkos_in_tmux() {
local NODE_ID=$1
local NODE_IP=$2

# SSH into the node and start SnarkOS in a new tmux session
# SSH into the node and start snarkOS in a new tmux session
ssh -o StrictHostKeyChecking=no aws-n$NODE_ID << EOF
# Commands to run on the remote instance
sudo -i # Switch to root user
WORKSPACE=~/snarkOS
cd \$WORKSPACE
# Start SnarkOS within a new tmux session named "snarkos-session"
# Start snarkOS within a new tmux session named "snarkos-session"
tmux new-session -d -s snarkos-session
# Send the SnarkOS start command to the tmux session with the NODE_ID
tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --validators $NODE_IP" C-m
# Send the snarkOS start command to the tmux session with the NODE_ID
tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --validators $NODE_IP:5000" C-m
exit # Exit root user
EOF

# Check the exit status of the SSH command
if [ $? -eq 0 ]; then
echo "SnarkOS started successfully in a tmux session on aws-n$NODE_ID."
echo "snarkOS started successfully in a tmux session on aws-n$NODE_ID."
else
echo "Failed to start SnarkOS in a tmux session on aws-n$NODE_ID."
echo "Failed to start snarkOS in a tmux session on aws-n$NODE_ID."
fi
}

# Loop through aws-n nodes and start SnarkOS in tmux sessions in parallel
# Loop through aws-n nodes and start snarkOS in tmux sessions in parallel
for NODE_ID in $(seq 0 $NUM_INSTANCES); do
start_snarkos_in_tmux $NODE_ID "$NODE_0_IP" &
done
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ cargo run --release -- clean --dev <NODE_ID>
```

## 7. Contributors
Thank you for helping make SnarkOS better!
Thank you for helping make snarkOS better!
[🧐 What do the emojis mean?](https://allcontributors.org/docs/en/emoji-key)

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
Expand Down
1 change: 1 addition & 0 deletions build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ echo " for 4133 and 3033 on your router."
echo "=================================================="

# Open ports on system
ufw allow 5000/tcp
ufw allow 4133/tcp
ufw allow 3033/tcp

0 comments on commit 3f2c847

Please sign in to comment.