Skip to content

Commit 26a6cdd

Browse files
committed
Download genesis from prysm if required
1 parent a8aefdc commit 26a6cdd

4 files changed

Lines changed: 57 additions & 33 deletions

File tree

rocketpool-cli/service/service.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,15 @@ func updateConfigParamFromCliArg(c *cli.Context, sectionName string, param *cfgt
406406
func changeNetworks(c *cli.Context, rp *rocketpool.Client, apiContainerName string) error {
407407

408408
// Stop all of the containers
409-
fmt.Print("Stopping containers... ")
409+
fmt.Println("Stopping containers... ")
410410
err := rp.PauseService(getComposeFiles(c))
411411
if err != nil {
412412
return fmt.Errorf("error stopping service: %w", err)
413413
}
414414
fmt.Println("done")
415415

416416
// Restart the API container
417-
fmt.Print("Starting API container... ")
417+
fmt.Println("Starting API container... ")
418418
output, err := rp.StartContainer(apiContainerName)
419419
if err != nil {
420420
return fmt.Errorf("error starting API container: %w", err)
@@ -425,38 +425,38 @@ func changeNetworks(c *cli.Context, rp *rocketpool.Client, apiContainerName stri
425425
fmt.Println("done")
426426

427427
// Get the path of the user's data folder
428-
fmt.Print("Retrieving data folder path... ")
428+
fmt.Println("Retrieving data folder path... ")
429429
volumePath, err := rp.GetClientVolumeSource(apiContainerName, dataFolderVolumeName)
430430
if err != nil {
431431
return fmt.Errorf("error getting data folder path: %w", err)
432432
}
433433
fmt.Printf("done, data folder = %s\n", volumePath)
434434

435435
// Delete the data folder
436-
fmt.Print("Removing data folder... ")
436+
fmt.Println("Removing data folder... ")
437437
_, err = rp.TerminateDataFolder()
438438
if err != nil {
439439
return err
440440
}
441441
fmt.Println("done")
442442

443443
// Terminate the current setup
444-
fmt.Print("Removing old installation... ")
444+
fmt.Println("Removing old installation... ")
445445
err = rp.StopService(getComposeFiles(c))
446446
if err != nil {
447447
return fmt.Errorf("error terminating old installation: %w", err)
448448
}
449449
fmt.Println("done")
450450

451451
// Create new validator folder
452-
fmt.Print("Recreating data folder... ")
452+
fmt.Println("Recreating data folder... ")
453453
err = os.MkdirAll(filepath.Join(volumePath, "validators"), 0775)
454454
if err != nil {
455455
return fmt.Errorf("error recreating data folder: %w", err)
456456
}
457457

458458
// Start the service
459-
fmt.Print("Starting Rocket Pool... ")
459+
fmt.Println("Starting Rocket Pool... ")
460460
err = rp.StartService(getComposeFiles(c))
461461
if err != nil {
462462
return fmt.Errorf("error starting service: %w", err)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Grab the Testnet genesis state if needed
5+
if [ "$NETWORK" = "testnet" ]; then
6+
echo "Prysm is configured to use Hoodi, genesis state required."
7+
if [ ! -f "/ethclient/hoodi-genesis.ssz" ]; then
8+
echo "Downloading from Github..."
9+
wget https://github.com/eth-clients/hoodi/blob/main/metadata/genesis.ssz -O /ethclient/hoodi-genesis.ssz
10+
echo "Download complete."
11+
else
12+
echo "Genesis state already downloaded, continuing."
13+
fi
14+
elif [ "$NETWORK" = "devnet" ]; then
15+
echo "Prysm is configured to use Hoodi, genesis state required."
16+
if [ ! -f "/ethclient/hoodi-genesis.ssz" ]; then
17+
echo "Downloading from Github..."
18+
wget https://github.com/eth-clients/hoodi/blob/main/metadata/genesis.ssz -O /ethclient/hoodi-genesis.ssz
19+
echo "Download complete."
20+
else
21+
echo "Genesis state already downloaded, continuing."
22+
fi
23+
else
24+
echo "Genesis download not required for $NETWORK"
25+
fi

shared/services/rocketpool/assets/install/scripts/start-bn.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,27 +210,6 @@ fi
210210
# Prysm startup
211211
if [ "$CC_CLIENT" = "prysm" ]; then
212212

213-
# Grab the Testnet genesis state if needed
214-
if [ "$NETWORK" = "testnet" ]; then
215-
echo "Prysm is configured to use Hoodi, genesis state required."
216-
if [ ! -f "/ethclient/hoodi-genesis.ssz" ]; then
217-
echo "Downloading from Github..."
218-
wget https://github.com/eth-clients/hoodi/blob/main/metadata/genesis.ssz -O /ethclient/hoodi-genesis.ssz
219-
echo "Download complete."
220-
else
221-
echo "Genesis state already downloaded, continuing."
222-
fi
223-
elif [ "$NETWORK" = "devnet" ]; then
224-
echo "Prysm is configured to use Hoodi, genesis state required."
225-
if [ ! -f "/ethclient/hoodi-genesis.ssz" ]; then
226-
echo "Downloading from Github..."
227-
wget https://github.com/eth-clients/hoodi/blob/main/metadata/genesis.ssz -O /ethclient/hoodi-genesis.ssz
228-
echo "Download complete."
229-
else
230-
echo "Genesis state already downloaded, continuing."
231-
fi
232-
fi
233-
234213
CMD="$PERF_PREFIX /app/cmd/beacon-chain/beacon-chain \
235214
--accept-terms-of-use \
236215
$PRYSM_NETWORK \

shared/services/rocketpool/assets/install/templates/eth2.tmpl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
# See https://docs.docker.com/compose/extends/#adding-and-overriding-configuration
66
# for more information on overriding specific parameters of docker-compose files.
77

8+
{{define "GENESIS_DL"}}
9+
eth2_genesis_downloader:
10+
image: curlimages/curl:8.13.0
11+
user: root
12+
container_name: {{.Smartnode.ProjectName}}_genesis_downloader
13+
volumes:
14+
- eth2clientdata:/ethclient
15+
- {{.RocketPoolDirectory}}/scripts:/setup:ro
16+
network_mode: host
17+
environment:
18+
- NETWORK={{.Smartnode.Network}}
19+
entrypoint: sh
20+
command: "/setup/download-genesis.sh"
21+
{{end}}
22+
823
services:
924
eth2:
1025
image: {{.GetBeaconContainerTag}}
@@ -72,18 +87,23 @@ services:
7287
{{- else if eq .ConsensusClient.String "lighthouse"}}
7388
- BN_P2P_QUIC_PORT={{.Lighthouse.P2pQuicPort}}
7489
{{- end}}
75-
{{- if eq .ConsensusClient.String "prysm"}}
76-
entrypoint: bash
77-
{{- else}}
78-
entrypoint: sh
79-
{{- end}}
8090
command: "/setup/start-bn.sh"
8191
cap_drop:
8292
- all
8393
cap_add:
8494
- dac_override
8595
security_opt:
8696
- no-new-privileges
97+
{{- if ne .ConsensusClient.String "prysm"}}
98+
entrypoint: sh
99+
{{- else}}
100+
{{- /* prysm has bash but not sh and may need us to download genesis for testnets */}}
101+
entrypoint: bash
102+
depends_on:
103+
eth2_genesis_downloader:
104+
condition: service_completed_successfully
105+
{{- template "GENESIS_DL" . }}
106+
{{- end}}
87107
networks:
88108
net:
89109
volumes:

0 commit comments

Comments
 (0)