diff --git a/spartan/aztec-network/templates/_helpers.tpl b/spartan/aztec-network/templates/_helpers.tpl index 145b42914fde..66f9678f6212 100644 --- a/spartan/aztec-network/templates/_helpers.tpl +++ b/spartan/aztec-network/templates/_helpers.tpl @@ -80,6 +80,10 @@ http://{{ include "aztec-network.fullname" . }}-blob-sink.{{ .Release.Namespace http://{{ include "aztec-network.fullname" . }}-metrics.{{ .Release.Namespace }} {{- end -}} +{{- define "aztec-network.fullNodeAdminUrl" -}} +http://{{ include "aztec-network.fullname" . }}-full-node-admin.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.fullNode.service.adminPort }} +{{- end -}} + {{- define "helpers.flag" -}} {{- $name := index . 0 -}} {{- $value := index . 1 -}} diff --git a/spartan/aztec-network/templates/create-snapshot.yaml b/spartan/aztec-network/templates/create-snapshot.yaml new file mode 100644 index 000000000000..a4a82f86c2af --- /dev/null +++ b/spartan/aztec-network/templates/create-snapshot.yaml @@ -0,0 +1,33 @@ +{{- if and (.Values.snapshots.uploadLocation) (.Values.snapshots.frequency) (gt (int .Values.fullNode.replicas) 0) }} +# Cronjob for creating and uploading database snapshots to a public location +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "aztec-network.fullname" . }}-upload-snapshots-cron-job + labels: + {{- include "aztec-network.labels" . | nindent 4 }} +spec: + schedule: "{{ .Values.snapshots.frequency }}" + jobTemplate: + spec: + template: + metadata: + labels: + {{- include "aztec-network.selectorLabels" . | nindent 12 }} + app: request-upload-snapshot + spec: + restartPolicy: Never + {{- if .Values.network.public }} + serviceAccountName: {{ include "aztec-network.fullname" . }}-node + {{- end }} + containers: + - name: request-upload-snapshot + image: {{ .Values.images.curl.image }} + command: + - /bin/sh + - -c + - | + set -ex + echo "Starting snapshot upload to {{ .Values.snapshots.uploadLocation }} via {{ include "aztec-network.fullNodeAdminUrl" . }}" + curl -XPOST {{ include "aztec-network.fullNodeAdminUrl" . }} -d '{"method": "nodeAdmin_startSnapshotUpload", "params": ["{{ .Values.snapshots.uploadLocation }}"], "id": 1, "jsonrpc": "2.0"}' -H 'Content-Type: application/json' +{{- end }} diff --git a/spartan/aztec-network/templates/full-node.yaml b/spartan/aztec-network/templates/full-node.yaml index e83e308f2020..f385f789f80c 100644 --- a/spartan/aztec-network/templates/full-node.yaml +++ b/spartan/aztec-network/templates/full-node.yaml @@ -102,6 +102,8 @@ spec: value: "--max-old-space-size={{ .Values.fullNode.maxOldSpaceSize}}" - name: AZTEC_PORT value: "{{ .Values.fullNode.service.nodePort }}" + - name: AZTEC_ADMIN_PORT + value: "{{ .Values.fullNode.service.adminPort }}" - name: LOG_LEVEL value: "{{ .Values.fullNode.logLevel }}" - name: LOG_JSON @@ -156,12 +158,15 @@ spec: value: "{{ .Values.aztec.testAccounts }}" - name: SPONSORED_FPC value: "{{ .Values.aztec.sponsoredFPC }}" + - name: SYNC_SNAPSHOTS_URL + value: "{{ .Values.snapshots.syncUrl }}" {{- if .Values.blobSink.enabled }} - name: BLOB_SINK_URL value: {{ include "aztec-network.blobSinkUrl" . }} {{- end }} ports: - containerPort: {{ .Values.fullNode.service.nodePort }} + - containerPort: {{ .Values.fullNode.service.adminPort }} - containerPort: {{ .Values.fullNode.service.p2pPort }} - containerPort: {{ .Values.fullNode.service.p2pPort }} protocol: UDP @@ -223,6 +228,25 @@ spec: - port: {{ .Values.fullNode.service.nodePort }} name: node --- +# Internal service for accessing the admin port +apiVersion: v1 +kind: Service +metadata: + name: {{ include "aztec-network.fullname" . }}-full-node-admin + labels: + {{- include "aztec-network.labels" . | nindent 4 }} + app: full-node +spec: + type: ClusterIP + selector: + {{- include "aztec-network.selectorLabels" . | nindent 4 }} + app: full-node + # The admin port is restricted from public access thanks to terraform/gke-cluster/firewall.tf + ports: + - port: {{ .Values.fullNode.service.adminPort }} + targetPort: {{ .Values.fullNode.service.adminPort }} + name: admin +--- {{- if hasKey .Values.fullNode "fixedExternalIP" }} apiVersion: networking.gke.io/v1beta2 kind: ManagedCertificate diff --git a/spartan/aztec-network/templates/prover-node.yaml b/spartan/aztec-network/templates/prover-node.yaml index 7f30c9f83d85..d25986baef01 100644 --- a/spartan/aztec-network/templates/prover-node.yaml +++ b/spartan/aztec-network/templates/prover-node.yaml @@ -242,6 +242,8 @@ spec: {{- end }} - name: P2P_BOOTSTRAP_NODES_AS_FULL_PEERS value: "{{ .Values.network.p2pBootstrapNodesAsFullPeers }}" + - name: SYNC_SNAPSHOTS_URL + value: "{{ .Values.snapshots.syncUrl }}" ports: - containerPort: {{ .Values.proverNode.service.nodePort }} - containerPort: {{ .Values.proverNode.service.p2pPort }} diff --git a/spartan/aztec-network/templates/validator.yaml b/spartan/aztec-network/templates/validator.yaml index 6c1136cc6b48..d6ee33167806 100644 --- a/spartan/aztec-network/templates/validator.yaml +++ b/spartan/aztec-network/templates/validator.yaml @@ -191,6 +191,8 @@ spec: value: "{{ .Values.aztec.sponsoredFPC }}" - name: P2P_BOOTSTRAP_NODES_AS_FULL_PEERS value: "{{ .Values.network.p2pBootstrapNodesAsFullPeers }}" + - name: SYNC_SNAPSHOTS_URL + value: "{{ .Values.snapshots.syncUrl }}" {{- if .Values.blobSink.enabled }} - name: BLOB_SINK_URL value: {{ include "aztec-network.blobSinkUrl" . }} diff --git a/spartan/aztec-network/values.yaml b/spartan/aztec-network/values.yaml index 30676220b10f..7ccd0a4f971e 100644 --- a/spartan/aztec-network/values.yaml +++ b/spartan/aztec-network/values.yaml @@ -29,6 +29,11 @@ telemetry: useGcloudLogging: true excludeMetrics: "" +snapshots: + uploadLocation: + syncUrl: + frequency: + images: aztec: image: aztecprotocol/aztec @@ -116,6 +121,7 @@ fullNode: service: p2pPort: 40400 nodePort: 8080 + adminPort: 8880 logLevel: "debug; info: aztec:simulator, json-rpc" p2p: enabled: "true" diff --git a/spartan/aztec-network/values/alpha-testnet.yaml b/spartan/aztec-network/values/alpha-testnet.yaml index 90c422ad40bd..30e63fff4ed9 100644 --- a/spartan/aztec-network/values/alpha-testnet.yaml +++ b/spartan/aztec-network/values/alpha-testnet.yaml @@ -1,6 +1,11 @@ telemetry: enabled: true +snapshots: + uploadLocation: "gs://aztec-testnet/snapshots/" + syncUrl: "https://storage.googleapis.com/aztec-testnet/snapshots/" + frequency: "0 0 * * *" # daily uploads at midnight + aztec: realProofs: true numberOfDefaultAccounts: 0 diff --git a/yarn-project/aztec/src/cli/chain_l2_config.ts b/yarn-project/aztec/src/cli/chain_l2_config.ts index bb7ca1fba3c5..d42dcbdb87a7 100644 --- a/yarn-project/aztec/src/cli/chain_l2_config.ts +++ b/yarn-project/aztec/src/cli/chain_l2_config.ts @@ -20,6 +20,7 @@ export type L2ChainConfig = { seqMinTxsPerBlock: number; seqMaxTxsPerBlock: number; realProofs: boolean; + snapshotsUrl: string; }; export const testnetIgnitionL2ChainConfig: L2ChainConfig = { @@ -38,6 +39,7 @@ export const testnetIgnitionL2ChainConfig: L2ChainConfig = { seqMinTxsPerBlock: 0, seqMaxTxsPerBlock: 0, realProofs: true, + snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/', }; export const alphaTestnetL2ChainConfig: L2ChainConfig = { @@ -56,6 +58,7 @@ export const alphaTestnetL2ChainConfig: L2ChainConfig = { seqMinTxsPerBlock: 0, seqMaxTxsPerBlock: 4, realProofs: true, + snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/', }; export async function getBootnodes(networkName: NetworkNames) { @@ -114,4 +117,5 @@ export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames enrichVar('DATA_DIRECTORY', path.join(process.env.HOME || '~', '.aztec', networkName, 'data')); enrichVar('PROVER_REAL_PROOFS', config.realProofs.toString()); enrichVar('PXE_PROVER_ENABLED', config.realProofs.toString()); + enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl); }