Skip to content

Commit bc69b44

Browse files
marioevzRjected
authored andcommitted
clients/lodestar: new beacon node and validator client definition (ethereum#680)
1 parent 0ae689f commit bc69b44

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed

clients/lodestar-bn/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ARG branch=next
2+
3+
FROM chainsafe/lodestar:$branch
4+
5+
ADD lodestar_bn.sh /lodestar_bn.sh
6+
RUN chmod +x /lodestar_bn.sh
7+
8+
RUN node /usr/app/node_modules/.bin/lodestar --version | grep "Version:.*" | grep -o "v.*" > /version.txt
9+
10+
ENTRYPOINT ["/lodestar_bn.sh"]

clients/lodestar-bn/hive.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
roles:
2+
- beacon
3+
build_targets:
4+
- mainnet

clients/lodestar-bn/lodestar_bn.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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}"

clients/lodestar-vc/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ARG branch=next
2+
3+
FROM chainsafe/lodestar:$branch
4+
5+
ADD lodestar_vc.sh /lodestar_vc.sh
6+
RUN chmod +x /lodestar_vc.sh
7+
8+
RUN node /usr/app/node_modules/.bin/lodestar --version | grep "Version:.*" | grep -o "v.*" > /version.txt
9+
10+
ENTRYPOINT ["/lodestar_vc.sh"]

clients/lodestar-vc/hive.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
roles:
2+
- validator

clients/lodestar-vc/lodestar_vc.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
# Immediately abort the script on any error encountered
4+
set -e
5+
6+
mkdir -p /data/testnet_setup
7+
mkdir -p /data/vc
8+
mkdir -p /data/validators
9+
mkdir -p /data/secrets
10+
11+
cp /hive/input/config.yaml /data/testnet_setup
12+
13+
echo "${HIVE_ETH2_CONFIG_DEPOSIT_CONTRACT_ADDRESS:-0x1111111111111111111111111111111111111111}" > /data/testnet_setup/deposit_contract.txt
14+
echo "${HIVE_ETH2_DEPOSIT_DEPLOY_BLOCK_NUMBER:-0}" > /data/testnet_setup/deploy_block.txt
15+
16+
for keystore_path in /hive/input/keystores/*
17+
do
18+
pubkey=$(basename "$keystore_path")
19+
mkdir "/data/validators/$pubkey"
20+
cp "/hive/input/keystores/$pubkey/keystore.json" "/data/validators/$pubkey/voting-keystore.json"
21+
cp "/hive/input/secrets/$pubkey" "/data/secrets/$pubkey"
22+
done
23+
24+
metrics_option=$([[ "$HIVE_ETH2_METRICS_PORT" == "" ]] && echo "" || echo "--metrics --metrics.address=$CONTAINER_IP --metrics.port=$HIVE_ETH2_METRICS_PORT")
25+
26+
LOG=info
27+
case "$HIVE_LOGLEVEL" in
28+
0|1) LOG=error ;;
29+
2) LOG=warn ;;
30+
3) LOG=info ;;
31+
4) LOG=debug ;;
32+
5) LOG=trace ;;
33+
esac
34+
35+
echo Starting Lodestar Validator Client
36+
37+
node /usr/app/node_modules/.bin/lodestar \
38+
validator \
39+
--logLevel="$LOG" \
40+
--dataDir=/data/vc \
41+
--paramsFile=/hive/input/config.yaml \
42+
--keystoresDir="/data/validators" \
43+
--secretsDir="/data/secrets" \
44+
$metrics_option \
45+
--beaconNodes="http://$HIVE_ETH2_BN_API_IP:$HIVE_ETH2_BN_API_PORT"
46+

0 commit comments

Comments
 (0)