Skip to content

Commit 8ede7b1

Browse files
authored
chore(spartan): kind test speedup (#12478)
1 parent ab13d43 commit 8ede7b1

22 files changed

+434
-330
lines changed

spartan/aztec-network/files/config/deploy-l1-contracts.sh

+20-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ SALT=${1:-$RANDOM}
1616
CHAIN_ID=$2
1717
VALIDATOR_ADDRESSES=$3
1818

19+
# If the chain ID is 11155111 or 1, we are deploying to a public network, make sure that we do not use accelerated test deployments
20+
PUBLIC_CHAIN_ID=false
21+
if [ "$CHAIN_ID" = "11155111" -o "$CHAIN_ID" = "1" ]; then
22+
PUBLIC_CHAIN_ID=true
23+
fi
24+
25+
# Overwrite the value of ACCELERATED_TEST_DEPLOYMENTS env variable if we are deploying to a public network
26+
if [ "$PUBLIC_CHAIN_ID" = "true" ]; then
27+
ACCELERATED_TEST_DEPLOYMENTS=false
28+
fi
29+
1930
# Run the deploy-l1-contracts command and capture the output
2031
output=""
2132
MAX_RETRIES=5
@@ -26,9 +37,14 @@ if [ "$TEST_ACCOUNTS" = "true" ]; then
2637
TEST_ACCOUNTS_ARG="--test-accounts"
2738
fi
2839

40+
ACCELERATED_TEST_DEPLOYMENTS_ARG=""
41+
if [ "$ACCELERATED_TEST_DEPLOYMENTS" = "true" ]; then
42+
ACCELERATED_TEST_DEPLOYMENTS_ARG="--accelerated-test-deployments"
43+
fi
44+
2945
for attempt in $(seq 1 $MAX_RETRIES); do
3046
# Construct base command
31-
base_cmd="LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts $TEST_ACCOUNTS_ARG"
47+
base_cmd="LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts $TEST_ACCOUNTS_ARG $ACCELERATED_TEST_DEPLOYMENTS_ARG"
3248

3349
# Add account - use private key if set, otherwise use mnemonic
3450
if [ -n "${L1_DEPLOYMENT_PRIVATE_KEY:-}" ]; then
@@ -39,11 +55,11 @@ for attempt in $(seq 1 $MAX_RETRIES); do
3955

4056
# Add validators if INIT_VALIDATORS is true
4157
if [ "${INIT_VALIDATORS:-false}" = "true" ]; then
42-
output=$(eval $base_cmd --validators $VALIDATOR_ADDRESSES --l1-chain-id $CHAIN_ID --salt $SALT) && break
43-
else
44-
output=$(eval $base_cmd --l1-chain-id $CHAIN_ID --salt $SALT) && break
58+
base_cmd="$base_cmd --validators $VALIDATOR_ADDRESSES"
4559
fi
4660

61+
output=$(eval $base_cmd --l1-chain-id $CHAIN_ID --salt $SALT) && break
62+
4763
echo "Attempt $attempt failed. Retrying in $RETRY_DELAY seconds..."
4864
sleep "$RETRY_DELAY"
4965
done || {

spartan/aztec-network/files/config/setup-p2p-addresses.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ else
3030
fi
3131

3232
# Write addresses to file for sourcing
33-
echo "export P2P_TCP_ANNOUNCE_ADDR=${TCP_ADDR}" > /shared/p2p/p2p-addresses
34-
echo "export P2P_TCP_LISTEN_ADDR=0.0.0.0:${P2P_TCP_PORT}" >> /shared/p2p/p2p-addresses
35-
echo "export P2P_UDP_ANNOUNCE_ADDR=${UDP_ADDR}" >> /shared/p2p/p2p-addresses
36-
echo "export P2P_UDP_LISTEN_ADDR=0.0.0.0:${P2P_UDP_PORT}" >> /shared/p2p/p2p-addresses
33+
echo "export P2P_TCP_ANNOUNCE_ADDR=${TCP_ADDR}" > /shared/config/p2p-addresses
34+
echo "export P2P_TCP_LISTEN_ADDR=0.0.0.0:${P2P_TCP_PORT}" >> /shared/config/p2p-addresses
35+
echo "export P2P_UDP_ANNOUNCE_ADDR=${UDP_ADDR}" >> /shared/config/p2p-addresses
36+
echo "export P2P_UDP_LISTEN_ADDR=0.0.0.0:${P2P_UDP_PORT}" >> /shared/config/p2p-addresses
3737

3838
echo "P2P addresses configured:"
39-
cat /shared/p2p/p2p-addresses
39+
cat /shared/config/p2p-addresses

spartan/aztec-network/templates/_helpers.tpl

+142-35
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ http://{{ include "aztec-network.fullname" . }}-pxe.{{ .Release.Namespace }}:{{
6565
{{- end -}}
6666

6767
{{- define "aztec-network.bootNodeUrl" -}}
68-
http://{{ include "aztec-network.fullname" . }}-boot-node-0.{{ include "aztec-network.fullname" . }}-boot-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.bootNode.service.nodePort }}
68+
http://{{ include "aztec-network.fullname" . }}-boot-node.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.bootNode.service.nodePort }}
6969
{{- end -}}
7070

7171
{{- define "aztec-network.validatorUrl" -}}
@@ -94,34 +94,6 @@ http://{{ include "aztec-network.fullname" . }}-metrics.{{ .Release.Namespace }}
9494
{{- end -}}
9595
{{- end -}}
9696

97-
{{/*
98-
P2P Setup Container
99-
*/}}
100-
{{- define "aztec-network.p2pSetupContainer" -}}
101-
- name: setup-p2p-addresses
102-
image: bitnami/kubectl
103-
command:
104-
- /bin/sh
105-
- -c
106-
- |
107-
cp /scripts/setup-p2p-addresses.sh /tmp/setup-p2p-addresses.sh && \
108-
chmod +x /tmp/setup-p2p-addresses.sh && \
109-
/tmp/setup-p2p-addresses.sh
110-
env:
111-
- name: NETWORK_PUBLIC
112-
value: "{{ .Values.network.public }}"
113-
- name: NAMESPACE
114-
value: {{ .Release.Namespace }}
115-
- name: P2P_TCP_PORT
116-
value: "{{ .Values.validator.service.p2pTcpPort }}"
117-
- name: P2P_UDP_PORT
118-
value: "{{ .Values.validator.service.p2pUdpPort }}"
119-
volumeMounts:
120-
- name: scripts
121-
mountPath: /scripts
122-
- name: p2p-addresses
123-
mountPath: /shared/p2p
124-
{{- end -}}
12597

12698
{{/*
12799
Service Address Setup Container
@@ -133,9 +105,7 @@ Service Address Setup Container
133105
- /bin/bash
134106
- -c
135107
- |
136-
cp /scripts/setup-service-addresses.sh /tmp/setup-service-addresses.sh && \
137-
chmod +x /tmp/setup-service-addresses.sh && \
138-
/tmp/setup-service-addresses.sh
108+
/scripts/setup-service-addresses.sh
139109
env:
140110
- name: NETWORK_PUBLIC
141111
value: "{{ .Values.network.public }}"
@@ -189,9 +159,7 @@ Sets up the OpenTelemetry resource attributes for a service
189159
- /bin/bash
190160
- -c
191161
- |
192-
cp /scripts/setup-otel-resource.sh /tmp/setup-otel-resource.sh && \
193-
chmod +x /tmp/setup-otel-resource.sh && \
194-
/tmp/setup-otel-resource.sh
162+
/scripts/setup-otel-resource.sh
195163
env:
196164
- name: POD_IP
197165
valueFrom:
@@ -263,3 +231,142 @@ while true; do
263231
sleep 5
264232
done
265233
{{- end -}}
234+
235+
{{/*
236+
Combined wait-for-services and configure-env container for full nodes
237+
*/}}
238+
{{- define "aztec-network.combinedWaitAndConfigureContainer" -}}
239+
- name: wait-and-configure
240+
{{- include "aztec-network.image" . | nindent 2 }}
241+
command:
242+
- /bin/bash
243+
- -c
244+
- |
245+
# If we already have a registry address, and the bootstrap nodes are set, then we don't need to wait for the services
246+
if [ -n "{{ .Values.aztec.contracts.registryAddress }}" ] && [ -n "{{ .Values.aztec.bootstrapENRs }}" ]; then
247+
echo "Registry address and bootstrap nodes already set, skipping wait for services"
248+
echo "{{ include "aztec-network.pxeUrl" . }}" > /shared/pxe/pxe_url
249+
else
250+
source /shared/config/service-addresses
251+
cat /shared/config/service-addresses
252+
{{- include "aztec-network.waitForEthereum" . | nindent 8 }}
253+
254+
if [ "{{ .Values.validator.dynamicBootNode }}" = "true" ]; then
255+
echo "{{ include "aztec-network.pxeUrl" . }}" > /shared/pxe/pxe_url
256+
else
257+
until curl --silent --head --fail "${BOOT_NODE_HOST}/status" > /dev/null; do
258+
echo "Waiting for boot node..."
259+
sleep 5
260+
done
261+
echo "Boot node is ready!"
262+
echo "${BOOT_NODE_HOST}" > /shared/pxe/pxe_url
263+
fi
264+
fi
265+
266+
# Configure environment
267+
source /shared/config/service-addresses
268+
/scripts/configure-full-node-env.sh "$(cat /shared/pxe/pxe_url)"
269+
volumeMounts:
270+
- name: pxe-url
271+
mountPath: /shared/pxe
272+
- name: scripts
273+
mountPath: /scripts
274+
- name: config
275+
mountPath: /shared/config
276+
- name: contracts-env
277+
mountPath: /shared/contracts
278+
env:
279+
- name: P2P_ENABLED
280+
value: "{{ .Values.fullNode.p2p.enabled }}"
281+
- name: BOOTSTRAP_NODES
282+
value: "{{ .Values.aztec.bootstrapENRs }}"
283+
- name: REGISTRY_CONTRACT_ADDRESS
284+
value: "{{ .Values.aztec.contracts.registryAddress }}"
285+
- name: SLASH_FACTORY_CONTRACT_ADDRESS
286+
value: "{{ .Values.aztec.contracts.slashFactoryAddress }}"
287+
{{- end -}}
288+
289+
{{/*
290+
Combined P2P, Service Address, and OpenTelemetry Setup Container
291+
*/}}
292+
{{- define "aztec-network.combinedAllSetupContainer" -}}
293+
{{- $serviceName := base $.Template.Name | trimSuffix ".yaml" -}}
294+
- name: setup-all
295+
{{- include "aztec-network.image" . | nindent 2 }}
296+
command:
297+
- /bin/bash
298+
- -c
299+
- |
300+
# Setup P2P addresses
301+
/scripts/setup-p2p-addresses.sh
302+
303+
# Setup service addresses
304+
/scripts/setup-service-addresses.sh
305+
306+
# Setup OpenTelemetry resource
307+
/scripts/setup-otel-resource.sh
308+
env:
309+
- name: NETWORK_PUBLIC
310+
value: "{{ .Values.network.public }}"
311+
- name: NAMESPACE
312+
value: {{ .Release.Namespace }}
313+
- name: P2P_TCP_PORT
314+
value: "{{ .Values.validator.service.p2pTcpPort }}"
315+
- name: P2P_UDP_PORT
316+
value: "{{ .Values.validator.service.p2pUdpPort }}"
317+
- name: TELEMETRY
318+
value: "{{ .Values.telemetry.enabled }}"
319+
- name: OTEL_COLLECTOR_ENDPOINT
320+
value: "{{ .Values.telemetry.otelCollectorEndpoint }}"
321+
- name: EXTERNAL_ETHEREUM_HOSTS
322+
value: "{{ .Values.ethereum.execution.externalHosts }}"
323+
- name: ETHEREUM_PORT
324+
value: "{{ .Values.ethereum.execution.service.port }}"
325+
- name: EXTERNAL_ETHEREUM_CONSENSUS_HOST
326+
value: "{{ .Values.ethereum.beacon.externalHost }}"
327+
- name: EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY
328+
value: "{{ .Values.ethereum.beacon.apiKey }}"
329+
- name: EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY_HEADER
330+
value: "{{ .Values.ethereum.beacon.apiKeyHeader }}"
331+
- name: ETHEREUM_CONSENSUS_PORT
332+
value: "{{ .Values.ethereum.beacon.service.port }}"
333+
- name: EXTERNAL_BOOT_NODE_HOST
334+
value: "{{ .Values.bootNode.externalHost }}"
335+
- name: BOOT_NODE_PORT
336+
value: "{{ .Values.bootNode.service.nodePort }}"
337+
- name: EXTERNAL_PROVER_NODE_HOST
338+
value: "{{ .Values.proverNode.externalHost }}"
339+
- name: PROVER_NODE_PORT
340+
value: "{{ .Values.proverNode.service.nodePort }}"
341+
- name: PROVER_BROKER_PORT
342+
value: "{{ .Values.proverBroker.service.nodePort }}"
343+
- name: USE_GCLOUD_LOGGING
344+
value: "{{ .Values.telemetry.useGcloudLogging }}"
345+
- name: SERVICE_NAME
346+
value: {{ include "aztec-network.fullname" . }}
347+
- name: POD_IP
348+
valueFrom:
349+
fieldRef:
350+
fieldPath: status.podIP
351+
- name: K8S_POD_UID
352+
valueFrom:
353+
fieldRef:
354+
fieldPath: metadata.uid
355+
- name: K8S_POD_NAME
356+
valueFrom:
357+
fieldRef:
358+
fieldPath: metadata.name
359+
- name: K8S_NAMESPACE_NAME
360+
valueFrom:
361+
fieldRef:
362+
fieldPath: metadata.namespace
363+
- name: OTEL_SERVICE_NAME
364+
value: "{{ $serviceName }}"
365+
- name: OTEL_RESOURCE_ATTRIBUTES
366+
value: 'service.namespace={{ .Release.Namespace }},environment={{ .Values.environment | default "production" }}'
367+
volumeMounts:
368+
- name: scripts
369+
mountPath: /scripts
370+
- name: config
371+
mountPath: /shared/config
372+
{{- end -}}

spartan/aztec-network/templates/boot-node.yaml

+8-25
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ spec:
3939
serviceAccountName: {{ include "aztec-network.fullname" . }}-node
4040
{{- include "aztec-network.publicAntiAffinity" . | nindent 6 }}
4141
{{- end }}
42+
terminationGracePeriodSeconds: 5 # default is 30 - speed up initcontainer termination
4243
initContainers:
43-
{{- include "aztec-network.p2pSetupContainer" . | nindent 8 }}
44-
{{- include "aztec-network.serviceAddressSetupContainer" . | nindent 8 }}
45-
{{- include "aztec-network.otelResourceSetupContainer" . | nindent 8 }}
44+
{{- include "aztec-network.combinedAllSetupContainer" . | nindent 8 }}
4645

4746
# Generate the validator addresses; used in the deploy-l1-contracts step
4847
- name: generate-validator-addresses
@@ -66,32 +65,18 @@ spec:
6665
- name: NUMBER_OF_VALIDATORS
6766
value: {{ .Values.validator.replicas | quote }}
6867

69-
- name: wait-for-ethereum
70-
{{- include "aztec-network.image" . | nindent 10 }}
71-
command:
72-
- /bin/bash
73-
- -c
74-
- |
75-
source /shared/config/service-addresses
76-
cat /shared/config/service-addresses
77-
{{- include "aztec-network.waitForEthereum" . | nindent 14 }}
78-
volumeMounts:
79-
- name: config
80-
mountPath: /shared/config
8168
- name: deploy-l1-contracts
8269
{{- include "aztec-network.image" . | nindent 10 }}
8370
command:
8471
- /bin/bash
8572
- -c
8673
- |
87-
cp /scripts/deploy-l1-contracts.sh /tmp/deploy-l1-contracts.sh
88-
chmod +x /tmp/deploy-l1-contracts.sh
8974
source /shared/config/service-addresses
9075
source /shared/config/validator-addresses
9176
{{- include "aztec-network.waitForEthereum" . | nindent 14 }}
9277
9378
94-
/tmp/deploy-l1-contracts.sh "{{ .Values.aztec.l1Salt }}" "{{ .Values.ethereum.chainId }}" "$VALIDATOR_ADDRESSES"
79+
/scripts/deploy-l1-contracts.sh "{{ .Values.aztec.l1Salt }}" "{{ .Values.ethereum.chainId }}" "$VALIDATOR_ADDRESSES"
9580
volumeMounts:
9681
- name: scripts-output
9782
mountPath: /shared/contracts
@@ -100,6 +85,8 @@ spec:
10085
- name: scripts
10186
mountPath: /scripts
10287
env:
88+
- name: ACCELERATED_TEST_DEPLOYMENTS
89+
value: "{{ .Values.ethereum.acceleratedTestDeployments }}"
10390
- name: TEST_ACCOUNTS
10491
value: "{{ .Values.aztec.testAccounts }}"
10592
- name: REGISTRY_CONTRACT_ADDRESS
@@ -145,9 +132,8 @@ spec:
145132
- /bin/bash
146133
- -c
147134
- |
148-
sleep 30 && \
149135
source /shared/contracts/contracts.env && \
150-
source /shared/p2p/p2p-addresses && \
136+
source /shared/config/p2p-addresses && \
151137
source /shared/config/service-addresses && \
152138
source /shared/config/otel-resource && \
153139
env && \
@@ -167,8 +153,6 @@ spec:
167153
timeoutSeconds: 30
168154
failureThreshold: 3
169155
volumeMounts:
170-
- name: p2p-addresses
171-
mountPath: /shared/p2p
172156
- name: config
173157
mountPath: /shared/config
174158
- name: boot-node-data
@@ -256,8 +240,6 @@ spec:
256240
resources:
257241
{{- toYaml .Values.bootNode.resources | nindent 12 }}
258242
volumes:
259-
- name: p2p-addresses
260-
emptyDir: {}
261243
- name: config
262244
emptyDir: {}
263245
{{- if .Values.storage.localSsd }}
@@ -271,6 +253,7 @@ spec:
271253
- name: scripts
272254
configMap:
273255
name: {{ include "aztec-network.fullname" . }}-scripts
256+
defaultMode: 0755
274257
- name: scripts-output
275258
emptyDir: {}
276259
---
@@ -300,7 +283,7 @@ spec:
300283
# External load balancers cannot handle mixed TCP/UDP ports, so we only expose the node port
301284
{{- if not .Values.network.public }}
302285
- port: {{ .Values.bootNode.service.p2pTcpPort }}
303-
name: p2p-tpc
286+
name: p2p-tcp
304287
- port: {{ .Values.bootNode.service.p2pUdpPort }}
305288
name: p2p-udp
306289
protocol: UDP

spartan/aztec-network/templates/consolidate-balances.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ spec:
2626
- name: scripts
2727
configMap:
2828
name: {{ include "aztec-network.fullname" . }}-scripts
29+
defaultMode: 0755
2930
containers:
3031
- name: consolidate-balances
3132
{{- include "aztec-network.image" . | nindent 10 }}
@@ -38,9 +39,7 @@ spec:
3839
- /bin/bash
3940
- -c
4041
- |
41-
cp /scripts/consolidate-sepolia-balances.sh /tmp/consolidate-sepolia-balances.sh
42-
chmod +x /tmp/consolidate-sepolia-balances.sh
43-
/tmp/consolidate-sepolia-balances.sh "{{ .Values.aztec.l1DeploymentMnemonic }}" {{ add .Values.validator.replicas .Values.proverNode.replicas }}
42+
/scripts/consolidate-sepolia-balances.sh "{{ .Values.aztec.l1DeploymentMnemonic }}" {{ add .Values.validator.replicas .Values.proverNode.replicas }}
4443
env:
4544
- name: ETHEREUM_HOSTS
4645
value: "{{ .Values.ethereum.execution.externalHosts }}"

0 commit comments

Comments
 (0)