From 96882cd4774d1bbe1672d724cd604358b6b90859 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 5 Oct 2024 17:40:05 +0000 Subject: [PATCH 01/29] start of helm-based native tests --- noir-projects/tmux-splits-stdin | 33 ++++ .../end-to-end/scripts/native_network_test.sh | 180 ++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100755 noir-projects/tmux-splits-stdin create mode 100755 yarn-project/end-to-end/scripts/native_network_test.sh diff --git a/noir-projects/tmux-splits-stdin b/noir-projects/tmux-splits-stdin new file mode 100755 index 00000000000..86e6e64b5e2 --- /dev/null +++ b/noir-projects/tmux-splits-stdin @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -eux +# Launches tmux with 1 window that has as many panes as lines of input +session_name=$1 + +# Kill any existing tmux session with the same name +tmux kill-session -t "$session_name" || true + +# Start a new tmux session +tmux new-session -d -s "$session_name" + +# Read commands from stdin into an array +commands=() +while IFS= read -r command; do + commands+=("$command") +done + +# Create the necessary number of panes +num_commands=${#commands[@]} +for ((i=1; i +# Optional environment variables: +# VALUES_FILE (default: "default.yaml") + +set -eux + +command -v yq || (echo "We need 'yq' installed to be able to query our rendered helm template network config" && exit 1) +command -v tmux || (echo "We need 'tmux' installed to be able to run our commands as one easily-managed session" && exit 1) + +# Main positional parameter +TEST="$1" + +VALUES_FILE="${VALUES_FILE:-default.yaml}" + +# Path to the multi-YAML file +yaml_file="multi-yaml-file.yaml" + +# The helm charts are our base truth - let's just make helm tell us what the values are and be selective about applying them! +# This is a good lightweight test of helm chart values before running a full helm scenario and more maintainable than a separate base truth +helm template spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" > $yaml_file + +# # Function to extract env variables, commands, and run them +# process_container() { +# container_name=$1 +# echo "Processing container: $container_name" + +# # Extract and join the command array into a string, handle nulls +# command=$(yq e -o=json ".spec.template.spec.containers[] | select(.name == \"$container_name\") | .command" $yaml_file | jq -r 'if . == null then "" else join(" ") end') + +# # Extract and join the args array into a string, handle nulls +# args=$(yq e -o=json ".spec.template.spec.containers[] | select(.name == \"$container_name\") | .args" $yaml_file | jq -r 'if . == null then "" else join(" ") end') + +# # Extract environment variables +# env_vars=$(yq e ".spec.template.spec.containers[] | select(.name == \"$container_name\") | .env[]? | .name + \"=\" + .value" $yaml_file) + +# # Set environment variables +# echo "Exporting environment variables:" +# if [ -n "$env_vars" ]; then +# while IFS= read -r env_var; do +# echo "export $env_var" +# echo export $env_var +# done <<< "$env_vars" +# else +# echo "No environment variables to export." +# fi + +# # Run the command if it exists +# if [ -n "$command" ]; then +# echo "Running command for $container_name:" +# full_command="$command $args" +# echo "$full_command" +# echo eval "$full_command" +# else +# echo "No command to run for container: $container_name" +# fi + +# echo "Finished processing container: $container_name" +# echo "----------------------------------------" +# } + +# function filter_telemetry() { +# # We do not desire telemetry for our native test. +# grep -v otel-collector | grep -v prometheus | grep -v grafana | grep -v jaeger +# } + +# # Extract all containers from the YAML file +# containers=$(yq e '.spec.template.spec.containers[].name' $yaml_file | filter_telemetry) +# echo $containers +# # # Loop through each container and process it +# # while IFS= read -r container; do +# # process_container "$container" +# # done <<< "$containers" + +# Name of the tmux session +tmux_session="native_network_test_session" + +# Create a fresh tmux session +tmux kill-session -t $tmux_session || true +tmux new-session -d -s $tmux_session + +# Function to process each resource by metadata.name +process_resource() { + resource_name=$1 + + echo "Processing resource: $resource_name" + + # Check if the resource exists + resource_exists=$(yq e "select(.metadata.name == \"$resource_name\") | .metadata.name" $yaml_file) + + if [ -z "$resource_exists" ]; then + echo "Resource $resource_name not found in the YAML file." + echo "----------------------------------------" + return + fi + + # Extract containers within this resource + container_names=$(yq e "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[].name" $yaml_file) + + if [ -z "$container_names" ]; then + echo "Resource $resource_name does not have containers to process." + echo "----------------------------------------" + return + fi + + # Initialize pane index + pane_index=0 + + # Loop through each container in the resource + while IFS= read -r container_name; do + echo " Processing container: $container_name" + + # Extract and join the command array into a string, handle nulls + command=$(yq e -o=json "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .command" $yaml_file | jq -r 'if . == null then "" else join(" ") end') + + # Extract and join the args array into a string, handle nulls + args=$(yq e -o=json "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .args" $yaml_file | jq -r 'if . == null then "" else join(" ") end') + + # Extract environment variables + env_vars=$(yq e "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .env[]? | .name + \"=\" + .value" $yaml_file) + + # Prepare environment variable exports + env_exports="" + if [ -n "$env_vars" ]; then + while IFS= read -r env_var; do + env_exports+="export $env_var; " + done <<< "$env_vars" + fi + + # Combine the command and args + full_command="$command $args" + # If there's no command, skip running + if [ -z "$full_command" ]; then + echo " No command to run for container: $container_name" + continue + fi + + # Build the pane command + pane_command="vim" #$env_exports $full_command; read -p 'Press Enter to exit...';" + + # If this is the first pane, send the command to the initial pane + if [ $pane_index -eq 0 ]; then + tmux send-keys -t $tmux_session "$pane_command" Enter + else + # Split the window to create a new pane and run the command + tmux split-window -t $tmux_session -h + tmux select-layout -t $tmux_session tiled + tmux send-keys -t $tmux_session "$pane_command" Enter + fi + + # Increment the pane index + pane_index=$((pane_index + 1)) + + echo " Command sent to tmux pane for container: $container_name" + + done <<< "$container_names" + + echo "Finished processing resource: $resource_name" + echo "----------------------------------------" +} + +# List of resource names to process +resource_names=( + "spartan-aztec-network-ethereum" + "spartan-aztec-network-pxe" + "spartan-aztec-network-bot" + "spartan-aztec-network-boot-node" + "spartan-aztec-network-prover-node" + "spartan-aztec-network-validator" +) + +for resource_name in "${resource_names[@]}"; do + process_resource "$resource_name" +done + +# Attach to the tmux session +tmux attach-session -t $tmux_session \ No newline at end of file From 21b3925132b70a22696ea809e8db201ea5df552d Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 5 Oct 2024 17:42:11 +0000 Subject: [PATCH 02/29] start of helm-based native tests --- .../end-to-end/scripts/native_network_test.sh | 112 ++---------------- 1 file changed, 12 insertions(+), 100 deletions(-) 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 ab16b4826be..55428d2c0ec 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -8,82 +8,22 @@ set -eux +# Ensure dependencies are installed command -v yq || (echo "We need 'yq' installed to be able to query our rendered helm template network config" && exit 1) -command -v tmux || (echo "We need 'tmux' installed to be able to run our commands as one easily-managed session" && exit 1) +command -v tmux || (echo "We need 'tmux' installed to be able to manage terminal sessions" && exit 1) # Main positional parameter TEST="$1" - VALUES_FILE="${VALUES_FILE:-default.yaml}" # Path to the multi-YAML file yaml_file="multi-yaml-file.yaml" # The helm charts are our base truth - let's just make helm tell us what the values are and be selective about applying them! -# This is a good lightweight test of helm chart values before running a full helm scenario and more maintainable than a separate base truth -helm template spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" > $yaml_file - -# # Function to extract env variables, commands, and run them -# process_container() { -# container_name=$1 -# echo "Processing container: $container_name" - -# # Extract and join the command array into a string, handle nulls -# command=$(yq e -o=json ".spec.template.spec.containers[] | select(.name == \"$container_name\") | .command" $yaml_file | jq -r 'if . == null then "" else join(" ") end') - -# # Extract and join the args array into a string, handle nulls -# args=$(yq e -o=json ".spec.template.spec.containers[] | select(.name == \"$container_name\") | .args" $yaml_file | jq -r 'if . == null then "" else join(" ") end') - -# # Extract environment variables -# env_vars=$(yq e ".spec.template.spec.containers[] | select(.name == \"$container_name\") | .env[]? | .name + \"=\" + .value" $yaml_file) - -# # Set environment variables -# echo "Exporting environment variables:" -# if [ -n "$env_vars" ]; then -# while IFS= read -r env_var; do -# echo "export $env_var" -# echo export $env_var -# done <<< "$env_vars" -# else -# echo "No environment variables to export." -# fi - -# # Run the command if it exists -# if [ -n "$command" ]; then -# echo "Running command for $container_name:" -# full_command="$command $args" -# echo "$full_command" -# echo eval "$full_command" -# else -# echo "No command to run for container: $container_name" -# fi - -# echo "Finished processing container: $container_name" -# echo "----------------------------------------" -# } - -# function filter_telemetry() { -# # We do not desire telemetry for our native test. -# grep -v otel-collector | grep -v prometheus | grep -v grafana | grep -v jaeger -# } - -# # Extract all containers from the YAML file -# containers=$(yq e '.spec.template.spec.containers[].name' $yaml_file | filter_telemetry) -# echo $containers -# # # Loop through each container and process it -# # while IFS= read -r container; do -# # process_container "$container" -# # done <<< "$containers" - -# Name of the tmux session -tmux_session="native_network_test_session" - -# Create a fresh tmux session -tmux kill-session -t $tmux_session || true -tmux new-session -d -s $tmux_session - -# Function to process each resource by metadata.name -process_resource() { +helm template spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ + --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" > "$yaml_file" + +function extract_commands_by_helm_metadata_name() { resource_name=$1 echo "Processing resource: $resource_name" @@ -106,13 +46,8 @@ process_resource() { return fi - # Initialize pane index - pane_index=0 - # Loop through each container in the resource while IFS= read -r container_name; do - echo " Processing container: $container_name" - # Extract and join the command array into a string, handle nulls command=$(yq e -o=json "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .command" $yaml_file | jq -r 'if . == null then "" else join(" ") end') @@ -131,31 +66,10 @@ process_resource() { fi # Combine the command and args - full_command="$command $args" - # If there's no command, skip running - if [ -z "$full_command" ]; then - echo " No command to run for container: $container_name" - continue - fi - - # Build the pane command - pane_command="vim" #$env_exports $full_command; read -p 'Press Enter to exit...';" - - # If this is the first pane, send the command to the initial pane - if [ $pane_index -eq 0 ]; then - tmux send-keys -t $tmux_session "$pane_command" Enter - else - # Split the window to create a new pane and run the command - tmux split-window -t $tmux_session -h - tmux select-layout -t $tmux_session tiled - tmux send-keys -t $tmux_session "$pane_command" Enter - fi - - # Increment the pane index - pane_index=$((pane_index + 1)) - - echo " Command sent to tmux pane for container: $container_name" + full_command="echo '$env_exports $command $args'" + # Pipe the commands for tmux-splits-stdin (one command per line) + echo "$full_command" done <<< "$container_names" echo "Finished processing resource: $resource_name" @@ -172,9 +86,7 @@ resource_names=( "spartan-aztec-network-validator" ) +# Queue all commands to tmux-splits-stdin for resource_name in "${resource_names[@]}"; do - process_resource "$resource_name" -done - -# Attach to the tmux session -tmux attach-session -t $tmux_session \ No newline at end of file + extract_commands_by_helm_metadata_name "$resource_name" +done | "$(git rev-parse --show-toplevel)/scripts/tmux-splits-stdin "native_network_test_session" From 5ca483e873d6c7e77f8d5850841a7a543f83948f Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 5 Oct 2024 23:16:11 +0000 Subject: [PATCH 03/29] checkin --- noir-projects/tmux-splits-stdin | 0 .../files/config/config-validator-env.sh | 1 - .../scripts/native-network/.gitignore | 2 + .../scripts/native-network/boot-node.sh | 34 ++++++ .../native-network/deploy-l1-contracts.sh | 38 ++++++ .../native-network/deploy-l2-contracts.sh | 21 ++++ .../scripts/native-network/ethereum.sh | 14 +++ .../scripts/native-network/prover-node.sh | 33 +++++ .../end-to-end/scripts/native-network/pxe.sh | 19 +++ .../scripts/native-network/transaction-bot.sh | 32 +++++ .../scripts/native-network/validator.sh | 58 +++++++++ .../end-to-end/scripts/native_network_test.sh | 113 +++++------------- .../end-to-end/scripts/network_test.sh | 67 +++++------ .../end-to-end/src/spartan/smoke.test.ts | 2 +- 14 files changed, 312 insertions(+), 122 deletions(-) mode change 100755 => 100644 noir-projects/tmux-splits-stdin create mode 100644 yarn-project/end-to-end/scripts/native-network/.gitignore create mode 100755 yarn-project/end-to-end/scripts/native-network/boot-node.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/ethereum.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/prover-node.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/pxe.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/transaction-bot.sh create mode 100755 yarn-project/end-to-end/scripts/native-network/validator.sh diff --git a/noir-projects/tmux-splits-stdin b/noir-projects/tmux-splits-stdin old mode 100755 new mode 100644 diff --git a/spartan/aztec-network/files/config/config-validator-env.sh b/spartan/aztec-network/files/config/config-validator-env.sh index f25834ad54d..a3f2ac3d9a0 100644 --- a/spartan/aztec-network/files/config/config-validator-env.sh +++ b/spartan/aztec-network/files/config/config-validator-env.sh @@ -28,7 +28,6 @@ aztec add-l1-validator --validator $address --rollup $rollup_address aztec fast-forward-epochs --rollup $rollup_address --count 1 - # Write the addresses to a file in the shared volume cat < /shared/contracts.env export BOOTSTRAP_NODES=$boot_node_enr diff --git a/yarn-project/end-to-end/scripts/native-network/.gitignore b/yarn-project/end-to-end/scripts/native-network/.gitignore new file mode 100644 index 00000000000..2c3814328bf --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/.gitignore @@ -0,0 +1,2 @@ +l1-contracts.env +l2-contracts.env \ No newline at end of file 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 new file mode 100755 index 00000000000..b2fc85cb576 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/boot-node.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -eu +# Starts the Boot Node + +# Set environment variables +export PORT="8080" +export LOG_LEVEL="debug" +export LOG_JSON="1" +export DEBUG="aztec:*,-aztec:avm_simulator:*" +export ETHEREUM_HOST="http://127.0.0.1:8545" +export P2P_ENABLED="true" +export VALIDATOR_DISABLED="true" +export SEQ_MAX_SECONDS_BETWEEN_BLOCKS="0" +export SEQ_MIN_TX_PER_BLOCK="1" +export P2P_TCP_ANNOUNCE_ADDR="0.0.0.0:40400" +export P2P_UDP_ANNOUNCE_ADDR="0.0.0.0:40400" +export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400" +export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400" +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 + sleep 1 +done + +source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env + +# Wait for anvil and deploy contracts +# source this script to get the L1 contract addresses in env +source "$REPO"/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh + +# Start the Aztec node with the sequencer and archiver +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe 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 new file mode 100755 index 00000000000..cda06ea6448 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Deploys L1 contracts and captures the output + +set -eu + +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}' \ + http://127.0.0.1:8545 2>/dev/null | grep -q 'result' ; do + sleep 1 +done + +# 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) + +echo "$output" + +# Extract contract addresses using grep and regex +ROLLUP_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}') +REGISTRY_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}') +INBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}') +OUTBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}') +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 +export ROLLUP_CONTRACT_ADDRESS=$ROLLUP_CONTRACT_ADDRESS +export REGISTRY_CONTRACT_ADDRESS=$REGISTRY_CONTRACT_ADDRESS +export INBOX_CONTRACT_ADDRESS=$INBOX_CONTRACT_ADDRESS +export OUTBOX_CONTRACT_ADDRESS=$OUTBOX_CONTRACT_ADDRESS +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" 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 new file mode 100755 index 00000000000..678c2a9f95c --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Deploys L2 contracts + +set -eu + +# Wait for PXE service to be ready +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 "PXE service is ready!" + +# Deploy L2 contracts +export AZTEC_NODE_URL="http://127.0.0.1:8080" +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts +echo "Deployed L2 contracts" +# Use file just as done signal +echo "" > l2-contracts.env \ 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 new file mode 100755 index 00000000000..c5432ad0786 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/ethereum.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -eu +# Starts the Ethereum node using Anvil + +# Ensure anvil is installed +command -v anvil >/dev/null 2>&1 || { echo >&2 "Anvil is not installed. Aborting."; exit 1; } + +# Start Anvil with specified parameters +anvil \ + --host 0.0.0.0 \ + --block-time 12 \ + --chain-id 31337 \ + --gas-limit 1000000000 \ + -p 8545 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 new file mode 100755 index 00000000000..22ab695a9cb --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/prover-node.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -eu + +# Starts the Prover 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 + sleep 1 +done + +source "$REPO"/yarn-project/end-to-end/scripts/native-network/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 $BOOT_NODE_URL) + +# Extract boot node ENR +export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') + +# Set environment variables +export PORT="8080" +export LOG_LEVEL="debug" +export LOG_JSON="1" +export DEBUG="aztec:*" +export ETHEREUM_HOST="http://127.0.0.1:8545" +export PROVER_REAL_PROOFS="false" +export PROVER_AGENT_ENABLED="true" +export PROVER_PUBLISHER_PRIVATE_KEY="0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97" +export PROVER_COORDINATION_NODE_URL="127.0.0.1:8080" +export AZTEC_NODE_URL="127.0.0.1:8080" + +# Start the Prover Node with the prover and archiver +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --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 new file mode 100755 index 00000000000..b9c71e121e1 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -eu + +# Starts the PXE (Private eXecution Environment) service +# Set environment variables +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 DEBUG="aztec:*" +export PXE_PORT="http://127.0.0.1:8079" + +echo "Waiting for Aztec Node..." +until curl -s http://127.0.0.1:8080/status; do + sleep 1 +done + +# Start the PXE service +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --pxe 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 new file mode 100755 index 00000000000..27e83811736 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/transaction-bot.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -eu +# Starts the transaction bot + +# Wait for the Aztec Node to be ready +echo "Waiting for Aztec Node..." +until curl -s http://127.0.0.1:8080/status; do + 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 + sleep 1 +done + +# Set environment variables +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 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_NO_START="false" +export PXE_PROVER_ENABLED="false" +export PROVER_REAL_PROOFS="false" + +# Start the bot +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --pxe --bot diff --git a/yarn-project/end-to-end/scripts/native-network/validator.sh b/yarn-project/end-to-end/scripts/native-network/validator.sh new file mode 100755 index 00000000000..ff1d5aef7d3 --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -eu + +export PORT="$1" + +# 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 + sleep 1 +done + +source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env + +echo "Waiting for Aztec Node..." +until curl -s http://127.0.0.1:8080/status; do + sleep 1 +done + +# Set the boot node URL +BOOT_NODE_URL="http://127.0.0.1:8080" + +# Get node info from the boot node +output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-node-info -u $BOOT_NODE_URL) + +# Extract boot node ENR +export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') + +# 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 VALIDATOR_PRIVATE_KEY=$(echo $json_account | jq -r '.privateKey') +export L1_PRIVATE_KEY=$VALIDATOR_PRIVATE_KEY +export SEQ_PUBLISHER_PRIVATE_KEY=$VALIDATOR_PRIVATE_KEY + +# Add L1 validator +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js add-l1-validator --validator $ADDRESS --rollup $ROLLUP_CONTRACT_ADDRESS + +# Fast forward epochs +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js fast-forward-epochs --rollup $ROLLUP_CONTRACT_ADDRESS --count 1 + +# Set environment variables +export LOG_LEVEL="debug" +export LOG_JSON="1" +export 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="0.0.0.0:40400" +export P2P_UDP_ANNOUNCE_ADDR="0.0.0.0:40400" +export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400" +export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400" + +# Start the Validator Node with the sequencer and archiver +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer 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 55428d2c0ec..092313be52d 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -3,90 +3,35 @@ # Starts a test scenario where as many pieces as practical are # just natively running - running on the same computer, no docker or k8s # Usage: ./network_test.sh -# Optional environment variables: -# VALUES_FILE (default: "default.yaml") -set -eux +set -eu # Ensure dependencies are installed -command -v yq || (echo "We need 'yq' installed to be able to query our rendered helm template network config" && exit 1) -command -v tmux || (echo "We need 'tmux' installed to be able to manage terminal sessions" && exit 1) - -# Main positional parameter -TEST="$1" -VALUES_FILE="${VALUES_FILE:-default.yaml}" - -# Path to the multi-YAML file -yaml_file="multi-yaml-file.yaml" - -# The helm charts are our base truth - let's just make helm tell us what the values are and be selective about applying them! -helm template spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ - --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" > "$yaml_file" - -function extract_commands_by_helm_metadata_name() { - resource_name=$1 - - echo "Processing resource: $resource_name" - - # Check if the resource exists - resource_exists=$(yq e "select(.metadata.name == \"$resource_name\") | .metadata.name" $yaml_file) - - if [ -z "$resource_exists" ]; then - echo "Resource $resource_name not found in the YAML file." - echo "----------------------------------------" - return - fi - - # Extract containers within this resource - container_names=$(yq e "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[].name" $yaml_file) - - if [ -z "$container_names" ]; then - echo "Resource $resource_name does not have containers to process." - echo "----------------------------------------" - return - fi - - # Loop through each container in the resource - while IFS= read -r container_name; do - # Extract and join the command array into a string, handle nulls - command=$(yq e -o=json "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .command" $yaml_file | jq -r 'if . == null then "" else join(" ") end') - - # Extract and join the args array into a string, handle nulls - args=$(yq e -o=json "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .args" $yaml_file | jq -r 'if . == null then "" else join(" ") end') - - # Extract environment variables - env_vars=$(yq e "select(.metadata.name == \"$resource_name\") | .spec.template.spec.containers[] | select(.name == \"$container_name\") | .env[]? | .name + \"=\" + .value" $yaml_file) - - # Prepare environment variable exports - env_exports="" - if [ -n "$env_vars" ]; then - while IFS= read -r env_var; do - env_exports+="export $env_var; " - done <<< "$env_vars" - fi - - # Combine the command and args - full_command="echo '$env_exports $command $args'" - - # Pipe the commands for tmux-splits-stdin (one command per line) - echo "$full_command" - done <<< "$container_names" - - echo "Finished processing resource: $resource_name" - echo "----------------------------------------" -} - -# List of resource names to process -resource_names=( - "spartan-aztec-network-ethereum" - "spartan-aztec-network-pxe" - "spartan-aztec-network-bot" - "spartan-aztec-network-boot-node" - "spartan-aztec-network-prover-node" - "spartan-aztec-network-validator" -) - -# Queue all commands to tmux-splits-stdin -for resource_name in "${resource_names[@]}"; do - extract_commands_by_helm_metadata_name "$resource_name" -done | "$(git rev-parse --show-toplevel)/scripts/tmux-splits-stdin "native_network_test_session" +command -v anvil >/dev/null || (echo "We need 'anvil' installed to be able to simulate ethereum" && exit 1) +command -v tmux >/dev/null || (echo "We need 'tmux' installed to be able to manage terminal sessions" && exit 1) + +REPO=$(git rev-parse --show-toplevel) + +if ! command -v node &> /dev/null; then + echo "Node.js is not installed. Please install Node.js version 18 (exactly!)." + exit 1 +fi + +NODE_VERSION=$(node --version | grep -oP 'v\K[0-9]+') +if ! [ "$NODE_VERSION" = 18 ] ; then + echo "Expected node.js version at 18.x.x. You have version $(node --version)." + exit 1 +fi + +cd "$REPO"/yarn-project/end-to-end/scripts/native-network +rm -f l1-contracts.env l2-contracts.env +# Pass all scripts to tmux-split-args +"$REPO"/scripts/tmux-split-args native_network_test_session \ + boot-node.sh \ + deploy-l1-contracts.sh \ + deploy-l2-contracts.sh \ + ethereum.sh \ + prover-node.sh \ + pxe.sh \ + transaction-bot.sh \ + "validator.sh 8081" diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index 00e58e54f4a..be24d2846a0 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -34,53 +34,48 @@ if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotoco exit 1 fi -# Load the Docker images into kind -kind load docker-image aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG -kind load docker-image aztecprotocol/aztec:$AZTEC_DOCKER_TAG +# # Load the Docker images into kind +# kind load docker-image aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG +# kind load docker-image aztecprotocol/aztec:$AZTEC_DOCKER_TAG -# If FRESH_INSTALL is true, delete the namespace -if [ "$FRESH_INSTALL" = "true" ]; then - kubectl delete namespace "$NAMESPACE" --ignore-not-found=true --wait=true --now --timeout=10m -fi +# # If FRESH_INSTALL is true, delete the namespace +# if [ "$FRESH_INSTALL" = "true" ]; then +# kubectl delete namespace "$NAMESPACE" --ignore-not-found=true --wait=true --now --timeout=10m +# fi -function show_status_until_pxe_ready() { - set +x # don't spam with our commands - sleep 15 # let helm upgrade start - for i in {1..100} ; do - if kubectl wait pod -l app==pxe --for=condition=Ready -n "transfer" --timeout=20s >/dev/null 2>/dev/null ; then - break # we are up, stop showing status - fi - # show startup status - kubectl get pods -n "$NAMESPACE" - done -} +# function show_status_until_pxe_ready() { +# set +x # don't spam with our commands +# sleep 15 # let helm upgrade start +# for i in {1..100} ; do +# if kubectl wait pod -l app==pxe --for=condition=Ready -n "transfer" --timeout=20s >/dev/null 2>/dev/null ; then +# break # we are up, stop showing status +# fi +# # show startup status +# kubectl get pods -n "$NAMESPACE" +# done +# } -show_status_until_pxe_ready & +# show_status_until_pxe_ready & -# Install the Helm chart -helm upgrade --install spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ - --namespace "$NAMESPACE" \ - --create-namespace \ - --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" \ - --set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \ - --set ingress.enabled=true \ - --wait \ - --wait-for-jobs=true \ - --timeout=30m +# # Install the Helm chart +# helm upgrade --install spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ +# --namespace "$NAMESPACE" \ +# --create-namespace \ +# --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" \ +# --set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \ +# --wait \ +# --wait-for-jobs=true \ +# --timeout=30m -kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m +# kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m -function forward_pxe_k8s_port() { - # NOTE we fail silently, and work in the background - kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true -} # tunnel in to get access directly to our PXE service in k8s -(kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true) & +(kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9087:8080 2>/dev/null >/dev/null || true) & # run our test in the host network namespace (so we can access the above with localhost) docker run --rm --network=host \ -e SCENARIO=default \ - -e PXE_URL=http://localhost:9082 \ + -e PXE_URL=http://localhost:9087 \ -e DEBUG="aztec:*" \ -e LOG_LEVEL=debug \ -e LOG_JSON=1 \ diff --git a/yarn-project/end-to-end/src/spartan/smoke.test.ts b/yarn-project/end-to-end/src/spartan/smoke.test.ts index f1a58fa1731..d819e93e60b 100644 --- a/yarn-project/end-to-end/src/spartan/smoke.test.ts +++ b/yarn-project/end-to-end/src/spartan/smoke.test.ts @@ -8,7 +8,7 @@ if (!PXE_URL) { const debugLogger = createDebugLogger('aztec:spartan-test:smoke'); // const userLog = createConsoleLogger(); -describe('sample test', () => { +describe('smoke test', () => { let pxe: PXE; beforeAll(async () => { pxe = await createCompatibleClient(PXE_URL, debugLogger); From 50f03e02d70d337a694052159277dd3c385220d1 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sat, 5 Oct 2024 23:17:09 +0000 Subject: [PATCH 04/29] update --- .../end-to-end/scripts/network_test.sh | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index be24d2846a0..00e58e54f4a 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -34,48 +34,53 @@ if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotoco exit 1 fi -# # Load the Docker images into kind -# kind load docker-image aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG -# kind load docker-image aztecprotocol/aztec:$AZTEC_DOCKER_TAG +# Load the Docker images into kind +kind load docker-image aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG +kind load docker-image aztecprotocol/aztec:$AZTEC_DOCKER_TAG -# # If FRESH_INSTALL is true, delete the namespace -# if [ "$FRESH_INSTALL" = "true" ]; then -# kubectl delete namespace "$NAMESPACE" --ignore-not-found=true --wait=true --now --timeout=10m -# fi +# If FRESH_INSTALL is true, delete the namespace +if [ "$FRESH_INSTALL" = "true" ]; then + kubectl delete namespace "$NAMESPACE" --ignore-not-found=true --wait=true --now --timeout=10m +fi -# function show_status_until_pxe_ready() { -# set +x # don't spam with our commands -# sleep 15 # let helm upgrade start -# for i in {1..100} ; do -# if kubectl wait pod -l app==pxe --for=condition=Ready -n "transfer" --timeout=20s >/dev/null 2>/dev/null ; then -# break # we are up, stop showing status -# fi -# # show startup status -# kubectl get pods -n "$NAMESPACE" -# done -# } +function show_status_until_pxe_ready() { + set +x # don't spam with our commands + sleep 15 # let helm upgrade start + for i in {1..100} ; do + if kubectl wait pod -l app==pxe --for=condition=Ready -n "transfer" --timeout=20s >/dev/null 2>/dev/null ; then + break # we are up, stop showing status + fi + # show startup status + kubectl get pods -n "$NAMESPACE" + done +} -# show_status_until_pxe_ready & +show_status_until_pxe_ready & -# # Install the Helm chart -# helm upgrade --install spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ -# --namespace "$NAMESPACE" \ -# --create-namespace \ -# --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" \ -# --set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \ -# --wait \ -# --wait-for-jobs=true \ -# --timeout=30m +# Install the Helm chart +helm upgrade --install spartan "$(git rev-parse --show-toplevel)/spartan/aztec-network/" \ + --namespace "$NAMESPACE" \ + --create-namespace \ + --values "$(git rev-parse --show-toplevel)/spartan/aztec-network/values/$VALUES_FILE" \ + --set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \ + --set ingress.enabled=true \ + --wait \ + --wait-for-jobs=true \ + --timeout=30m -# kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m +kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m +function forward_pxe_k8s_port() { + # NOTE we fail silently, and work in the background + kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true +} # tunnel in to get access directly to our PXE service in k8s -(kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9087:8080 2>/dev/null >/dev/null || true) & +(kubectl port-forward --namespace transfer svc/spartan-aztec-network-pxe 9082:8080 2>/dev/null >/dev/null || true) & # run our test in the host network namespace (so we can access the above with localhost) docker run --rm --network=host \ -e SCENARIO=default \ - -e PXE_URL=http://localhost:9087 \ + -e PXE_URL=http://localhost:9082 \ -e DEBUG="aztec:*" \ -e LOG_LEVEL=debug \ -e LOG_JSON=1 \ From aef20d075122c7ade338d25e7ca4c8e4c054ba41 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 01:25:27 +0000 Subject: [PATCH 05/29] commit all files --- .gitignore | 5 +- scripts/tmux-split-args | 39 ++++++++++++++ spartan/scripts/k8s_log_interleave.py | 53 +++++++++++++++++++ .../end-to-end/scripts/native_network_test.sh | 16 +++--- 4 files changed, 104 insertions(+), 9 deletions(-) create mode 100755 scripts/tmux-split-args create mode 100755 spartan/scripts/k8s_log_interleave.py diff --git a/.gitignore b/.gitignore index 9a2dd48b704..3d05f4652a1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,7 @@ terraform.tfstate* .bb_tmp # Terraform -*.tfvars \ No newline at end of file +*.tfvars + +# tmux +tmux-client-*.log diff --git a/scripts/tmux-split-args b/scripts/tmux-split-args new file mode 100755 index 00000000000..26bfa0efef3 --- /dev/null +++ b/scripts/tmux-split-args @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -eu +# Usage: tmux-splits-stdin ... + +# Launches tmux with 1 window that has as many panes as commands +session_name=$1 + +# Kill any existing tmux session with the same name +tmux kill-session -t "$session_name" 2>/dev/null || true + +# Start a new tmux session +tmux new-session -d -s "$session_name" + +shift 1 +commands=("$@") + +# Set pane-border-status to top and pane-border-format to display pane title +tmux set-option -t "$session_name" pane-border-status top +tmux set-option -t "$session_name" pane-border-format "#{pane_title}" + +# Create the necessary number of panes and set titles +num_commands=${#commands[@]} +for ((i=0; i Date: Sun, 6 Oct 2024 01:28:08 +0000 Subject: [PATCH 06/29] revert --- noir-projects/tmux-splits-stdin | 33 ------------------- .../files/config/config-validator-env.sh | 1 + 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 noir-projects/tmux-splits-stdin diff --git a/noir-projects/tmux-splits-stdin b/noir-projects/tmux-splits-stdin deleted file mode 100644 index 86e6e64b5e2..00000000000 --- a/noir-projects/tmux-splits-stdin +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -set -eux -# Launches tmux with 1 window that has as many panes as lines of input -session_name=$1 - -# Kill any existing tmux session with the same name -tmux kill-session -t "$session_name" || true - -# Start a new tmux session -tmux new-session -d -s "$session_name" - -# Read commands from stdin into an array -commands=() -while IFS= read -r command; do - commands+=("$command") -done - -# Create the necessary number of panes -num_commands=${#commands[@]} -for ((i=1; i /shared/contracts.env export BOOTSTRAP_NODES=$boot_node_enr From 2eaa3b0f9d6dd853febb08d5a74eb36863dd686c Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 01:47:42 +0000 Subject: [PATCH 07/29] ci vs not scripts --- scripts/run_in_bg_args.sh | 37 +++++++++++++++++++ .../{tmux-split-args => tmux_split_args.sh} | 13 ++++++- .../end-to-end/scripts/native_network_test.sh | 17 +++++++-- 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 scripts/run_in_bg_args.sh rename scripts/{tmux-split-args => tmux_split_args.sh} (68%) diff --git a/scripts/run_in_bg_args.sh b/scripts/run_in_bg_args.sh new file mode 100644 index 00000000000..b86f7c202f7 --- /dev/null +++ b/scripts/run_in_bg_args.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -eu + +# Usage: run_bg_args.sh
... +# Runs interleaved commands, with the prefix being the command string passed for each line of input +# *Finishes when the main command exits.* + +# Check if at least two commands are provided (otherwise what is the point) +if [ "$#" -lt 2 ]; then + echo "Usage: $0 ..." + exit 1 +fi + +# Function to run a command and prefix the output +function run_command() { + local cmd="$1" + while IFS= read -r line; do + echo "[$cmd] $line" + done < <($cmd) +} + +# Run each command in the background, piping output through the run_command function +for cmd in "$@"; do + run_command "$cmd" & +done + +# Wait for the first command to finish and capture its exit code +wait ${pids[0]} +first_exit_code=$? + +# Kill any remaining background jobs if first command succeeded +for pid in "${pids[@]:1}"; do + kill "$pid" 2>/dev/null || true +done + +# Exit with the same code as the first command +exit $first_exit_code diff --git a/scripts/tmux-split-args b/scripts/tmux_split_args.sh similarity index 68% rename from scripts/tmux-split-args rename to scripts/tmux_split_args.sh index 26bfa0efef3..f47f779e818 100755 --- a/scripts/tmux-split-args +++ b/scripts/tmux_split_args.sh @@ -1,6 +1,14 @@ #!/usr/bin/env bash set -eu -# Usage: tmux-splits-stdin ... +# Usage: tmux-splits-stdin
... +# Runs commands in parallel in a tmux window. +# *Finishes when the main command exits.* + +# Check if at least two commands are provided (otherwise what is the point) +if [ "$#" -lt 2 ]; then + echo "Usage: $0 ..." + exit 1 +fi # Launches tmux with 1 window that has as many panes as commands session_name=$1 @@ -30,6 +38,9 @@ for ((i=0; i +# Optional environment variables: +# INTERLEAVED (default: "false") should we just start all programs in the background? set -eu @@ -25,9 +27,18 @@ fi cd "$REPO"/yarn-project/end-to-end/scripts/native-network rm -f l1-contracts.env l2-contracts.env -# Pass all scripts to tmux-split-args -"$REPO"/scripts/tmux-split-args native_network_test_session \ - ./boot-node.sh \ + +function run_parallel() { + if [ "${INTERLEAVED:-false}" = true ] ; then + # Run in tmux for local debugging + "$REPO"/scripts/tmux_split_args.sh native_network_test_session $@ + else + # Run interleaved for CI + "$REPO"/scripts/run_interleaved.sh $@ + fi +} + +run_parallel ./boot-node.sh \ ./deploy-l1-contracts.sh \ ./deploy-l2-contracts.sh \ ./ethereum.sh \ From 2fa5e6878472c5e7478baf64b486970c3700e6d8 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 01:56:01 +0000 Subject: [PATCH 08/29] better tests --- .../scripts/native-network/test-transfer.sh | 11 +++++++++++ .../end-to-end/scripts/native_network_test.sh | 3 ++- yarn-project/end-to-end/scripts/network_test.sh | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 yarn-project/end-to-end/scripts/native-network/test-transfer.sh 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 new file mode 100755 index 00000000000..86c0ef2299f --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/test-transfer.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -eu +# Run our test assuming the port in pxe.sh + +export DEBUG="aztec:*" +export 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 +cwd $(git rev-parse --show-toplevel)/yarn-project/end-to-end \ No newline at end of file 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 4a7ce91b339..a74fd5e733b 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -38,7 +38,8 @@ function run_parallel() { fi } -run_parallel ./boot-node.sh \ +run_parallel ./test-transfer.sh \ + ./boot-node.sh \ ./deploy-l1-contracts.sh \ ./deploy-l2-contracts.sh \ ./ethereum.sh \ diff --git a/yarn-project/end-to-end/scripts/network_test.sh b/yarn-project/end-to-end/scripts/network_test.sh index 00e58e54f4a..7dcd25c1712 100755 --- a/yarn-project/end-to-end/scripts/network_test.sh +++ b/yarn-project/end-to-end/scripts/network_test.sh @@ -79,7 +79,6 @@ function forward_pxe_k8s_port() { # run our test in the host network namespace (so we can access the above with localhost) docker run --rm --network=host \ - -e SCENARIO=default \ -e PXE_URL=http://localhost:9082 \ -e DEBUG="aztec:*" \ -e LOG_LEVEL=debug \ From 4ac2fb26d85cab7828c6b111e72ab20eb59fe868 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 01:59:14 +0000 Subject: [PATCH 09/29] rename --- scripts/{run_in_bg_args.sh => run_interleaved.sh} | 0 .../end-to-end/scripts/native-network/test-transfer.sh | 3 +-- yarn-project/end-to-end/scripts/native_network_test.sh | 4 +++- 3 files changed, 4 insertions(+), 3 deletions(-) rename scripts/{run_in_bg_args.sh => run_interleaved.sh} (100%) diff --git a/scripts/run_in_bg_args.sh b/scripts/run_interleaved.sh similarity index 100% rename from scripts/run_in_bg_args.sh rename to scripts/run_interleaved.sh 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 86c0ef2299f..6c0f78629a5 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 @@ -7,5 +7,4 @@ export DEBUG="aztec:*" export 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 -cwd $(git rev-parse --show-toplevel)/yarn-project/end-to-end \ No newline at end of file +yarn test src/spartan/transfer.test.ts \ No newline at end of file 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 a74fd5e733b..7c36b2373c3 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -29,7 +29,7 @@ cd "$REPO"/yarn-project/end-to-end/scripts/native-network rm -f l1-contracts.env l2-contracts.env function run_parallel() { - if [ "${INTERLEAVED:-false}" = true ] ; then + if [ "${INTERLEAVED:-false}" = "false" ] ; then # Run in tmux for local debugging "$REPO"/scripts/tmux_split_args.sh native_network_test_session $@ else @@ -38,6 +38,8 @@ function run_parallel() { fi } +# We exit with the return code of the first command +# While the others are ran in the background, either in tmux or just interleaved run_parallel ./test-transfer.sh \ ./boot-node.sh \ ./deploy-l1-contracts.sh \ From 4d601f893025619d73d9986310e0cff44d125eed Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 02:03:32 +0000 Subject: [PATCH 10/29] rename --- scripts/tmux_split_args.sh | 2 +- yarn-project/end-to-end/scripts/native_network_test.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tmux_split_args.sh b/scripts/tmux_split_args.sh index f47f779e818..237d54c1608 100755 --- a/scripts/tmux_split_args.sh +++ b/scripts/tmux_split_args.sh @@ -39,7 +39,7 @@ for ((i=0; i Date: Sun, 6 Oct 2024 02:07:29 +0000 Subject: [PATCH 11/29] go after improper usage --- avm-transpiler/scripts/compile_then_transpile.sh | 4 ++-- aztec-up/bin/aztec | 4 ++-- aztec-up/bin/aztec-nargo | 4 ++-- aztec-up/bin/aztec-wallet | 2 +- barretenberg/acir_tests/run_acir_tests_browser.sh | 2 +- barretenberg/bootstrap.sh | 4 ++-- yarn-project/builder/aztec-builder-dest | 2 +- yarn-project/cli-wallet/wallet-entrypoint.sh | 2 +- yarn-project/end-to-end/Makefile | 2 +- yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh | 2 +- yarn-project/end-to-end/scripts/e2e_test.sh | 2 +- yarn-project/end-to-end/scripts/start_e2e.sh | 2 +- yarn-project/scripts/run_script.sh | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index 97303dd314b..fec470bb0af 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -12,13 +12,13 @@ TRANSPILER=${TRANSPILER:-avm-transpiler} if [ "${1:-}" != "compile" ]; then # if not compiling, just pass through to nargo verbatim - $NARGO $@ + $NARGO "$@" exit $? fi shift # remove the compile arg so we can inject --show-artifact-paths # Forward all arguments to nargo, tee output to console -artifacts_to_transpile=$($NARGO compile --show-artifact-paths $@ | tee /dev/tty | grep -oP 'Saved contract artifact to: \K.*') +artifacts_to_transpile=$($NARGO compile --show-artifact-paths "$@" | tee /dev/tty | grep -oP 'Saved contract artifact to: \K.*') # NOTE: the output that is teed to /dev/tty will normally not be redirectable by the caller. # If the script is run via docker, however, the user will see this output on stdout and will be able to redirect. diff --git a/aztec-up/bin/aztec b/aztec-up/bin/aztec index 998d05478de..5962ffaa9d3 100755 --- a/aztec-up/bin/aztec +++ b/aztec-up/bin/aztec @@ -12,7 +12,7 @@ function get_compose { # Favour 'docker compose', falling back on docker-compose. CMD="docker compose" $CMD &>/dev/null || CMD="docker-compose" - $CMD $@ + $CMD "$@" } # Function to parse the TypeScript file @@ -21,7 +21,7 @@ function parse_ts_file { } function cleanup { - get_compose $@ down + get_compose "$@" down } CALLED_FROM=$PWD diff --git a/aztec-up/bin/aztec-nargo b/aztec-up/bin/aztec-nargo index c3437a78e08..59a8e423870 100755 --- a/aztec-up/bin/aztec-nargo +++ b/aztec-up/bin/aztec-nargo @@ -6,7 +6,7 @@ export SKIP_PORT_ASSIGNMENT=1 export PATH=$PATH:$HOME/bin if [ "${1:-}" == "lsp" ]; then - docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/aztec-nargo $@ + docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/aztec-nargo "$@" else - $(dirname $0)/.aztec-run aztecprotocol/aztec-nargo $@ + $(dirname $0)/.aztec-run aztecprotocol/aztec-nargo "$@" fi diff --git a/aztec-up/bin/aztec-wallet b/aztec-up/bin/aztec-wallet index 675b8bfeda6..1d45e13c06d 100755 --- a/aztec-up/bin/aztec-wallet +++ b/aztec-up/bin/aztec-wallet @@ -7,4 +7,4 @@ export ENV_VARS_TO_INJECT="WALLET_DATA_DIRECTORY SSH_AUTH_SOCK" mkdir -p $WALLET_DATA_DIRECTORY -$(dirname $0)/.aztec-run aztecprotocol/cli-wallet $@ \ No newline at end of file +$(dirname $0)/.aztec-run aztecprotocol/cli-wallet "$@" \ No newline at end of file diff --git a/barretenberg/acir_tests/run_acir_tests_browser.sh b/barretenberg/acir_tests/run_acir_tests_browser.sh index 1c1f2ce0e08..61daee3356e 100755 --- a/barretenberg/acir_tests/run_acir_tests_browser.sh +++ b/barretenberg/acir_tests/run_acir_tests_browser.sh @@ -18,5 +18,5 @@ THREAD_MODEL=${THREAD_MODEL:-mt} echo "Testing thread model: $THREAD_MODEL" (cd browser-test-app && yarn serve:dest:$THREAD_MODEL) > /dev/null 2>&1 & sleep 1 -VERBOSE=1 BIN=./headless-test/bb.js.browser ./run_acir_tests.sh $@ +VERBOSE=1 BIN=./headless-test/bb.js.browser ./run_acir_tests.sh "$@" lsof -i ":8080" | awk 'NR>1 {print $2}' | xargs kill -9 diff --git a/barretenberg/bootstrap.sh b/barretenberg/bootstrap.sh index c16fd294b6c..d0d339da951 100755 --- a/barretenberg/bootstrap.sh +++ b/barretenberg/bootstrap.sh @@ -3,5 +3,5 @@ set -eu cd "$(dirname "$0")" -(cd cpp && ./bootstrap.sh $@) -(cd ts && ./bootstrap.sh $@) +(cd cpp && ./bootstrap.sh "$@") +(cd ts && ./bootstrap.sh "$@") diff --git a/yarn-project/builder/aztec-builder-dest b/yarn-project/builder/aztec-builder-dest index 3a0f43e3061..bbdd765a760 100755 --- a/yarn-project/builder/aztec-builder-dest +++ b/yarn-project/builder/aztec-builder-dest @@ -1,3 +1,3 @@ #!/bin/sh SCRIPT_PATH=$(dirname $(realpath $0)) -node --no-warnings $SCRIPT_PATH/dest/bin/cli.js $@ +node --no-warnings $SCRIPT_PATH/dest/bin/cli.js "$@" diff --git a/yarn-project/cli-wallet/wallet-entrypoint.sh b/yarn-project/cli-wallet/wallet-entrypoint.sh index 7629e9bde26..e6d1fb3adc9 100755 --- a/yarn-project/cli-wallet/wallet-entrypoint.sh +++ b/yarn-project/cli-wallet/wallet-entrypoint.sh @@ -13,4 +13,4 @@ if [[ -n "${SSH_AUTH_SOCK_SOCAT_PORT:-}" ]]; then export SSH_AUTH_SOCK="${SOCKET:-}" fi -node --no-warnings /usr/src/yarn-project/cli-wallet/dest/bin/index.js $@ +node --no-warnings /usr/src/yarn-project/cli-wallet/dest/bin/index.js "$@" diff --git a/yarn-project/end-to-end/Makefile b/yarn-project/end-to-end/Makefile index 6c04c93a441..9f7c37a32df 100644 --- a/yarn-project/end-to-end/Makefile +++ b/yarn-project/end-to-end/Makefile @@ -3,7 +3,7 @@ # We have to use a Makefile to run them all parallel interleaved while preserving error codes. # perform an end-to-end test with an earthly build +%: - earthly $@ + earthly "$@" DEPS := $(shell earthly ls) # perform all, meant to be used with -j diff --git a/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh b/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh index f03ae0e1abb..b451304a4e0 100755 --- a/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh +++ b/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh @@ -36,7 +36,7 @@ fi # echo "Parent PID: $PARENT_PID" # Start anvil in the background. -anvil $@ & +anvil "$@" & CHILD_PID=$! cleanup() { diff --git a/yarn-project/end-to-end/scripts/e2e_test.sh b/yarn-project/end-to-end/scripts/e2e_test.sh index 3dcf49edfac..8a3aa7fcc1c 100755 --- a/yarn-project/end-to-end/scripts/e2e_test.sh +++ b/yarn-project/end-to-end/scripts/e2e_test.sh @@ -20,4 +20,4 @@ if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotoco exit 1 fi -docker run -e HARDWARE_CONCURRENCY="$HARDWARE_CONCURRENCY" -e FAKE_PROOFS="$FAKE_PROOFS" --rm aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG "$TEST" $@ +docker run -e HARDWARE_CONCURRENCY="$HARDWARE_CONCURRENCY" -e FAKE_PROOFS="$FAKE_PROOFS" --rm aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG "$TEST" "$@" diff --git a/yarn-project/end-to-end/scripts/start_e2e.sh b/yarn-project/end-to-end/scripts/start_e2e.sh index 018c3d79603..67ea77ff218 100755 --- a/yarn-project/end-to-end/scripts/start_e2e.sh +++ b/yarn-project/end-to-end/scripts/start_e2e.sh @@ -2,4 +2,4 @@ set -eu export NODE_NO_WARNINGS=1 -node ${NODE_ARGS-} --openssl-legacy-provider --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --passWithNoTests $@ +node ${NODE_ARGS-} --openssl-legacy-provider --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --passWithNoTests "$@" diff --git a/yarn-project/scripts/run_script.sh b/yarn-project/scripts/run_script.sh index 7ec857a955f..72e70aa3212 100755 --- a/yarn-project/scripts/run_script.sh +++ b/yarn-project/scripts/run_script.sh @@ -11,4 +11,4 @@ REPO="yarn-project" retry docker pull $(calculate_image_uri $REPO) retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest -docker run ${DOCKER_RUN_OPTS:-} --rm aztecprotocol/$REPO:latest $@ +docker run ${DOCKER_RUN_OPTS:-} --rm aztecprotocol/$REPO:latest "$@" From 64f7ac9c309db15ba6c6e73f0a5b0460add2f2e8 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 17:41:00 +0000 Subject: [PATCH 12/29] iteration --- .../scripts/native-network/prover-node.sh | 2 +- .../end-to-end/scripts/native-network/pxe.sh | 2 +- .../scripts/native-network/test-transfer.sh | 15 +++++++++++++++ .../scripts/native-network/transaction-bot.sh | 11 ++++++++--- .../scripts/native-network/validator.sh | 2 +- 5 files changed, 26 insertions(+), 6 deletions(-) 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 22ab695a9cb..996cd4dfe24 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 @@ -12,7 +12,7 @@ done source "$REPO"/yarn-project/end-to-end/scripts/native-network/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 $BOOT_NODE_URL) +output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-node-info -u 127.0.0.1:8080) # Extract boot node ENR export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') 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 b9c71e121e1..20f362ec58b 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 @@ export DEBUG="aztec:*" export PXE_PORT="http://127.0.0.1:8079" echo "Waiting for Aztec Node..." -until curl -s http://127.0.0.1:8080/status; do +until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 done 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 6c0f78629a5..a3cef5d6a3e 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 @@ -2,6 +2,21 @@ set -eu # 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/l2-contracts.env ] ; do + sleep 1 +done export DEBUG="aztec:*" export LOG_LEVEL=debug 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 27e83811736..0eae91d5f6e 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 @@ -1,13 +1,18 @@ #!/bin/bash set -eu # Starts the transaction bot +REPO=$(git rev-parse --show-toplevel) -# Wait for the Aztec Node to be ready echo "Waiting for Aztec Node..." -until curl -s http://127.0.0.1:8080/status; do +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/l2-contracts.env ] ; do sleep 1 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 ff1d5aef7d3..910f95e94b6 100755 --- a/yarn-project/end-to-end/scripts/native-network/validator.sh +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -14,7 +14,7 @@ done source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env echo "Waiting for Aztec Node..." -until curl -s http://127.0.0.1:8080/status; do +until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 done From d1da81d1fd4b402b9aa1ea9686f1f1b7bce43bb9 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 18:57:44 +0000 Subject: [PATCH 13/29] improve script logging --- .../end-to-end/scripts/native-network/.gitignore | 3 ++- .../end-to-end/scripts/native-network/boot-node.sh | 7 +++++++ .../scripts/native-network/deploy-l1-contracts.sh | 8 ++++++++ .../scripts/native-network/deploy-l2-contracts.sh | 11 ++++++++++- .../end-to-end/scripts/native-network/ethereum.sh | 7 +++++++ .../end-to-end/scripts/native-network/prover-node.sh | 6 ++++++ yarn-project/end-to-end/scripts/native-network/pxe.sh | 6 ++++++ .../scripts/native-network/test-transfer.sh | 7 +++++++ .../scripts/native-network/transaction-bot.sh | 7 +++++++ .../end-to-end/scripts/native-network/validator.sh | 6 ++++++ .../end-to-end/scripts/native_network_test.sh | 9 +++++++-- 11 files changed, 73 insertions(+), 4 deletions(-) diff --git a/yarn-project/end-to-end/scripts/native-network/.gitignore b/yarn-project/end-to-end/scripts/native-network/.gitignore index 2c3814328bf..8b5dc6656c3 100644 --- a/yarn-project/end-to-end/scripts/native-network/.gitignore +++ b/yarn-project/end-to-end/scripts/native-network/.gitignore @@ -1,2 +1,3 @@ l1-contracts.env -l2-contracts.env \ No newline at end of file +l2-contracts.env +*.log \ No newline at end of file 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 b2fc85cb576..32d604f3285 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 @@ -1,5 +1,12 @@ #!/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) + # Starts the Boot Node # Set environment variables 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 cda06ea6448..b08e008cdb2 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 @@ -1,5 +1,11 @@ #!/bin/bash +# 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) + # Deploys L1 contracts and captures the output set -eu @@ -36,3 +42,5 @@ export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$FEE_JUICE_PORTAL_CONTRACT_ADDRESS EOCONFIG echo "Contract addresses saved to l1-contracts.env" +sleep 5 +tmux kill-pane \ No newline at end of file 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 678c2a9f95c..b2620a5dd07 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 @@ -1,5 +1,11 @@ #!/bin/bash +# 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) + # Deploys L2 contracts set -eu @@ -18,4 +24,7 @@ export AZTEC_NODE_URL="http://127.0.0.1:8080" node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts echo "Deployed L2 contracts" # Use file just as done signal -echo "" > l2-contracts.env \ No newline at end of file +echo "" > l2-contracts.env +echo "Wrote to l2-contracts.env to signal completion" +sleep 5 +tmux kill-pane \ 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 c5432ad0786..c58753ce00b 100755 --- a/yarn-project/end-to-end/scripts/native-network/ethereum.sh +++ b/yarn-project/end-to-end/scripts/native-network/ethereum.sh @@ -1,5 +1,12 @@ #!/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) + # Starts the Ethereum node using Anvil # Ensure anvil is installed 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 996cd4dfe24..5f49d2ad4d4 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,6 +1,12 @@ #!/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) + # Starts the Prover Node REPO=$(git rev-parse --show-toplevel) 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 20f362ec58b..86fb0f1995b 100755 --- a/yarn-project/end-to-end/scripts/native-network/pxe.sh +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -1,6 +1,12 @@ #!/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) + # Starts the PXE (Private eXecution Environment) service # Set environment variables export ETHEREUM_HOST="http://127.0.0.1:8545" 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 a3cef5d6a3e..d154e975001 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 @@ -1,6 +1,13 @@ #!/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) + # Run our test assuming the port in pxe.sh # Wait for the Aztec Node to be ready echo "Waiting for Aztec Node..." 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 0eae91d5f6e..7bdce5fcb06 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 @@ -1,5 +1,12 @@ #!/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) + # Starts the transaction bot REPO=$(git rev-parse --show-toplevel) 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 910f95e94b6..d3849b9ee9d 100755 --- a/yarn-project/end-to-end/scripts/native-network/validator.sh +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -1,6 +1,12 @@ #!/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) + export PORT="$1" # Starts the Validator Node 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 4eb0caa31b6..112b455b148 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -1,8 +1,13 @@ #!/bin/bash +# Usage: ./native_network_test.sh # Starts a test scenario where as many pieces as practical are # just natively running - running on the same computer, no docker or k8s -# Usage: ./network_test.sh +# The script exits when the first command used, the test command, exits. +# All scripts are in the native-network folder +# The will run in parallel either in tmux or just interleaved +# They will log to native-network/logs, where it is easier to debug errors further up the logs, while watching tmux helps catch issues live, +# or where things crash and need to be tweaked and restarted. # Optional environment variables: # INTERLEAVED (default: "false") should we just start all programs in the background? @@ -26,7 +31,7 @@ if ! [ "$NODE_VERSION" = 18 ] ; then fi cd "$REPO"/yarn-project/end-to-end/scripts/native-network -rm -f l1-contracts.env l2-contracts.env +rm -f l1-contracts.env l2-contracts.env logs/*.log function run_parallel() { if [ "${INTERLEAVED:-false}" = "false" ] ; then From 15fd463f883c89cd0743e35e757f5e2199a52ad5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 19:05:11 +0000 Subject: [PATCH 14/29] boot node no deploy redundantly --- .../end-to-end/scripts/native-network/boot-node.sh | 4 ---- .../end-to-end/scripts/native_network_test.sh | 14 +++++++------- 2 files changed, 7 insertions(+), 11 deletions(-) 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 32d604f3285..6f4c2f6bcfe 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 @@ -33,9 +33,5 @@ done source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env -# Wait for anvil and deploy contracts -# source this script to get the L1 contract addresses in env -source "$REPO"/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh - # Start the Aztec node with the sequencer and archiver node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe 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 112b455b148..1dc56c917ca 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -47,10 +47,10 @@ function run_parallel() { # While the others are ran in the background, either in tmux or just interleaved run_parallel ./test-transfer.sh \ ./boot-node.sh \ - ./deploy-l1-contracts.sh \ - ./deploy-l2-contracts.sh \ - ./ethereum.sh \ - ./prover-node.sh \ - ./pxe.sh \ - ./transaction-bot.sh \ - "./validator.sh 8081" + ./deploy-l1-contracts.sh \ + ./deploy-l2-contracts.sh \ + ./ethereum.sh \ + ./prover-node.sh \ + ./pxe.sh \ + ./transaction-bot.sh \ + "./validator.sh 8081" From befc67c511b073a4781e62c8ef565b50b5a99e54 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 6 Oct 2024 19:59:15 +0000 Subject: [PATCH 15/29] iteration on tmux splits --- scripts/tmux_split_args.sh | 4 ++-- yarn-project/end-to-end/scripts/native_network_test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tmux_split_args.sh b/scripts/tmux_split_args.sh index 237d54c1608..2fbe88d7453 100755 --- a/scripts/tmux_split_args.sh +++ b/scripts/tmux_split_args.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -eu -# Usage: tmux-splits-stdin
... +# Usage: tmux_splits_args.sh
... # Runs commands in parallel in a tmux window. # *Finishes when the main command exits.* @@ -39,7 +39,7 @@ for ((i=0; i Date: Mon, 7 Oct 2024 08:13:10 +0000 Subject: [PATCH 16/29] fixes --- .../scripts/native-network/deploy-l2-contracts.sh | 1 + .../scripts/native-network/prover-node.sh | 9 ++++----- .../end-to-end/scripts/native-network/pxe.sh | 3 +-- .../scripts/native-network/test-transfer.sh | 1 + .../end-to-end/scripts/native-network/validator.sh | 14 +++++--------- 5 files changed, 12 insertions(+), 16 deletions(-) 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 b2620a5dd07..d547b421732 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 @@ -21,6 +21,7 @@ echo "PXE service is ready!" # Deploy L2 contracts export AZTEC_NODE_URL="http://127.0.0.1:8080" +export PXE_URL="http://127.0.0.1:8079" node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts echo "Deployed L2 contracts" # Use file just as done signal 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 5f49d2ad4d4..412577a8a7c 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 @@ -18,13 +18,12 @@ done source "$REPO"/yarn-project/end-to-end/scripts/native-network/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 127.0.0.1:8080) +output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-node-info -u http://127.0.0.1:8080) # Extract boot node ENR export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') # Set environment variables -export PORT="8080" export LOG_LEVEL="debug" export LOG_JSON="1" export DEBUG="aztec:*" @@ -32,8 +31,8 @@ export ETHEREUM_HOST="http://127.0.0.1:8545" export PROVER_REAL_PROOFS="false" export PROVER_AGENT_ENABLED="true" export PROVER_PUBLISHER_PRIVATE_KEY="0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97" -export PROVER_COORDINATION_NODE_URL="127.0.0.1:8080" -export AZTEC_NODE_URL="127.0.0.1:8080" +export PROVER_COORDINATION_NODE_URL="http://127.0.0.1:8080" +export AZTEC_NODE_URL="http://127.0.0.1:8080" # Start the Prover Node with the prover and archiver -node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --prover-node --prover --archiver +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --port=8078 --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 86fb0f1995b..8c1da8da995 100755 --- a/yarn-project/end-to-end/scripts/native-network/pxe.sh +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -14,7 +14,6 @@ export AZTEC_NODE_URL="http://127.0.0.1:8080" export LOG_JSON="1" export LOG_LEVEL="debug" export DEBUG="aztec:*" -export PXE_PORT="http://127.0.0.1:8079" echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do @@ -22,4 +21,4 @@ until curl -s http://127.0.0.1:8080/status >/dev/null ; do done # Start the PXE service -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --pxe +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --port=8079 --pxe 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 d154e975001..25f24fcd4cf 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 @@ -8,6 +8,7 @@ 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..." 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 d3849b9ee9d..5b33e60fc61 100755 --- a/yarn-project/end-to-end/scripts/native-network/validator.sh +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -39,14 +39,6 @@ export ADDRESS=$(echo $json_account | jq -r '.address') 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 - -# Add L1 validator -node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js add-l1-validator --validator $ADDRESS --rollup $ROLLUP_CONTRACT_ADDRESS - -# Fast forward epochs -node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js fast-forward-epochs --rollup $ROLLUP_CONTRACT_ADDRESS --count 1 - -# Set environment variables export LOG_LEVEL="debug" export LOG_JSON="1" export DEBUG="aztec:*,-aztec:avm_simulator:*" @@ -60,5 +52,9 @@ export P2P_UDP_ANNOUNCE_ADDR="0.0.0.0:40400" export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400" export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400" +# Add L1 validator +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js add-l1-validator --validator $ADDRESS --rollup $ROLLUP_CONTRACT_ADDRESS +# Fast forward epochs +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 --node --archiver --sequencer +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node -- --archiver --sequencer From f9eb2bb2ec6993fc8d6e05432fd4b7ff61f04d4e Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 09:32:05 +0000 Subject: [PATCH 17/29] better errors --- .github/ensure-tester/action.yml | 1 + .../aztec.js/src/rpc_clients/node/index.ts | 16 ++++++++++++---- .../src/json-rpc/client/json_rpc_client.ts | 10 +++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/ensure-tester/action.yml b/.github/ensure-tester/action.yml index ca85b7da853..db4d711025e 100644 --- a/.github/ensure-tester/action.yml +++ b/.github/ensure-tester/action.yml @@ -96,6 +96,7 @@ runs: - name: Ensure Tester Cleanup uses: gacts/run-and-post-run@v1 + if: always() with: post: scripts/run_on_tester "sudo shutdown now" || true diff --git a/yarn-project/aztec.js/src/rpc_clients/node/index.ts b/yarn-project/aztec.js/src/rpc_clients/node/index.ts index 9029ac67383..72784ab7fe5 100644 --- a/yarn-project/aztec.js/src/rpc_clients/node/index.ts +++ b/yarn-project/aztec.js/src/rpc_clients/node/index.ts @@ -2,10 +2,15 @@ import { type PXE } from '@aztec/circuit-types'; import { type DebugLogger } from '@aztec/foundation/log'; import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry'; + + import axios, { type AxiosError, type AxiosResponse } from 'axios'; + + import { createPXEClient } from '../pxe_client.js'; + /** * A fetch implementation using axios. * @param host - The URL of the host. @@ -47,10 +52,13 @@ async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndp const isOK = resp.status >= 200 && resp.status < 300; if (isOK) { return resp.data; - } else if (resp.status >= 400 && resp.status < 500) { - throw new NoRetryError('(JSON-RPC PROPAGATED) ' + resp.data.error.message); } else { - throw new Error('(JSON-RPC PROPAGATED) ' + resp.data.error.message); + const errorMessage = `(JSON-RPC PROPAGATED) (host ${host}) (method ${rpcMethod}) (code ${resp.data.status}) ${resp.data.error.message}`; + if (resp.status >= 400 && resp.status < 500) { + throw new NoRetryError(errorMessage); + } else { + throw new Error(errorMessage); + } } } @@ -75,4 +83,4 @@ export function createCompatibleClient(rpcUrl: string, logger: DebugLogger): Pro const pxe = createPXEClient(rpcUrl, fetch); return Promise.resolve(pxe); -} +} \ No newline at end of file diff --git a/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts b/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts index a29e23d3580..80a6d533177 100644 --- a/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts +++ b/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts @@ -5,11 +5,14 @@ import { type RemoteObject } from 'comlink'; import { format } from 'util'; + + import { type DebugLogger, createDebugLogger } from '../../log/index.js'; import { NoRetryError, makeBackoff, retry } from '../../retry/index.js'; import { ClassConverter, type JsonClassConverterInput, type StringClassConverterInput } from '../class_converter.js'; import { JsonStringify, convertFromJsonObj, convertToJsonObj } from '../convert.js'; + export { JsonStringify } from '../convert.js'; const log = createDebugLogger('json-rpc:json_rpc_client'); @@ -56,10 +59,11 @@ export async function defaultFetch( throw new Error(`Failed to parse body as JSON: ${resp.text()}`); } if (!resp.ok) { + const errorMessage = `(JSON-RPC PROPAGATED) (host ${host}) (method ${rpcMethod}) (code ${resp.status}) ${responseJson.error.message}`; if (noRetry || (resp.status >= 400 && resp.status < 500)) { - throw new NoRetryError('(JSON-RPC PROPAGATED) ' + responseJson.error.message); + throw new NoRetryError(errorMessage); } else { - throw new Error('(JSON-RPC PROPAGATED) ' + responseJson.error.message); + throw new Error(errorMessage); } } @@ -144,4 +148,4 @@ export function createJsonRpcClient( }, }, ) as RemoteObject; -} +} \ No newline at end of file From 945594f6ec2536c6784a4e7ed0a022e6d35ad49d Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 10:04:28 +0000 Subject: [PATCH 18/29] improve logging --- yarn-project/aztec/src/sandbox.ts | 2 ++ .../src/prover_coordination/epoch_proof_quote.ts | 5 +++-- .../infrastructure/deploy_protocol_contract.ts | 14 +++++++++----- yarn-project/cli/src/cmds/misc/deploy_contracts.ts | 4 ++++ .../scripts/native-network/logs/README.md | 2 ++ .../scripts/native-network/prover-node.sh | 1 - .../end-to-end/scripts/native-network/validator.sh | 5 ++--- 7 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 yarn-project/end-to-end/scripts/native-network/logs/README.md diff --git a/yarn-project/aztec/src/sandbox.ts b/yarn-project/aztec/src/sandbox.ts index 9e508647a4b..1f3d465c2b4 100644 --- a/yarn-project/aztec/src/sandbox.ts +++ b/yarn-project/aztec/src/sandbox.ts @@ -195,6 +195,8 @@ export async function createSandbox(config: Partial = {}) { await deployCanonicalL2FeeJuice( new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(aztecNodeConfig.l1ChainId, aztecNodeConfig.version)), aztecNodeConfig.l1Contracts.feeJuicePortalAddress, + undefined, + logger.info ); } diff --git a/yarn-project/circuit-types/src/prover_coordination/epoch_proof_quote.ts b/yarn-project/circuit-types/src/prover_coordination/epoch_proof_quote.ts index cfa073407cf..69a1dad25ff 100644 --- a/yarn-project/circuit-types/src/prover_coordination/epoch_proof_quote.ts +++ b/yarn-project/circuit-types/src/prover_coordination/epoch_proof_quote.ts @@ -1,5 +1,5 @@ import { Buffer32 } from '@aztec/foundation/buffer'; -import { type Secp256k1Signer } from '@aztec/foundation/crypto'; +import { keccak256, type Secp256k1Signer } from '@aztec/foundation/crypto'; import { Signature } from '@aztec/foundation/eth-signature'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; @@ -20,7 +20,8 @@ export class EpochProofQuote extends Gossipable { } override p2pMessageIdentifier(): Buffer32 { - return new Buffer32(this.signature.toBuffer()); + // TODO: https://github.com/AztecProtocol/aztec-packages/issues/8911 + return new Buffer32(keccak256(this.signature.toBuffer())); } override toBuffer(): Buffer { diff --git a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts index dae8b36732d..24cbc9e935f 100644 --- a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts +++ b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts @@ -2,8 +2,11 @@ import { SignerlessWallet, type WaitOpts, createPXEClient, makeFetch } from '@az import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint'; import { type LogFn } from '@aztec/foundation/log'; + + import { deployCanonicalAuthRegistry, deployCanonicalL2FeeJuice } from '../misc/deploy_contracts.js'; + const waitOpts: WaitOpts = { timeout: 180, interval: 1, @@ -12,18 +15,19 @@ const waitOpts: WaitOpts = { }; export async function deployProtocolContracts(rpcUrl: string, l1ChainId: number, json: boolean, log: LogFn) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment - // const { TokenContract } = await import('@aztec/noir-contracts.js'); + log('deployProtocolContracts: Creating PXE client...'); const pxe = createPXEClient(rpcUrl, makeFetch([], true)); const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(l1ChainId, 1)); + log('deployProtocolContracts: Deploying canonical auth registry...'); // Deploy Auth Registry const authRegistryAddress = await deployCanonicalAuthRegistry(deployer, waitOpts); + log('deployProtocolContracts: Getting fee juice portal address...'); // Deploy Fee Juice const feeJuicePortalAddress = (await deployer.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress; - const feeJuiceAddress = await deployCanonicalL2FeeJuice(deployer, feeJuicePortalAddress, waitOpts); + log('deployProtocolContracts: Deploying fee juice portal...'); + const feeJuiceAddress = await deployCanonicalL2FeeJuice(deployer, feeJuicePortalAddress, waitOpts, log); if (json) { log( @@ -40,4 +44,4 @@ export async function deployProtocolContracts(rpcUrl: string, l1ChainId: number, log(`Auth Registry: ${authRegistryAddress}`); log(`Fee Juice: ${feeJuiceAddress}`); } -} +} \ No newline at end of file diff --git a/yarn-project/cli/src/cmds/misc/deploy_contracts.ts b/yarn-project/cli/src/cmds/misc/deploy_contracts.ts index 944503a9712..3bf0dbb32de 100644 --- a/yarn-project/cli/src/cmds/misc/deploy_contracts.ts +++ b/yarn-project/cli/src/cmds/misc/deploy_contracts.ts @@ -6,6 +6,7 @@ import { MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, } from '@aztec/circuits.js'; import { bufferAsFields } from '@aztec/foundation/abi'; +import { type LogFn } from '@aztec/foundation/log'; import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry'; import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice'; @@ -16,6 +17,7 @@ export async function deployCanonicalL2FeeJuice( deployer: Wallet, feeJuicePortalAddress: EthAddress, waitOpts = DefaultWaitOpts, + log: LogFn ): Promise { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment @@ -29,8 +31,10 @@ export async function deployCanonicalL2FeeJuice( const publicBytecode = canonicalFeeJuice.contractClass.packedBytecode; const encodedBytecode = bufferAsFields(publicBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS); + log("deployCanonicalL2FeeJuice: Adding capsule..."); await deployer.addCapsule(encodedBytecode); const feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, deployer); + log("deployCanonicalL2FeeJuice: Calling deploy on fee juice contract..."); await feeJuiceContract.methods .deploy( canonicalFeeJuice.contractClass.artifactHash, diff --git a/yarn-project/end-to-end/scripts/native-network/logs/README.md b/yarn-project/end-to-end/scripts/native-network/logs/README.md new file mode 100644 index 00000000000..9454f6d5e8c --- /dev/null +++ b/yarn-project/end-to-end/scripts/native-network/logs/README.md @@ -0,0 +1,2 @@ +Logs from our native-network scripts. +This ensures this folder exists. \ 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 412577a8a7c..6bd86f2bcbb 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 @@ -25,7 +25,6 @@ export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') # Set environment variables export LOG_LEVEL="debug" -export LOG_JSON="1" export DEBUG="aztec:*" export ETHEREUM_HOST="http://127.0.0.1:8545" 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 5b33e60fc61..581b54ac4aa 100755 --- a/yarn-project/end-to-end/scripts/native-network/validator.sh +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -7,7 +7,7 @@ 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) -export PORT="$1" +PORT="$1" # Starts the Validator Node REPO=$(git rev-parse --show-toplevel) @@ -40,7 +40,6 @@ 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 LOG_JSON="1" export DEBUG="aztec:*,-aztec:avm_simulator:*" export ETHEREUM_HOST="http://127.0.0.1:8545" export P2P_ENABLED="true" @@ -57,4 +56,4 @@ node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js add-l1-validator # Fast forward epochs 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 --node -- --archiver --sequencer +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --port="$PORT" --node --archiver --sequencer From f87078f12085f1bda6d9c5050faaa8b69c823fbd Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 13:47:00 +0000 Subject: [PATCH 19/29] try to stabilize network with 0 validators --- .../cli/src/cmds/infrastructure/deploy_protocol_contract.ts | 3 --- yarn-project/end-to-end/scripts/native-network/boot-node.sh | 4 ++-- yarn-project/end-to-end/scripts/native_network_test.sh | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts index 24cbc9e935f..d8cd941ca5a 100644 --- a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts +++ b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts @@ -2,11 +2,8 @@ import { SignerlessWallet, type WaitOpts, createPXEClient, makeFetch } from '@az import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint'; import { type LogFn } from '@aztec/foundation/log'; - - import { deployCanonicalAuthRegistry, deployCanonicalL2FeeJuice } from '../misc/deploy_contracts.js'; - const waitOpts: WaitOpts = { timeout: 180, interval: 1, 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 6f4c2f6bcfe..24149de5e88 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 @@ -19,8 +19,8 @@ export P2P_ENABLED="true" export VALIDATOR_DISABLED="true" export SEQ_MAX_SECONDS_BETWEEN_BLOCKS="0" export SEQ_MIN_TX_PER_BLOCK="1" -export P2P_TCP_ANNOUNCE_ADDR="0.0.0.0:40400" -export P2P_UDP_ANNOUNCE_ADDR="0.0.0.0:40400" +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 VALIDATOR_PRIVATE_KEY="0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a" 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 0a8aaee9b5b..f37e3e5cfc2 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -52,5 +52,5 @@ run_parallel ./test-transfer.sh \ ./ethereum.sh \ ./prover-node.sh \ ./pxe.sh \ - ./transaction-bot.sh \ - "./validator.sh 8081" + ./transaction-bot.sh + # "./validator.sh 8081" From 2346ded9aeb0c850d6e3d5e30477e58026a7c4d2 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 14:50:28 +0000 Subject: [PATCH 20/29] Iterative --- .../end-to-end/scripts/native-network/boot-node.sh | 8 ++++++-- .../scripts/native-network/deploy-l1-contracts.sh | 1 + .../scripts/native-network/deploy-l2-contracts.sh | 2 +- .../end-to-end/scripts/native-network/prover-node.sh | 1 + yarn-project/end-to-end/scripts/native-network/pxe.sh | 8 ++++++-- .../end-to-end/scripts/native-network/test-transfer.sh | 1 + .../end-to-end/scripts/native-network/transaction-bot.sh | 1 + .../end-to-end/scripts/native-network/validator.sh | 5 +++-- 8 files changed, 20 insertions(+), 7 deletions(-) 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 24149de5e88..0bcf282e568 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 @@ -12,7 +12,6 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname # Set environment variables export PORT="8080" export LOG_LEVEL="debug" -export LOG_JSON="1" export DEBUG="aztec:*,-aztec:avm_simulator:*" export ETHEREUM_HOST="http://127.0.0.1:8545" export P2P_ENABLED="true" @@ -30,8 +29,13 @@ echo "Waiting for l1 contracts to be deployed..." until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env ] ; do sleep 1 done +echo "Done waiting." source "$REPO"/yarn-project/end-to-end/scripts/native-network/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" +} + # Start the Aztec node with the sequencer and archiver -node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe | filter_noise \ No newline at end of file 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 b08e008cdb2..cc05f41e5af 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 @@ -16,6 +16,7 @@ until curl -s -X POST -H 'Content-Type: application/json' \ http://127.0.0.1:8545 2>/dev/null | grep -q 'result' ; do sleep 1 done +echo "Done waiting." # Run the deploy-l1-contracts command and capture the output export ETHEREUM_HOST="http://127.0.0.1:8545" 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 d547b421732..638355822e8 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 @@ -17,7 +17,7 @@ until curl -s -X POST -H 'content-type: application/json' \ http://127.0.0.1:8079 | grep -q '"enr:-'; do sleep 1 done -echo "PXE service is ready!" +echo "Done waiting." # Deploy L2 contracts export AZTEC_NODE_URL="http://127.0.0.1:8080" 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 6bd86f2bcbb..bb326896456 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 @@ -14,6 +14,7 @@ echo "Waiting for l1 contracts to be deployed..." until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env ] ; do sleep 1 done +echo "Done waiting." source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env 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 8c1da8da995..6853f0c65aa 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,6 @@ 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_JSON="1" export LOG_LEVEL="debug" export DEBUG="aztec:*" @@ -19,6 +18,11 @@ echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 done +echo "Done waiting." + +function filter_noise() { + grep -v node_getProvenBlockNumber +} # Start the PXE service -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --port=8079 --pxe +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --port=8079 --pxe | filter_noise \ 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 25f24fcd4cf..d6044e4487a 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 @@ -25,6 +25,7 @@ echo "Waiting for l2 contracts to be deployed..." until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l2-contracts.env ] ; do sleep 1 done +echo "Done waiting." export DEBUG="aztec:*" export LOG_LEVEL=debug 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 7bdce5fcb06..5b1db277d96 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 @@ -24,6 +24,7 @@ echo "Waiting for l2 contracts to be deployed..." until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l2-contracts.env ] ; do sleep 1 done +echo "Done waiting." # Set environment variables export ETHEREUM_HOST="http://127.0.0.1:8545" 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 581b54ac4aa..5c9c9fec4c4 100755 --- a/yarn-project/end-to-end/scripts/native-network/validator.sh +++ b/yarn-project/end-to-end/scripts/native-network/validator.sh @@ -23,6 +23,7 @@ echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 done +echo "Done waiting." # Set the boot node URL BOOT_NODE_URL="http://127.0.0.1:8080" @@ -46,8 +47,8 @@ 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="0.0.0.0:40400" -export P2P_UDP_ANNOUNCE_ADDR="0.0.0.0:40400" +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" From df723cc2ae59384ff172419894196e2ca451ac1e Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 15:04:29 +0000 Subject: [PATCH 21/29] proverless fix --- .../deploy_protocol_contract.ts | 23 +++++++++++-------- .../cli/src/cmds/infrastructure/index.ts | 9 +++++++- .../cli/src/cmds/misc/deploy_contracts.ts | 6 ++--- .../scripts/native-network/boot-node.sh | 2 +- .../end-to-end/scripts/native-network/pxe.sh | 5 +++- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts index d8cd941ca5a..38137a73e37 100644 --- a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts +++ b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts @@ -4,14 +4,19 @@ import { type LogFn } from '@aztec/foundation/log'; import { deployCanonicalAuthRegistry, deployCanonicalL2FeeJuice } from '../misc/deploy_contracts.js'; -const waitOpts: WaitOpts = { - timeout: 180, - interval: 1, - proven: true, - provenTimeout: 600, -}; - -export async function deployProtocolContracts(rpcUrl: string, l1ChainId: number, json: boolean, log: LogFn) { +export async function deployProtocolContracts( + rpcUrl: string, + l1ChainId: number, + json: boolean, + waitForProven: boolean, + log: LogFn, +) { + const waitOpts: WaitOpts = { + timeout: 180, + interval: 1, + proven: waitForProven, + provenTimeout: 600, + }; log('deployProtocolContracts: Creating PXE client...'); const pxe = createPXEClient(rpcUrl, makeFetch([], true)); const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(l1ChainId, 1)); @@ -41,4 +46,4 @@ export async function deployProtocolContracts(rpcUrl: string, l1ChainId: number, log(`Auth Registry: ${authRegistryAddress}`); log(`Fee Juice: ${feeJuiceAddress}`); } -} \ No newline at end of file +} diff --git a/yarn-project/cli/src/cmds/infrastructure/index.ts b/yarn-project/cli/src/cmds/infrastructure/index.ts index 873b92ebc26..022e300c0c3 100644 --- a/yarn-project/cli/src/cmds/infrastructure/index.ts +++ b/yarn-project/cli/src/cmds/infrastructure/index.ts @@ -11,9 +11,16 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL .addOption(pxeOption) .addOption(l1ChainIdOption) .option('--json', 'Output the contract addresses in JSON format') + .option('--waitForProven', 'Should we wait for proofs to be posted?', 'true') .action(async options => { const { deployProtocolContracts } = await import('./deploy_protocol_contract.js'); - await deployProtocolContracts(options.rpcUrl, options.l1ChainId, options.json, log); + await deployProtocolContracts( + options.rpcUrl, + options.l1ChainId, + options.json, + options.waitForProven === 'true', + log, + ); }); program diff --git a/yarn-project/cli/src/cmds/misc/deploy_contracts.ts b/yarn-project/cli/src/cmds/misc/deploy_contracts.ts index 3bf0dbb32de..06c4eec340b 100644 --- a/yarn-project/cli/src/cmds/misc/deploy_contracts.ts +++ b/yarn-project/cli/src/cmds/misc/deploy_contracts.ts @@ -17,7 +17,7 @@ export async function deployCanonicalL2FeeJuice( deployer: Wallet, feeJuicePortalAddress: EthAddress, waitOpts = DefaultWaitOpts, - log: LogFn + log: LogFn, ): Promise { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment @@ -31,10 +31,10 @@ export async function deployCanonicalL2FeeJuice( const publicBytecode = canonicalFeeJuice.contractClass.packedBytecode; const encodedBytecode = bufferAsFields(publicBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS); - log("deployCanonicalL2FeeJuice: Adding capsule..."); + log('deployCanonicalL2FeeJuice: Adding capsule...'); await deployer.addCapsule(encodedBytecode); const feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, deployer); - log("deployCanonicalL2FeeJuice: Calling deploy on fee juice contract..."); + log('deployCanonicalL2FeeJuice: Calling deploy on fee juice contract...'); await feeJuiceContract.methods .deploy( canonicalFeeJuice.contractClass.artifactHash, 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 0bcf282e568..6ec8909d3a0 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 @@ -38,4 +38,4 @@ function filter_noise() { } # Start the Aztec node with the sequencer and archiver -node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe | filter_noise \ No newline at end of file +node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe 2>&1 | filter_noise \ No newline at end of file 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 6853f0c65aa..79fb2ff59d9 100755 --- a/yarn-project/end-to-end/scripts/native-network/pxe.sh +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -14,6 +14,9 @@ export AZTEC_NODE_URL="http://127.0.0.1:8080" export LOG_LEVEL="debug" export DEBUG="aztec:*" +# TODO(AD): Add option for prover-enabled mode +WAIT_FOR_PROVEN="false" + echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 @@ -25,4 +28,4 @@ function filter_noise() { } # Start the PXE service -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --port=8079 --pxe | filter_noise \ No newline at end of file +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --waitForProven="$WAIT_FOR_PROVEN" --port=8079 --pxe 2>&1 | filter_noise \ No newline at end of file From c1490f9f53fb329e8e6fe2ca0984009f2d4b3b25 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 15:45:56 +0000 Subject: [PATCH 22/29] add waitForProven flag --- .../cli/src/cmds/infrastructure/index.ts | 4 ++-- .../scripts/native-network/boot-node.sh | 2 +- .../native-network/deploy-l1-contracts.sh | 2 +- .../native-network/deploy-l2-contracts.sh | 7 +++++-- .../scripts/native-network/ethereum.sh | 16 +++++++++++++++- .../end-to-end/scripts/native-network/pxe.sh | 5 +---- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/yarn-project/cli/src/cmds/infrastructure/index.ts b/yarn-project/cli/src/cmds/infrastructure/index.ts index 022e300c0c3..6d48331e5ec 100644 --- a/yarn-project/cli/src/cmds/infrastructure/index.ts +++ b/yarn-project/cli/src/cmds/infrastructure/index.ts @@ -11,14 +11,14 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL .addOption(pxeOption) .addOption(l1ChainIdOption) .option('--json', 'Output the contract addresses in JSON format') - .option('--waitForProven', 'Should we wait for proofs to be posted?', 'true') + .option('--waitForProven', 'Should we wait for proofs to be posted?', true) .action(async options => { const { deployProtocolContracts } = await import('./deploy_protocol_contract.js'); await deployProtocolContracts( options.rpcUrl, options.l1ChainId, options.json, - options.waitForProven === 'true', + options.waitForProven, 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 6ec8909d3a0..ecc5cf83a20 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 @@ -34,7 +34,7 @@ echo "Done waiting." source "$REPO"/yarn-project/end-to-end/scripts/native-network/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" + 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" } # Start the Aztec node with the sequencer and archiver 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 cc05f41e5af..7ff2036f5f3 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 @@ -44,4 +44,4 @@ EOCONFIG echo "Contract addresses saved to l1-contracts.env" sleep 5 -tmux kill-pane \ No newline at end of file +tmux kill-pane -t $(tmux display -p '#{pane_id}') \ No newline at end of file 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 638355822e8..7a23fd6d5ef 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 @@ -19,13 +19,16 @@ until curl -s -X POST -H 'content-type: application/json' \ done echo "Done waiting." +# TODO(AD): Add option for prover-enabled mode +WAIT_FOR_PROVEN="false" + # Deploy L2 contracts export AZTEC_NODE_URL="http://127.0.0.1:8080" export PXE_URL="http://127.0.0.1:8079" -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts --waitForProven "$WAIT_FOR_PROVEN" 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 -tmux kill-pane \ No newline at end of file +tmux kill-pane -t $(tmux display -p '#{pane_id}') \ 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 c58753ce00b..0bedc54556e 100755 --- a/yarn-project/end-to-end/scripts/native-network/ethereum.sh +++ b/yarn-project/end-to-end/scripts/native-network/ethereum.sh @@ -12,10 +12,24 @@ 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." + 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 + sleep 1 + done + echo "Anvil has started." +} +function filter_noise() { + grep -Ev "eth_blockNumber|eth_getTransactionReceipt|eth_getBlockByNumber" +} + +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 + -p 8545 2>&1 | filter_noise 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 79fb2ff59d9..10649d1efa9 100755 --- a/yarn-project/end-to-end/scripts/native-network/pxe.sh +++ b/yarn-project/end-to-end/scripts/native-network/pxe.sh @@ -14,9 +14,6 @@ export AZTEC_NODE_URL="http://127.0.0.1:8080" export LOG_LEVEL="debug" export DEBUG="aztec:*" -# TODO(AD): Add option for prover-enabled mode -WAIT_FOR_PROVEN="false" - echo "Waiting for Aztec Node..." until curl -s http://127.0.0.1:8080/status >/dev/null ; do sleep 1 @@ -28,4 +25,4 @@ function filter_noise() { } # Start the PXE service -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --waitForProven="$WAIT_FOR_PROVEN" --port=8079 --pxe 2>&1 | filter_noise \ No newline at end of file +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --port=8079 --pxe 2>&1 | filter_noise \ No newline at end of file From e9a29f3208afd03bc429357c304f605f17b51a7a Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 15:59:29 +0000 Subject: [PATCH 23/29] skip proof wait fix --- .../infrastructure/deploy_protocol_contract.ts | 10 +++++++--- .../cli/src/cmds/infrastructure/index.ts | 17 ++++++++--------- .../native-network/deploy-l2-contracts.sh | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts index 38137a73e37..fd12dbc02e5 100644 --- a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts +++ b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts @@ -2,21 +2,25 @@ import { SignerlessWallet, type WaitOpts, createPXEClient, makeFetch } from '@az import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint'; import { type LogFn } from '@aztec/foundation/log'; + + import { deployCanonicalAuthRegistry, deployCanonicalL2FeeJuice } from '../misc/deploy_contracts.js'; + export async function deployProtocolContracts( rpcUrl: string, l1ChainId: number, json: boolean, - waitForProven: boolean, + skipProofWait: boolean, log: LogFn, ) { const waitOpts: WaitOpts = { timeout: 180, interval: 1, - proven: waitForProven, + proven: !skipProofWait, provenTimeout: 600, }; + log('deployProtocolContracts: Wait options for deployments' + JSON.stringify(waitOpts)); log('deployProtocolContracts: Creating PXE client...'); const pxe = createPXEClient(rpcUrl, makeFetch([], true)); const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(l1ChainId, 1)); @@ -46,4 +50,4 @@ export async function deployProtocolContracts( log(`Auth Registry: ${authRegistryAddress}`); log(`Fee Juice: ${feeJuiceAddress}`); } -} +} \ No newline at end of file diff --git a/yarn-project/cli/src/cmds/infrastructure/index.ts b/yarn-project/cli/src/cmds/infrastructure/index.ts index 6d48331e5ec..0c8099b21de 100644 --- a/yarn-project/cli/src/cmds/infrastructure/index.ts +++ b/yarn-project/cli/src/cmds/infrastructure/index.ts @@ -1,9 +1,14 @@ import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; + + import { type Command } from 'commander'; + + import { ETHEREUM_HOST, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js'; + export function injectCommands(program: Command, log: LogFn, debugLogger: DebugLogger) { program .command('deploy-protocol-contracts') @@ -11,16 +16,10 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL .addOption(pxeOption) .addOption(l1ChainIdOption) .option('--json', 'Output the contract addresses in JSON format') - .option('--waitForProven', 'Should we wait for proofs to be posted?', true) + .option('--skipProofWait', "Don't wait for proofs to land.") .action(async options => { const { deployProtocolContracts } = await import('./deploy_protocol_contract.js'); - await deployProtocolContracts( - options.rpcUrl, - options.l1ChainId, - options.json, - options.waitForProven, - log, - ); + await deployProtocolContracts(options.rpcUrl, options.l1ChainId, options.json, options.skipProofWait, log); }); program @@ -57,4 +56,4 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL }); return program; -} +} \ No newline at end of file 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 7a23fd6d5ef..69e3d6c3a1f 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 @@ -20,12 +20,12 @@ done echo "Done waiting." # TODO(AD): Add option for prover-enabled mode -WAIT_FOR_PROVEN="false" +ARGS="--skipProofWait" # Deploy L2 contracts export AZTEC_NODE_URL="http://127.0.0.1:8080" export PXE_URL="http://127.0.0.1:8079" -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts --waitForProven "$WAIT_FOR_PROVEN" +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts $ARGS echo "Deployed L2 contracts" # Use file just as done signal echo "" > l2-contracts.env From d6a40fecab1a88ad305447f2103d186090d3b4b4 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 16:40:22 +0000 Subject: [PATCH 24/29] fix serialization issue with DeployProvenTx --- .../aztec.js/src/contract/deploy_proven_tx.ts | 2 +- .../aztec.js/src/contract/proven_tx.ts | 31 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts b/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts index 86f205cf711..43f5d70e449 100644 --- a/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts +++ b/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts @@ -25,7 +25,7 @@ export class DeployProvenTx extends Prove */ public override send(): DeploySentTx { const promise = (() => { - return this.wallet.sendTx(this); + return this.wallet.sendTx(this.getPlainDataTx()); })(); return new DeploySentTx(this.wallet, promise, this.postDeployCtor, this.instance); diff --git a/yarn-project/aztec.js/src/contract/proven_tx.ts b/yarn-project/aztec.js/src/contract/proven_tx.ts index f6654bdec51..cf4853bbebf 100644 --- a/yarn-project/aztec.js/src/contract/proven_tx.ts +++ b/yarn-project/aztec.js/src/contract/proven_tx.ts @@ -1,8 +1,11 @@ import { type PXE, Tx } from '@aztec/circuit-types'; + + import { type Wallet } from '../account/index.js'; import { SentTx } from './sent_tx.js'; + /** * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction. */ @@ -19,25 +22,27 @@ export class ProvenTx extends Tx { ); } + // Clone the TX data to get a serializable object. + protected getPlainDataTx(): Tx { + return new Tx( + this.data, + this.clientIvcProof, + this.noteEncryptedLogs, + this.encryptedLogs, + this.unencryptedLogs, + this.enqueuedPublicFunctionCalls, + this.publicTeardownFunctionCall, + ); + } + /** * Sends the transaction to the network via the provided wallet. */ public send(): SentTx { const promise = (() => { - // Clone the TX data to avoid serializing the ProvenTx object. - return this.wallet.sendTx( - new Tx( - this.data, - this.clientIvcProof, - this.noteEncryptedLogs, - this.encryptedLogs, - this.unencryptedLogs, - this.enqueuedPublicFunctionCalls, - this.publicTeardownFunctionCall, - ), - ); + return this.wallet.sendTx(this.getPlainDataTx()); })(); return new SentTx(this.wallet, promise); } -} +} \ No newline at end of file From e386ff25aa906a54c687305374b7fa6ab4dbea7b Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 20:30:49 +0100 Subject: [PATCH 25/29] Update action.yml --- .github/ensure-tester/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ensure-tester/action.yml b/.github/ensure-tester/action.yml index db4d711025e..ca85b7da853 100644 --- a/.github/ensure-tester/action.yml +++ b/.github/ensure-tester/action.yml @@ -96,7 +96,6 @@ runs: - name: Ensure Tester Cleanup uses: gacts/run-and-post-run@v1 - if: always() with: post: scripts/run_on_tester "sudo shutdown now" || true From 149c5f9495a73f08269d0c3730ef4306982c585b Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 19:33:15 +0000 Subject: [PATCH 26/29] fix tx bot --- .../end-to-end/scripts/native-network/transaction-bot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5b1db277d96..37abb2725f9 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 @@ -42,4 +42,4 @@ export PXE_PROVER_ENABLED="false" export PROVER_REAL_PROOFS="false" # Start the bot -node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --pxe --bot +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --port=8077 --pxe --bot From 0ed4ba52170f0d53cc492e3782b2bb13f1149746 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 19:34:04 +0000 Subject: [PATCH 27/29] revert --- avm-transpiler/scripts/compile_then_transpile.sh | 4 ++-- aztec-up/bin/aztec | 4 ++-- aztec-up/bin/aztec-nargo | 4 ++-- aztec-up/bin/aztec-wallet | 2 +- barretenberg/acir_tests/run_acir_tests_browser.sh | 2 +- barretenberg/bootstrap.sh | 4 ++-- yarn-project/builder/aztec-builder-dest | 2 +- yarn-project/cli-wallet/wallet-entrypoint.sh | 2 +- yarn-project/end-to-end/Makefile | 2 +- yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh | 2 +- yarn-project/end-to-end/scripts/e2e_test.sh | 2 +- yarn-project/end-to-end/scripts/start_e2e.sh | 2 +- yarn-project/scripts/run_script.sh | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/avm-transpiler/scripts/compile_then_transpile.sh b/avm-transpiler/scripts/compile_then_transpile.sh index fec470bb0af..97303dd314b 100755 --- a/avm-transpiler/scripts/compile_then_transpile.sh +++ b/avm-transpiler/scripts/compile_then_transpile.sh @@ -12,13 +12,13 @@ TRANSPILER=${TRANSPILER:-avm-transpiler} if [ "${1:-}" != "compile" ]; then # if not compiling, just pass through to nargo verbatim - $NARGO "$@" + $NARGO $@ exit $? fi shift # remove the compile arg so we can inject --show-artifact-paths # Forward all arguments to nargo, tee output to console -artifacts_to_transpile=$($NARGO compile --show-artifact-paths "$@" | tee /dev/tty | grep -oP 'Saved contract artifact to: \K.*') +artifacts_to_transpile=$($NARGO compile --show-artifact-paths $@ | tee /dev/tty | grep -oP 'Saved contract artifact to: \K.*') # NOTE: the output that is teed to /dev/tty will normally not be redirectable by the caller. # If the script is run via docker, however, the user will see this output on stdout and will be able to redirect. diff --git a/aztec-up/bin/aztec b/aztec-up/bin/aztec index 5962ffaa9d3..998d05478de 100755 --- a/aztec-up/bin/aztec +++ b/aztec-up/bin/aztec @@ -12,7 +12,7 @@ function get_compose { # Favour 'docker compose', falling back on docker-compose. CMD="docker compose" $CMD &>/dev/null || CMD="docker-compose" - $CMD "$@" + $CMD $@ } # Function to parse the TypeScript file @@ -21,7 +21,7 @@ function parse_ts_file { } function cleanup { - get_compose "$@" down + get_compose $@ down } CALLED_FROM=$PWD diff --git a/aztec-up/bin/aztec-nargo b/aztec-up/bin/aztec-nargo index 59a8e423870..c3437a78e08 100755 --- a/aztec-up/bin/aztec-nargo +++ b/aztec-up/bin/aztec-nargo @@ -6,7 +6,7 @@ export SKIP_PORT_ASSIGNMENT=1 export PATH=$PATH:$HOME/bin if [ "${1:-}" == "lsp" ]; then - docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/aztec-nargo "$@" + docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/aztec-nargo $@ else - $(dirname $0)/.aztec-run aztecprotocol/aztec-nargo "$@" + $(dirname $0)/.aztec-run aztecprotocol/aztec-nargo $@ fi diff --git a/aztec-up/bin/aztec-wallet b/aztec-up/bin/aztec-wallet index 1d45e13c06d..675b8bfeda6 100755 --- a/aztec-up/bin/aztec-wallet +++ b/aztec-up/bin/aztec-wallet @@ -7,4 +7,4 @@ export ENV_VARS_TO_INJECT="WALLET_DATA_DIRECTORY SSH_AUTH_SOCK" mkdir -p $WALLET_DATA_DIRECTORY -$(dirname $0)/.aztec-run aztecprotocol/cli-wallet "$@" \ No newline at end of file +$(dirname $0)/.aztec-run aztecprotocol/cli-wallet $@ \ No newline at end of file diff --git a/barretenberg/acir_tests/run_acir_tests_browser.sh b/barretenberg/acir_tests/run_acir_tests_browser.sh index 61daee3356e..1c1f2ce0e08 100755 --- a/barretenberg/acir_tests/run_acir_tests_browser.sh +++ b/barretenberg/acir_tests/run_acir_tests_browser.sh @@ -18,5 +18,5 @@ THREAD_MODEL=${THREAD_MODEL:-mt} echo "Testing thread model: $THREAD_MODEL" (cd browser-test-app && yarn serve:dest:$THREAD_MODEL) > /dev/null 2>&1 & sleep 1 -VERBOSE=1 BIN=./headless-test/bb.js.browser ./run_acir_tests.sh "$@" +VERBOSE=1 BIN=./headless-test/bb.js.browser ./run_acir_tests.sh $@ lsof -i ":8080" | awk 'NR>1 {print $2}' | xargs kill -9 diff --git a/barretenberg/bootstrap.sh b/barretenberg/bootstrap.sh index d0d339da951..c16fd294b6c 100755 --- a/barretenberg/bootstrap.sh +++ b/barretenberg/bootstrap.sh @@ -3,5 +3,5 @@ set -eu cd "$(dirname "$0")" -(cd cpp && ./bootstrap.sh "$@") -(cd ts && ./bootstrap.sh "$@") +(cd cpp && ./bootstrap.sh $@) +(cd ts && ./bootstrap.sh $@) diff --git a/yarn-project/builder/aztec-builder-dest b/yarn-project/builder/aztec-builder-dest index bbdd765a760..3a0f43e3061 100755 --- a/yarn-project/builder/aztec-builder-dest +++ b/yarn-project/builder/aztec-builder-dest @@ -1,3 +1,3 @@ #!/bin/sh SCRIPT_PATH=$(dirname $(realpath $0)) -node --no-warnings $SCRIPT_PATH/dest/bin/cli.js "$@" +node --no-warnings $SCRIPT_PATH/dest/bin/cli.js $@ diff --git a/yarn-project/cli-wallet/wallet-entrypoint.sh b/yarn-project/cli-wallet/wallet-entrypoint.sh index e6d1fb3adc9..7629e9bde26 100755 --- a/yarn-project/cli-wallet/wallet-entrypoint.sh +++ b/yarn-project/cli-wallet/wallet-entrypoint.sh @@ -13,4 +13,4 @@ if [[ -n "${SSH_AUTH_SOCK_SOCAT_PORT:-}" ]]; then export SSH_AUTH_SOCK="${SOCKET:-}" fi -node --no-warnings /usr/src/yarn-project/cli-wallet/dest/bin/index.js "$@" +node --no-warnings /usr/src/yarn-project/cli-wallet/dest/bin/index.js $@ diff --git a/yarn-project/end-to-end/Makefile b/yarn-project/end-to-end/Makefile index 9f7c37a32df..6c04c93a441 100644 --- a/yarn-project/end-to-end/Makefile +++ b/yarn-project/end-to-end/Makefile @@ -3,7 +3,7 @@ # We have to use a Makefile to run them all parallel interleaved while preserving error codes. # perform an end-to-end test with an earthly build +%: - earthly "$@" + earthly $@ DEPS := $(shell earthly ls) # perform all, meant to be used with -j diff --git a/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh b/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh index b451304a4e0..f03ae0e1abb 100755 --- a/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh +++ b/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh @@ -36,7 +36,7 @@ fi # echo "Parent PID: $PARENT_PID" # Start anvil in the background. -anvil "$@" & +anvil $@ & CHILD_PID=$! cleanup() { diff --git a/yarn-project/end-to-end/scripts/e2e_test.sh b/yarn-project/end-to-end/scripts/e2e_test.sh index 8a3aa7fcc1c..3dcf49edfac 100755 --- a/yarn-project/end-to-end/scripts/e2e_test.sh +++ b/yarn-project/end-to-end/scripts/e2e_test.sh @@ -20,4 +20,4 @@ if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotoco exit 1 fi -docker run -e HARDWARE_CONCURRENCY="$HARDWARE_CONCURRENCY" -e FAKE_PROOFS="$FAKE_PROOFS" --rm aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG "$TEST" "$@" +docker run -e HARDWARE_CONCURRENCY="$HARDWARE_CONCURRENCY" -e FAKE_PROOFS="$FAKE_PROOFS" --rm aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG "$TEST" $@ diff --git a/yarn-project/end-to-end/scripts/start_e2e.sh b/yarn-project/end-to-end/scripts/start_e2e.sh index 67ea77ff218..018c3d79603 100755 --- a/yarn-project/end-to-end/scripts/start_e2e.sh +++ b/yarn-project/end-to-end/scripts/start_e2e.sh @@ -2,4 +2,4 @@ set -eu export NODE_NO_WARNINGS=1 -node ${NODE_ARGS-} --openssl-legacy-provider --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --passWithNoTests "$@" +node ${NODE_ARGS-} --openssl-legacy-provider --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --passWithNoTests $@ diff --git a/yarn-project/scripts/run_script.sh b/yarn-project/scripts/run_script.sh index 72e70aa3212..7ec857a955f 100755 --- a/yarn-project/scripts/run_script.sh +++ b/yarn-project/scripts/run_script.sh @@ -11,4 +11,4 @@ REPO="yarn-project" retry docker pull $(calculate_image_uri $REPO) retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest -docker run ${DOCKER_RUN_OPTS:-} --rm aztecprotocol/$REPO:latest "$@" +docker run ${DOCKER_RUN_OPTS:-} --rm aztecprotocol/$REPO:latest $@ From 65839a7054df1a8cfa8fe52c0634d56ddc07517c Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 7 Oct 2024 19:36:35 +0000 Subject: [PATCH 28/29] fix status --- yarn-project/aztec.js/src/rpc_clients/node/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/aztec.js/src/rpc_clients/node/index.ts b/yarn-project/aztec.js/src/rpc_clients/node/index.ts index 72784ab7fe5..2e779515bf5 100644 --- a/yarn-project/aztec.js/src/rpc_clients/node/index.ts +++ b/yarn-project/aztec.js/src/rpc_clients/node/index.ts @@ -53,7 +53,7 @@ async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndp if (isOK) { return resp.data; } else { - const errorMessage = `(JSON-RPC PROPAGATED) (host ${host}) (method ${rpcMethod}) (code ${resp.data.status}) ${resp.data.error.message}`; + const errorMessage = `(JSON-RPC PROPAGATED) (host ${host}) (method ${rpcMethod}) (code ${resp.status}) ${resp.data.error.message}`; if (resp.status >= 400 && resp.status < 500) { throw new NoRetryError(errorMessage); } else { From fc8179ded1c053ba1b546448b46af45b49ec1ce3 Mon Sep 17 00:00:00 2001 From: ludamad Date: Tue, 8 Oct 2024 11:12:16 +0000 Subject: [PATCH 29/29] formatting --- scripts/run_interleaved.sh | 31 ++++++++++++------- .../aztec.js/src/contract/proven_tx.ts | 5 +-- .../aztec.js/src/rpc_clients/node/index.ts | 7 +---- yarn-project/aztec/src/sandbox.ts | 2 +- .../deploy_protocol_contract.ts | 5 +-- .../cli/src/cmds/infrastructure/index.ts | 7 +---- .../src/json-rpc/client/json_rpc_client.ts | 5 +-- 7 files changed, 26 insertions(+), 36 deletions(-) mode change 100644 => 100755 scripts/run_interleaved.sh diff --git a/scripts/run_interleaved.sh b/scripts/run_interleaved.sh old mode 100644 new mode 100755 index b86f7c202f7..1df4e16fc3d --- a/scripts/run_interleaved.sh +++ b/scripts/run_interleaved.sh @@ -2,8 +2,8 @@ set -eu # Usage: run_bg_args.sh
... -# Runs interleaved commands, with the prefix being the command string passed for each line of input -# *Finishes when the main command exits.* +# Runs the main command with output logging and background commands without logging. +# Finishes when the main command exits. # Check if at least two commands are provided (otherwise what is the point) if [ "$#" -lt 2 ]; then @@ -11,27 +11,36 @@ if [ "$#" -lt 2 ]; then exit 1 fi +main_cmd="$1" +shift + # Function to run a command and prefix the output function run_command() { local cmd="$1" while IFS= read -r line; do echo "[$cmd] $line" - done < <($cmd) + done < <($cmd 2>&1) } -# Run each command in the background, piping output through the run_command function +# Run the main command, piping output through the run_command function +run_command "$main_cmd" & +main_pid=$! + +# Run background commands without logging output +declare -a bg_pids for cmd in "$@"; do run_command "$cmd" & + bg_pids+=($!) done -# Wait for the first command to finish and capture its exit code -wait ${pids[0]} -first_exit_code=$? +# Wait for the main command to finish and capture its exit code +wait $main_pid +main_exit_code=$? -# Kill any remaining background jobs if first command succeeded -for pid in "${pids[@]:1}"; do +# Kill any remaining background jobs +for pid in "${bg_pids[@]}"; do kill "$pid" 2>/dev/null || true done -# Exit with the same code as the first command -exit $first_exit_code +# Exit with the same code as the main command +exit $main_exit_code diff --git a/yarn-project/aztec.js/src/contract/proven_tx.ts b/yarn-project/aztec.js/src/contract/proven_tx.ts index cf4853bbebf..05c8defd745 100644 --- a/yarn-project/aztec.js/src/contract/proven_tx.ts +++ b/yarn-project/aztec.js/src/contract/proven_tx.ts @@ -1,11 +1,8 @@ import { type PXE, Tx } from '@aztec/circuit-types'; - - import { type Wallet } from '../account/index.js'; import { SentTx } from './sent_tx.js'; - /** * A proven transaction that can be sent to the network. Returned by the `prove` method of a contract interaction. */ @@ -45,4 +42,4 @@ export class ProvenTx extends Tx { return new SentTx(this.wallet, promise); } -} \ No newline at end of file +} diff --git a/yarn-project/aztec.js/src/rpc_clients/node/index.ts b/yarn-project/aztec.js/src/rpc_clients/node/index.ts index 2e779515bf5..9cf3195f334 100644 --- a/yarn-project/aztec.js/src/rpc_clients/node/index.ts +++ b/yarn-project/aztec.js/src/rpc_clients/node/index.ts @@ -2,15 +2,10 @@ import { type PXE } from '@aztec/circuit-types'; import { type DebugLogger } from '@aztec/foundation/log'; import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry'; - - import axios, { type AxiosError, type AxiosResponse } from 'axios'; - - import { createPXEClient } from '../pxe_client.js'; - /** * A fetch implementation using axios. * @param host - The URL of the host. @@ -83,4 +78,4 @@ export function createCompatibleClient(rpcUrl: string, logger: DebugLogger): Pro const pxe = createPXEClient(rpcUrl, fetch); return Promise.resolve(pxe); -} \ No newline at end of file +} diff --git a/yarn-project/aztec/src/sandbox.ts b/yarn-project/aztec/src/sandbox.ts index 1f3d465c2b4..e2ac66f513a 100644 --- a/yarn-project/aztec/src/sandbox.ts +++ b/yarn-project/aztec/src/sandbox.ts @@ -196,7 +196,7 @@ export async function createSandbox(config: Partial = {}) { new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(aztecNodeConfig.l1ChainId, aztecNodeConfig.version)), aztecNodeConfig.l1Contracts.feeJuicePortalAddress, undefined, - logger.info + logger.info, ); } diff --git a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts index fd12dbc02e5..d947ed758ce 100644 --- a/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts +++ b/yarn-project/cli/src/cmds/infrastructure/deploy_protocol_contract.ts @@ -2,11 +2,8 @@ import { SignerlessWallet, type WaitOpts, createPXEClient, makeFetch } from '@az import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint'; import { type LogFn } from '@aztec/foundation/log'; - - import { deployCanonicalAuthRegistry, deployCanonicalL2FeeJuice } from '../misc/deploy_contracts.js'; - export async function deployProtocolContracts( rpcUrl: string, l1ChainId: number, @@ -50,4 +47,4 @@ export async function deployProtocolContracts( log(`Auth Registry: ${authRegistryAddress}`); log(`Fee Juice: ${feeJuiceAddress}`); } -} \ No newline at end of file +} diff --git a/yarn-project/cli/src/cmds/infrastructure/index.ts b/yarn-project/cli/src/cmds/infrastructure/index.ts index 0c8099b21de..cded2ef76b3 100644 --- a/yarn-project/cli/src/cmds/infrastructure/index.ts +++ b/yarn-project/cli/src/cmds/infrastructure/index.ts @@ -1,14 +1,9 @@ import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - - import { type Command } from 'commander'; - - import { ETHEREUM_HOST, l1ChainIdOption, parseOptionalInteger, pxeOption } from '../../utils/commands.js'; - export function injectCommands(program: Command, log: LogFn, debugLogger: DebugLogger) { program .command('deploy-protocol-contracts') @@ -56,4 +51,4 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL }); return program; -} \ No newline at end of file +} diff --git a/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts b/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts index 80a6d533177..6cf3761ed83 100644 --- a/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts +++ b/yarn-project/foundation/src/json-rpc/client/json_rpc_client.ts @@ -5,14 +5,11 @@ import { type RemoteObject } from 'comlink'; import { format } from 'util'; - - import { type DebugLogger, createDebugLogger } from '../../log/index.js'; import { NoRetryError, makeBackoff, retry } from '../../retry/index.js'; import { ClassConverter, type JsonClassConverterInput, type StringClassConverterInput } from '../class_converter.js'; import { JsonStringify, convertFromJsonObj, convertToJsonObj } from '../convert.js'; - export { JsonStringify } from '../convert.js'; const log = createDebugLogger('json-rpc:json_rpc_client'); @@ -148,4 +145,4 @@ export function createJsonRpcClient( }, }, ) as RemoteObject; -} \ No newline at end of file +}