Skip to content

Commit

Permalink
test: basic network matrix (#8257)
Browse files Browse the repository at this point in the history
Adds new values files to the aztec-network helm chart, and creates a
matrix over them for CI.

Presently we test a single ("boot") node with validator off, and a boot
+ 3 validators with validators on.

The test was also update to perform several transfers serially.

Fix #8001
  • Loading branch information
just-mitch authored Aug 29, 2024
1 parent 54e1cc7 commit 2a76b1a
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 26 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ jobs:
export FORCE_COLOR=1
../../scripts/earthly-ci -P --no-output +${{ matrix.test }}
# all the network end-to-end tests for aztec (not required to merge)
network-e2e:
needs: [build, changes]
if: ${{ needs.changes.outputs.non-barretenberg-cpp == 'true' }}
runs-on: ubuntu-20.04
strategy:
matrix:
values_file: ["default.yaml", "3-validators.yaml"]
steps:
- uses: actions/checkout@v4
with: { ref: "${{ env.GIT_COMMIT }}" }
Expand All @@ -188,7 +190,7 @@ jobs:
./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 ./+network-transfer
../../scripts/earthly-ci --exec-stats -P --no-output ./+network-transfer --values-file=${{ matrix.values_file }}
# all the benchmarking end-to-end integration tests for aztec (not required to merge)
bench-e2e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ spec:
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: P2P_ENABLED
value: "{{ .Values.bootNode.p2p.enabled }}"
- name: VALIDATOR_DISABLED
value: "{{ .Values.bootNode.validator.disabled }}"
- name: SEQ_MAX_SECONDS_BETWEEN_BLOCKS
value: "{{ .Values.bootNode.sequencer.maxSecondsBetweenBlocks }}"
- name: SEQ_MIN_TX_PER_BLOCK
value: "{{ .Values.bootNode.sequencer.minTxsPerBlock }}"
- name: P2P_TCP_ANNOUNCE_ADDR
value: "$(POD_DNS_NAME):{{ .Values.bootNode.service.p2pPort }}"
- name: P2P_UDP_ANNOUNCE_ADDR
Expand Down
10 changes: 10 additions & 0 deletions helm-charts/aztec-network/templates/validator.stateful-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ spec:
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: P2P_ENABLED
value: "{{ .Values.validator.p2p.enabled }}"
- name: VALIDATOR_DISABLED
value: "{{ .Values.validator.validator.disabled }}"
- name: SEQ_MAX_SECONDS_BETWEEN_BLOCKS
value: "{{ .Values.bootNode.sequencer.maxSecondsBetweenBlocks }}"
- name: SEQ_MIN_TX_PER_BLOCK
value: "{{ .Values.bootNode.sequencer.minTxsPerBlock }}"
- name: P2P_TCP_ANNOUNCE_ADDR
value: "$(POD_DNS_NAME):{{ .Values.validator.service.p2pPort }}"
- name: P2P_UDP_ANNOUNCE_ADDR
Expand All @@ -73,6 +79,10 @@ spec:
value: "0.0.0.0:{{ .Values.validator.service.p2pPort }}"
- name: P2P_UDP_LISTEN_ADDR
value: "0.0.0.0:{{ .Values.validator.service.p2pPort }}"
- name: OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
value: {{ include "aztec-network.otelCollectorMetricsEndpoint" . | quote }}
- name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
value: {{ include "aztec-network.otelCollectorTracesEndpoint" . | quote }}
ports:
- containerPort: {{ .Values.validator.service.nodePort }}
- containerPort: {{ .Values.validator.service.p2pPort }}
Expand Down
14 changes: 12 additions & 2 deletions helm-charts/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ bootNode:
p2pPort: 40400
nodePort: 8080
logLevel: "debug"
debug: "aztec:*"
debug: "aztec:*,-aztec:avm_simulator:*"
sequencer:
maxSecondsBetweenBlocks: 0
minTxsPerBlock: 1
validator:
disabled: true
p2p:
enabled: "true"
resources: {}
Expand All @@ -41,7 +46,12 @@ validator:
p2pPort: 40400
nodePort: 8080
logLevel: "debug"
debug: "aztec:*"
debug: "aztec:*,-aztec:avm_simulator:*"
sequencer:
maxSecondsBetweenBlocks: 0
minTxsPerBlock: 1
validator:
disabled: false
p2p:
enabled: "true"
resources: {}
Expand Down
8 changes: 8 additions & 0 deletions helm-charts/aztec-network/values/3-validators.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
validator:
replicas: 3
validator:
disabled: false

bootNode:
validator:
disabled: false
1 change: 1 addition & 0 deletions helm-charts/aztec-network/values/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Left intentionally blank- this file is used to override the default values in the values.yaml file
12 changes: 8 additions & 4 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ E2E_TEST_PUBLIC_TESTNET:

NETWORK_TEST:
FUNCTION
ARG hardware_concurrency=""
ARG values_file="default.yaml"
ARG namespace
ARG test
ARG chaos_values
Expand All @@ -93,7 +93,9 @@ NETWORK_TEST:
END

RUN helm install spartan ../../helm-charts/aztec-network \
--namespace $namespace --create-namespace \
--namespace $namespace \
--create-namespace \
--values ../../helm-charts/aztec-network/values/$values_file \
--set images.test.image="aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG" \
--set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \
--set test="$test" \
Expand Down Expand Up @@ -325,8 +327,10 @@ e2e-cli-wallet:

network-smoke:
ARG force_build
DO +NETWORK_TEST --force_build=$force_build --fresh_install=true --namespace=smoke --test=./src/spartan/smoke.test.ts
ARG values_file="default.yaml"
DO +NETWORK_TEST --test=./src/spartan/smoke.test.ts --namespace=smoke --fresh_install=true --force_build=$force_build --values_file=$values_file

network-transfer:
ARG force_build
DO +NETWORK_TEST --force_build=$force_build --fresh_install=true --namespace=transfer --test=./src/spartan/transfer.test.ts
ARG values_file="default.yaml"
DO +NETWORK_TEST --test=./src/spartan/transfer.test.ts --namespace=transfer --fresh_install=true --force_build=$force_build --values_file=$values_file
46 changes: 28 additions & 18 deletions yarn-project/end-to-end/src/spartan/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { createDebugLogger } from '@aztec/foundation/log';
import { TokenContract } from '@aztec/noir-contracts.js';

import { jest } from '@jest/globals';

import { addAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';

const { PXE_URL } = process.env;
Expand Down Expand Up @@ -56,11 +58,13 @@ const addPendingShieldNoteToPXE = async (args: {
};

describe('token transfer test', () => {
jest.setTimeout(10 * 60 * 1000); // 10 minutes

const logger = createDebugLogger(`aztec:spartan-test:transfer`);
const TOKEN_NAME = 'USDC';
const TOKEN_SYMBOL = 'USD';
const TOKEN_DECIMALS = 18n;
const MINT_AMOUNT = 1000000n;
const MINT_AMOUNT = 20n;
let pxe: PXE;
let wallets: AccountWalletWithSecretKey[];
let completeAddresses: CompleteAddress[];
Expand Down Expand Up @@ -117,26 +121,32 @@ describe('token transfer test', () => {

it('can transfer 1 publicly', async () => {
const transferAmount = 1n;
const balance0 = await tokenAtWallet0.methods.balance_of_public(completeAddresses[0].address).simulate();
expect(balance0).toBeGreaterThanOrEqual(transferAmount);
await tokenAtWallet0.methods
.transfer_public(completeAddresses[0].address, completeAddresses[1].address, transferAmount, 0)
.send()
.wait();
const balance0After = await tokenAtWallet0.methods.balance_of_public(completeAddresses[0].address).simulate();
const balance1After = await tokenAtWallet0.methods.balance_of_public(completeAddresses[1].address).simulate();
expect(balance0After).toBe(balance0 - transferAmount);
expect(balance1After).toBe(transferAmount);
const numTransfers = MINT_AMOUNT / transferAmount;
const initialBalance = await tokenAtWallet0.methods.balance_of_public(completeAddresses[0].address).simulate();
expect(initialBalance).toBeGreaterThanOrEqual(transferAmount);
for (let i = 1n; i <= numTransfers; i++) {
await tokenAtWallet0.methods
.transfer_public(completeAddresses[0].address, completeAddresses[1].address, transferAmount, 0)
.send()
.wait();
}
const finalBalance0 = await tokenAtWallet0.methods.balance_of_public(completeAddresses[0].address).simulate();
expect(finalBalance0).toBe(0n);
const finalBalance1 = await tokenAtWallet0.methods.balance_of_public(completeAddresses[1].address).simulate();
expect(finalBalance1).toBe(MINT_AMOUNT);
});

it('can transfer 1 privately', async () => {
const transferAmount = 1n;
const balance0 = await tokenAtWallet0.methods.balance_of_private(completeAddresses[0].address).simulate();
expect(balance0).toBeGreaterThanOrEqual(transferAmount);
await tokenAtWallet0.methods.transfer(completeAddresses[1].address, transferAmount).send().wait();
const balance0After = await tokenAtWallet0.methods.balance_of_private(completeAddresses[0].address).simulate();
const balance1After = await tokenAtWallet0.methods.balance_of_private(completeAddresses[1].address).simulate();
expect(balance0After).toBe(balance0 - transferAmount);
expect(balance1After).toBe(transferAmount);
const numTransfers = MINT_AMOUNT / transferAmount;
const initialBalance = await tokenAtWallet0.methods.balance_of_private(completeAddresses[0].address).simulate();
expect(initialBalance).toBeGreaterThanOrEqual(transferAmount);
for (let i = 1n; i <= numTransfers; i++) {
await tokenAtWallet0.methods.transfer(completeAddresses[1].address, transferAmount).send().wait();
}
const finalBalance0 = await tokenAtWallet0.methods.balance_of_private(completeAddresses[0].address).simulate();
expect(finalBalance0).toBe(0n);
const finalBalance1 = await tokenAtWallet0.methods.balance_of_private(completeAddresses[1].address).simulate();
expect(finalBalance1).toBe(MINT_AMOUNT);
});
});

0 comments on commit 2a76b1a

Please sign in to comment.