Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci3): network tests #11650

Merged
merged 21 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion barretenberg/ts/src/crs/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class Crs {
* @returns The points data.
*/
getG1Data(): Uint8Array {
const length = this.numPoints * 64;
// Ensure length > 0, otherwise we might read a huge file.
// This is a backup.
const length = Math.max(this.numPoints, 1) * 64;
const fd = openSync(this.path + '/bn254_g1.dat', 'r');
const buffer = new Uint8Array(length);
readSync(fd, buffer, 0, length, 0);
Expand Down
11 changes: 10 additions & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ function check_toolchains {
exit 1
fi
done
# Check for yarn availability
if ! command -v yarn > /dev/null; then
encourage_dev_container
echo "yarn not found."
echo "Installation: corepack enable"
exit 1
fi
}

# Install pre-commit git hooks.
Expand All @@ -97,6 +104,7 @@ function install_hooks {
echo "(cd barretenberg/cpp && ./format.sh staged)" >$hooks_dir/pre-commit
echo "./yarn-project/precommit.sh" >>$hooks_dir/pre-commit
echo "./noir-projects/precommit.sh" >>$hooks_dir/pre-commit
echo "./yarn-project/circuits.js/precommit.sh" >>$hooks_dir/pre-commit
chmod +x $hooks_dir/pre-commit
}

Expand Down Expand Up @@ -142,9 +150,10 @@ function build {
projects=(
noir
barretenberg
l1-contracts
avm-transpiler
noir-projects
# Relies on noir-projects for verifier solidity generation.
l1-contracts
yarn-project
boxes
docs
Expand Down
3 changes: 2 additions & 1 deletion build-images/src/home/.gitconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[safe]
directory = /workspaces/aztec-packages
directory = /root/aztec-packages
[advice]
detachedHead = false
detachedHead = false
4 changes: 2 additions & 2 deletions ci3/aws/ami_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ ssh $ssh_args -F build_instance_ssh_config ubuntu@$ip < ../../barretenberg/scrip

# Pull devbox onto host, and build into docker-in-docker volume.
ssh $ssh_args -F build_instance_ssh_config ubuntu@$ip "
docker run --privileged --rm -v bootstrap_ci_local_docker:/var/lib/docker $DEVBOX_IMAGE bash -c \"
docker pull $ISOLATION_IMAGE
docker run --privileged --rm -v bootstrap_ci_local_docker:/var/lib/docker aztecprotocol/devbox:3.0 bash -c \"
docker pull aztecprotocol/build:3.0
\"
"

Expand Down
2 changes: 1 addition & 1 deletion ci3/bootstrap_ec2
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ssh ${ssh_args:-} -F $ci3/aws/build_instance_ssh_config ubuntu@$ip "
-e LOCAL_GROUP_ID=\$(id -g) \
-e BUILD_SYSTEM_DEBUG=${BUILD_SYSTEM_DEBUG:-} \
--pids-limit=32768 \
$DEVBOX_IMAGE bash -c '$container_script'
aztecprotocol/devbox:3.0 bash -c '$container_script'
"
code=$?
echo "SSH exited with code: $code"
Expand Down
2 changes: 1 addition & 1 deletion ci3/bootstrap_local
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ docker run -ti --rm --privileged \
-e BUILD_SYSTEM_DEBUG=${BUILD_SYSTEM_DEBUG:-} \
--cpus=$(get_num_cpus) \
--pids-limit=32768 \
$DEVBOX_IMAGE bash -c "
aztecprotocol/devbox:3.0 bash -c "
set -e
git config --global --add safe.directory /aztec-packages-host/.git
git clone --depth 1 file:///aztec-packages-host aztec-packages
Expand Down
25 changes: 25 additions & 0 deletions ci3/docker_isolate
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -eu

# Isolate the network stack etc using docker.
# Carefully set things so we can use our git repo mounted as-is.

NO_CD=1
source $(git rev-parse --show-toplevel)/ci3/source
name=docker-isolate-$(hash_str "$*")
[ "${UNNAMED:-0}" -eq 0 ] && name_arg="--name $name"
trap 'docker rm -f $name &>/dev/null' SIGINT SIGTERM
docker rm -f $name &>/dev/null || true
# TODO: possibly compute --cpus and --memory flags
docker run --rm \
${name_arg:-} \
${DOCKER_FLAGS:-} \
-v$(git rev-parse --show-toplevel):/root/aztec-packages \
-v$HOME/.bb-crs:/root/.bb-crs \
-v$HOME/.cache:/root/.cache \
--mount type=tmpfs,target=/tmp,tmpfs-size=1g \
--workdir /root/aztec-packages/$(git rev-parse --show-prefix) \
-e GIT_CONFIG_GLOBAL=/root/aztec-packages/build-images/src/home/.gitconfig \
-e FORCE_COLOR=true \
aztecprotocol/build:3.0 \
$@
4 changes: 0 additions & 4 deletions ci3/source
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export root=${root:-$(git rev-parse --show-toplevel)}
export ci3="$root/ci3"
[[ "$PATH" != *"$ci3:" ]] && export PATH=$ci3:$PATH

# For when we need to reference our devbox and test isolation images.
export DEVBOX_IMAGE=aztecprotocol/devbox:3.0
export ISOLATION_IMAGE=aztecprotocol/build:3.0

# We always want color.
export FORCE_COLOR=true

Expand Down
2 changes: 1 addition & 1 deletion ci3/source_redis
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ -z "${CI_REDIS_AVAILABLE:-}" ]; then
else
echo_stderr -e "${yellow}Failed to establish connection to remote redis. Log and test cache will be disabled.${reset}"
fi
else
elif command -v docker &> /dev/null; then
echo_stderr "Starting local redis container..."
docker run -d --rm --name ci-redis -p 6379:6379 redis:latest &>/dev/null && true
if nc -z $CI_REDIS 6379 &>/dev/null; then
Expand Down
2 changes: 2 additions & 0 deletions noir-projects/noir-contracts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export -f compile
# Otherwise parse out all relevant contracts from the root Nargo.toml and process them in parallel.
function build {
set +e
rm -rf target
mkdir -p $tmp_dir
echo_stderr "Compiling contracts (bb-hash: $BB_HASH)..."
grep -oP '(?<=contracts/)[^"]+' Nargo.toml | \
parallel $PARALLEL_FLAGS --joblog joblog.txt -v --line-buffer --tag compile {}
Expand Down
1 change: 1 addition & 0 deletions noir-projects/noir-protocol-circuits/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export BB_HASH=$(cache_content_hash ../../barretenberg/cpp/.rebuild_patterns)
export NARGO_HASH=$(cache_content_hash ../../noir/.rebuild_patterns)

key_dir=./target/keys
mkdir -p $key_dir

# Hash of the entire protocol circuits.
# Needed for test hash, as we presently don't have a program hash for each individual test.
Expand Down
1 change: 1 addition & 0 deletions spartan/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.tgz
scripts/logs
2 changes: 1 addition & 1 deletion spartan/aztec-network/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ include "aztec-network.fullname" . }}-node
namespace: {{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
23 changes: 19 additions & 4 deletions spartan/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ cmd=${1:-}

scripts/install_deps.sh

hash=$(hash_str $(cache_content_hash .rebuild_patterns) $(../yarn-project/bootstrap.sh hash))

function network_shaping {
namespace="$1"
chaos_values="$2"
Expand Down Expand Up @@ -46,6 +48,17 @@ function gke {
fi
}

function test_cmds {
echo "$hash NAMESPACE=smoke FRESH_INSTALL=true INSTALL_METRICS=false spartan/scripts/run_test.sh kind ./src/spartan/smoke.test.ts ci-smoke.yaml"
echo "$hash NAMESPACE=4epochs FRESH_INSTALL=true INSTALL_METRICS=false spartan/scripts/run_test.sh kind ./src/spartan/4epochs.test.ts ci.yaml"
echo "$hash spartan/scripts/run_test.sh local -t ./test-transfer.sh -val 3"
}

function test {
echo_header "spartan test"
test_cmds | parallelise
}

case "$cmd" in
"")
# do nothing but the install_deps.sh above
Expand Down Expand Up @@ -83,11 +96,13 @@ case "$cmd" in
network_shaping "$namespace" "$chaos_values"
;;
"hash")
hash_str $(cache_content_hash .rebuild_patterns) $(../yarn-project/bootstrap.sh hash)
echo $hash
;;
"test-kind")
shift
scripts/test_kind.sh $@
"test-cmds")
test_cmds
;;
"test")
test
;;
"gke")
gke
Expand Down
6 changes: 3 additions & 3 deletions spartan/scripts/deploy_kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ if ! docker_has_image "aztecprotocol/aztec:$aztec_docker_tag"; then
fi

# Switch to a KIND cluster (will also pull in necessary dependencies)
../bootstrap.sh kind
flock logs/kind-boot.lock ../bootstrap.sh kind

# Load the Docker image into kind
kind load docker-image aztecprotocol/aztec:$aztec_docker_tag
flock logs/kind-image.lock kind load docker-image aztecprotocol/aztec:$aztec_docker_tag

function show_status_until_pxe_ready {
set +x # don't spam with our commands
Expand Down Expand Up @@ -79,4 +79,4 @@ if [ -n "$chaos_values" ]; then
../bootstrap.sh network-shaping "$chaos_values"
else
echo "Skipping network chaos configuration (CHAOS_VALUES not set)"
fi
fi
16 changes: 16 additions & 0 deletions spartan/scripts/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# This runs a network in KIND or locally.
# It's the script used by ./bootstrap.sh test-cmds.
source $(git rev-parse --show-toplevel)/ci3/source

# Isolate in docker to not overlap our network stack or KIND setup.
# For local debugging, it is recommended to not pass the -i (interleave flag)
# and not isolate, to have a nice tmux splits experience that can be iterated on easily (e.g. close a tab).

cmd=$1
shift
if [ "$cmd" = kind ]; then
./test_kind.sh "$@"
elif [ "$cmd" = local ]; then
docker_isolate ../../scripts/run_native_testnet.sh -i "$@"
fi
79 changes: 22 additions & 57 deletions spartan/scripts/test_kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ fresh_install="${FRESH_INSTALL:-false}"
aztec_docker_tag=${AZTEC_DOCKER_TAG:-$(git rev-parse HEAD)}
cleanup_cluster=${CLEANUP_CLUSTER:-false}
install_metrics=${INSTALL_METRICS:-true}
# NOTE: slated for removal along with e2e image!
use_docker=${USE_DOCKER:-true}

# Ensure we have kind context
../bootstrap.sh kind
Expand All @@ -42,12 +40,6 @@ if [ -z "$namespace" ]; then
exit 1
fi

# Only check for end-to-end image if a test is specified
if [ "$use_docker" = "true" ] && ! docker_has_image "aztecprotocol/end-to-end:$aztec_docker_tag"; then
echo "End-to-end Docker image not found. It needs to be built."
exit 1
fi

if [ "$install_metrics" = "true" ]; then
../bootstrap.sh metrics-kind
fi
Expand Down Expand Up @@ -104,52 +96,25 @@ aztec_slot_duration=$(./read_value.sh "aztec.slotDuration" $value_yamls)
aztec_epoch_duration=$(./read_value.sh "aztec.epochDuration" $value_yamls)
aztec_epoch_proof_claim_window_in_l2_slots=$(./read_value.sh "aztec.epochProofClaimWindow" $value_yamls)

if [ "$use_docker" = "true" ]; then
echo "RUNNING TEST: $test (docker)"
# Run test in Docker.
# Note this will go away soon with the end-to-end image (which also means we deal with the duplication for now.)
docker run --rm --network=host \
-v ~/.kube:/root/.kube \
-e K8S=local \
-e INSTANCE_NAME="spartan" \
-e SPARTAN_DIR="/usr/src/spartan" \
-e NAMESPACE="$namespace" \
-e HOST_PXE_PORT=$pxe_port \
-e CONTAINER_PXE_PORT=8081 \
-e HOST_ETHEREUM_PORT=$anvil_port \
-e CONTAINER_ETHEREUM_PORT=8545 \
-e HOST_METRICS_PORT=$metrics_port \
-e CONTAINER_METRICS_PORT=80 \
-e GRAFANA_PASSWORD=$grafana_password \
-e DEBUG=${DEBUG:-""} \
-e LOG_JSON=1 \
-e LOG_LEVEL=${LOG_LEVEL:-"debug; info: aztec:simulator, json-rpc"} \
-e ETHEREUM_SLOT_DURATION=$ethereum_slot_duration \
-e AZTEC_SLOT_DURATION=$aztec_slot_duration \
-e AZTEC_EPOCH_DURATION=$aztec_epoch_duration \
-e AZTEC_EPOCH_PROOF_CLAIM_WINDOW_IN_L2_SLOTS=$aztec_epoch_proof_claim_window_in_l2_slots \
aztecprotocol/end-to-end:$aztec_docker_tag $test
else
echo "RUNNING TEST: $test"
# Run test locally.
export K8S="local"
export INSTANCE_NAME="spartan"
export SPARTAN_DIR="$(pwd)/.."
export NAMESPACE="$namespace"
export HOST_PXE_PORT="$pxe_port"
export CONTAINER_PXE_PORT="8081"
export HOST_ETHEREUM_PORT="$anvil_port"
export CONTAINER_ETHEREUM_PORT="8545"
export HOST_METRICS_PORT="$metrics_port"
export CONTAINER_METRICS_PORT="80"
export GRAFANA_PASSWORD="$grafana_password"
export DEBUG="${DEBUG:-""}"
export LOG_JSON="1"
export LOG_LEVEL="${LOG_LEVEL:-"debug; info: aztec:simulator, json-rpc"}"
export ETHEREUM_SLOT_DURATION="$ethereum_slot_duration"
export AZTEC_SLOT_DURATION="$aztec_slot_duration"
export AZTEC_EPOCH_DURATION="$aztec_epoch_duration"
export AZTEC_EPOCH_PROOF_CLAIM_WINDOW_IN_L2_SLOTS="$aztec_epoch_proof_claim_window_in_l2_slots"

yarn --cwd ../../yarn-project/end-to-end test --forceExit "$test"
fi
echo "RUNNING TEST: $test"
# Run test locally.
export K8S="local"
export INSTANCE_NAME="spartan"
export SPARTAN_DIR="$(pwd)/.."
export NAMESPACE="$namespace"
export HOST_PXE_PORT="$pxe_port"
export CONTAINER_PXE_PORT="8081"
export HOST_ETHEREUM_PORT="$anvil_port"
export CONTAINER_ETHEREUM_PORT="8545"
export HOST_METRICS_PORT="$metrics_port"
export CONTAINER_METRICS_PORT="80"
export GRAFANA_PASSWORD="$grafana_password"
export DEBUG="${DEBUG:-""}"
export LOG_JSON="1"
export LOG_LEVEL="${LOG_LEVEL:-"debug; info: aztec:simulator, json-rpc"}"
export ETHEREUM_SLOT_DURATION="$ethereum_slot_duration"
export AZTEC_SLOT_DURATION="$aztec_slot_duration"
export AZTEC_EPOCH_DURATION="$aztec_epoch_duration"
export AZTEC_EPOCH_PROOF_CLAIM_WINDOW_IN_L2_SLOTS="$aztec_epoch_proof_claim_window_in_l2_slots"

yarn --cwd ../../yarn-project/end-to-end test --forceExit "$test"
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/scripts/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ case "$type" in
--mount type=tmpfs,target=/tmp-jest,tmpfs-size=512m \
-e JEST_CACHE_DIR=/tmp-jest \
--workdir /root/aztec-packages/yarn-project/end-to-end \
$ISOLATION_IMAGE ./scripts/test_simple.sh $TEST
aztecprotocol/build:3.0 ./scripts/test_simple.sh $TEST
;;
"compose")
name="${TEST//[\/\.]/_}${NAME_POSTFIX:-}"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/scripts/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ "${ISOLATE:-0}" -eq 1 ]; then
--workdir /root/aztec-packages/yarn-project/$dir \
-e FORCE_COLOR=true \
-e NODE_OPTIONS="--no-warnings --experimental-vm-modules --loader @swc-node/register" \
$ISOLATION_IMAGE \
aztecprotocol/build:3.0 \
node ../node_modules/.bin/jest --forceExit --runInBand $test
else
export NODE_OPTIONS="--no-warnings --experimental-vm-modules --loader @swc-node/register"
Expand Down