-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathstart-bn.sh
More file actions
executable file
·337 lines (275 loc) · 10.4 KB
/
start-bn.sh
File metadata and controls
executable file
·337 lines (275 loc) · 10.4 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#!/bin/sh
# This script launches ETH2 beacon clients for Rocket Pool's docker stack; only edit if you know what you're doing ;)
# Performance tuning for ARM systems
UNAME_VAL=$(uname -m)
if [ "$UNAME_VAL" = "arm64" ] || [ "$UNAME_VAL" = "aarch64" ]; then
# Get the number of available cores
CORE_COUNT=$(nproc)
# Don't do performance tweaks on systems with 6+ cores
if [ "$CORE_COUNT" -gt "5" ]; then
echo "$CORE_COUNT cores detected, skipping performance tuning"
else
echo "$CORE_COUNT cores detected, activating performance tuning"
PERF_PREFIX="ionice -c 2 -n 0"
echo "Performance tuning: $PERF_PREFIX"
fi
fi
# Set up the network-based flags
if [ "$NETWORK" = "mainnet" ]; then
LH_NETWORK="mainnet"
LODESTAR_NETWORK="mainnet"
NIMBUS_NETWORK="mainnet"
PRYSM_NETWORK="--mainnet"
TEKU_NETWORK="mainnet"
PRYSM_GENESIS_STATE=""
elif [ "$NETWORK" = "devnet" ]; then
LH_NETWORK="hoodi"
LODESTAR_NETWORK="hoodi"
NIMBUS_NETWORK="hoodi"
PRYSM_NETWORK="--hoodi"
TEKU_NETWORK="hoodi"
elif [ "$NETWORK" = "testnet" ]; then
LH_NETWORK="hoodi"
LODESTAR_NETWORK="hoodi"
NIMBUS_NETWORK="hoodi"
PRYSM_NETWORK="--hoodi"
TEKU_NETWORK="hoodi"
else
echo "Unknown network [$NETWORK]"
exit 1
fi
# Check for the JWT auth file
if [ ! -f "/secrets/jwtsecret" ]; then
echo "JWT secret file not found, please try again when the Execution Client has created one."
exit 1
fi
# Report a missing fee recipient file
if [ ! -f "/validators/$FEE_RECIPIENT_FILE" ]; then
echo "Fee recipient file not found, please wait for the rocketpool_node process to create one."
exit 1
fi
# Lighthouse startup
if [ "$CC_CLIENT" = "lighthouse" ]; then
CMD="$PERF_PREFIX /usr/local/bin/lighthouse beacon \
--network $LH_NETWORK \
--port $BN_P2P_PORT \
--discovery-port $BN_P2P_PORT \
--datadir /ethclient/lighthouse \
--execution-endpoint $EC_ENGINE_ENDPOINT \
--http \
--http-address 0.0.0.0 \
--http-port ${BN_API_PORT:-5052} \
--disable-upnp \
--staking \
--execution-jwt=/secrets/jwtsecret \
--quic-port ${BN_P2P_QUIC_PORT:-8001} \
--historic-state-cache-size 2 \
$BN_ADDITIONAL_FLAGS"
# Performance tuning for ARM systems
UNAME_VAL=$(uname -m)
if [ "$UNAME_VAL" = "arm64" ] || [ "$UNAME_VAL" = "aarch64" ]; then
CMD="$CMD --execution-timeout-multiplier 2"
fi
if [ ! -z "$PBS_URL" ]; then
CMD="$CMD --builder $PBS_URL"
fi
if [ ! -z "$BN_MAX_PEERS" ]; then
CMD="$CMD --target-peers $BN_MAX_PEERS"
fi
if [ "$ENABLE_METRICS" = "true" ]; then
CMD="$CMD --metrics --metrics-address 0.0.0.0 --metrics-port $BN_METRICS_PORT --validator-monitor-auto"
fi
if [ ! -z "$CHECKPOINT_SYNC_URL" ]; then
CMD="$CMD --checkpoint-sync-url $CHECKPOINT_SYNC_URL"
fi
if [ "$ENABLE_BITFLY_NODE_METRICS" = "true" ]; then
CMD="$CMD --monitoring-endpoint $BITFLY_NODE_METRICS_ENDPOINT?apikey=$BITFLY_NODE_METRICS_SECRET&machine=$BITFLY_NODE_METRICS_MACHINE_NAME"
fi
if [ "$ENABLE_IPV6" = "true" ]; then
CMD="$CMD --listen-address :: --port6 $BN_P2P_PORT --enr-udp6-port $BN_P2P_PORT --quic-port6 ${BN_P2P_QUIC_PORT:-8001}"
fi
exec ${CMD}
fi
# Lodestar startup
if [ "$CC_CLIENT" = "lodestar" ]; then
CMD="$PERF_PREFIX /usr/local/bin/node --max-http-header-size=65536 /usr/app/packages/cli/bin/lodestar beacon \
--network $LODESTAR_NETWORK \
--dataDir /ethclient/lodestar \
--serveHistoricalState \
--port $BN_P2P_PORT \
--execution.urls $EC_ENGINE_ENDPOINT \
--rest \
--rest.address 0.0.0.0 \
--rest.port ${BN_API_PORT:-5052} \
--jwt-secret /secrets/jwtsecret \
$BN_ADDITIONAL_FLAGS"
if [ ! -z "$TTD_OVERRIDE" ]; then
CMD="$CMD --terminal-total-difficulty-override $TTD_OVERRIDE"
fi
if [ ! -z "$PBS_URL" ]; then
CMD="$CMD --builder --builder.urls $PBS_URL"
fi
if [ ! -z "$BN_MAX_PEERS" ]; then
CMD="$CMD --targetPeers $BN_MAX_PEERS"
fi
if [ "$ENABLE_METRICS" = "true" ]; then
CMD="$CMD --metrics --metrics.address 0.0.0.0 --metrics.port $BN_METRICS_PORT"
fi
if [ ! -z "$EXTERNAL_IP" ]; then
if expr "$EXTERNAL_IP" : '.*:' >/dev/null; then
CMD="$CMD --enr.ip6 $EXTERNAL_IP --nat"
else
CMD="$CMD --enr.ip $EXTERNAL_IP --nat"
fi
fi
if [ "$ENABLE_IPV6" = "true" ]; then
CMD="$CMD --listenAddress6 :: --port6 $BN_P2P_PORT"
fi
if [ ! -z "$CHECKPOINT_SYNC_URL" ]; then
CMD="$CMD --checkpointSyncUrl $CHECKPOINT_SYNC_URL"
fi
if [ "$ENABLE_BITFLY_NODE_METRICS" = "true" ]; then
CMD="$CMD --monitoring.endpoint $BITFLY_NODE_METRICS_ENDPOINT?apikey=$BITFLY_NODE_METRICS_SECRET&machine=$BITFLY_NODE_METRICS_MACHINE_NAME"
fi
exec ${CMD}
fi
# Nimbus startup
if [ "$CC_CLIENT" = "nimbus" ]; then
# Handle checkpoint syncing
if [ ! -z "$CHECKPOINT_SYNC_URL" ]; then
# Ignore it if a DB already exists
if [ -f "/ethclient/nimbus/db/nbc.sqlite3" ]; then
echo "Nimbus database already exists, ignoring checkpoint sync."
else
echo "Starting checkpoint sync for Nimbus..."
$PERF_PREFIX /home/user/nimbus-eth2/build/nimbus_beacon_node trustedNodeSync --network=$NIMBUS_NETWORK --data-dir=/ethclient/nimbus --trusted-node-url=$CHECKPOINT_SYNC_URL --backfill=false
echo "Checkpoint sync complete!"
fi
fi
CMD="$PERF_PREFIX /home/user/nimbus-eth2/build/nimbus_beacon_node \
--non-interactive \
--enr-auto-update \
--network=$NIMBUS_NETWORK \
--data-dir=/ethclient/nimbus \
--tcp-port=$BN_P2P_PORT \
--udp-port=$BN_P2P_PORT \
--web3-url=$EC_ENGINE_ENDPOINT \
--rest \
--rest-address=0.0.0.0 \
--rest-port=${BN_API_PORT:-5052} \
--jwt-secret=/secrets/jwtsecret \
$BN_ADDITIONAL_FLAGS"
if [ ! -z "$BN_SUGGESTED_BLOCK_GAS_LIMIT" ]; then
CMD="$CMD --suggested-gas-limit=$BN_SUGGESTED_BLOCK_GAS_LIMIT"
fi
if [ ! -z "$PBS_URL" ]; then
CMD="$CMD --payload-builder --payload-builder-url=$PBS_URL"
fi
if [ ! -z "$BN_MAX_PEERS" ]; then
CMD="$CMD --max-peers=$BN_MAX_PEERS"
fi
if [ "$ENABLE_METRICS" = "true" ]; then
CMD="$CMD --metrics --metrics-address=0.0.0.0 --metrics-port=$BN_METRICS_PORT"
fi
if [ ! -z "$EXTERNAL_IP" ]; then
CMD="$CMD --nat=extip:$EXTERNAL_IP"
fi
if [ ! -z "$NIMBUS_PRUNING_MODE" ]; then
CMD="$CMD --history=$NIMBUS_PRUNING_MODE"
fi
exec ${CMD}
fi
# Prysm startup
if [ "$CC_CLIENT" = "prysm" ]; then
CMD="$PERF_PREFIX /app/cmd/beacon-chain/beacon-chain \
--accept-terms-of-use \
$PRYSM_NETWORK \
$PRYSM_GENESIS_STATE \
--datadir /ethclient/prysm \
--p2p-tcp-port $BN_P2P_PORT \
--p2p-udp-port $BN_P2P_PORT \
--execution-endpoint $EC_ENGINE_ENDPOINT \
--rpc-host 0.0.0.0 \
--rpc-port ${BN_RPC_PORT:-5053} \
--grpc-gateway-host 0.0.0.0 \
--grpc-gateway-port ${BN_API_PORT:-5052} \
--p2p-quic-port ${BN_P2P_QUIC_PORT:-8001} \
--eth1-header-req-limit 150 \
--jwt-secret=/secrets/jwtsecret \
--api-timeout 20s \
--enable-experimental-backfill \
--blob-storage-layout=by-epoch \
$BN_ADDITIONAL_FLAGS"
if [ ! -z "$PBS_URL" ]; then
CMD="$CMD --http-mev-relay $PBS_URL"
fi
if [ ! -z "$BN_MAX_PEERS" ]; then
CMD="$CMD --p2p-max-peers $BN_MAX_PEERS"
fi
if [ "$ENABLE_METRICS" = "true" ]; then
CMD="$CMD --monitoring-host 0.0.0.0 --monitoring-port $BN_METRICS_PORT"
else
CMD="$CMD --disable-monitoring"
fi
if [ "$NETWORK" = "testnet" ]; then
CMD="$CMD --genesis-state /ethclient/hoodi-genesis.ssz"
elif [ "$NETWORK" = "devnet" ]; then
CMD="$CMD --genesis-state /devnet/genesis.ssz"
fi
if [ ! -z "$CHECKPOINT_SYNC_URL" ]; then
CMD="$CMD --checkpoint-sync-url=$CHECKPOINT_SYNC_URL --genesis-beacon-api-url=$CHECKPOINT_SYNC_URL"
fi
exec ${CMD}
fi
# Teku startup
if [ "$CC_CLIENT" = "teku" ]; then
CMD="$PERF_PREFIX /opt/teku/bin/teku \
--network=$TEKU_NETWORK \
--data-path=/ethclient/teku \
--p2p-port=$BN_P2P_PORT \
--ee-endpoint=$EC_ENGINE_ENDPOINT \
--rest-api-enabled \
--rest-api-interface=0.0.0.0 \
--rest-api-port=${BN_API_PORT:-5052} \
--rest-api-host-allowlist=* \
--eth1-deposit-contract-max-request-size=150 \
--log-destination=CONSOLE \
--ee-jwt-secret-file=/secrets/jwtsecret \
--beacon-liveness-tracking-enabled \
--validators-proposer-default-fee-recipient=$RETH_ADDRESS \
--validators-graffiti-client-append-format=DISABLED \
$BN_ADDITIONAL_FLAGS"
if [ ! -z "$BN_SUGGESTED_BLOCK_GAS_LIMIT" ]; then
CMD="$CMD --validators-builder-registration-default-gas-limit=$BN_SUGGESTED_BLOCK_GAS_LIMIT"
fi
if [ "$TEKU_ARCHIVE_MODE" = "true" ]; then
CMD="$CMD --data-storage-mode=archive"
fi
if [ ! -z "$PBS_URL" ]; then
CMD="$CMD --builder-endpoint=$PBS_URL"
fi
if [ ! -z "$BN_MAX_PEERS" ]; then
CMD="$CMD --p2p-peer-lower-bound=$BN_MAX_PEERS --p2p-peer-upper-bound=$BN_MAX_PEERS"
fi
if [ "$ENABLE_METRICS" = "true" ]; then
CMD="$CMD --metrics-enabled=true --metrics-interface=0.0.0.0 --metrics-port=$BN_METRICS_PORT --metrics-host-allowlist=*"
fi
if [ ! -z "$CHECKPOINT_SYNC_URL" ]; then
CMD="$CMD --checkpoint-sync-url=$CHECKPOINT_SYNC_URL"
fi
if [ "$ENABLE_BITFLY_NODE_METRICS" = "true" ]; then
CMD="$CMD --metrics-publish-endpoint=$BITFLY_NODE_METRICS_ENDPOINT?apikey=$BITFLY_NODE_METRICS_SECRET&machine=$BITFLY_NODE_METRICS_MACHINE_NAME"
fi
if [ "$ENABLE_IPV6" = "true" ]; then
CMD="$CMD --p2p-interface=0.0.0.0,:: --p2p-port-ipv6=$BN_IPV6_P2P_PORT"
if [ ! -z "$EXTERNAL_IP" ]; then
if expr "$EXTERNAL_IP" : '.*:' >/dev/null; then
CMD="$CMD --p2p-advertised-ip=$EXTERNAL_IP"
fi
fi
fi
if [ "$TEKU_JVM_HEAP_SIZE" -gt "0" ]; then
CMD="env JAVA_OPTS=\"-Xmx${TEKU_JVM_HEAP_SIZE}m\" $CMD"
fi
exec ${CMD}
fi