|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Immediately abort the script on any error encountered |
| 4 | +set -e |
| 5 | + |
| 6 | +if [ ! -f "/hive/input/genesis.ssz" ]; then |
| 7 | + if [ -z "$HIVE_ETH2_ETH1_RPC_ADDRS" ]; then |
| 8 | + echo "genesis.ssz file is missing, and no Eth1 RPC addr was provided for building genesis from scratch." |
| 9 | + # TODO: alternative to start from weak-subjectivity-state |
| 10 | + exit 1 |
| 11 | + fi |
| 12 | +fi |
| 13 | + |
| 14 | +mkdir -p /data/testnet_setup |
| 15 | + |
| 16 | + |
| 17 | +# empty bootnodes file, required for custom testnet setup, use CLI arg instead to configure it. |
| 18 | + |
| 19 | +echo "${HIVE_ETH2_CONFIG_DEPOSIT_CONTRACT_ADDRESS:-0x1111111111111111111111111111111111111111}" > /data/testnet_setup/deposit_contract.txt |
| 20 | + |
| 21 | +mkdir -p /data/beacon |
| 22 | +mkdir -p /data/network |
| 23 | + |
| 24 | +case "$HIVE_LOGLEVEL" in |
| 25 | + 0|1) LOG=error ;; |
| 26 | + 2) LOG=warn ;; |
| 27 | + 3) LOG=info ;; |
| 28 | + 4) LOG=debug ;; |
| 29 | + 5) LOG=silly ;; |
| 30 | +esac |
| 31 | +LOG=debug |
| 32 | + |
| 33 | +echo "bootnodes: ${HIVE_ETH2_BOOTNODE_ENRS}" |
| 34 | + |
| 35 | +CONTAINER_IP=`hostname -i | awk '{print $1;}'` |
| 36 | +echo Container IP: $CONTAINER_IP |
| 37 | +bootnodes_option=$([[ "$HIVE_ETH2_BOOTNODE_ENRS" == "" ]] && echo "" || echo "--bootnodes ${HIVE_ETH2_BOOTNODE_ENRS//,/ }") |
| 38 | +metrics_option=$([[ "$HIVE_ETH2_METRICS_PORT" == "" ]] && echo "" || echo "--metrics --metrics.address=$CONTAINER_IP --metrics.port=$HIVE_ETH2_METRICS_PORT") |
| 39 | + |
| 40 | +echo "bootnodes option : ${bootnodes_option}" |
| 41 | + |
| 42 | +echo -n "0x7365637265747365637265747365637265747365637265747365637265747365" > /jwtsecret |
| 43 | + |
| 44 | +echo Starting Lodestar Beacon Node |
| 45 | + |
| 46 | +node /usr/app/node_modules/.bin/lodestar \ |
| 47 | + beacon \ |
| 48 | + --logLevel="$LOG" \ |
| 49 | + --dataDir=/data/beacon \ |
| 50 | + --port="${HIVE_ETH2_P2P_TCP_PORT:-9000}" \ |
| 51 | + --discoveryPort="${HIVE_ETH2_P2P_UDP_PORT:-9000}" \ |
| 52 | + --paramsFile=/hive/input/config.yaml \ |
| 53 | + --genesisStateFile=/hive/input/genesis.ssz \ |
| 54 | + --rest \ |
| 55 | + --rest.namespace="*" \ |
| 56 | + --rest.address=0.0.0.0 \ |
| 57 | + --rest.port="${HIVE_ETH2_BN_API_PORT:-4000}" \ |
| 58 | + --eth1 \ |
| 59 | + --execution.urls="$HIVE_ETH2_ETH1_ENGINE_RPC_ADDRS" \ |
| 60 | + --eth1.depositContractDeployBlock=${HIVE_ETH2_DEPOSIT_DEPLOY_BLOCK_NUMBER:-0} \ |
| 61 | + --jwt-secret=/jwtsecret \ |
| 62 | + $metrics_option \ |
| 63 | + $bootnodes_option \ |
| 64 | + --enr.ip="${CONTAINER_IP}" \ |
| 65 | + --enr.tcp="${HIVE_ETH2_P2P_TCP_PORT:-9000}" \ |
| 66 | + --enr.udp="${HIVE_ETH2_P2P_UDP_PORT:-9000}" \ |
| 67 | + --network.connectToDiscv5Bootnodes=true \ |
| 68 | + --discv5 \ |
| 69 | + --subscribeAllSubnets=true \ |
| 70 | + --targetPeers="${HIVE_ETH2_P2P_TARGET_PEERS:-10}" |
0 commit comments