Skip to content

Commit

Permalink
Add clients to devnet script
Browse files Browse the repository at this point in the history
  • Loading branch information
vicsn committed Jan 4, 2024
1 parent 67c1bc9 commit f8defc9
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
read -p "Enter the total number of validators (default: 4): " total_validators
total_validators=${total_validators:-4}

# Read the total number of clients from the user or use a default value of 2
read -p "Enter the total number of clients (default: 2): " total_clients
total_clients=${total_clients:-2}

# Ask the user if they want to run 'cargo install --path .' or use a pre-installed binary
read -p "Do you want to run 'cargo install --path .' to build the binary? (y/n, default: y): " build_binary
build_binary=${build_binary:-y}

# Ask the user whether to clear the existing ledger logs
read -p "Do you want to clear the existing ledger logs? (y/n, default: n): " clear_logs
clear_logs=${clear_logs:-n}
# Ask the user whether to clear the existing .ledger directories
read -p "Do you want to clear the existing .ledger directories? (y/n, default: n): " clear_ledger
clear_ledger=${clear_ledger:-n}

if [[ $build_binary == "y" ]]; then
# Build the binary using 'cargo install --path .'
cargo install --path . || exit 1
fi

# Clear the ledger logs for each validator if the user chooses to clear logs
if [[ $clear_logs == "y" ]]; then
# Clear the ledger logs for each validator if the user chooses to clear ledger
if [[ $clear_ledger == "y" ]]; then
# Create an array to store background processes
clean_processes=()

Expand Down Expand Up @@ -48,6 +52,7 @@ validator_indices=($(seq 0 $((total_validators - 1))))

# Loop through the list of validator indices and create a new window for each
for validator_index in "${validator_indices[@]}"; do

# Generate a unique and incrementing log file name based on the validator index
log_file="$log_dir/validator-$validator_index.log"

Expand All @@ -62,5 +67,22 @@ for validator_index in "${validator_indices[@]}"; do
fi
done

# Generate client indices from 0 to (total_clients - 1)
client_indices=($(seq 0 $((total_clients - 1))))

# Loop through the list of client indices and create a new window for each
for client_index in "${client_indices[@]}"; do
# Generate a unique and incrementing log file name based on the client index
log_file="$log_dir/client-$client_index.log"

window_index=$(($client_index + $total_validators))

# Create a new window with a unique name
tmux new-window -t "devnet:$window_index" -n "window-$window_index"

# Send the command to start the validator to the new window and capture output to the log file
tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --dev $window_index --client --logfile $log_file" C-m
done

# Attach to the tmux session to view and interact with the windows
tmux attach-session -t "devnet"

0 comments on commit f8defc9

Please sign in to comment.