Skip to content

Commit

Permalink
chore(deployments): native network test (#9138)
Browse files Browse the repository at this point in the history
This runs a version of the tmux-outputting test that is normally
runnable with:
```
./bootstrap.sh fast
yarn-project/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 \
        ./transaction-bot.sh \
        "./validator.sh 8081"
```
it uses the RUN_INTERLEAVED=1 env var to make it suitable output for CI.
This catches application issues, isolating them from k8s-specific
issues. It is meant to continue to be maintained alongside the k8s
deploy as this is by far the most productive dev workflow, being able to
simply restart network components after tweaks (especially with yarn
build:dev)
  • Loading branch information
ludamad authored Oct 9, 2024
1 parent 7dfa295 commit 975ea36
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 45 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/nightly-kind-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions scripts/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VERSION 0.8

scripts:
FROM scratch
COPY *.sh .
SAVE ARTIFACT *.sh
64 changes: 38 additions & 26 deletions scripts/run_interleaved.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
#!/bin/bash
set -eu
# propagate errors inside while loop pipe
set -o pipefail

# Usage: run_bg_args.sh <main command> <background commands>...
# Usage: run_interleaved.sh <main command> <background commands>...
# 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 <main-command> <background commands>..."
exit 1
echo "Usage: $0 <main-command> <background commands>..."
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"
19 changes: 19 additions & 0 deletions yarn-project/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 303 in yarn-project/end-to-end/Earthfile

View workflow job for this annotation

GitHub Actions / e2e (kind-network-transfer)

Error

The command RUN NAMESPACE=transfer FRESH_INSTALL=true VALUES_FILE=${values_file:-default.yaml} ./scripts/network_test.sh ./src/spartan/transfer.test.ts did not complete successfully. Exit code 127
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ EOCONFIG

echo "Contract addresses saved to l1-contracts.env"
sleep 5
tmux kill-pane -t $(tmux display -p '#{pane_id}')
function close_tmux_pane() {
tmux kill-pane -t $(tmux display -p '#{pane_id}')
}
close_tmux_pane 2>/dev/null || true
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
function close_tmux_pane() {
tmux kill-pane -t $(tmux display -p '#{pane_id}')
}
close_tmux_pane 2>/dev/null || true
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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"
Expand Down
14 changes: 4 additions & 10 deletions yarn-project/end-to-end/scripts/native_network_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
# 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?

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)

Expand All @@ -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
Expand All @@ -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 "$@"
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/spartan/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 975ea36

Please sign in to comment.