Skip to content

Commit

Permalink
feat: Add Aztec Bot to helm testnet package (#8702)
Browse files Browse the repository at this point in the history
This PR adds an Aztec bot to the Helm package used to deploy testnets
into the Spartan Kubernetes cluster.

The code is an adaptation of the container parameters used in the
existing [docker
compose](https://github.com/AztecProtocol/aztec-packages/blob/master/docker-compose.provernet.yml#L55)
configuration for provernet. The code has been tested by completing a
deployment to the Spartan cluster and viewing the stdout of the bot
container to validate that all processes come online without error.

Bot node stdout:
```
{"level":"debug","message":"JsonRpcClient.result node_getBlocks -> { jsonrpc: '2.0', id: 755, result: [] }","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:18.555Z"}
{"level":"debug","message":"JsonRpcClient.result node_getTxReceipt -> {\n  jsonrpc: '2.0',\n  id: 756,\n  result: {\n    type: 'TxReceipt',\n    data: {\n      txHash: '044a9048eca9fc47c13ccf71243a588ed90835e3822d24e05f21bea74de75cc5',\n      status: 'pending',\n      error: ''\n    }\n  }\n}","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:18.556Z"}
{"level":"debug","message":"JsonRpcClient.constructor proxy node_getBlocks <- [ 12, 1 ]","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.555Z"}
{"level":"debug","message":"JsonRpcClient.request node_getBlocks <- [ 12, 1 ]","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.555Z"}
{"level":"debug","message":"JsonRpcClient.fetch http://staging-aztec-network-boot-node-0.staging-aztec-network-boot-node.staging.svc.cluster.local:8080/ node_getBlocks -> {\n  jsonrpc: '2.0',\n  id: 757,\n  method: 'node_getBlocks',\n  params: [ 12, 1 ]\n}","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.555Z"}
{"level":"debug","message":"JsonRpcClient.constructor proxy node_getTxReceipt <- [\n  TxHash {\n    buffer: <Buffer 04 4a 90 48 ec a9 fc 47 c1 3c cf 71 24 3a 58 8e d9 08 35 e3 82 2d 24 e0 5f 21 be a7 4d e7 5c c5>\n  }\n]","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.556Z"}
{"level":"debug","message":"JsonRpcClient.request node_getTxReceipt <- [\n  TxHash {\n    buffer: <Buffer 04 4a 90 48 ec a9 fc 47 c1 3c cf 71 24 3a 58 8e d9 08 35 e3 82 2d 24 e0 5f 21 be a7 4d e7 5c c5>\n  }\n]","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.556Z"}
{"level":"debug","message":"JsonRpcClient.fetch http://staging-aztec-network-boot-node-0.staging-aztec-network-boot-node.staging.svc.cluster.local:8080/ node_getTxReceipt -> {\n  jsonrpc: '2.0',\n  id: 758,\n  method: 'node_getTxReceipt',\n  params: [\n    {\n      type: 'TxHash',\n      data: '044a9048eca9fc47c13ccf71243a588ed90835e3822d24e05f21bea74de75cc5'\n    }\n  ]\n}","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.556Z"}
{"level":"debug","message":"JsonRpcClient.result node_getBlocks -> { jsonrpc: '2.0', id: 757, result: [] }","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.569Z"}
{"level":"debug","message":"JsonRpcClient.result node_getTxReceipt -> {\n  jsonrpc: '2.0',\n  id: 758,\n  result: {\n    type: 'TxReceipt',\n    data: {\n      txHash: '044a9048eca9fc47c13ccf71243a588ed90835e3822d24e05f21bea74de75cc5',\n      status: 'pending',\n      error: ''\n    }\n  }\n}","module":"json-rpc:json_rpc_client","timestamp":"2024-09-20T20:29:19.569Z"}
```
  • Loading branch information
stevenplatt authored Sep 24, 2024
1 parent c96d923 commit 982a04e
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
102 changes: 102 additions & 0 deletions spartan/aztec-network/templates/transaction-bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "aztec-network.fullname" . }}-bot
labels:
app: {{- include "aztec-network.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.bot.replicas }}
selector:
matchLabels:
app: {{- include "aztec-network.selectorLabels" . | nindent 6 }}
app: bot
template:
metadata:
labels:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: bot
spec:
initContainers:
- name: wait-for-aztec-node
image: "{{ .Values.images.curl.image }}"
command:
- /bin/sh
- -c
- |
until curl -s {{ include "aztec-network.bootNodeUrl" . }}/status; do echo waiting for aztec-node; sleep 2; done
containers:
- name: aztec
image: "{{ .Values.images.aztec.image }}"
command:
- "/bin/bash"
- "-c"
- >
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe --bot
env:
- name: ETHEREUM_HOST
value: {{ include "aztec-network.ethereumHost" . | quote }}
- name: AZTEC_NODE_URL
value: {{ include "aztec-network.bootNodeUrl" . | quote }}
- name: LOG_JSON
value: "1"
- name: LOG_LEVEL
value: "{{ .Values.bot.logLevel }}"
- name: DEBUG
value: "{{ .Values.bot.debug }}"
- name: BOT_PRIVATE_KEY
value: "{{ .Values.bot.botPrivateKey }}"
- name: BOT_TX_INTERVAL_SECONDS
value: "{{ .Values.bot.txIntervalSeconds }}"
- name: BOT_PRIVATE_TRANSFERS_PER_TX
value: "{{ .Values.bot.privateTransfersPerTx }}"
- name: BOT_PUBLIC_TRANSFERS_PER_TX
value: "{{ .Values.bot.publicTransfersPerTx }}"
- name: BOT_NO_WAIT_FOR_TRANSFERS
value: "{{ .Values.bot.noWaitForTransfers }}"
- name: BOT_NO_START
value: "{{ .Values.bot.botNoStart }}"
- name: PXE_PROVER_ENABLED
value: "{{ .Values.bot.pxeProverEnabled }}"
- name: PROVER_REAL_PROOFS
value: "{{ .Values.bot.proverRealProofs }}"
ports:
- name: http
containerPort: {{ .Values.bot.service.port }}
protocol: TCP
readinessProbe:
exec:
command:
- /bin/bash
- -c
- |
curl -s -X POST -H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","method":"pxe_getNodeInfo","params":[],"id":67}' \
127.0.0.1:{{ .Values.bot.service.port }} > /tmp/probe_output.txt && \
cat /tmp/probe_output.txt && \
grep -q '"enr:-' /tmp/probe_output.txt
initialDelaySeconds: {{ .Values.bot.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.bot.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.bot.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.bot.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.bot.readinessProbe.failureThreshold }}
resources:
{{- toYaml .Values.bot.resources | nindent 12 }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-bot
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: {{ .Values.bot.service.type }}
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: bot
ports:
- protocol: TCP
port: {{ .Values.bot.service.port }}
targetPort: {{ .Values.bot.service.targetPort }}
{{- if and (eq .Values.bot.service.type "NodePort") .Values.bot.service.nodePort }}
nodePort: {{ .Values.bot.service.nodePort }}
{{- end }}
24 changes: 24 additions & 0 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,30 @@ pxe:
failureThreshold: 3
resources: {}

bot:
logLevel: "debug"
debug: "aztec:*"
replicas: 1
botPrivateKey: "0xcafe"
txIntervalSeconds: 5
privateTransfersPerTx: 1
publicTransfersPerTx: 0
noWaitForTransfers: true
botNoStart: false
pxeProverEnabled: false
proverRealProofs: false
service:
type: ClusterIP
port: 8080
targetPort: 8080
readinessProbe:
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
resources: {}

ethereum:
replicas: 1
chainId: 31337
Expand Down

0 comments on commit 982a04e

Please sign in to comment.