Skip to content

Commit

Permalink
feat: sequencer selection in k8s tests (#8313)
Browse files Browse the repository at this point in the history
Update the k8s e2e tests to use proper validators.
  • Loading branch information
just-mitch authored Sep 3, 2024
1 parent e8a097c commit 8d9947d
Show file tree
Hide file tree
Showing 17 changed files with 397 additions and 62 deletions.
34 changes: 34 additions & 0 deletions helm-charts/aztec-network/files/config/config-prover-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
set -e

alias aztec='node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js'

# Pass the bootnode url as an argument
# Ask the bootnode for l1 contract addresses
output=$(aztec get-node-info -u $1)

echo "$output"

boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+')
rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')


# Write the addresses to a file in the shared volume
cat <<EOF > /shared/contracts.env
export BOOTSTRAP_NODES=$boot_node_enr
export ROLLUP_CONTRACT_ADDRESS=$rollup_address
export REGISTRY_CONTRACT_ADDRESS=$registry_address
export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
EOF

cat /shared/contracts.env
48 changes: 48 additions & 0 deletions helm-charts/aztec-network/files/config/config-validator-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
set -e

alias aztec='node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js'

# Pass the bootnode url as an argument
# Ask the bootnode for l1 contract addresses
output=$(aztec get-node-info -u $1)

echo "$output"

boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+')
rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

# Generate a private key for the validator
json_account=$(aztec generate-l1-account)

echo "$json_account"
address=$(echo $json_account | jq -r '.address')
private_key=$(echo $json_account | jq -r '.privateKey')

aztec add-l1-validator --validator $address --rollup $rollup_address

aztec fast-forward-epochs --rollup $rollup_address --count 1


# Write the addresses to a file in the shared volume
cat <<EOF > /shared/contracts.env
export BOOTSTRAP_NODES=$boot_node_enr
export ROLLUP_CONTRACT_ADDRESS=$rollup_address
export REGISTRY_CONTRACT_ADDRESS=$registry_address
export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
export VALIDATOR_PRIVATE_KEY=$private_key
export L1_PRIVATE_KEY=$private_key
export SEQ_PUBLISHER_PRIVATE_KEY=$private_key
EOF

cat /shared/contracts.env
14 changes: 13 additions & 1 deletion helm-charts/aztec-network/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,16 @@ http://{{ include "aztec-network.fullname" . }}-metrics.{{ .Release.Namespace }}




{{- define "helpers.flag" -}}
{{- $name := index . 0 -}}
{{- $value := index . 1 -}}
{{- if $value -}}
{{- if kindIs "string" $value -}}
{{- if ne $value "" -}}
--{{ $name }} {{ $value }}
{{- end -}}
{{- else -}}
--{{ $name }} {{ $value }}
{{- end -}}
{{- end -}}
{{- end -}}
23 changes: 9 additions & 14 deletions helm-charts/aztec-network/templates/anvil.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,18 @@ spec:
imagePullPolicy: {{ .Values.images.foundry.pullPolicy }}
command: ["/bin/sh", "-c"]
args:
- |
[ -n "$FORK_URL" ] && ARGS="$ARGS --fork-url $FORK_URL";
[ -n "$FORK_BLOCK_NUMBER" ] && ARGS="$ARGS --fork-block-number $FORK_BLOCK_NUMBER";
echo anvil --block-time 12 -p $ANVIL_PORT --host 0.0.0.0 --chain-id {{ .Values.ethereum.chainId }} $ARGS;
anvil --block-time 12 -p $ANVIL_PORT --host 0.0.0.0 --chain-id {{ .Values.ethereum.chainId }} $ARGS;
- >-
anvil
--host 0.0.0.0
{{ include "helpers.flag" (list "block-time" .Values.ethereum.blockTime) }}
{{ include "helpers.flag" (list "chain-id" .Values.ethereum.chainId) }}
{{ include "helpers.flag" (list "gas-limit" .Values.ethereum.gasLimit) }}
{{ include "helpers.flag" (list "fork-url" .Values.ethereum.forkUrl) }}
{{ include "helpers.flag" (list "fork-block-number" .Values.ethereum.forkBlockNumber) }}
-p {{ .Values.ethereum.service.port }}
ports:
- containerPort: {{ .Values.ethereum.service.port }}
name: anvil
env:
- name: FORK_URL
value: {{ .Values.ethereum.forkUrl | quote }}
- name: FORK_BLOCK_NUMBER
value: {{ .Values.ethereum.forkBlockNumber | quote }}
- name: ANVIL_PORT
value: {{ .Values.ethereum.service.port | quote }}
- name: ARGS
value: {{ .Values.ethereum.args | quote }}
readinessProbe:
exec:
command:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ spec:
sleep 5
done
echo "PXE service is ready!"
set -e
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts
echo "Deployed L2 contracts"
env:
- name: PXE_URL
value: {{ include "aztec-network.pxeUrl" . | quote }}
Expand Down
17 changes: 14 additions & 3 deletions helm-charts/aztec-network/templates/prover-node.stateful-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ spec:
app: prover-node
spec:
initContainers:
- name: configure-validator-env
- name: configure-prover-env
image: "{{ .Values.images.aztec.image }}"
imagePullPolicy: {{ .Values.images.aztec.pullPolicy }}
command:
- "/bin/sh"
- "-c"
- "cp /scripts/configure-validator-env.sh /tmp/configure-validator-env.sh && chmod +x /tmp/configure-validator-env.sh && /tmp/configure-validator-env.sh"
- "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" . }}"
volumeMounts:
- name: shared-volume
mountPath: /shared
Expand Down Expand Up @@ -84,4 +84,15 @@ spec:
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
name: {{ include "aztec-network.fullname" . }}-configure-prover-env

---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "aztec-network.fullname" . }}-configure-prover-env
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
data:
configure-prover-env.sh: |
{{ .Files.Get "files/config/config-prover-env.sh" | nindent 4 }}
15 changes: 13 additions & 2 deletions helm-charts/aztec-network/templates/validator.stateful-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
command:
- "/bin/sh"
- "-c"
- "cp /scripts/configure-validator-env.sh /tmp/configure-validator-env.sh && chmod +x /tmp/configure-validator-env.sh && /tmp/configure-validator-env.sh"
- "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" . }}"
volumeMounts:
- name: shared-volume
mountPath: /shared
Expand Down Expand Up @@ -93,4 +93,15 @@ spec:
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
name: {{ include "aztec-network.fullname" . }}-configure-validator-env

---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "aztec-network.fullname" . }}-configure-validator-env
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
data:
configure-validator-env.sh: |
{{ .Files.Get "files/config/config-validator-env.sh" | nindent 4 }}
6 changes: 5 additions & 1 deletion helm-charts/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ images:
image: curlimages/curl:7.81.0
pullPolicy: IfNotPresent
foundry:
image: ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f
image: ghcr.io/foundry-rs/foundry@sha256:ce4b236f6760fdeb08e82267c9fa17647d29a374760bfe7ee01998fb8c0aaad7
pullPolicy: IfNotPresent
otelCollector:
image: otel/opentelemetry-collector-contrib
Expand Down Expand Up @@ -83,6 +83,10 @@ pxe:
ethereum:
replicas: 1
chainId: 31337
blockTime: 12
# 1 billion gas limit
# helps ensure we can deploy public contracts
gasLimit: "1000000000"
forkUrl: ""
forkBlockNumber: ""
args: ""
Expand Down
3 changes: 2 additions & 1 deletion helm-charts/aztec-network/values/3-validators.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
validator:
debug: "aztec:*,-aztec:avm_simulator:*,-aztec:libp2p_service"
replicas: 3
validator:
disabled: false

bootNode:
validator:
disabled: false
disabled: true
2 changes: 1 addition & 1 deletion yarn-project/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ aztec-prod:

aztec:
FROM ubuntu:noble
RUN apt update && apt install nodejs curl -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt update && apt install nodejs curl jq -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY +aztec-prod/usr/src /usr/src
ENV BB_WORKING_DIRECTORY=/usr/src/bb
ENV BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb
Expand Down
13 changes: 13 additions & 0 deletions yarn-project/aztec.js/src/utils/cheat_codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ export class EthCheatCodes {
this.logger.info(`Mined ${numberOfBlocks} blocks`);
}

/**
* Set the balance of an account
* @param account - The account to set the balance for
* @param balance - The balance to set
*/
public async setBalance(account: EthAddress, balance: bigint): Promise<void> {
const res = await this.rpcCall('anvil_setBalance', [account.toString(), toHex(balance)]);
if (res.error) {
throw new Error(`Error setting balance for ${account}: ${res.error.message}`);
}
this.logger.info(`Set balance for ${account} to ${balance}`);
}

/**
* Set the interval between blocks (block time)
* @param interval - The interval to use between blocks
Expand Down
Loading

0 comments on commit 8d9947d

Please sign in to comment.