From 71cce4233ce596bd5b96ef998eeab93b40e6ef0b Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Fri, 14 Apr 2023 13:06:54 +0530 Subject: [PATCH] Use mounted volumes for data in lighthouse nodes --- .../compose/docker-compose-fixturenet-eth.yml | 9 +++++++++ .../genesis/cl/bootnode.sh | 17 ++++++++++++----- .../cerc-fixturenet-eth-lighthouse/run-cl.sh | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/data/compose/docker-compose-fixturenet-eth.yml b/app/data/compose/docker-compose-fixturenet-eth.yml index 238ca38e..940c1a8e 100644 --- a/app/data/compose/docker-compose-fixturenet-eth.yml +++ b/app/data/compose/docker-compose-fixturenet-eth.yml @@ -63,6 +63,8 @@ services: environment: RUN_BOOTNODE: "true" image: cerc/fixturenet-eth-lighthouse:local + volumes: + - fixturenet_eth_bootnode_data:/opt/testnet/build/cl/bootnode fixturenet-eth-lighthouse-1: hostname: fixturenet-eth-lighthouse-1 @@ -79,6 +81,8 @@ services: ETH1_ENDPOINT: "http://fixturenet-eth-geth-1:8545" EXECUTION_ENDPOINT: "http://fixturenet-eth-geth-1:8551" image: cerc/fixturenet-eth-lighthouse:local + volumes: + - fixturenet_eth_lighthouse_1_data:/opt/testnet/build/cl/node_1 depends_on: fixturenet-eth-bootnode-lighthouse: condition: service_started @@ -103,6 +107,8 @@ services: EXECUTION_ENDPOINT: "http://fixturenet-eth-geth-2:8551" LIGHTHOUSE_GENESIS_STATE_URL: "http://fixturenet-eth-lighthouse-1:8001/eth/v2/debug/beacon/states/0" image: cerc/fixturenet-eth-lighthouse:local + volumes: + - fixturenet_eth_lighthouse_2_data:/opt/testnet/build/cl/node_2 depends_on: fixturenet-eth-bootnode-lighthouse: condition: service_started @@ -114,3 +120,6 @@ volumes: bootnode_geth_data: fixturenet_eth_geth_1_data: fixturenet_eth_geth_2_data: + fixturenet_eth_bootnode_data: + fixturenet_eth_lighthouse_1_data: + fixturenet_eth_lighthouse_2_data: diff --git a/app/data/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh b/app/data/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh index f6f5cc73..e6970650 100755 --- a/app/data/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh +++ b/app/data/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh @@ -21,14 +21,21 @@ if [ ! -f "$DATADIR/bootnode/enr.dat" ]; then --udp-port $BOOTNODE_PORT \ --tcp-port $BOOTNODE_PORT \ --genesis-fork-version $GENESIS_FORK_VERSION \ - --output-dir $DATADIR/bootnode + --output-dir $DATADIR/bootnode-temp - bootnode_enr=`cat $DATADIR/bootnode/enr.dat` - echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml - - echo "Generated bootnode enr and written to $TESTNET_DIR/boot_enr.yaml" + # Output ENR to a temp dir and mv as "lcli generate-bootnode-enr" will not overwrite an empty dir (mounted volume) + mv $DATADIR/bootnode-temp/* $DATADIR/bootnode + rm -r $DATADIR/bootnode-temp + + echo "Generated bootnode enr" +else + echo "Found existing bootnode enr" fi +bootnode_enr=`cat $DATADIR/bootnode/enr.dat` +echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml +echo "Written bootnode enr to $TESTNET_DIR/boot_enr.yaml" + exec lighthouse boot_node \ --testnet-dir $TESTNET_DIR \ --port $BOOTNODE_PORT \ diff --git a/app/data/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh b/app/data/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh index ee5fc55c..25b2268c 100755 --- a/app/data/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh +++ b/app/data/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ "true" == "$RUN_BOOTNODE" ]; then +if [ "true" == "$RUN_BOOTNODE" ]; then cd /opt/testnet/build/cl python3 -m http.server 3000 & @@ -25,6 +25,7 @@ else cd /opt/testnet/cl if [ -z "$LIGHTHOUSE_GENESIS_STATE_URL" ]; then + # TODO Avoid on a restart ./reset_genesis_time.sh else while [ 1 -eq 1 ]; do