From 88f2947aee145aca28646e51f8d4feaa6709b5df 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 entry point scripts --- .../eth-devnet/docker-compose.yml | 8 +--- .../entrypoints/eth-beacon.Dockerfile | 4 +- .../eth-devnet/entrypoints/eth-beacon.sh | 8 ++++ .../entrypoints/eth-execution.Dockerfile | 4 +- .../eth-devnet/entrypoints/eth-execution.sh | 0 .../entrypoints/eth-validator.Dockerfile | 2 +- .../eth-devnet/entrypoints/eth-validator.sh | 11 +++++ .../templates/{ => eth}/eth-beacon.yaml | 43 +++++++------------ .../eth/eth-entrypoint-configmap.yaml | 10 +++++ .../templates/{ => eth}/eth-execution.yaml | 36 +++++++--------- .../templates/{ => eth}/eth-validator.yaml | 33 ++++++-------- 11 files changed, 79 insertions(+), 80 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/docker-compose.yml b/spartan/aztec-network/eth-devnet/docker-compose.yml index 78d861f1ff7a..da47adb59da6 100644 --- a/spartan/aztec-network/eth-devnet/docker-compose.yml +++ b/spartan/aztec-network/eth-devnet/docker-compose.yml @@ -13,7 +13,7 @@ services: volumes: - "eth_execution_data:/data" - "${PWD}/out/genesis.json:/genesis/genesis.json" - - "${PWD}/out/jwt-secret.txt:/genesis/jwt-secret.txt" + - "${PWD}/out/jwt-secret.hex:/genesis/jwt-secret.hex" environment: - HTTP_PORT=8545 - MAX_TX_INPUT_SIZE_BYTES=1310720 @@ -35,9 +35,6 @@ services: environment: ETH_EXECUTION_URL: "http://eth_execution:8545" BEACON_HTTP_PORT: 5052 - entrypoint: - - "/bin/sh" - - "/entrypoints/eth-beacon.sh" eth_validator: depends_on: @@ -55,6 +52,3 @@ services: - "${PWD}/out/genesis.ssz:/genesis/genesis.ssz" environment: ETH_BEACON_URL: "http://eth_beacon:5052/" - entrypoint: - - "/bin/sh" - - "/entrypoints/eth-validator.sh" diff --git a/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.Dockerfile b/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.Dockerfile index 062077e8f113..ed43caff4ece 100644 --- a/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.Dockerfile +++ b/spartan/aztec-network/eth-devnet/entrypoints/eth-beacon.Dockerfile @@ -1,5 +1,5 @@ FROM sigp/lighthouse:v6.0.1 -COPY ./eth-beacon.sh ./eth-beacon.sh +COPY ./entrypoints/eth-beacon.sh /eth-beacon.sh -ENTRYPOINT ["/eth-beacon.sh"] +ENTRYPOINT ["./eth-beacon.sh"] 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..c30e419257b0 --- 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 [ "$K8S_MODE" = "true" ]; 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.Dockerfile b/spartan/aztec-network/eth-devnet/entrypoints/eth-execution.Dockerfile index e980df78b03b..070b1df81217 100644 --- a/spartan/aztec-network/eth-devnet/entrypoints/eth-execution.Dockerfile +++ b/spartan/aztec-network/eth-devnet/entrypoints/eth-execution.Dockerfile @@ -1,6 +1,6 @@ FROM ghcr.io/paradigmxyz/reth:v1.0.8 # Run in the context of the docker-compose file .. -COPY ./eth-execution.sh ./eth-execution.sh +COPY ./entrypoints/eth-execution.sh /eth-execution.sh -ENTRYPOINT ["/eth-execution.sh"] +ENTRYPOINT ["./eth-execution.sh"] 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.Dockerfile b/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.Dockerfile index cb4fc2ed737d..60d36eb87bd6 100644 --- a/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.Dockerfile +++ b/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.Dockerfile @@ -1,5 +1,5 @@ FROM sigp/lighthouse:v6.0.1 -COPY ./eth-validator.sh ./eth-validator.sh +COPY ./entrypoints/eth-validator.sh /eth-validator.sh ENTRYPOINT ["/eth-validator.sh"] 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..768097318756 --- a/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh +++ b/spartan/aztec-network/eth-devnet/entrypoints/eth-validator.sh @@ -1,5 +1,16 @@ #! /bin/bash +if [ "$K8S_MODE" = "true" ]; 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 + +echo $ETH_BEACON_URL + 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..8ac9cf59438a 100644 --- a/spartan/aztec-network/templates/eth-beacon.yaml +++ b/spartan/aztec-network/templates/eth/eth-beacon.yaml @@ -24,39 +24,22 @@ 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 - name: genesis mountPath: /genesis-template + - name: entrypoint-scripts + mountPath: /entrypoints resources: {{- toYaml .Values.ethereum.beacon.resources | nindent 12 }} volumes: @@ -66,6 +49,10 @@ spec: - name: genesis configMap: name: {{ include "aztec-network.fullname" . }}-eth-beacon-genesis + - name: entrypoint-scripts + configMap: + name: {{ include "aztec-network.fullname" . }}-entrypoint-scripts + defaultMode: 0755 --- apiVersion: v1 kind: Service 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..361e74acdc9b 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 @@ -53,6 +41,8 @@ spec: mountPath: /genesis - name: shared-volume mountPath: /data + - name: entrypoint-scripts + mountPath: /entrypoints resources: {{- toYaml .Values.ethereum.resources | nindent 12 }} volumes: @@ -62,6 +52,10 @@ spec: - name: genesis configMap: name: {{ include "aztec-network.fullname" . }}-eth-execution-genesis + - name: entrypoint-scripts + configMap: + name: {{ include "aztec-network.fullname" . }}-entrypoint-scripts + defaultMode: 0755 --- apiVersion: v1 kind: Service 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