diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb816c42c2b..3d7167fdcf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -542,6 +542,19 @@ jobs: timeout-minutes: 40 run: earthly-ci --no-output ./yarn-project/+prover-client-test + network-test-fake-proofs: + needs: build + runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86 + steps: + - uses: actions/checkout@v4 + with: { ref: "${{ env.GIT_COMMIT }}" } + - uses: ./.github/ci-setup-action + with: + concurrency_key: network-test-fake-proofs-x86 + - name: "Prover Client Tests" + timeout-minutes: 40 + run: earthly-ci --no-output ./yarn-project/+network-test-fake-proofs + l1-contracts-test: needs: [build, changes] runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86 @@ -766,6 +779,7 @@ jobs: - yarn-project-formatting - yarn-project-test - prover-client-test + - network-test-fake-proofs - l1-contracts-test - docs-preview # - bb-bench # non-blocking @@ -821,6 +835,7 @@ jobs: - yarn-project-formatting - yarn-project-test - prover-client-test + - network-test-fake-proofs - l1-contracts-test - docs-preview # - bb-bench # non-blocking diff --git a/.github/workflows/network-deploy.yml b/.github/workflows/network-deploy.yml index 8acd9378d61..2aa862f4499 100644 --- a/.github/workflows/network-deploy.yml +++ b/.github/workflows/network-deploy.yml @@ -54,4 +54,4 @@ jobs: - name: Deploy Helm chart run: | helm dependency update ${{ env.CHART_PATH }} - helm upgrade --install ${{ env.NAMESPACE }} ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --set network.public=true --atomic + helm upgrade --install ${{ env.NAMESPACE }} ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --set network.public=true --atomic --create-namespace --timeout 20m diff --git a/.github/workflows/nightly-kind-test.yml b/.github/workflows/nightly-kind-test.yml index 8c2a1a4daad..255835daa76 100644 --- a/.github/workflows/nightly-kind-test.yml +++ b/.github/workflows/nightly-kind-test.yml @@ -75,7 +75,7 @@ jobs: ./spartan/scripts/setup_local_k8s.sh export FORCE_COLOR=1 export EARTHLY_BUILD_ARGS="${{ env.EARTHLY_BUILD_ARGS }}" - ./scripts/earthly-ci --exec-stats -P --no-output ./yarn-project/end-to-end/+network-transfer --values-file=${{ matrix.values_file }} + ./scripts/earthly-ci --exec-stats -P --no-output ./yarn-project/end-to-end/+kind-network-transfer --values-file=${{ matrix.values_file }} success-check: runs-on: ubuntu-20.04 diff --git a/scripts/Earthfile b/scripts/Earthfile new file mode 100644 index 00000000000..2aa3bae9244 --- /dev/null +++ b/scripts/Earthfile @@ -0,0 +1,6 @@ +VERSION 0.8 + +scripts: + FROM scratch + COPY *.sh . + SAVE ARTIFACT *.sh \ No newline at end of file diff --git a/scripts/run_interleaved.sh b/scripts/run_interleaved.sh index 1df4e16fc3d..854c80e4bd9 100755 --- a/scripts/run_interleaved.sh +++ b/scripts/run_interleaved.sh @@ -1,46 +1,58 @@ #!/bin/bash set -eu +# propagate errors inside while loop pipe +set -o pipefail -# Usage: run_bg_args.sh
... +# Usage: run_interleaved.sh
... # 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 - echo "Usage: $0 ..." - exit 1 + echo "Usage: $0 ..." + exit 1 fi +# Define colors +colors=( + "\e[33m" # Yellow + "\e[34m" # Blue + "\e[35m" # Magenta + "\e[36m" # Cyan + "\e[92m" # Bright Green + "\e[93m" # Bright Yellow + "\e[94m" # Bright Blue + "\e[95m" # Bright Magenta + "\e[96m" # Bright Cyan + "\e[91m" # Bright Red +) + 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 2>&1) +# pattern from https://stackoverflow.com/questions/28238952/how-to-kill-a-running-bash-function-from-terminal +function cleanup_function() { + kill $(jobs -p) 2>/dev/null || true + return } -# Run the main command, piping output through the run_command function -run_command "$main_cmd" & -main_pid=$! +# Function to run a command and prefix the output with color +function run_command() { + # pattern from https://stackoverflow.com/questions/28238952/how-to-kill-a-running-bash-function-from-terminal + trap cleanup_function INT EXIT + local cmd="$1" + local color="$2" + $cmd 2>&1 | while IFS= read -r line; do + echo -e "${color}[$cmd]\e[0m $line" + done +} # Run background commands without logging output -declare -a bg_pids +i=0 for cmd in "$@"; do - run_command "$cmd" & - bg_pids+=($!) -done - -# Wait for the main command to finish and capture its exit code -wait $main_pid -main_exit_code=$? - -# Kill any remaining background jobs -for pid in "${bg_pids[@]}"; do - kill "$pid" 2>/dev/null || true + run_command "$cmd" "${colors[$((i % ${#colors[@]}))]}" & + ((i++)) || true # annoyingly considered a failure based on result done -# Exit with the same code as the main command -exit $main_exit_code +# Run the main command synchronously, piping output through the run_command function with green color +run_command "$main_cmd" "\e[32m" \ No newline at end of file diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 3accd2fee52..6b6abd466ed 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -279,6 +279,25 @@ prover-client-test: ARG debug="" RUN cd prover-client && DEBUG=$debug yarn test $test +# NOTE: This is not in the end-to-end Earthfile as that is entirely LOCALLY commands that will go away sometime. +# Running this inside the main builder as the point is not to run this through dockerization. +network-test-fake-proofs: + FROM +build + WORKDIR /usr/src/ + # Bare minimum git setup to run 'git rev-parse --show-toplevel' + RUN git init -b master + COPY ../scripts/+scripts/run_interleaved.sh scripts/run_interleaved.sh + WORKDIR /usr/src/yarn-project + # All script arguments are in the end-to-end/scripts/native-network folder + RUN INTERLEAVED=true end-to-end/scripts/native_network_test.sh \ + ./test-transfer.sh \ + ./deploy-l1-contracts.sh \ + ./deploy-l2-contracts.sh \ + ./boot-node.sh \ + ./ethereum.sh \ + "./prover-node.sh false" \ + ./pxe.sh + publish-npm: FROM +build ARG DIST_TAG="latest" diff --git a/yarn-project/end-to-end/Earthfile b/yarn-project/end-to-end/Earthfile index a8346f103d8..1844c503cb1 100644 --- a/yarn-project/end-to-end/Earthfile +++ b/yarn-project/end-to-end/Earthfile @@ -297,7 +297,7 @@ network-smoke: LOCALLY RUN NAMESPACE=smoke FRESH_INSTALL=true VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/smoke.test.ts -network-transfer: +kind-network-transfer: ARG values_file LOCALLY - RUN NAMESPACE=transfer FRESH_INSTALL=true VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/transfer.test.ts + RUN NAMESPACE=transfer FRESH_INSTALL=true VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/transfer.test.ts \ 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 7ff2036f5f3..99d24e4f0ea 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,7 @@ EOCONFIG echo "Contract addresses saved to l1-contracts.env" sleep 5 -tmux kill-pane -t $(tmux display -p '#{pane_id}') \ No newline at end of file +function close_tmux_pane() { + tmux kill-pane -t $(tmux display -p '#{pane_id}') +} +close_tmux_pane 2>/dev/null || true \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh b/yarn-project/end-to-end/scripts/native-network/deploy-l2-contracts.sh index 69e3d6c3a1f..e015b8a862b 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 @@ -25,10 +25,13 @@ 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 $ARGS +node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts $ARGS echo "Deployed L2 contracts" # Use file just as done signal echo "" > l2-contracts.env echo "Wrote to l2-contracts.env to signal completion" sleep 5 -tmux kill-pane -t $(tmux display -p '#{pane_id}') \ No newline at end of file +function close_tmux_pane() { + tmux kill-pane -t $(tmux display -p '#{pane_id}') +} +close_tmux_pane 2>/dev/null || true \ No newline at end of file diff --git a/yarn-project/end-to-end/scripts/native-network/prover-node.sh b/yarn-project/end-to-end/scripts/native-network/prover-node.sh index bb326896456..a7e6218e9c7 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,7 @@ #!/bin/bash set -eu +export PROVER_REAL_PROOFS="$1" # Get the name of the script without the path and extension SCRIPT_NAME=$(basename "$0" .sh) @@ -28,7 +29,6 @@ export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*') export LOG_LEVEL="debug" 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="http://127.0.0.1:8080" 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 f37e3e5cfc2..cc5b15cbe4c 100755 --- a/yarn-project/end-to-end/scripts/native_network_test.sh +++ b/yarn-project/end-to-end/scripts/native_network_test.sh @@ -8,6 +8,8 @@ # 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. +# Arguments: +# Expects a list of scripts from the native-network folder. # Optional environment variables: # INTERLEAVED (default: "false") should we just start all programs in the background? @@ -15,7 +17,6 @@ set -eu # Ensure dependencies are installed 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) @@ -35,6 +36,7 @@ rm -f l1-contracts.env l2-contracts.env logs/*.log function run_parallel() { if [ "${INTERLEAVED:-false}" = "false" ] ; then + command -v tmux >/dev/null || (echo "We need 'tmux' installed to be able to manage terminal sessions" && exit 1) # Run in tmux for local debugging "$REPO"/scripts/tmux_split_args.sh native_network_test_session "$@" else @@ -45,12 +47,4 @@ function run_parallel() { # 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 \ - ./deploy-l1-contracts.sh \ - ./deploy-l2-contracts.sh \ - ./boot-node.sh \ - ./ethereum.sh \ - ./prover-node.sh \ - ./pxe.sh \ - ./transaction-bot.sh - # "./validator.sh 8081" +run_parallel "$@" \ No newline at end of file diff --git a/yarn-project/end-to-end/src/spartan/transfer.test.ts b/yarn-project/end-to-end/src/spartan/transfer.test.ts index 0e1bda7c720..4c675c7541d 100644 --- a/yarn-project/end-to-end/src/spartan/transfer.test.ts +++ b/yarn-project/end-to-end/src/spartan/transfer.test.ts @@ -39,7 +39,7 @@ describe('token transfer test', () => { const TOKEN_DECIMALS = 18n; const MINT_AMOUNT = 20n; - const WALLET_COUNT = 16; + const WALLET_COUNT = 1; // TODO fix this to allow for 16 wallets again const ROUNDS = 5n; let pxe: PXE;