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

wip: debugging k8s network transfer #8982

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f15e1b7
fix PROVER_COORDINATION_NODE_URL missing
ludamad Oct 1, 2024
95a0398
better testing
ludamad Oct 1, 2024
bd1fcc8
iterate on kind local tests
ludamad Oct 1, 2024
d3f4866
ok phew dont need crazy nginx ingress control kind config kubectl pat…
ludamad Oct 1, 2024
deb1559
metrics dashboard
ludamad Oct 1, 2024
7610950
debuggable
ludamad Oct 2, 2024
2bb7558
try to debug kind test
ludamad Oct 2, 2024
2c566fa
merge
ludamad Oct 2, 2024
64a866a
more robust k8s port forwarding
ludamad Oct 2, 2024
1c8a838
Merge github.com:AztecProtocol/aztec-packages into ad/debuggable-kind…
ludamad Oct 2, 2024
8bd7988
Better iterative workflow for changing e2e tests
ludamad Oct 2, 2024
17476c4
fix
ludamad Oct 2, 2024
ec96432
revert transfer test
ludamad Oct 2, 2024
e495271
.
ludamad Oct 2, 2024
e3db2da
simple deploy test CI
ludamad Oct 2, 2024
97956fa
smoke test spartan on each pr
ludamad Oct 2, 2024
412ac50
smoke test spartan on each pr
ludamad Oct 2, 2024
20c831f
fix: deploy test
ludamad Oct 3, 2024
935c133
add lobbed off step
ludamad Oct 3, 2024
1c43932
cleanup
ludamad Oct 3, 2024
b583a9c
Merge branch 'master' into ad/debugging-kind
ludamad Oct 3, 2024
ec356e2
Revert "feat: Prover node stakes to escrow contract (#8975)"
ludamad Oct 3, 2024
98f027c
fix EpochProofQuote serialization
ludamad Oct 3, 2024
4ff9f8f
Reapply "feat: Prover node stakes to escrow contract (#8975)"
ludamad Oct 3, 2024
4ed5c66
Merge remote-tracking branch 'origin/master' into ad/debugging-kind
ludamad Oct 3, 2024
e4a7efb
port kill fix
ludamad Oct 3, 2024
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
noir: ${{ steps.filter.outputs.noir }}
noir-projects: ${{ steps.filter.outputs.noir-projects }}
txe: ${{ steps.filter.outputs.txe }}
yarn-project: ${{ steps.filter.outputs.yarn-project }}
l1-contracts: ${{ steps.filter.outputs.l1-contracts }}
non-docs: ${{ steps.filter.outputs.non-docs }}
non-misc-ci: ${{ steps.filter.outputs.non-misc-ci }}
Expand All @@ -81,6 +82,8 @@ jobs:
- 'l1-contracts/**'
noir-projects:
- 'noir-projects/**'
yarn-project:
- 'yarn-project/**'
txe:
- 'yarn-project/txe/**'
non-barretenberg-cpp:
Expand Down Expand Up @@ -746,6 +749,7 @@ jobs:
- changes
- build
- e2e
- deploy-test
# - bench-e2e # non-blocking
# - acir-bench # non-blocking
# - bench-summary # non-blocking
Expand Down Expand Up @@ -791,6 +795,32 @@ jobs:
if: github.event.pull_request.draft
run: echo "Can't merge drafts." && exit 1

deploy-test:
needs: [build, changes]
runs-on: ubuntu-20.04
if: needs.changes.outputs.yarn-project == 'true' || needs.changes.outputs.l1-contracts == 'true' || contains(github.event.pull_request.labels.*.name, 'e2e-all')
steps:
- uses: actions/checkout@v4
with: { ref: "${{ env.GIT_COMMIT }}" }
- uses: ./.github/ci-setup-action
- name: Setup and Test
uses: ./.github/ensure-tester-with-images
timeout-minutes: 45
with:
runner_type: '16core-tester-x86'
builder_type: builder-x86
# these are copied to the tester and expected by the earthly command below
# if they fail to copy, it will try to build them on the tester and fail
builder_images_to_copy: aztecprotocol/aztec:${{ env.GIT_COMMIT }} aztecprotocol/end-to-end:${{ env.GIT_COMMIT }}
# command to produce the images in case they don't exist
builder_command: scripts/earthly-ci ./yarn-project+export-e2e-test-images
tester_ttl: 40
run: |
set -eux
./spartan/scripts/setup_local_k8s.sh
cd yarn-project/end-to-end
NAMESPACE=transfer FRESH_INSTALL=true VALUES_FILE=3-validators.yaml ./scripts/network_test.sh ./src/spartan/smoke.test.ts

rerun-check:
runs-on: ubuntu-20.04
permissions:
Expand All @@ -801,6 +831,7 @@ jobs:
- changes
- build
- e2e
- deploy-test
# - bench-e2e # non-blocking
# - acir-bench # non-blocking
# - bench-summary # non-blocking
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/rpc_clients/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndp
if (isOK) {
return resp.data;
} else if (resp.status >= 400 && resp.status < 500) {
throw new NoRetryError('(JSON-RPC PROPAGATED) ' + resp.data.error.message);
throw new NoRetryError(`(JSON-RPC PROPAGATED) ' (${resp.status}) ${resp.data.error.message}`);
} else {
throw new Error('(JSON-RPC PROPAGATED) ' + resp.data.error.message);
throw new Error(`(JSON-RPC PROPAGATED) ' (${resp.status}) ${resp.data.error.message}`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { PublicDataWitness } from '../../public_data_witness.js';
import { SiblingPath } from '../../sibling_path/index.js';
import { PublicSimulationOutput, Tx, TxHash, TxReceipt } from '../../tx/index.js';
import { TxEffect } from '../../tx_effect.js';
import { EpochProofQuote } from '../../prover_coordination/epoch_proof_quote.js';

/**
* Creates a JSON-RPC client to remotely talk to an Aztec Node.
Expand All @@ -33,6 +34,7 @@ export function createAztecNodeClient(url: string, fetch = defaultFetch): AztecN
AztecAddress,
Buffer32,
EthAddress,
EpochProofQuote,
EventSelector,
ExtendedUnencryptedL2Log,
Fr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { Signature } from '@aztec/foundation/eth-signature';
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
import { type FieldsOf } from '@aztec/foundation/types';



import { Gossipable } from '../p2p/gossipable.js';
import { TopicType, createTopicString } from '../p2p/topic_type.js';
import { EpochProofQuotePayload } from './epoch_proof_quote_payload.js';


export class EpochProofQuote extends Gossipable {
static override p2pTopic: string = createTopicString(TopicType.epoch_proof_quote);

Expand All @@ -27,6 +30,21 @@ export class EpochProofQuote extends Gossipable {
return serializeToBuffer(...EpochProofQuote.getFields(this));
}

/**
* Returns a string representation of the EpochProofQuote object.
*/
override toString(): string {
return this.toBuffer().toString('hex');
}
/**
* Deserializes a EpochProofQuote object from a string.
* @param str - String to deserialize.
* @returns An instance of EpochProofQuote.
*/
static fromString(str: string) {
return EpochProofQuote.fromBuffer(Buffer.from(str, 'hex'));
}

static fromBuffer(buf: Buffer | BufferReader): EpochProofQuote {
const reader = BufferReader.asReader(buf);
return new EpochProofQuote(reader.readObject(EpochProofQuotePayload), reader.readObject(Signature));
Expand Down Expand Up @@ -57,4 +75,4 @@ export class EpochProofQuote extends Gossipable {
signature: this.signature.toViemSignature(),
};
}
}
}
63 changes: 63 additions & 0 deletions yarn-project/end-to-end/scripts/helm_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Usage: ./helm_deploy.sh
# Required environment variables:
# NAMESPACE
# Optional environment variables:
# VALUES_FILE (default: "default.yaml")
# CHAOS_VALUES (default: "")
# FRESH_INSTALL (default: "false")
# AZTEC_DOCKER_TAG (default: current git commit)

set -eux

# Default values for environment variables
VALUES_FILE="${VALUES_FILE:-default.yaml}"
CHAOS_VALUES="${CHAOS_VALUES:-}"
FRESH_INSTALL="${FRESH_INSTALL:-false}"
AZTEC_DOCKER_TAG=${AZTEC_DOCKER_TAG:-$(git rev-parse HEAD)}

# Check required environment variable
if [ -z "${NAMESPACE:-}" ]; then
echo "Environment variable NAMESPACE is required."
exit 1
fi

if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/aztec:$AZTEC_DOCKER_TAG"; then
echo "Aztec docker image not found. It needs to be built with 'earthly ./yarn-project/+export-aztec' or otherwise an image named aztecprotocol/aztec:$AZTEC_DOCKER_TAG needs to exist, or AZTEC_DOCKER_TAG passed with a tag that exists."
exit 1
fi

# Load the Docker images into kind
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

function show_status_until_pxe_ready() {
set +x # don't spam with our commands
sleep 15 # let helm upgrade start
for i in {1..200} ; do
if kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --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 &

# 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
83 changes: 21 additions & 62 deletions yarn-project/end-to-end/scripts/network_test.sh
Original file line number Diff line number Diff line change
@@ -1,87 +1,46 @@
#!/bin/bash

# Usage: ./network_test.sh <test>
# Required environment variables:
# NAMESPACE
# Optional environment variables:
# END_TO_END_DOCKER_TAG (default: AZTEC_DOCKER_TAG, if not set then current git commit)
# Required environment variables passed to helm_deploy.sh:
# NAMESPACE
# Optional environment variables passed to helm_deploy.sh:
# VALUES_FILE (default: "default.yaml")
# CHAOS_VALUES (default: "")
# FRESH_INSTALL (default: "false")
# AZTEC_DOCKER_TAG (default: current git commit)

set -eux

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Main positional parameter
TEST="$1"

# Default values for environment variables
VALUES_FILE="${VALUES_FILE:-default.yaml}"
CHAOS_VALUES="${CHAOS_VALUES:-}"
FRESH_INSTALL="${FRESH_INSTALL:-false}"
AZTEC_DOCKER_TAG=${AZTEC_DOCKER_TAG:-$(git rev-parse HEAD)}
END_TO_END_DOCKER_TAG=${END_TO_END_DOCKER_TAG:-$AZTEC_DOCKER_TAG}

# Check required environment variable
if [ -z "${NAMESPACE:-}" ]; then
echo "Environment variable NAMESPACE is required."
exit 1
fi

if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/aztec:$AZTEC_DOCKER_TAG" || \
! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG"; then
echo "Docker images not found. They need to be built with 'earthly ./yarn-project/+export-e2e-test-images' or otherwise tagged with aztecprotocol/aztec:$AZTEC_DOCKER_TAG and aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG."
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
# Ensure our aztec helm chart is deployed
$(git rev-parse --show-toplevel)/yarn-project/end-to-end/scripts/helm_deploy.sh

# 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 k8s_pxe_port_forward() {
# Clear any existing port forward
ps aux | grep "kubectl port-forward" | grep 9080 | awk '{print $2}' | xargs kill || true
# tunnel in to get access directly to our PXE service in k8s
kubectl port-forward -n "$NAMESPACE" svc/spartan-aztec-network-pxe 9080:8080 || true
}

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

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) &
# Make sure the port forwarding outlives the script
nohup k8s_pxe_port_forward >/dev/null 2>/dev/null &

# run our test in the host network namespace (so we can access the above with localhost)
if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/aztec:$END_TO_END_DOCKER_TAG"; then
echo "Test docker image not found. It needs to be built with 'earthly ./yarn-project/+export-end-to-end' or otherwise an image named aztecprotocol/aztec:$AZTEC_DOCKER_TAG needs to exist, or AZTEC_DOCKER_TAG passed with a tag that exists."
exit 1
fi

docker run --rm --network=host \
-e SCENARIO=default \
-e PXE_URL=http://localhost:9082 \
-e PXE_URL=http://localhost:9080 \
-e DEBUG="aztec:*" \
-e LOG_LEVEL=debug \
-e LOG_JSON=1 \
aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG $TEST
aztecprotocol/end-to-end:$END_TO_END_DOCKER_TAG $TEST
Loading