Skip to content

Commit

Permalink
Merge pull request #595 from hyperweb-io/anmol/eth-setup
Browse files Browse the repository at this point in the history
feature: add initial setup for eth
  • Loading branch information
Anmol1696 authored Feb 9, 2025
2 parents 5c246a4 + d5abb1c commit bab1cfc
Show file tree
Hide file tree
Showing 11 changed files with 563 additions and 7 deletions.
41 changes: 41 additions & 0 deletions starship/charts/devnet/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,47 @@ defaultChains:
exponent: 6
coingecko_id: stake
keywords: [ "stake" ]
ethereum:
image: ghcr.io/hyperweb-io/starship/ethereum/client-go:latest
home: /ethereum
binary: geth
prefix: eth
denom: wei
prettyName: Ethereum Execution Chain
coins: 100000000000000wei
hdPath: m/44'/60'/0'/0/0
coinType: 60
repo: https://github.com/ethereum/go-ethereum
assets:
- base: wei
name: "Ether"
description: "The native token of Ethereum"
display: "eth"
symbol: "ETH"
logo_URIs:
png: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/eth-white.png"
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/eth-white.svg"
denom_units:
- denom: wei
exponent: 0
- denom: gwei
exponent: 9
- denom: ether
exponent: 18
aliases:
- "ether"
coingecko_id: "ethereum"
config:
beacon:
enabled: true
image: "ghcr.io/hyperweb-io/starship/prysm/beacon-chain:v5.2.0"
numValidator: 1
validator:
enabled: true
image: "ghcr.io/hyperweb-io/starship/prysm/validator:v5.2.0"
numValidator: 1
prysmctl:
image: "ghcr.io/hyperweb-io/starship/prysm/cmd/prysmctl:v5.2.0"
eth:
storageClassName: hostpath
genesisStateUrl: https://github.com/eth-clients/merge-testnets/blob/main/sepolia/genesis.ssz
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- range $chain := .Values.chains }}
{{- if ne $chain.name "virtual" }}
{{- if not (hasPrefix "ethereum" $chain.name) }}
{{ $dataExposer := dict "chain" $chain.id "port" ($.Values.exposer.ports.rest | quote | default "8081") }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- range $chain := .Values.chains }}
{{- if ne $chain.name "virtual" }}
{{- if not (hasPrefix "ethereum" $chain.name) }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}
{{ $chain := include "devnet.fullchain" (dict "name" $chain.id "file" $defaultFile "context" $) | fromJson }}
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- range $chain := .Values.chains }}
{{- if ne $chain.name "virtual" }}
{{- if not (hasPrefix "ethereum" $chain.name) }}
{{ $dataExposer := dict "chain" $chain.id "port" ($.Values.exposer.ports.rest | quote | default "8081") }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ $portMap := dict "p2p" 26656 "address" 26658 "grpc" 9090 "grpc-web" 9091 "rest" 1317 }}
{{- range $chain := .Values.chains }}
{{- if ne $chain.name "virtual" }}
{{- if not (hasPrefix "ethereum" $chain.name) }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}

{{ $chain := include "devnet.fullchain" (dict "name" $chain.id "file" $defaultFile "context" $) | fromJson }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- range $chain := .Values.chains }}
{{- if ne $chain.name "virtual" }}
{{- if not (hasPrefix "ethereum" $chain.name) }}
{{- if gt $chain.numValidators 1.0 }}
{{ $dataExposer := dict "chain" $chain.id "port" ($.Values.exposer.ports.rest | quote | default "8081") }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}
Expand Down
188 changes: 188 additions & 0 deletions starship/charts/devnet/templates/chains/eth/beacon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
{{- range $chain := .Values.chains }}
{{- if hasPrefix "ethereum-beacon" $chain.name }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}

{{ $chain := include "devnet.fullchain" (dict "name" $chain.id "file" $defaultFile "context" $) | fromJson }}
{{ $initParams := dict "chains" (list $chain.id) "port" $.Values.exposer.ports.rest "context" $ }}

{{ $executionChain := include "devnet.fullchain" (dict "name" $chain.config.execution.id "file" $defaultFile "context" $) | fromJson }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $chain.name }}-{{ $chain.id }}
namespace: {{ $.Release.Namespace }}
labels:
app: {{ $chain.name }}-{{ $chain.id }}
spec:
serviceName: {{ $chain.name }}-{{ $chain.id }}
replicas: {{ $chain.replicas }}
selector:
matchLabels:
app.kubernetes.io/instance: {{ $chain.name }}-{{ $chain.id }}
app.kubernetes.io/name: {{ $chain.name }}-{{ $chain.id }}
template:
metadata:
annotations:
quality: release
role: api-gateway
sla: high
tier: gateway
labels:
app.kubernetes.io/instance: {{ $chain.name }}-{{ $chain.id }}
app.kubernetes.io/type: {{ $chain.name }}-{{ $chain.id }}
app.kubernetes.io/name: {{ $chain.name }}-{{ $chain.id }}
app.kubernetes.io/rawname: "{{ $chain.id }}"
app.kubernetes.io/version: {{ $.Chart.AppVersion }}
spec:
{{- include "imagePullSecrets" $chain | indent 6 }}
initContainers:
- name: init-genesis
image: {{ $chain.config.prysmctl.image }}
imagePullPolicy: Always
command:
- bash
- "-c"
- |
mkdir -p /ethereum/consensus /ethereum/execution
cp /config-execution/genesis.json /ethereum/execution/genesis.json
cp /config-beacon/config.yaml /ethereum/consensus/config.yaml
echo "Initializing genesis"
prysmctl testnet generate-genesis \
--fork=capella \
--num-validators={{ $chain.config.validator.numValidator }} \
--genesis-time-delay=15 \
--output-ssz=/ethereum/consensus/genesis.ssz \
--chain-config-file=/ethereum/consensus/config.yaml \
--geth-genesis-json-in=/ethereum/execution/genesis.json \
--geth-genesis-json-out=/ethereum/execution/genesis.json
echo "Copy secrets over"
cp /config-execution/jwt.hex /etc/secrets/jwt.hex
resources: {{- include "devnet.node.resources" ( dict "node" $chain "context" $ ) | trim | nindent 12 }}
volumeMounts:
- name: secrets
mountPath: /etc/secrets
- name: config-beacon
mountPath: /config-beacon
- name: config-execution
mountPath: /config-execution
- name: ethereum
mountPath: /ethereum
containers:
- name: node
image: {{ $chain.image }}
imagePullPolicy: Always
env:
- name: HTTP_PORT
value: "8545"
- name: WS_PORT
value: "8546"
- name: RPC_PORT
value: "8551"
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command:
- bash
- "-c"
- |
echo "Waiting 15 seconds for execution client to be ready..."
sleep 15
echo "Starting consensus chain"
beacon-chain \
--execution-endpoint=http://{{ $executionChain.name }}-{{ $executionChain.id }}-0.{{ $executionChain.name }}-{{ $executionChain.id }}.default.svc.cluster.local:8551 \
--jwt-secret=/etc/secrets/jwt.hex \
--accept-terms-of-use \
--http-host 0.0.0.0 \
--rpc-host 0.0.0.0 \
--chain-id {{ $executionChain.id }} \
--contract-deployment-block=0 \
--datadir /ethereum/consensus \
--genesis-state /ethereum/consensus/genesis.ssz \
--min-sync-peers=0 \
--chain-config-file=/ethereum/consensus/config.yaml \
--network-id {{ $executionChain.id }} \
--suggested-fee-recipient=0x123463a4B065722E99115D6c222f267d9cABb524 \
--minimum-peers-per-subnet=0 \
--force-clear-db
resources: {{- include "devnet.node.resources" ( dict "node" $chain "context" $ ) | trim | nindent 12 }}
volumeMounts:
- name: ethereum
mountPath: /ethereum
- name: secrets
mountPath: /etc/secrets
- name: validator
image: {{ $chain.config.validator.image }}
imagePullPolicy: Always
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command:
- bash
- "-c"
- |
echo "Waiting 15 seconds for execution client to be ready..."
sleep 20
mkdir -p /ethereum/consensus/validator
echo "Starting validator node"
validator \
--accept-terms-of-use \
--beacon-rpc-provider=localhost:4000 \
--datadir=/ethereum/consensus/validator \
--interop-num-validators={{ $chain.config.validator.numValidator }} \
--interop-start-index=0 \
--force-clear-db \
--chain-config-file=/ethereum/consensus/config.yaml \
--suggested-fee-recipient=0x0C46c2cAFE097b4f7e1BB868B89e5697eE65f934
resources: {{- include "devnet.node.resources" ( dict "node" $chain "context" $ ) | trim | nindent 12 }}
volumeMounts:
- name: ethereum
mountPath: /ethereum
- name: secrets
mountPath: /etc/secrets
- name: exposer
image: {{ $.Values.exposer.image }}
imagePullPolicy: Always
env:
- name: GENESIS_HOST
value: "{{ $chain.name }}-{{ $chain.id }}-0"
- name: GENESIS_PORT
value: "{{ $.Values.exposer.ports.rest }}"
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: EXPOSER_HTTP_PORT
value: "8081"
- name: EXPOSER_GRPC_PORT
value: "9099"
- name: EXPOSER_GENESIS_FILE
value: /ethereum/execution/genesis.json
- name: EXPOSER_GENESIS_SSZ
value: /ethereum/execution/genesis.ssz
- name: EXPOSER_PRIV_VAL_FILE
value: {{ $chain.home }}/config/priv_validator_key.json
- name: EXPOSER_NODE_KEY_FILE
value: {{ $chain.home }}/config/node_key.json
- name: EXPOSER_NODE_ID_FILE
value: {{ $chain.home }}/config/node_id.json
- name: EXPOSER_PRIV_VAL_STATE_FILE
value: {{ $chain.home }}/data/priv_validator_state.json
resources: {{- include "devnet.exposer.resources" ( dict "node" $chain "context" $ ) | trim | nindent 12 }}
volumes:
- name: config
configMap:
name: config-ethereum
- name: ethereum
emptyDir: { }
- name: secrets
emptyDir: { }
---
{{- end }}
{{- end }}
Loading

0 comments on commit bab1cfc

Please sign in to comment.