From 802bcca2d8dbaae6be9edbd17bc0a441e7a3f858 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:02:05 +0000 Subject: [PATCH] chore: migrate k8s cluster to use the same scripts --- .../eth-devnet/entrypoints/eth-beacon.sh | 8 ++++ .../eth-devnet/entrypoints/eth-execution.sh | 0 .../eth-devnet/entrypoints/eth-validator.sh | 9 +++++ .../templates/{ => eth}/eth-beacon.yaml | 37 +++++-------------- .../eth/eth-entrypoint-configmap.yaml | 10 +++++ .../templates/{ => eth}/eth-execution.yaml | 30 +++++---------- .../templates/{ => eth}/eth-validator.yaml | 33 +++++++---------- 7 files changed, 59 insertions(+), 68 deletions(-) mode change 100644 => 100755 spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.sh mode change 100644 => 100755 spartan/aztec-network/eth-devnet/entrypoints/eth-execution.sh mode change 100644 => 100755 spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh rename spartan/aztec-network/templates/{ => eth}/eth-beacon.yaml (69%) create mode 100644 spartan/aztec-network/templates/eth/eth-entrypoint-configmap.yaml rename spartan/aztec-network/templates/{ => eth}/eth-execution.yaml (79%) rename spartan/aztec-network/templates/{ => eth}/eth-validator.yaml (74%) diff --git a/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.sh b/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.sh old mode 100644 new mode 100755 index 928c0978984e..572ac88970e1 --- a/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.sh +++ b/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.sh @@ -1,5 +1,13 @@ #! /bin/bash +if [ -n $K8S_MODE ]; then + # In k8s config maps cannot contain ssz files + # Genesis information is copied such that we can write into it + # First serialize the ssz file + cp -r /genesis-template /genesis && + base64 -d /genesis/genesis-ssz > /genesis/genesis.ssz +fi + lighthouse bn \ --disable-peer-scoring \ --disable-packet-filter \ diff --git a/spartan/aztec-network/eth-devnet/entrypoints/eth-execution.sh b/spartan/aztec-network/eth-devnet/entrypoints/eth-execution.sh old mode 100644 new mode 100755 diff --git a/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh b/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh old mode 100644 new mode 100755 index df98f4b01d33..5db280b3d8df --- a/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh +++ b/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh @@ -1,5 +1,14 @@ #! /bin/bash +if [ -n $K8S_MODE ]; then + cp -r /genesis-template /genesis && + mkdir -p /data/validators && + mkdir -p /data/secrets && + cp -r /validator-setup/keys/* /data/validators && + cp -r /validator-setup/secrets/* /data/secrets && + base64 -d /genesis/genesis-ssz > /genesis/genesis.ssz && +fi + lighthouse vc \ --datadir="/data" \ --beacon-nodes=$ETH_BEACON_URL \ diff --git a/spartan/aztec-network/templates/eth-beacon.yaml b/spartan/aztec-network/templates/eth/eth-beacon.yaml similarity index 69% rename from spartan/aztec-network/templates/eth-beacon.yaml rename to spartan/aztec-network/templates/eth/eth-beacon.yaml index af528260766a..ca9cd1668acc 100644 --- a/spartan/aztec-network/templates/eth-beacon.yaml +++ b/spartan/aztec-network/templates/eth/eth-beacon.yaml @@ -24,34 +24,15 @@ spec: - name: eth-beacon image: "{{ .Values.images.lighthouse.image }}" imagePullPolicy: {{ .Values.images.lighthouse.pullPolicy }} - command: ["/bin/sh", "-c"] - args: - # Genesis information is copied such that we can write into it - # First serialize the ssz file - - >- - cp -r /genesis-template /genesis && - base64 -d /genesis/genesis-ssz > /genesis/genesis.ssz && - - - lighthouse bn - --disable-peer-scoring - --disable-packet-filter - --enable-private-discovery - --disable-enr-auto-update - --staking - --http - --http-address=0.0.0.0 - --http-port=5052 - --validator-monitor-auto - --http-allow-origin='*' - --listen-address=0.0.0.0 - {{- include "helpers.flag" (list "port" .Values.ethereum.beacon.port) }} - --target-peers=0 - --testnet-dir=/genesis - --execution-endpoints="http://{{ include "aztec-network.fullname" . }}-eth-execution.{{ .Release.Namespace }}.svc.cluster.local:8551" - --execution-jwt-secret-key="61e1dd9539e8cc37b3d71dcf8ce372f0e119cc1c73426ee80472a4214f2a41a1" - --allow-insecure-genesis-sync - --debug-level=info + command: ["/bin/sh"] + args: ["/entrypoints/eth-beacon.sh"] + env: + - name: K8S_MODE + value: "true" + - name: BEACON_HTTP_PORT + value: "{{ .Values.ethereum.beacon.service.port }}" + - name: ETH_EXECUTION_URL + value: "http://{{ include "aztec-network.fullname" . }}-eth-execution.{{ .Release.Namespace }}.svc.cluster.local:8551" volumeMounts: - name: shared-volume mountPath: /data diff --git a/spartan/aztec-network/templates/eth/eth-entrypoint-configmap.yaml b/spartan/aztec-network/templates/eth/eth-entrypoint-configmap.yaml new file mode 100644 index 000000000000..e7df010bf87e --- /dev/null +++ b/spartan/aztec-network/templates/eth/eth-entrypoint-configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "aztec-network.fullname" . }}-entrypoint-scripts + labels: + {{- include "aztec-network.labels" . | nindent 4 }} +data: + eth-validator.sh: {{ .Files.Get "eth-devnet/entrypoints/eth-validator.sh" | quote }} + eth-beacon.sh: {{ .Files.Get "eth-devnet/entrypoints/eth-beacon.sh" | quote }} + eth-execution.sh: {{ .Files.Get "eth-devnet/entrypoints/eth-execution.sh" | quote }} \ No newline at end of file diff --git a/spartan/aztec-network/templates/eth-execution.yaml b/spartan/aztec-network/templates/eth/eth-execution.yaml similarity index 79% rename from spartan/aztec-network/templates/eth-execution.yaml rename to spartan/aztec-network/templates/eth/eth-execution.yaml index 39f1e722e96d..3dca039cac2c 100644 --- a/spartan/aztec-network/templates/eth-execution.yaml +++ b/spartan/aztec-network/templates/eth/eth-execution.yaml @@ -24,27 +24,15 @@ spec: - name: ethereum image: "{{ .Values.images.reth.image }}" imagePullPolicy: {{ .Values.images.reth.pullPolicy }} - command: ["/bin/sh", "-c"] - args: - - >- - reth node - {{ include "helpers.flag" (list "http.port" .Values.ethereum.execution.service.port) }} - --http - --http.addr="0.0.0.0" - --http.api="admin,net,eth,web3,debug,trace" - --http.corsdomain="*" - --txpool.max-tx-input-bytes={{ .Values.ethereum.maxTxInputSizeBytes }} - --max-outbound-peers=0 - --max-inbound-peers=0 - --ipcdisable - --disable-discovery - --authrpc.addr="0.0.0.0" - --authrpc.port=8551 - --authrpc.jwtsecret="/genesis/jwt-secret.hex" - --chain="/genesis/genesis.json" - --datadir="/data" - -vvvv - + command: ["/bin/sh"] + args: ["/entrypoints/eth-execution.sh"] + env: + - name: K8S_MODE + value: "true" + - name: HTTP_PORT + value: "{{ .Values.ethereum.execution.service.port }}" + - name: MAX_TX_INPUT_SIZE_BYTES + value: "{{ .Values.ethereum.maxTxInputSizeBytes }}" ports: - containerPort: {{ .Values.ethereum.execution.service.port }} name: eth-execution diff --git a/spartan/aztec-network/templates/eth-validator.yaml b/spartan/aztec-network/templates/eth/eth-validator.yaml similarity index 74% rename from spartan/aztec-network/templates/eth-validator.yaml rename to spartan/aztec-network/templates/eth/eth-validator.yaml index 6f259e67aad9..b4ea835b2d0a 100644 --- a/spartan/aztec-network/templates/eth-validator.yaml +++ b/spartan/aztec-network/templates/eth/eth-validator.yaml @@ -46,31 +46,22 @@ spec: - name: eth-validator image: "{{ .Values.images.lighthouse.image }}" imagePullPolicy: {{ .Values.images.lighthouse.pullPolicy }} - command: ["/bin/sh", "-c"] - # Copy the genesis and validator setup into the data directory - args: - - >- - cp -r /genesis-template /genesis && - mkdir -p /data/validators && - mkdir -p /data/secrets && - cp -r /validator-setup/keys/* /data/validators && - cp -r /validator-setup/secrets/* /data/secrets && - base64 -d /genesis/genesis-ssz > /genesis/genesis.ssz && - - lighthouse vc - --datadir="/data" - --beacon-nodes="http://{{ include "aztec-network.fullname" . }}-eth-beacon.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.ethereum.beacon.service.port }}" - --testnet-dir=/genesis - --init-slashing-protection - --suggested-fee-recipient="0xff00000000000000000000000000000000c0ffee" - --debug-level=debug + command: ["/bin/sh"] + args: ["/entrypoints/eth-validator.sh"] + env: + - name: ETH_BEACON_URL + value: "http://{{ include "aztec-network.fullname" . }}-eth-beacon.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.ethereum.beacon.service.port }}" + - name: K8S_MODE + value: "true" volumeMounts: - name: shared-volume mountPath: /data - name: genesis - mountPath: /genesis-template + mountPath: /genesis - name: validator-setup mountPath: /validator-setup + - name: entrypoint-scripts + mountPath: /entrypoints resources: {{- toYaml .Values.ethereum.validator.resources | nindent 12 }} volumes: @@ -83,6 +74,10 @@ spec: name: {{ include "aztec-network.fullname" . }}-eth-beacon-genesis - name: validator-setup emptyDir: {} + - name: entrypoint-scripts + configMap: + name: {{ include "aztec-network.fullname" . }}-entrypoint-scripts + defaultMode: 0755 {{- if gt (.Values.ethereum.replicas | int) 0 }} --- apiVersion: v1