From 870260e930202ddf00429c476eafe6e9aad627e9 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 14:24:06 +0000 Subject: [PATCH 01/20] script fixes --- scripts/run_interleaved.sh | 16 ++++++------- scripts/run_native_testnet.sh | 45 +++++++++++++++++------------------ 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/scripts/run_interleaved.sh b/scripts/run_interleaved.sh index 854c80e4bd90..8a52bc840910 100755 --- a/scripts/run_interleaved.sh +++ b/scripts/run_interleaved.sh @@ -27,19 +27,18 @@ colors=( "\e[91m" # Bright Red ) +FINISHED=false main_cmd="$1" shift -# pattern from https://stackoverflow.com/questions/28238952/how-to-kill-a-running-bash-function-from-terminal -function cleanup_function() { - kill $(jobs -p) 2>/dev/null || true - return +function cleanup() { + # kill everything in our process group except our process + trap - SIGTERM && kill $(pgrep -g $$ | grep -v $$) 2>/dev/null || true } +trap cleanup SIGINT SIGTERM EXIT # Function to run a command and prefix the output with color function run_command() { - # pattern from https://stackoverflow.com/questions/28238952/how-to-kill-a-running-bash-function-from-terminal - trap cleanup_function INT EXIT local cmd="$1" local color="$2" $cmd 2>&1 | while IFS= read -r line; do @@ -50,9 +49,10 @@ function run_command() { # Run background commands without logging output i=0 for cmd in "$@"; do - run_command "$cmd" "${colors[$((i % ${#colors[@]}))]}" & + (run_command "$cmd" "${colors[$((i % ${#colors[@]}))]}" || [ $FINISHED = true ] || (echo "$cmd causing terminate" && kill 0) ) & ((i++)) || true # annoyingly considered a failure based on result done # Run the main command synchronously, piping output through the run_command function with green color -run_command "$main_cmd" "\e[32m" \ No newline at end of file +run_command "$main_cmd" "\e[32m" || (echo "$main_cmd causing terminate" && kill 0) +FINISHED=true \ No newline at end of file diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index 6ae04506b088..1a77a010d2fc 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -17,32 +17,28 @@ Steps: 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) +Usage: Run with -h to see display_help output below. ' +# Default values +TEST_FILE=src/spartan/transfer.test.ts +PROVER_SCRIPT="\"./prover-node.sh 7900 false\"" +NUM_VALIDATORS=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 " -t Specify the test file (default: src/spartan/transfer.test.ts)" + echo " -p Specify the prover command (default: $PROVER_SCRIPT)" + echo " -v Specify the number of validators (default: $NUM_VALIDATORS)" 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 @@ -50,7 +46,9 @@ while getopts "ht:v:" opt; do display_help exit 0 ;; - t) TEST_SCRIPT="$OPTARG" + t) TEST_FILE="$OPTARG" + ;; + p) PROVER_SCRIPT="\"$OPTARG\"" ;; v) NUM_VALIDATORS="$OPTARG" ;; @@ -61,23 +59,24 @@ while getopts "ht:v:" opt; do esac done +# Go to repo root +cd $(git rev-parse --show-toplevel) +if [ $NUM_VALIDATORS = 1 ] ; then + VALIDATOR_CMD="\"./validator.sh 8081\"" +else + VALIDATOR_CMD="\"./validators.sh $NUM_VALIDATORS\"" +fi # Base command BASE_CMD="./yarn-project/end-to-end/scripts/native_network_test.sh \ - $TEST_SCRIPT \ + \"./test.sh $TEST_FILE\" \ ./deploy-l1-contracts.sh \ ./deploy-l2-contracts.sh \ ./boot-node.sh \ ./ethereum.sh \ - \"./prover-node.sh false\" \ + $VALIDATOR_CMD \ + $PROVER_SCRIPT \ ./pxe.sh \ ./transaction-bot.sh" -# Generate validator commands -for ((i=0; i Date: Mon, 21 Oct 2024 14:25:18 +0000 Subject: [PATCH 02/20] other scripts --- .../scripts/native-network/.gitignore | 6 +-- .../scripts/native-network/boot-node.sh | 12 +++--- .../native-network/deploy-l1-contracts.sh | 20 +++++++-- .../native-network/deploy-l2-contracts.sh | 15 +++---- .../scripts/native-network/ethereum.sh | 41 ++++++++++++++----- .../scripts/native-network/prover-node.sh | 21 ++++++---- .../end-to-end/scripts/native-network/pxe.sh | 10 ++++- .../scripts/native-network/state/.gitignore | 1 + .../scripts/native-network/state/README.md | 1 + .../scripts/native-network/test-transfer.sh | 6 +-- .../end-to-end/scripts/native-network/test.sh | 36 ++++++++++++++++ .../scripts/native-network/transaction-bot.sh | 5 ++- .../scripts/native-network/validator.sh | 20 +++++---- .../scripts/native-network/validators.sh | 34 +++++++++++++++ .../end-to-end/scripts/native_network_test.sh | 2 +- 15 files changed, 179 insertions(+), 51 deletions(-) create mode 100644 yarn-project/end-to-end/scripts/native-network/state/.gitignore create mode 100644 yarn-project/end-to-end/scripts/native-network/state/README.md create mode 100755 yarn-project/end-to-end/scripts/native-network/test.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/validators.sh diff --git a/yarn-project/end-to-end/scripts/native-network/.gitignore b/yarn-project/end-to-end/scripts/native-network/.gitignore index 8b5dc6656c31..43314c6eb25a 100644 --- a/yarn-project/end-to-end/scripts/native-network/.gitignore +++ b/yarn-project/end-to-end/scripts/native-network/.gitignore @@ -1,3 +1,3 @@ -l1-contracts.env -l2-contracts.env -*.log \ No newline at end of file +state/*.env +state/*.json +*.log diff --git a/yarn-project/end-to-end/scripts/native-network/boot-node.sh b/yarn-project/end-to-end/scripts/native-network/boot-node.sh index ecc5cf83a203..379a6842ec67 100755 --- a/yarn-project/end-to-end/scripts/native-network/boot-node.sh +++ b/yarn-project/end-to-end/scripts/native-network/boot-node.sh @@ -10,9 +10,9 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname # Starts the Boot Node # Set environment variables -export PORT="8080" -export LOG_LEVEL="debug" -export DEBUG="aztec:*,-aztec:avm_simulator:*" +export PORT=${PORT:-"8080"} +export DEBUG=${DEBUG:-"aztec:*,-aztec:avm_simulator:*"} +export LOG_LEVEL=${LOG_LEVEL:-"debug"} export ETHEREUM_HOST="http://127.0.0.1:8545" export P2P_ENABLED="true" export VALIDATOR_DISABLED="true" @@ -22,16 +22,18 @@ export P2P_TCP_ANNOUNCE_ADDR="127.0.0.1:40400" export P2P_UDP_ANNOUNCE_ADDR="127.0.0.1:40400" export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400" export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400" +export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="" +export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="" export VALIDATOR_PRIVATE_KEY="0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a" REPO=$(git rev-parse --show-toplevel) echo "Waiting for l1 contracts to be deployed..." -until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env ] ; do +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env ] ; do sleep 1 done echo "Done waiting." -source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env +source "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env function filter_noise() { grep -Ev "node_getProvenBlockNumber|getBlocks|Last block mined|Running random nodes query|Not creating block because not enough txs in the pool|Peers to connect" diff --git a/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh b/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh index 319dc7babbed..413b30d1b252 100755 --- a/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh +++ b/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh @@ -10,6 +10,14 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname set -eu +# Check for validator addresses +if [ $# -gt 0 ]; then + INIT_VALIDATORS="true" + VALIDATOR_ADDRESSES="$1" +else + INIT_VALIDATORS="false" +fi + echo "Waiting for Anvil to be up at port 8545..." until curl -s -X POST -H 'Content-Type: application/json' \ --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ @@ -20,7 +28,11 @@ 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 --salt 1337) +if [ "$INIT_VALIDATORS" = "true" ]; then + output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --validators "$VALIDATOR_ADDRESSES" --salt 1337) +else + output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --salt 1337) +fi echo "$output" @@ -32,8 +44,8 @@ OUTBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K FEE_JUICE_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}') FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}') -# Save contract addresses to l1-contracts.env -cat << EOCONFIG > $(git rev-parse --show-toplevel)/yarn-project/end-to-end/scripts/native-network/l1-contracts.env +# Save contract addresses to state/l1-contracts.env +cat << EOCONFIG > $(git rev-parse --show-toplevel)/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env export ROLLUP_CONTRACT_ADDRESS=$ROLLUP_CONTRACT_ADDRESS export REGISTRY_CONTRACT_ADDRESS=$REGISTRY_CONTRACT_ADDRESS export INBOX_CONTRACT_ADDRESS=$INBOX_CONTRACT_ADDRESS @@ -42,4 +54,4 @@ export FEE_JUICE_CONTRACT_ADDRESS=$FEE_JUICE_CONTRACT_ADDRESS export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$FEE_JUICE_PORTAL_CONTRACT_ADDRESS EOCONFIG -echo "Contract addresses saved to l1-contracts.env" +echo "Contract addresses saved to state/l1-contracts.env" diff --git a/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh b/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh index e015b8a862b4..4c32ca456990 100755 --- a/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh +++ b/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh @@ -28,10 +28,11 @@ export PXE_URL="http://127.0.0.1:8079" node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts $ARGS echo "Deployed L2 contracts" # Use file just as done signal -echo "" > l2-contracts.env -echo "Wrote to l2-contracts.env to signal completion" -sleep 5 -function close_tmux_pane() { - tmux kill-pane -t $(tmux display -p '#{pane_id}') -} -close_tmux_pane 2>/dev/null || true \ No newline at end of file +echo "" > state/l2-contracts.env +echo "Wrote to state/l2-contracts.env to signal completion" + +# sleep 5 +# function close_tmux_pane() { +# tmux kill-pane -t $(tmux display -p '#{pane_id}') +# } +# close_tmux_pane 2>/dev/null || true \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/native-network/ethereum.sh b/yarn-project/end-to-end/scripts/native-network/ethereum.sh index 0bedc54556ea..417bf4ae349b 100755 --- a/yarn-project/end-to-end/scripts/native-network/ethereum.sh +++ b/yarn-project/end-to-end/scripts/native-network/ethereum.sh @@ -1,8 +1,10 @@ #!/bin/bash set -eu +set -o pipefail # Get the name of the script without the path and extension SCRIPT_NAME=$(basename "$0" .sh) +PORT=8545 # Redirect stdout and stderr to .log while also printing to the console exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) @@ -11,12 +13,11 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname # Ensure anvil is installed command -v anvil >/dev/null 2>&1 || { echo >&2 "Anvil is not installed. Aborting."; exit 1; } - function report_when_anvil_up() { - echo "Starting anvil." + echo "Starting anvil with port $PORT" until curl -s -X POST -H 'Content-Type: application/json' \ --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ - http://127.0.0.1:8545 2>/dev/null | grep -q 'result' ; do + http://127.0.0.1:$PORT 2>/dev/null | grep -q 'result' ; do sleep 1 done echo "Anvil has started." @@ -26,10 +27,30 @@ function filter_noise() { } report_when_anvil_up & -# Start Anvil with specified parameters -anvil \ - --host 0.0.0.0 \ - --block-time 12 \ - --chain-id 31337 \ - --gas-limit 1000000000 \ - -p 8545 2>&1 | filter_noise +STATE_DIR="$(git rev-parse --show-toplevel)/yarn-project/end-to-end/scripts/native-network/state" +STATE_FILE="$STATE_DIR/state.json" + +mkdir -p "$STATE_DIR" + +if [ -f "$STATE_FILE" ]; then + echo "State file found. Loading existing state." + anvil \ + --host 0.0.0.0 \ + --load-state "$STATE_DIR" \ + --dump-state "$STATE_DIR" \ + --block-time 12 \ + --chain-id 31337 \ + --gas-limit 1000000000 \ + --accounts 3 \ + -p $PORT 2>&1 | filter_noise +else + echo "No state file found. Starting with a fresh state and enabling state dumping." + anvil \ + --host 0.0.0.0 \ + --dump-state "$STATE_DIR" \ + --block-time 12 \ + --chain-id 31337 \ + --gas-limit 1000000000 \ + --accounts 3 \ + -p $PORT 2>&1 | filter_noise +fi \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/native-network/prover-node.sh b/yarn-project/end-to-end/scripts/native-network/prover-node.sh index a7e6218e9c7a..734916441e3a 100755 --- a/yarn-project/end-to-end/scripts/native-network/prover-node.sh +++ b/yarn-project/end-to-end/scripts/native-network/prover-node.sh @@ -1,10 +1,12 @@ #!/bin/bash set -eu -export PROVER_REAL_PROOFS="$1" # Get the name of the script without the path and extension SCRIPT_NAME=$(basename "$0" .sh) +PORT="$1" +export PROVER_REAL_PROOFS="$2" + # Redirect stdout and stderr to .log while also printing to the console exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) @@ -12,12 +14,16 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname REPO=$(git rev-parse --show-toplevel) echo "Waiting for l1 contracts to be deployed..." -until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env ] ; do +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env ] ; do + sleep 1 +done +echo "Waiting for Aztec Node..." +until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 done echo "Done waiting." -source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env +source "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env # Get node info from the boot node output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-node-info -u http://127.0.0.1:8080) @@ -26,13 +32,14 @@ output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-nod export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') # Set environment variables -export LOG_LEVEL="debug" -export DEBUG="aztec:*" +export LOG_LEVEL=${LOG_LEVEL:-"debug"} +export DEBUG=${DEBUG:-"aztec:*"} export ETHEREUM_HOST="http://127.0.0.1:8545" export PROVER_AGENT_ENABLED="true" -export PROVER_PUBLISHER_PRIVATE_KEY="0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97" +export PROVER_PUBLISHER_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" export PROVER_COORDINATION_NODE_URL="http://127.0.0.1:8080" export AZTEC_NODE_URL="http://127.0.0.1:8080" +export PROVER_JOB_SOURCE_URL="http://127.0.0.1:$PORT" # Start the Prover Node with the prover and archiver -node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --port=8078 --prover-node --prover --archiver +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --port="$PORT" --prover-node --prover --archiver diff --git a/yarn-project/end-to-end/scripts/native-network/pxe.sh b/yarn-project/end-to-end/scripts/native-network/pxe.sh index 10649d1efa94..e1ec0eab112e 100755 --- a/yarn-project/end-to-end/scripts/native-network/pxe.sh +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -11,7 +11,7 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname # Set environment variables export ETHEREUM_HOST="http://127.0.0.1:8545" export AZTEC_NODE_URL="http://127.0.0.1:8080" -export LOG_LEVEL="debug" +export LOG_LEVEL=${LOG_LEVEL:-"debug"} export DEBUG="aztec:*" echo "Waiting for Aztec Node..." @@ -20,6 +20,14 @@ until curl -s http://127.0.0.1:8080/status >/dev/null ; do done echo "Done waiting." +# We need to also wait for the validator, as the initial node cannot +# Produce blocks on it's own +echo "Waiting for Validator 0..." +until curl -s http://127.0.0.1:8081/status >/dev/null ; do + sleep 1 +done +echo "Done waiting." + function filter_noise() { grep -v node_getProvenBlockNumber } diff --git a/yarn-project/end-to-end/scripts/native-network/state/.gitignore b/yarn-project/end-to-end/scripts/native-network/state/.gitignore new file mode 100644 index 000000000000..b7887cb1903d --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/state/.gitignore @@ -0,0 +1 @@ +state.json \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/native-network/state/README.md b/yarn-project/end-to-end/scripts/native-network/state/README.md new file mode 100644 index 000000000000..3ede1fe32523 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/state/README.md @@ -0,0 +1 @@ +This README ensures this folder exists in git. Ethereum state is written out here. \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/native-network/test-transfer.sh b/yarn-project/end-to-end/scripts/native-network/test-transfer.sh index d6044e4487a0..93e218a045e3 100755 --- a/yarn-project/end-to-end/scripts/native-network/test-transfer.sh +++ b/yarn-project/end-to-end/scripts/native-network/test-transfer.sh @@ -22,13 +22,13 @@ until curl -s -X POST -H 'content-type: application/json' \ sleep 1 done echo "Waiting for l2 contracts to be deployed..." -until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l2-contracts.env ] ; do +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l2-contracts.env ] ; do sleep 1 done echo "Done waiting." export DEBUG="aztec:*" -export LOG_LEVEL=debug +export LOG_LEVEL=${LOG_LEVEL:-"debug"} export PXE_URL=http://localhost:8079 cd $(git rev-parse --show-toplevel)/yarn-project/end-to-end -yarn test src/spartan/transfer.test.ts \ No newline at end of file +yarn test src/spartan/transfer.test.ts diff --git a/yarn-project/end-to-end/scripts/native-network/test.sh b/yarn-project/end-to-end/scripts/native-network/test.sh new file mode 100755 index 000000000000..ac034cfe99ed --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/test.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -eu + +TEST=$1 +# Get the name of the script without the path and extension +SCRIPT_NAME=$(basename "$0" .sh) + +# Redirect stdout and stderr to .log while also printing to the console +exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) + +REPO=$(git rev-parse --show-toplevel) +# Run our test assuming the port in pxe.sh +# Wait for the Aztec Node to be ready +echo "Waiting for Aztec Node..." +until curl -s http://127.0.0.1:8080/status >/dev/null ; do + sleep 1 +done +echo "Waiting for PXE service..." +until curl -s -X POST -H 'content-type: application/json' \ + -d '{"jsonrpc":"2.0","method":"pxe_getNodeInfo","params":[],"id":67}' \ + http://127.0.0.1:8079 | grep -q '"enr:-'; do + sleep 1 +done +echo "Waiting for l2 contracts to be deployed..." +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l2-contracts.env ] ; do + sleep 1 +done +echo "Done waiting." + +export DEBUG="aztec:*" +export LOG_LEVEL=${LOG_LEVEL:-"debug"} +export PXE_URL=http://localhost:8079 +export ETHEREUM_HOST=http://localhost:8545 +cd $(git rev-parse --show-toplevel)/yarn-project/end-to-end +yarn test "$TEST" diff --git a/yarn-project/end-to-end/scripts/native-network/transaction-bot.sh b/yarn-project/end-to-end/scripts/native-network/transaction-bot.sh index 37abb2725f9d..a1fc7cc641ac 100755 --- a/yarn-project/end-to-end/scripts/native-network/transaction-bot.sh +++ b/yarn-project/end-to-end/scripts/native-network/transaction-bot.sh @@ -21,7 +21,7 @@ until curl -s -X POST -H 'content-type: application/json' \ sleep 1 done echo "Waiting for l2 contracts to be deployed..." -until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l2-contracts.env ] ; do +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l2-contracts.env ] ; do sleep 1 done echo "Done waiting." @@ -30,13 +30,14 @@ echo "Done waiting." export ETHEREUM_HOST="http://127.0.0.1:8545" export AZTEC_NODE_URL="http://127.0.0.1:8080" export LOG_JSON="1" -export LOG_LEVEL="debug" +export LOG_LEVEL=${LOG_LEVEL:-"debug"} export DEBUG="aztec:*" export BOT_PRIVATE_KEY="0xcafe" export BOT_TX_INTERVAL_SECONDS="5" export BOT_PRIVATE_TRANSFERS_PER_TX="1" export BOT_PUBLIC_TRANSFERS_PER_TX="0" export BOT_NO_WAIT_FOR_TRANSFERS="true" +export BOT_FOLLOW_CHAIN="NONE" export BOT_NO_START="false" export PXE_PROVER_ENABLED="false" export PROVER_REAL_PROOFS="false" diff --git a/yarn-project/end-to-end/scripts/native-network/validator.sh b/yarn-project/end-to-end/scripts/native-network/validator.sh index 5c9c9fec4c44..26d5e9832634 100755 --- a/yarn-project/end-to-end/scripts/native-network/validator.sh +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -7,17 +7,19 @@ SCRIPT_NAME=$(basename "$0" .sh) # Redirect stdout and stderr to .log while also printing to the console exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) +# PORTS PORT="$1" +P2P_PORT="$2" # Starts the Validator Node REPO=$(git rev-parse --show-toplevel) echo "Waiting for l1 contracts to be deployed..." -until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env ] ; do +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env ] ; do sleep 1 done -source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env +source "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do @@ -33,24 +35,25 @@ output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-nod # Extract boot node ENR export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') +echo "BOOTSTRAP_NODES: $BOOTSTRAP_NODES" # Generate a private key for the validator json_account=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js generate-l1-account) export ADDRESS=$(echo $json_account | jq -r '.address') +export LOG_LEVEL=${LOG_LEVEL:-"debug"} export VALIDATOR_PRIVATE_KEY=$(echo $json_account | jq -r '.privateKey') export L1_PRIVATE_KEY=$VALIDATOR_PRIVATE_KEY export SEQ_PUBLISHER_PRIVATE_KEY=$VALIDATOR_PRIVATE_KEY -export LOG_LEVEL="debug" -export DEBUG="aztec:*,-aztec:avm_simulator:*" +export DEBUG=${DEBUG:-"aztec:*,-aztec:avm_simulator:*"} export ETHEREUM_HOST="http://127.0.0.1:8545" export P2P_ENABLED="true" export VALIDATOR_DISABLED="false" export SEQ_MAX_SECONDS_BETWEEN_BLOCKS="0" export SEQ_MIN_TX_PER_BLOCK="1" -export P2P_TCP_ANNOUNCE_ADDR="127.0.0.1:40400" -export P2P_UDP_ANNOUNCE_ADDR="127.0.0.1:40400" -export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400" -export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400" +export P2P_TCP_ANNOUNCE_ADDR="127.0.0.1:$P2P_PORT" +export P2P_UDP_ANNOUNCE_ADDR="127.0.0.1:$P2P_PORT" +export P2P_TCP_LISTEN_ADDR="0.0.0.0:$P2P_PORT" +export P2P_UDP_LISTEN_ADDR="0.0.0.0:$P2P_PORT" # Add L1 validator node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js add-l1-validator --validator $ADDRESS --rollup $ROLLUP_CONTRACT_ADDRESS @@ -58,3 +61,4 @@ node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js add-l1-validator node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js fast-forward-epochs --rollup $ROLLUP_CONTRACT_ADDRESS --count 1 # Start the Validator Node with the sequencer and archiver node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --port="$PORT" --node --archiver --sequencer + diff --git a/yarn-project/end-to-end/scripts/native-network/validators.sh b/yarn-project/end-to-end/scripts/native-network/validators.sh new file mode 100755 index 000000000000..6a9ac7f4f40b --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/validators.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Takes a number of validators to start, starting from port 8080. Calls out to validator.sh +set -eu + +# Get the name of the script without the path and extension +SCRIPT_NAME=$(basename "$0" .sh) + +# Redirect stdout and stderr to .log while also printing to the console +exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) + +NUM_VALIDATORS="$1" + +# enter script dir +cd "$(dirname "${BASH_SOURCE[0]}")" + +CMD=() + +# Generate validator commands +for ((i=0; i Date: Mon, 21 Oct 2024 10:33:51 -0400 Subject: [PATCH 03/20] Update run_native_testnet.sh --- scripts/run_native_testnet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index 74fdd5773fe1..feb000752463 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -26,7 +26,7 @@ Options: # Default values TEST_FILE=src/spartan/transfer.test.ts -PROVER_SCRIPT="\"./prover-node.sh 7900 false\"" +PROVER_SCRIPT="\"./prover-node.sh 8078 false\"" NUM_VALIDATORS=3 INTERLEAVED=false From f4d6e74e537b56e15cb8ccc97a51e192c169caee Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 14:44:56 +0000 Subject: [PATCH 04/20] pass --- scripts/run_native_testnet.sh | 8 ++--- .../scripts/native-network/test-transfer.sh | 34 ------------------- 2 files changed, 2 insertions(+), 40 deletions(-) delete mode 100755 yarn-project/end-to-end/scripts/native-network/test-transfer.sh diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index feb000752463..c58ca23b1a7f 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -44,7 +44,7 @@ display_help() { echo " -i Run interleaved (default: $INTERLEAVED)" echo echo "Example:" - echo " $0 -t ./custom-test.sh -val 5 -v" + echo " $0 -t src/spartan/smoke.test.ts -val 5 -v" } # Parse command line arguments @@ -95,11 +95,7 @@ export LOG_LEVEL # Go to repo root cd $(git rev-parse --show-toplevel) -if [ $NUM_VALIDATORS = 1 ] ; then - VALIDATOR_CMD="\"./validator.sh 8081\"" -else - VALIDATOR_CMD="\"./validators.sh $NUM_VALIDATORS\"" -fi + # Base command BASE_CMD="INTERLEAVED=$INTERLEAVED ./yarn-project/end-to-end/scripts/native_network_test.sh \ \"./test.sh $TEST_FILE\" \ diff --git a/yarn-project/end-to-end/scripts/native-network/test-transfer.sh b/yarn-project/end-to-end/scripts/native-network/test-transfer.sh deleted file mode 100755 index 93e218a045e3..000000000000 --- a/yarn-project/end-to-end/scripts/native-network/test-transfer.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -eu - -# Get the name of the script without the path and extension -SCRIPT_NAME=$(basename "$0" .sh) - -# Redirect stdout and stderr to .log while also printing to the console -exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) - -REPO=$(git rev-parse --show-toplevel) -# Run our test assuming the port in pxe.sh -# Wait for the Aztec Node to be ready -echo "Waiting for Aztec Node..." -until curl -s http://127.0.0.1:8080/status >/dev/null ; do - sleep 1 -done -echo "Waiting for PXE service..." -until curl -s -X POST -H 'content-type: application/json' \ - -d '{"jsonrpc":"2.0","method":"pxe_getNodeInfo","params":[],"id":67}' \ - http://127.0.0.1:8079 | grep -q '"enr:-'; do - sleep 1 -done -echo "Waiting for l2 contracts to be deployed..." -until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l2-contracts.env ] ; do - sleep 1 -done -echo "Done waiting." - -export DEBUG="aztec:*" -export LOG_LEVEL=${LOG_LEVEL:-"debug"} -export PXE_URL=http://localhost:8079 -cd $(git rev-parse --show-toplevel)/yarn-project/end-to-end -yarn test src/spartan/transfer.test.ts From 9cb16c0dd9430c2f6f081b1dbcd26a68a35ab050 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 14:45:41 +0000 Subject: [PATCH 05/20] test.sh fix --- yarn-project/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 0e6fa4fb698b..58c3138831b1 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -291,7 +291,7 @@ network-test-fake-proofs: # All script arguments are in the end-to-end/scripts/native-network folder ENV LOG_LEVEL=verbose RUN INTERLEAVED=true end-to-end/scripts/native_network_test.sh \ - ./test-transfer.sh \ + "./test.sh src/spartan/transfer.test.ts" \ ./deploy-l1-contracts.sh \ ./deploy-l2-contracts.sh \ ./boot-node.sh \ From 8452bea96e15873b4126c2fc1d06e0973eab6a50 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 14:50:43 +0000 Subject: [PATCH 06/20] fix validator command --- scripts/run_native_testnet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index c58ca23b1a7f..cedcf261c76c 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -103,7 +103,7 @@ BASE_CMD="INTERLEAVED=$INTERLEAVED ./yarn-project/end-to-end/scripts/native_netw ./deploy-l2-contracts.sh \ ./boot-node.sh \ ./ethereum.sh \ - $VALIDATOR_CMD \ + \"./validators.sh $NUM_VALIDATORS\" \ $PROVER_SCRIPT \ ./pxe.sh \ ./transaction-bot.sh" From f6b25aec820fedce373fd1bcf96c64bc90bdca80 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 14:50:54 +0000 Subject: [PATCH 07/20] fix validator command --- scripts/run_native_testnet.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index cedcf261c76c..332e8992af07 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -eu + : ' This script sets up and runs a native testnet for the Aztec network. From 2b25c829f54c8a2c2e7255a6bd3bd8edee336bf9 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 11:38:49 -0400 Subject: [PATCH 08/20] Update earthly-ci --- scripts/earthly-ci | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/earthly-ci b/scripts/earthly-ci index 8d667fddc5d4..1444cdc4b2d4 100755 --- a/scripts/earthly-ci +++ b/scripts/earthly-ci @@ -108,6 +108,7 @@ while [ $ATTEMPT_COUNT -lt $MAX_ATTEMPTS ]; do fi sleep 20 elif grep 'status 125: docker: Error response from daemon: layer does not exist.' $OUTPUT_FILE >/dev/null \ + || grep 'could not start container "earthly-buildkitd"' $OUTPUT_FILE >/dev/null \ || grep 'could not determine buildkit address - is Docker or Podman running?' $OUTPUT_FILE >/dev/null \ || grep 'please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host' $OUTPUT_FILE >/dev/null \ || grep 'docker: failed to register layer' $OUTPUT_FILE >/dev/null \ From 2738fc2584cfe5dd76c1fab5f38d378e22342f77 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 11:49:08 -0400 Subject: [PATCH 09/20] Update earthly-ci --- scripts/earthly-ci | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/earthly-ci b/scripts/earthly-ci index 1444cdc4b2d4..3df8047b7fbb 100755 --- a/scripts/earthly-ci +++ b/scripts/earthly-ci @@ -113,6 +113,7 @@ while [ $ATTEMPT_COUNT -lt $MAX_ATTEMPTS ]; do || grep 'please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host' $OUTPUT_FILE >/dev/null \ || grep 'docker: failed to register layer' $OUTPUT_FILE >/dev/null \ || grep 'docker: error during connect:' $OUTPUT_FILE >/dev/null \ + || grep 'docker: failed to write digest data' >/dev/null \ || grep 'docker: unexpected EOF' $OUTPUT_FILE >/dev/null ; then wipe_non_cache_docker_state # wait for other docker restarts From 6e585dad55b961ce5bd58f7c44965fbaf14fe9b0 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 15:53:27 +0000 Subject: [PATCH 10/20] flock on earthly restart --- scripts/earthly-ci | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/earthly-ci b/scripts/earthly-ci index 8d667fddc5d4..4879b707417d 100755 --- a/scripts/earthly-ci +++ b/scripts/earthly-ci @@ -23,13 +23,15 @@ export FORCE_COLOR=1 export EARTHLY_CONFIG=$(git rev-parse --show-toplevel)/.github/earthly-ci-config.yml function wipe_non_cache_docker_state { - echo "Detected corrupted docker images. Wiping and trying again." - # Based on https://stackoverflow.com/a/75849307 - # wipe everything but volumes where we have earthly cache - sudo service docker stop - sudo bash -c 'rm -rf /var/lib/docker/{buildkit,containers,image,network,overlay2,plugins.runtimes,swarm,tmp,trust}/*' || true - # restart docker - might take down builds, but we need to recover anyway - sudo service docker restart + flock -n "$HOME/wipe_docker_state.lock" bash -c ' + echo "Detected corrupted docker images. Wiping and trying again." + # Based on https://stackoverflow.com/a/75849307 + # wipe everything but volumes where we have earthly cache + sudo service docker stop + sudo bash -c '"'"'rm -rf /var/lib/docker/{buildkit,containers,image,network,overlay2,plugins,runtimes,swarm,tmp,trust}/*'"'"' || true + # restart docker - might take down builds, but we need to recover anyway + sudo service docker restart + ' } EARTHLY_RUN_STATS_JSON="earthly-run-stats.json" From 153e46a2b2d1cf52e76e2b79bbc22301436c55ed Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 15:58:28 +0000 Subject: [PATCH 11/20] port new tests --- .../end-to-end/src/spartan/4epochs.test.ts | 91 ++++++++++++++++++ .../src/spartan/setup_test_wallets.ts | 78 ++++++++++++++++ .../end-to-end/src/spartan/transfer.test.ts | 93 ++++--------------- 3 files changed, 185 insertions(+), 77 deletions(-) create mode 100644 yarn-project/end-to-end/src/spartan/4epochs.test.ts create mode 100644 yarn-project/end-to-end/src/spartan/setup_test_wallets.ts diff --git a/yarn-project/end-to-end/src/spartan/4epochs.test.ts b/yarn-project/end-to-end/src/spartan/4epochs.test.ts new file mode 100644 index 000000000000..306041cf3f2c --- /dev/null +++ b/yarn-project/end-to-end/src/spartan/4epochs.test.ts @@ -0,0 +1,91 @@ +import { EthCheatCodes, readFieldCompressedString } from '@aztec/aztec.js'; +import { AZTEC_SLOT_DURATION } from '@aztec/circuits.js'; +import { createDebugLogger } from '@aztec/foundation/log'; +import { TokenContract } from '@aztec/noir-contracts.js'; + + + +import { jest } from '@jest/globals'; + + + +import { RollupCheatCodes } from '../../../aztec.js/src/utils/cheat_codes.js'; +import { type TestWallets, setupTestWalletsWithTokens } from './setup_test_wallets.js'; + + +const { PXE_URL, ETHEREUM_HOST } = process.env; +if (!PXE_URL) { + throw new Error('PXE_URL env variable must be set'); +} +if (!ETHEREUM_HOST) { + throw new Error('ETHEREUM_HOST env variable must be set'); +} + +describe('token transfer test', () => { + jest.setTimeout(10 * 60 * 2000); // 20 minutes + + const logger = createDebugLogger(`aztec:spartan-test:transfer`); + // We want plenty of minted tokens for a lot of slots that fill up multiple epochs + const MINT_AMOUNT = 2000000n; + const TEST_EPOCHS = 4; + const ROUNDS = BigInt(AZTEC_SLOT_DURATION * TEST_EPOCHS); + + let testWallets: TestWallets; + + beforeAll(async () => { + testWallets = await setupTestWalletsWithTokens(PXE_URL, MINT_AMOUNT, logger); + expect(ROUNDS).toBeLessThanOrEqual(MINT_AMOUNT); + }); + + it('can get info', async () => { + const name = readFieldCompressedString(await testWallets.tokenAdminWallet.methods.private_get_name().simulate()); + expect(name).toBe(testWallets.tokenName); + }); + + it('transfer tokens for 4 epochs', async () => { + const ethCheatCodes = new EthCheatCodes(ETHEREUM_HOST); + // Get 4 epochs + const rollupCheatCodes = new RollupCheatCodes( + ethCheatCodes, + await testWallets.pxe.getNodeInfo().then(n => n.l1ContractAddresses), + ); + const recipient = testWallets.recipientWallet.getAddress(); + const transferAmount = 1n; + + testWallets.wallets.forEach(async w => { + expect(MINT_AMOUNT).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()); + }); + + expect(0n).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate()); + + // For each round, make both private and public transfers + const startSlot = await rollupCheatCodes.getSlot(); + for (let i = 1n; i <= ROUNDS; i++) { + const interactions = await Promise.all([ + ...testWallets.wallets.map(async w => + ( + await TokenContract.at(testWallets.tokenAddress, w) + ).methods.transfer_public(w.getAddress(), recipient, transferAmount, 0), + ), + ]); + + const txs = await Promise.all(interactions.map(async i => await i.prove())); + + await Promise.all(txs.map(t => t.send().wait({ timeout: 600 }))); + const currentSlot = await rollupCheatCodes.getSlot(); + expect(currentSlot).toBe(startSlot + i); + const startEpoch = await rollupCheatCodes.getEpoch(); + logger.debug(`Successfully reached slot ${currentSlot}/${startSlot + ROUNDS} (Epoch ${startEpoch})`); + } + + testWallets.wallets.forEach(async w => { + expect(MINT_AMOUNT - ROUNDS * transferAmount).toBe( + await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate(), + ); + }); + + expect(ROUNDS * transferAmount * BigInt(testWallets.wallets.length)).toBe( + await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate(), + ); + }); +}); \ No newline at end of file diff --git a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts new file mode 100644 index 000000000000..99121d5f664e --- /dev/null +++ b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts @@ -0,0 +1,78 @@ +import { getSchnorrAccount } from '@aztec/accounts/schnorr'; +import { type AccountWalletWithSecretKey, type AztecAddress, type PXE, createCompatibleClient } from '@aztec/aztec.js'; +import { type Logger } from '@aztec/foundation/log'; +import { TokenContract } from '@aztec/noir-contracts.js'; + +import { addAccounts } from '../fixtures/snapshot_manager.js'; + +export interface TestWallets { + pxe: PXE; + wallets: AccountWalletWithSecretKey[]; + tokenAdminWallet: TokenContract; + tokenName: string; + recipientWallet: AccountWalletWithSecretKey; + tokenAddress: AztecAddress; +} + +export async function setupTestWalletsWithTokens( + pxeUrl: string, + mintAmount: bigint, + logger: Logger, +): Promise { + const TOKEN_NAME = 'USDC'; + const TOKEN_SYMBOL = 'USD'; + const TOKEN_DECIMALS = 18n; + + const WALLET_COUNT = 1; // TODO fix this to allow for 16 wallets again + + let recipientWallet: AccountWalletWithSecretKey; + + const pxe = await createCompatibleClient(pxeUrl, logger); + + { + const { accountKeys } = await addAccounts(1, logger, false)({ pxe }); + const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)); + + const partialAddress = accountManagers[0].getCompleteAddress().partialAddress; + await pxe.registerAccount(accountKeys[0][0], partialAddress); + recipientWallet = await accountManagers[0].getWallet(); + logger.verbose(`Recipient Wallet address: ${recipientWallet.getAddress()} registered`); + } + + const { accountKeys } = await addAccounts(WALLET_COUNT, logger, false)({ pxe }); + const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)); + + const wallets = await Promise.all( + accountManagers.map(async (a, i) => { + const partialAddress = a.getCompleteAddress().partialAddress; + await pxe.registerAccount(accountKeys[i][0], partialAddress); + const wallet = await a.getWallet(); + logger.verbose(`Wallet ${i} address: ${wallet.getAddress()} registered`); + return wallet; + }), + ); + + logger.verbose(`Deploying TokenContract...`); + const tokenContract = await TokenContract.deploy( + wallets[0], + wallets[0].getAddress(), + TOKEN_NAME, + TOKEN_SYMBOL, + TOKEN_DECIMALS, + ) + .send() + .deployed({ timeout: 600 }); + + const tokenAddress = tokenContract.address; + const tokenAdminWallet = await TokenContract.at(tokenAddress, wallets[0]); + + logger.verbose(`Minting ${mintAmount} public assets to the ${wallets.length} wallets...`); + + await Promise.all( + wallets.map(w => tokenAdminWallet.methods.mint_public(w.getAddress(), mintAmount).send().wait({ timeout: 600 })), + ); + + logger.verbose(`Minting complete.`); + + return { pxe, wallets, tokenAdminWallet, tokenName: TOKEN_NAME, tokenAddress, recipientWallet }; +} diff --git a/yarn-project/end-to-end/src/spartan/transfer.test.ts b/yarn-project/end-to-end/src/spartan/transfer.test.ts index 066dfb355bae..ebbc84b70699 100644 --- a/yarn-project/end-to-end/src/spartan/transfer.test.ts +++ b/yarn-project/end-to-end/src/spartan/transfer.test.ts @@ -1,17 +1,10 @@ -import { getSchnorrAccount } from '@aztec/accounts/schnorr'; -import { - type AccountWalletWithSecretKey, - type AztecAddress, - type PXE, - createCompatibleClient, - readFieldCompressedString, -} from '@aztec/aztec.js'; +import { readFieldCompressedString } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts.js'; import { jest } from '@jest/globals'; -import { addAccounts } from '../fixtures/snapshot_manager.js'; +import { type TestWallets, setupTestWalletsWithTokens } from './setup_test_wallets.js'; const { PXE_URL } = process.env; if (!PXE_URL) { @@ -22,92 +15,38 @@ describe('token transfer test', () => { jest.setTimeout(10 * 60 * 2000); // 20 minutes const logger = createDebugLogger(`aztec:spartan-test:transfer`); - const TOKEN_NAME = 'USDC'; - const TOKEN_SYMBOL = 'USD'; - const TOKEN_DECIMALS = 18n; const MINT_AMOUNT = 20n; - const WALLET_COUNT = 1; // TODO fix this to allow for 16 wallets again const ROUNDS = 5n; - let pxe: PXE; - let wallets: AccountWalletWithSecretKey[]; - let recipientWallet: AccountWalletWithSecretKey; - let tokenAddress: AztecAddress; - let tokenAdminWallet: TokenContract; + let testWallets: TestWallets; beforeAll(async () => { + testWallets = await setupTestWalletsWithTokens(PXE_URL, MINT_AMOUNT, logger); expect(ROUNDS).toBeLessThanOrEqual(MINT_AMOUNT); - - pxe = await createCompatibleClient(PXE_URL, logger); - - { - const { accountKeys } = await addAccounts(1, logger, false)({ pxe }); - const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)); - - const partialAddress = accountManagers[0].getCompleteAddress().partialAddress; - await pxe.registerAccount(accountKeys[0][0], partialAddress); - recipientWallet = await accountManagers[0].getWallet(); - logger.verbose(`Recipient Wallet address: ${recipientWallet.getAddress()} registered`); - } - - const { accountKeys } = await addAccounts(WALLET_COUNT, logger, false)({ pxe }); - const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)); - - wallets = await Promise.all( - accountManagers.map(async (a, i) => { - const partialAddress = a.getCompleteAddress().partialAddress; - await pxe.registerAccount(accountKeys[i][0], partialAddress); - const wallet = await a.getWallet(); - logger.verbose(`Wallet ${i} address: ${wallet.getAddress()} registered`); - return wallet; - }), - ); - - logger.verbose(`Deploying TokenContract...`); - const tokenContract = await TokenContract.deploy( - wallets[0], - wallets[0].getAddress(), - TOKEN_NAME, - TOKEN_SYMBOL, - TOKEN_DECIMALS, - ) - .send() - .deployed({ timeout: 600 }); - - tokenAddress = tokenContract.address; - tokenAdminWallet = await TokenContract.at(tokenAddress, wallets[0]); - - logger.verbose(`Minting ${MINT_AMOUNT} public assets to the ${wallets.length} wallets...`); - - await Promise.all( - wallets.map(w => tokenAdminWallet.methods.mint_public(w.getAddress(), MINT_AMOUNT).send().wait({ timeout: 600 })), - ); - - logger.verbose(`Minting complete.`); }); it('can get info', async () => { - const name = readFieldCompressedString(await tokenAdminWallet.methods.private_get_name().simulate()); - expect(name).toBe(TOKEN_NAME); + const name = readFieldCompressedString(await testWallets.tokenAdminWallet.methods.private_get_name().simulate()); + expect(name).toBe(testWallets.tokenName); }); it('can transfer 1 token privately and publicly', async () => { - const recipient = recipientWallet.getAddress(); + const recipient = testWallets.recipientWallet.getAddress(); const transferAmount = 1n; - wallets.forEach(async w => { - expect(MINT_AMOUNT).toBe(await tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()); + testWallets.wallets.forEach(async w => { + expect(MINT_AMOUNT).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()); }); - expect(0n).toBe(await tokenAdminWallet.methods.balance_of_public(recipient).simulate()); + expect(0n).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate()); // For each round, make both private and public transfers for (let i = 1n; i <= ROUNDS; i++) { const interactions = await Promise.all([ - ...wallets.map(async w => + ...testWallets.wallets.map(async w => ( - await TokenContract.at(tokenAddress, w) + await TokenContract.at(testWallets.tokenAddress, w) ).methods.transfer_public(w.getAddress(), recipient, transferAmount, 0), ), ]); @@ -117,14 +56,14 @@ describe('token transfer test', () => { await Promise.all(txs.map(t => t.send().wait({ timeout: 600 }))); } - wallets.forEach(async w => { + testWallets.wallets.forEach(async w => { expect(MINT_AMOUNT - ROUNDS * transferAmount).toBe( - await tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate(), + await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate(), ); }); - expect(ROUNDS * transferAmount * BigInt(wallets.length)).toBe( - await tokenAdminWallet.methods.balance_of_public(recipient).simulate(), + expect(ROUNDS * transferAmount * BigInt(testWallets.wallets.length)).toBe( + await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate(), ); }); }); From db3499b1fd4c1df17d83cedeb78cef001e1c752e Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 20:55:58 +0000 Subject: [PATCH 12/20] fixes --- scripts/run_native_testnet.sh | 2 +- yarn-project/canary/scripts/cond_run_script | 34 ------------------- .../end-to-end/scripts/native-network/pxe.sh | 2 -- .../end-to-end/scripts/native-network/test.sh | 2 +- .../end-to-end/src/spartan/4epochs.test.ts | 11 ++---- 5 files changed, 5 insertions(+), 46 deletions(-) delete mode 100755 yarn-project/canary/scripts/cond_run_script diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index 332e8992af07..7008e97c9c62 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -46,7 +46,7 @@ display_help() { echo " -i Run interleaved (default: $INTERLEAVED)" echo echo "Example:" - echo " $0 -t src/spartan/smoke.test.ts -val 5 -v" + echo " $0 -t smoke.test.ts -val 5 -v" } # Parse command line arguments diff --git a/yarn-project/canary/scripts/cond_run_script b/yarn-project/canary/scripts/cond_run_script deleted file mode 100755 index 84c03bd4574a..000000000000 --- a/yarn-project/canary/scripts/cond_run_script +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# Conditionally runs a script if any dependent code has changed between -# the last successful run and the present commit. -# -# It's expected to be run from the project directory, and that there be a directory called `scripts` -# containing the given named script to execute. -# -# This script is only useful if there is nothing to do in the event there is no rebuild. This is fine -# for running a suite of tests for example, but is not useful for performing a build, as even if a -# build has nothing to do, the previous images are retagged with the new commit hash for upstream jobs. -# -# Arguments are: -# 1. REPOSITORY: The project repository name in ECR. Used to determine if there are changes since last success. -# 2. SUCCESS_TAG: To track if this job needs to be run, the repository image is tagged with a success tag after a -# successful run. The script will only run if there were relevant code changes since the last successful commit. -# 3... ARGS: Script to run and args. -[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace -set -eu - -REPOSITORY=$1 -shift -SUCCESS_TAG=$1 -shift -SCRIPT_TO_RUN=$1 -shift - -CONTENT_HASH=$(calculate_content_hash $REPOSITORY) -echo "Content hash tag: cache-$CONTENT_HASH-$SUCCESS_TAG" -echo "Script to run is $SCRIPT_TO_RUN $@" - -if ! check_rebuild cache-$CONTENT_HASH-$SUCCESS_TAG $REPOSITORY; then - "$SCRIPT_TO_RUN" "$@" - retry tag_remote_image $REPOSITORY cache-$CONTENT_HASH cache-$CONTENT_HASH-$SUCCESS_TAG -fi diff --git a/yarn-project/end-to-end/scripts/native-network/pxe.sh b/yarn-project/end-to-end/scripts/native-network/pxe.sh index e1ec0eab112e..e02133cf9433 100755 --- a/yarn-project/end-to-end/scripts/native-network/pxe.sh +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -18,8 +18,6 @@ echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 done -echo "Done waiting." - # We need to also wait for the validator, as the initial node cannot # Produce blocks on it's own echo "Waiting for Validator 0..." diff --git a/yarn-project/end-to-end/scripts/native-network/test.sh b/yarn-project/end-to-end/scripts/native-network/test.sh index ac034cfe99ed..c410bcdefca3 100755 --- a/yarn-project/end-to-end/scripts/native-network/test.sh +++ b/yarn-project/end-to-end/scripts/native-network/test.sh @@ -31,6 +31,6 @@ echo "Done waiting." export DEBUG="aztec:*" export LOG_LEVEL=${LOG_LEVEL:-"debug"} export PXE_URL=http://localhost:8079 -export ETHEREUM_HOST=http://localhost:8545 +export ETHEREUM_HOST=http://127.0.0.1:8545 cd $(git rev-parse --show-toplevel)/yarn-project/end-to-end yarn test "$TEST" diff --git a/yarn-project/end-to-end/src/spartan/4epochs.test.ts b/yarn-project/end-to-end/src/spartan/4epochs.test.ts index 306041cf3f2c..8c3dc52140a1 100644 --- a/yarn-project/end-to-end/src/spartan/4epochs.test.ts +++ b/yarn-project/end-to-end/src/spartan/4epochs.test.ts @@ -3,16 +3,11 @@ import { AZTEC_SLOT_DURATION } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts.js'; - - import { jest } from '@jest/globals'; - - import { RollupCheatCodes } from '../../../aztec.js/src/utils/cheat_codes.js'; import { type TestWallets, setupTestWalletsWithTokens } from './setup_test_wallets.js'; - const { PXE_URL, ETHEREUM_HOST } = process.env; if (!PXE_URL) { throw new Error('PXE_URL env variable must be set'); @@ -24,7 +19,7 @@ if (!ETHEREUM_HOST) { describe('token transfer test', () => { jest.setTimeout(10 * 60 * 2000); // 20 minutes - const logger = createDebugLogger(`aztec:spartan-test:transfer`); + const logger = createDebugLogger(`aztec:spartan:4epochs`); // We want plenty of minted tokens for a lot of slots that fill up multiple epochs const MINT_AMOUNT = 2000000n; const TEST_EPOCHS = 4; @@ -75,7 +70,7 @@ describe('token transfer test', () => { const currentSlot = await rollupCheatCodes.getSlot(); expect(currentSlot).toBe(startSlot + i); const startEpoch = await rollupCheatCodes.getEpoch(); - logger.debug(`Successfully reached slot ${currentSlot}/${startSlot + ROUNDS} (Epoch ${startEpoch})`); + logger.debug(`Successfully reached slot ${currentSlot} (iteration ${currentSlot - startSlot}/${ROUNDS}) (Epoch ${startEpoch})`); } testWallets.wallets.forEach(async w => { @@ -88,4 +83,4 @@ describe('token transfer test', () => { await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate(), ); }); -}); \ No newline at end of file +}); From 686195d670fc0ec6c15f650373db5f7a3a114e74 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 21:06:53 +0000 Subject: [PATCH 13/20] update --- scripts/run_native_testnet.sh | 8 ++++---- .../scripts/native-network/{test.sh => test-transfer.sh} | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) rename yarn-project/end-to-end/scripts/native-network/{test.sh => test-transfer.sh} (94%) diff --git a/scripts/run_native_testnet.sh b/scripts/run_native_testnet.sh index 7008e97c9c62..c4be98de940d 100755 --- a/scripts/run_native_testnet.sh +++ b/scripts/run_native_testnet.sh @@ -27,7 +27,7 @@ Options: ' # Default values -TEST_FILE=src/spartan/transfer.test.ts +TEST_SCRIPT=./test-transfer.sh PROVER_SCRIPT="\"./prover-node.sh 8078 false\"" NUM_VALIDATORS=3 INTERLEAVED=false @@ -46,7 +46,7 @@ display_help() { echo " -i Run interleaved (default: $INTERLEAVED)" echo echo "Example:" - echo " $0 -t smoke.test.ts -val 5 -v" + echo " $0 -t ./test-4epochs.sh -val 5 -v" } # Parse command line arguments @@ -57,7 +57,7 @@ while [[ $# -gt 0 ]]; do exit 0 ;; -t) - TEST_FILE="$2" + TEST_SCRIPT="$2" shift 2 ;; -p) @@ -100,7 +100,7 @@ cd $(git rev-parse --show-toplevel) # Base command BASE_CMD="INTERLEAVED=$INTERLEAVED ./yarn-project/end-to-end/scripts/native_network_test.sh \ - \"./test.sh $TEST_FILE\" \ + $TEST_SCRIPT \ ./deploy-l1-contracts.sh \ ./deploy-l2-contracts.sh \ ./boot-node.sh \ diff --git a/yarn-project/end-to-end/scripts/native-network/test.sh b/yarn-project/end-to-end/scripts/native-network/test-transfer.sh similarity index 94% rename from yarn-project/end-to-end/scripts/native-network/test.sh rename to yarn-project/end-to-end/scripts/native-network/test-transfer.sh index c410bcdefca3..93e218a045e3 100755 --- a/yarn-project/end-to-end/scripts/native-network/test.sh +++ b/yarn-project/end-to-end/scripts/native-network/test-transfer.sh @@ -2,7 +2,6 @@ set -eu -TEST=$1 # Get the name of the script without the path and extension SCRIPT_NAME=$(basename "$0" .sh) @@ -31,6 +30,5 @@ echo "Done waiting." export DEBUG="aztec:*" export LOG_LEVEL=${LOG_LEVEL:-"debug"} export PXE_URL=http://localhost:8079 -export ETHEREUM_HOST=http://127.0.0.1:8545 cd $(git rev-parse --show-toplevel)/yarn-project/end-to-end -yarn test "$TEST" +yarn test src/spartan/transfer.test.ts From 48b64119c3a92394d4bf6df8580848e95b34b1d6 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 21:08:43 +0000 Subject: [PATCH 14/20] fix --- yarn-project/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 58c3138831b1..0e6fa4fb698b 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -291,7 +291,7 @@ network-test-fake-proofs: # All script arguments are in the end-to-end/scripts/native-network folder ENV LOG_LEVEL=verbose RUN INTERLEAVED=true end-to-end/scripts/native_network_test.sh \ - "./test.sh src/spartan/transfer.test.ts" \ + ./test-transfer.sh \ ./deploy-l1-contracts.sh \ ./deploy-l2-contracts.sh \ ./boot-node.sh \ From e89cd7e5aebfb84b1e6762a47625356cbc33d698 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 21:09:54 +0000 Subject: [PATCH 15/20] missing file --- .../scripts/native-network/test-4epochs.sh | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 yarn-project/end-to-end/scripts/native-network/test-4epochs.sh diff --git a/yarn-project/end-to-end/scripts/native-network/test-4epochs.sh b/yarn-project/end-to-end/scripts/native-network/test-4epochs.sh new file mode 100755 index 000000000000..98393c402139 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/test-4epochs.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -eu + +# Get the name of the script without the path and extension +SCRIPT_NAME=$(basename "$0" .sh) + +# Redirect stdout and stderr to .log while also printing to the console +exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log" >&2) + +REPO=$(git rev-parse --show-toplevel) +# Run our test assuming the port in pxe.sh +# Wait for the Aztec Node to be ready +echo "Waiting for Aztec Node..." +until curl -s http://127.0.0.1:8080/status >/dev/null ; do + sleep 1 +done +echo "Waiting for PXE service..." +until curl -s -X POST -H 'content-type: application/json' \ + -d '{"jsonrpc":"2.0","method":"pxe_getNodeInfo","params":[],"id":67}' \ + http://127.0.0.1:8079 | grep -q '"enr:-'; do + sleep 1 +done +echo "Waiting for l2 contracts to be deployed..." +until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l2-contracts.env ] ; do + sleep 1 +done +echo "Done waiting." + +export DEBUG="aztec:*" +export LOG_LEVEL=${LOG_LEVEL:-"debug"} +export PXE_URL=http://localhost:8079 +export ETHEREUM_HOST=http://127.0.0.1:8545 +cd $(git rev-parse --show-toplevel)/yarn-project/end-to-end +yarn test src/spartan/4epochs.test.ts \ No newline at end of file From 90d12465dbf2da0da05ca5e46319f64a616181bb Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 21 Oct 2024 21:17:57 +0000 Subject: [PATCH 16/20] . --- yarn-project/end-to-end/scripts/network_test.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index 0b0bf8165622..3ab22fd4a7bc 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -62,7 +62,6 @@ function show_status_until_pxe_ready() { } show_status_until_pxe_ready & -SHOW_STATUS_PID=$! # Install the Helm chart helm upgrade --install spartan "$REPO/spartan/aztec-network/" \ @@ -79,15 +78,12 @@ kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m # tunnel in to get access directly to our PXE service in k8s (kubectl port-forward --namespace $NAMESPACE svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true) & -PORT_FORWARD_PID=$! -cleanup() { - echo "Cleaning up..." - kill $PORT_FORWARD_PID || true - kill $SHOW_STATUS_PID || true +function cleanup() { + # kill everything in our process group except our process + trap - SIGTERM && kill $(pgrep -g $$ | grep -v $$) 2>/dev/null || true } - -trap cleanup EXIT SIGINT SIGTERM +trap cleanup SIGINT SIGTERM EXIT docker run --rm --network=host \ -e PXE_URL=http://localhost:9082 \ From ac26c3e5b916057905b664d0de3c3b5190c14eff Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 22 Oct 2024 00:27:11 +0000 Subject: [PATCH 17/20] yarn fix --- yarn-project/end-to-end/src/spartan/4epochs.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/spartan/4epochs.test.ts b/yarn-project/end-to-end/src/spartan/4epochs.test.ts index 8c3dc52140a1..c58d31211112 100644 --- a/yarn-project/end-to-end/src/spartan/4epochs.test.ts +++ b/yarn-project/end-to-end/src/spartan/4epochs.test.ts @@ -70,7 +70,11 @@ describe('token transfer test', () => { const currentSlot = await rollupCheatCodes.getSlot(); expect(currentSlot).toBe(startSlot + i); const startEpoch = await rollupCheatCodes.getEpoch(); - logger.debug(`Successfully reached slot ${currentSlot} (iteration ${currentSlot - startSlot}/${ROUNDS}) (Epoch ${startEpoch})`); + logger.debug( + `Successfully reached slot ${currentSlot} (iteration ${ + currentSlot - startSlot + }/${ROUNDS}) (Epoch ${startEpoch})`, + ); } testWallets.wallets.forEach(async w => { From 79b2b2994399a1bd9de1565c32f4dd8e15fd7d45 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 22 Oct 2024 00:35:21 +0000 Subject: [PATCH 18/20] try fix --- yarn-project/end-to-end/scripts/network_test.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index 3ab22fd4a7bc..d9a57f8b3c19 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -63,6 +63,11 @@ function show_status_until_pxe_ready() { show_status_until_pxe_ready & +function cleanup() { + # kill everything in our process group except our process + echo kill $(pgrep -g $$ | grep -v $$) +} +trap cleanup SIGINT SIGTERM EXIT # Install the Helm chart helm upgrade --install spartan "$REPO/spartan/aztec-network/" \ --namespace "$NAMESPACE" \ @@ -79,12 +84,6 @@ kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m # tunnel in to get access directly to our PXE service in k8s (kubectl port-forward --namespace $NAMESPACE svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true) & -function cleanup() { - # kill everything in our process group except our process - trap - SIGTERM && kill $(pgrep -g $$ | grep -v $$) 2>/dev/null || true -} -trap cleanup SIGINT SIGTERM EXIT - docker run --rm --network=host \ -e PXE_URL=http://localhost:9082 \ -e DEBUG="aztec:*" \ From 4bde9cfe2c69a577d6fcb4c97caedec21f1d1e3c Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 22 Oct 2024 00:36:04 +0000 Subject: [PATCH 19/20] try fix --- yarn-project/end-to-end/scripts/network_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index d9a57f8b3c19..5f4fe05e85f6 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -65,7 +65,7 @@ show_status_until_pxe_ready & function cleanup() { # kill everything in our process group except our process - echo kill $(pgrep -g $$ | grep -v $$) + kill $(pgrep -g $$ | grep -v $$) } trap cleanup SIGINT SIGTERM EXIT # Install the Helm chart From e4b1828c08e3995385e7a0e14c2171b6d9e5883e Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 22 Oct 2024 00:36:58 +0000 Subject: [PATCH 20/20] try fix --- yarn-project/end-to-end/scripts/network_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index 5f4fe05e85f6..f85a22cded25 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -65,7 +65,8 @@ show_status_until_pxe_ready & function cleanup() { # kill everything in our process group except our process - kill $(pgrep -g $$ | grep -v $$) + kill $(pgrep -g $$ | grep -v $$) || true + kill $(jobs -p) || true } trap cleanup SIGINT SIGTERM EXIT # Install the Helm chart