Skip to content

Commit

Permalink
feat: native testnet helper script (#9260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored Oct 17, 2024
1 parent 8efdb47 commit 1613c0f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 6 deletions.
83 changes: 83 additions & 0 deletions scripts/run_native_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

: '
This script sets up and runs a native testnet for the Aztec network.
Steps:
1. Parse command-line arguments for custom test script and number of validators.
2. Set up the base command for running the native network test, including:
- Running the specified test script
- Deploying L1 and L2 contracts
- Starting the boot node
- Setting up the Ethereum environment
- Starting the prover node
- Starting the PXE
- Starting the transaction bot
3. Dynamically generate commands for the specified number of validators,
each with an incrementing port number starting from 8081.
4. Execute the complete command to start the testnet.
Usage:
./run_native_testnet.sh [options]
Options:
-h: Display help message
-t: Specify a custom test script (default: ./test-transfer.sh)
-v: Specify the number of validators (default: 3)
'

# Function to display help message
display_help() {
echo "Usage: $0 [options]"
echo
echo "Options:"
echo " -h Display this help message"
echo " -t Specify the test script file (default: ./test-transfer.sh)"
echo " -v Specify the number of validators (default: 3)"
echo
echo "Example:"
echo " $0 -t ./custom-test.sh -v 5"
}

# Default values
TEST_SCRIPT="./test-transfer.sh"
NUM_VALIDATORS=3

# Parse command line arguments
while getopts "ht:v:" opt; do
case $opt in
h)
display_help
exit 0
;;
t) TEST_SCRIPT="$OPTARG"
;;
v) NUM_VALIDATORS="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
display_help
exit 1
;;
esac
done

# Base command
BASE_CMD="./yarn-project/end-to-end/scripts/native_network_test.sh \
$TEST_SCRIPT \
./deploy-l1-contracts.sh \
./deploy-l2-contracts.sh \
./boot-node.sh \
./ethereum.sh \
\"./prover-node.sh false\" \
./pxe.sh \
./transaction-bot.sh"

# Generate validator commands
for ((i=0; i<NUM_VALIDATORS; i++))
do
PORT=$((8081 + i))
BASE_CMD+=" \"./validator.sh $PORT\""
done

# Execute the command
eval $BASE_CMD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo "Done waiting."

# Run the deploy-l1-contracts command and capture the output
export ETHEREUM_HOST="http://127.0.0.1:8545"
output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts)
output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --salt 1337)

echo "$output"

Expand All @@ -43,8 +43,3 @@ export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$FEE_JUICE_PORTAL_CONTRACT_ADDRESS
EOCONFIG

echo "Contract addresses saved to l1-contracts.env"
sleep 5
function close_tmux_pane() {
tmux kill-pane -t $(tmux display -p '#{pane_id}')
}
close_tmux_pane 2>/dev/null || true

0 comments on commit 1613c0f

Please sign in to comment.