Skip to content

Commit 8d9947d

Browse files
authored
feat: sequencer selection in k8s tests (#8313)
Update the k8s e2e tests to use proper validators.
1 parent e8a097c commit 8d9947d

17 files changed

+397
-62
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -e
3+
4+
alias aztec='node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js'
5+
6+
# Pass the bootnode url as an argument
7+
# Ask the bootnode for l1 contract addresses
8+
output=$(aztec get-node-info -u $1)
9+
10+
echo "$output"
11+
12+
boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+')
13+
rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
14+
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
15+
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
16+
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
17+
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
18+
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
19+
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')
20+
21+
22+
# Write the addresses to a file in the shared volume
23+
cat <<EOF > /shared/contracts.env
24+
export BOOTSTRAP_NODES=$boot_node_enr
25+
export ROLLUP_CONTRACT_ADDRESS=$rollup_address
26+
export REGISTRY_CONTRACT_ADDRESS=$registry_address
27+
export INBOX_CONTRACT_ADDRESS=$inbox_address
28+
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
29+
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
30+
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
31+
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
32+
EOF
33+
34+
cat /shared/contracts.env
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
set -e
3+
4+
alias aztec='node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js'
5+
6+
# Pass the bootnode url as an argument
7+
# Ask the bootnode for l1 contract addresses
8+
output=$(aztec get-node-info -u $1)
9+
10+
echo "$output"
11+
12+
boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+')
13+
rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
14+
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
15+
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
16+
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
17+
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
18+
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
19+
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')
20+
21+
# Generate a private key for the validator
22+
json_account=$(aztec generate-l1-account)
23+
24+
echo "$json_account"
25+
address=$(echo $json_account | jq -r '.address')
26+
private_key=$(echo $json_account | jq -r '.privateKey')
27+
28+
aztec add-l1-validator --validator $address --rollup $rollup_address
29+
30+
aztec fast-forward-epochs --rollup $rollup_address --count 1
31+
32+
33+
# Write the addresses to a file in the shared volume
34+
cat <<EOF > /shared/contracts.env
35+
export BOOTSTRAP_NODES=$boot_node_enr
36+
export ROLLUP_CONTRACT_ADDRESS=$rollup_address
37+
export REGISTRY_CONTRACT_ADDRESS=$registry_address
38+
export INBOX_CONTRACT_ADDRESS=$inbox_address
39+
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
40+
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
41+
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
42+
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
43+
export VALIDATOR_PRIVATE_KEY=$private_key
44+
export L1_PRIVATE_KEY=$private_key
45+
export SEQ_PUBLISHER_PRIVATE_KEY=$private_key
46+
EOF
47+
48+
cat /shared/contracts.env

helm-charts/aztec-network/templates/_helpers.tpl

+13-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,16 @@ http://{{ include "aztec-network.fullname" . }}-metrics.{{ .Release.Namespace }}
7676

7777

7878

79-
79+
{{- define "helpers.flag" -}}
80+
{{- $name := index . 0 -}}
81+
{{- $value := index . 1 -}}
82+
{{- if $value -}}
83+
{{- if kindIs "string" $value -}}
84+
{{- if ne $value "" -}}
85+
--{{ $name }} {{ $value }}
86+
{{- end -}}
87+
{{- else -}}
88+
--{{ $name }} {{ $value }}
89+
{{- end -}}
90+
{{- end -}}
91+
{{- end -}}

helm-charts/aztec-network/templates/anvil.deployment.yaml

+9-14
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,18 @@ spec:
2222
imagePullPolicy: {{ .Values.images.foundry.pullPolicy }}
2323
command: ["/bin/sh", "-c"]
2424
args:
25-
- |
26-
[ -n "$FORK_URL" ] && ARGS="$ARGS --fork-url $FORK_URL";
27-
[ -n "$FORK_BLOCK_NUMBER" ] && ARGS="$ARGS --fork-block-number $FORK_BLOCK_NUMBER";
28-
echo anvil --block-time 12 -p $ANVIL_PORT --host 0.0.0.0 --chain-id {{ .Values.ethereum.chainId }} $ARGS;
29-
anvil --block-time 12 -p $ANVIL_PORT --host 0.0.0.0 --chain-id {{ .Values.ethereum.chainId }} $ARGS;
25+
- >-
26+
anvil
27+
--host 0.0.0.0
28+
{{ include "helpers.flag" (list "block-time" .Values.ethereum.blockTime) }}
29+
{{ include "helpers.flag" (list "chain-id" .Values.ethereum.chainId) }}
30+
{{ include "helpers.flag" (list "gas-limit" .Values.ethereum.gasLimit) }}
31+
{{ include "helpers.flag" (list "fork-url" .Values.ethereum.forkUrl) }}
32+
{{ include "helpers.flag" (list "fork-block-number" .Values.ethereum.forkBlockNumber) }}
33+
-p {{ .Values.ethereum.service.port }}
3034
ports:
3135
- containerPort: {{ .Values.ethereum.service.port }}
3236
name: anvil
33-
env:
34-
- name: FORK_URL
35-
value: {{ .Values.ethereum.forkUrl | quote }}
36-
- name: FORK_BLOCK_NUMBER
37-
value: {{ .Values.ethereum.forkBlockNumber | quote }}
38-
- name: ANVIL_PORT
39-
value: {{ .Values.ethereum.service.port | quote }}
40-
- name: ARGS
41-
value: {{ .Values.ethereum.args | quote }}
4237
readinessProbe:
4338
exec:
4439
command:

helm-charts/aztec-network/templates/configure-validator-env.config-map.yaml

-38
This file was deleted.

helm-charts/aztec-network/templates/deploy-l2-contracts.job.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ spec:
2626
sleep 5
2727
done
2828
echo "PXE service is ready!"
29+
set -e
2930
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts
31+
echo "Deployed L2 contracts"
3032
env:
3133
- name: PXE_URL
3234
value: {{ include "aztec-network.pxeUrl" . | quote }}

helm-charts/aztec-network/templates/prover-node.stateful-set.yaml

+14-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ spec:
1818
app: prover-node
1919
spec:
2020
initContainers:
21-
- name: configure-validator-env
21+
- name: configure-prover-env
2222
image: "{{ .Values.images.aztec.image }}"
2323
imagePullPolicy: {{ .Values.images.aztec.pullPolicy }}
2424
command:
2525
- "/bin/sh"
2626
- "-c"
27-
- "cp /scripts/configure-validator-env.sh /tmp/configure-validator-env.sh && chmod +x /tmp/configure-validator-env.sh && /tmp/configure-validator-env.sh"
27+
- "cp /scripts/configure-prover-env.sh /tmp/configure-prover-env.sh && chmod +x /tmp/configure-prover-env.sh && /tmp/configure-prover-env.sh {{ include "aztec-network.bootNodeUrl" . }}"
2828
volumeMounts:
2929
- name: shared-volume
3030
mountPath: /shared
@@ -84,4 +84,15 @@ spec:
8484
emptyDir: {}
8585
- name: scripts
8686
configMap:
87-
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
87+
name: {{ include "aztec-network.fullname" . }}-configure-prover-env
88+
89+
---
90+
apiVersion: v1
91+
kind: ConfigMap
92+
metadata:
93+
name: {{ include "aztec-network.fullname" . }}-configure-prover-env
94+
labels:
95+
{{- include "aztec-network.labels" . | nindent 4 }}
96+
data:
97+
configure-prover-env.sh: |
98+
{{ .Files.Get "files/config/config-prover-env.sh" | nindent 4 }}

helm-charts/aztec-network/templates/validator.stateful-set.yaml

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
command:
2525
- "/bin/sh"
2626
- "-c"
27-
- "cp /scripts/configure-validator-env.sh /tmp/configure-validator-env.sh && chmod +x /tmp/configure-validator-env.sh && /tmp/configure-validator-env.sh"
27+
- "cp /scripts/configure-validator-env.sh /tmp/configure-validator-env.sh && chmod +x /tmp/configure-validator-env.sh && /tmp/configure-validator-env.sh {{ include "aztec-network.bootNodeUrl" . }}"
2828
volumeMounts:
2929
- name: shared-volume
3030
mountPath: /shared
@@ -93,4 +93,15 @@ spec:
9393
emptyDir: {}
9494
- name: scripts
9595
configMap:
96-
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
96+
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
97+
98+
---
99+
apiVersion: v1
100+
kind: ConfigMap
101+
metadata:
102+
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
103+
labels:
104+
{{- include "aztec-network.labels" . | nindent 4 }}
105+
data:
106+
configure-validator-env.sh: |
107+
{{ .Files.Get "files/config/config-validator-env.sh" | nindent 4 }}

helm-charts/aztec-network/values.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ images:
99
image: curlimages/curl:7.81.0
1010
pullPolicy: IfNotPresent
1111
foundry:
12-
image: ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f
12+
image: ghcr.io/foundry-rs/foundry@sha256:ce4b236f6760fdeb08e82267c9fa17647d29a374760bfe7ee01998fb8c0aaad7
1313
pullPolicy: IfNotPresent
1414
otelCollector:
1515
image: otel/opentelemetry-collector-contrib
@@ -83,6 +83,10 @@ pxe:
8383
ethereum:
8484
replicas: 1
8585
chainId: 31337
86+
blockTime: 12
87+
# 1 billion gas limit
88+
# helps ensure we can deploy public contracts
89+
gasLimit: "1000000000"
8690
forkUrl: ""
8791
forkBlockNumber: ""
8892
args: ""
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
validator:
2+
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:libp2p_service"
23
replicas: 3
34
validator:
45
disabled: false
56

67
bootNode:
78
validator:
8-
disabled: false
9+
disabled: true

yarn-project/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ aztec-prod:
150150

151151
aztec:
152152
FROM ubuntu:noble
153-
RUN apt update && apt install nodejs curl -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
153+
RUN apt update && apt install nodejs curl jq -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
154154
COPY +aztec-prod/usr/src /usr/src
155155
ENV BB_WORKING_DIRECTORY=/usr/src/bb
156156
ENV BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb

yarn-project/aztec.js/src/utils/cheat_codes.ts

+13
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ export class EthCheatCodes {
9494
this.logger.info(`Mined ${numberOfBlocks} blocks`);
9595
}
9696

97+
/**
98+
* Set the balance of an account
99+
* @param account - The account to set the balance for
100+
* @param balance - The balance to set
101+
*/
102+
public async setBalance(account: EthAddress, balance: bigint): Promise<void> {
103+
const res = await this.rpcCall('anvil_setBalance', [account.toString(), toHex(balance)]);
104+
if (res.error) {
105+
throw new Error(`Error setting balance for ${account}: ${res.error.message}`);
106+
}
107+
this.logger.info(`Set balance for ${account} to ${balance}`);
108+
}
109+
97110
/**
98111
* Set the interval between blocks (block time)
99112
* @param interval - The interval to use between blocks

0 commit comments

Comments
 (0)