diff --git a/compose-lodestar.yml b/compose-lodestar.yml new file mode 100644 index 0000000..c69c919 --- /dev/null +++ b/compose-lodestar.yml @@ -0,0 +1,87 @@ +# Docker compose file to aid developers to test lodestar VCs in a distributed validator cluster. +version: "3.8" + +services: + # _ _ _ + # | | ___ __| | ___ ___| |_ __ _ _ __ + # | |/ _ \ / _` |/ _ \/ __| __/ _` | '__| + # | | (_) | (_| | __/\__ \ || (_| | | + # |_|\___/ \__,_|\___||___/\__\__,_|_| + vc0-lodestar: + image: nflaig/lodestar:dvt-compatible + entrypoint: /opt/lodestar/run.sh + networks: [ cluster ] + depends_on: [ node0 ] + restart: unless-stopped + environment: + BEACON_NODE_ADDRESS: http://node0:3600 + ETH2_NETWORK: ${ETH2_NETWORK:-goerli} + volumes: + - ./lodestar/run.sh:/opt/lodestar/run.sh + - .charon/cluster/node0/validator_keys:/home/charon/validator_keys + + vc1-lodestar: + image: nflaig/lodestar:dvt-compatible + entrypoint: /opt/lodestar/run.sh + networks: [ cluster ] + depends_on: [ node1 ] + restart: unless-stopped + environment: + BEACON_NODE_ADDRESS: http://node1:3600 + ETH2_NETWORK: ${ETH2_NETWORK:-goerli} + volumes: + - ./lodestar/run.sh:/opt/lodestar/run.sh + - .charon/cluster/node1/validator_keys:/home/charon/validator_keys + + vc2-lodestar: + image: nflaig/lodestar:dvt-compatible + entrypoint: /opt/lodestar/run.sh + networks: [ cluster ] + depends_on: [ node2 ] + restart: unless-stopped + environment: + BEACON_NODE_ADDRESS: http://node2:3600 + ETH2_NETWORK: ${ETH2_NETWORK:-goerli} + volumes: + - ./lodestar/run.sh:/opt/lodestar/run.sh + - .charon/cluster/node2/validator_keys:/home/charon/validator_keys + + vc3-lodestar: + image: nflaig/lodestar:dvt-compatible + entrypoint: /opt/lodestar/run.sh + networks: [ cluster ] + depends_on: [ node3 ] + restart: unless-stopped + environment: + BEACON_NODE_ADDRESS: http://node3:3600 + ETH2_NETWORK: ${ETH2_NETWORK:-goerli} + volumes: + - ./lodestar/run.sh:/opt/lodestar/run.sh + - .charon/cluster/node3/validator_keys:/home/charon/validator_keys + + vc4-lodestar: + image: nflaig/lodestar:dvt-compatible + entrypoint: /opt/lodestar/run.sh + networks: [ cluster ] + depends_on: [ node4 ] + restart: unless-stopped + environment: + BEACON_NODE_ADDRESS: http://node4:3600 + ETH2_NETWORK: ${ETH2_NETWORK:-goerli} + volumes: + - ./lodestar/run.sh:/opt/lodestar/run.sh + - .charon/cluster/node4/validator_keys:/home/charon/validator_keys + + vc5-lodestar: + image: nflaig/lodestar:dvt-compatible + entrypoint: /opt/lodestar/run.sh + networks: [ cluster ] + depends_on: [ node5 ] + restart: unless-stopped + environment: + BEACON_NODE_ADDRESS: http://node5:3600 + ETH2_NETWORK: ${ETH2_NETWORK:-goerli} + volumes: + - ./lodestar/run.sh:/opt/lodestar/run.sh + - .charon/cluster/node5/validator_keys:/home/charon/validator_keys + diff --git a/lodestar/run.sh b/lodestar/run.sh new file mode 100755 index 0000000..efb0dfd --- /dev/null +++ b/lodestar/run.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +tmpkeys="/home/validator_keys/tmpkeys" +mkdir -p ${tmpkeys} + +for f in /home/charon/validator_keys/keystore-*.json; do + echo "Importing key ${f}" + + # Copy keystore file to tmpkeys/ directory. + cp "${f}" "${tmpkeys}" + + # Import keystore with password. + node /usr/app/packages/cli/bin/lodestar validator import \ + --network="$ETH2_NETWORK" \ + --importKeystores="/home/charon/validator_keys" \ + --importKeystoresPassword="${f//json/txt}" + + # Delete tmpkeys/keystore-*.json file that was copied before. + filename="$(basename ${f})" + rm "${tmpkeys}/${filename}" +done + +# Delete the tmpkeys/ directory since it's no longer needed. +rm -r ${tmpkeys} + +echo "Imported all keys" + +node /usr/app/packages/cli/bin/lodestar validator \ + --network="$ETH2_NETWORK" \ + --metrics=true \ + --metrics.address="0.0.0.0" \ + --metrics.port=5064 \ + --beaconNodes="$BEACON_NODE_ADDRESS" \ + --distributed \ No newline at end of file