forked from eth-educators/eth-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·103 lines (95 loc) · 3.93 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
set -Eeuo pipefail
if [ "$(id -u)" = '0' ]; then
chown -R prysmconsensus:prysmconsensus /var/lib/prysm
exec gosu prysmconsensus docker-entrypoint.sh "$@"
fi
if [ -n "${JWT_SECRET}" ]; then
echo -n "${JWT_SECRET}" > /var/lib/prysm/ee-secret/jwtsecret
echo "JWT secret was supplied in .env"
fi
if [[ -O "/var/lib/prysm/ee-secret" ]]; then
# In case someone specifies JWT_SECRET but it's not a distributed setup
chmod 777 /var/lib/prysm/ee-secret
fi
if [[ -O "/var/lib/prysm/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/prysm/ee-secret/jwtsecret
fi
if [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet at ${NETWORK}"
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
branch=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f1)
config_dir=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f2-)
echo "This appears to be the ${repo} repo, branch ${branch} and config directory ${config_dir}."
# For want of something more amazing, let's just fail if git fails to pull this
set -e
if [ ! -d "/var/lib/prysm/testnet/${config_dir}" ]; then
mkdir -p /var/lib/prysm/testnet
cd /var/lib/prysm/testnet
git init --initial-branch="${branch}"
git remote add origin "${repo}"
git config core.sparseCheckout true
echo "${config_dir}" > .git/info/sparse-checkout
git pull origin "${branch}"
fi
bootnodes="$(paste -s -d, "/var/lib/prysm/testnet/${config_dir}/bootstrap_nodes.txt")"
deploy_block=$(cat "/var/lib/prysm/testnet/${config_dir}/deploy_block.txt")
set +e
__network="--chain-config-file=/var/lib/prysm/testnet/${config_dir}/config.yaml --genesis-state=/var/lib/prysm/testnet/${config_dir}/genesis.ssz \
--enable-debug-rpc-endpoints --bootstrap-node=${bootnodes} --contract-deployment-block=${deploy_block}"
else
__network="--${NETWORK}"
fi
# Check whether we should rapid sync
if [ -n "${RAPID_SYNC_URL:+x}" ]; then
__rapid_sync="--checkpoint-sync-url=${RAPID_SYNC_URL}"
echo "Checkpoint sync enabled"
else
__rapid_sync=""
fi
# Check whether we should use MEV Boost
if [ "${MEV_BOOST}" = "true" ]; then
__mev_boost="--http-mev-relay=${MEV_NODE:-http://mev-boost:18550}"
echo "MEV Boost enabled"
else
__mev_boost=""
fi
if [ "${ARCHIVE_NODE}" = "true" ]; then
echo "Prysm archive node without pruning"
__prune="--slots-per-archive-point=32"
else
__prune=""
fi
# Fetch genesis file as needed
if [[ "${NETWORK}" = "goerli" || "${NETWORK}" = "prater" ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Görli testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/goerli/raw/main/prater/genesis.ssz
fi
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--genesis-state=$GENESIS" ${__network} ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
elif [[ "${NETWORK}" = "sepolia" ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Sepolia testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/sepolia/raw/main/bepolia/genesis.ssz
fi
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--genesis-state=$GENESIS" ${__network} ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
elif [[ "${NETWORK}" = "holesky" ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Holešky testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/holesky/raw/main/custom_config_data/genesis.ssz
fi
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--genesis-state=$GENESIS" ${__network} ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__network} ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
fi