From 863548530ac0a14e000e29a4babac41d74f97d31 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 3 Nov 2022 17:31:14 -0500 Subject: [PATCH] Integrate ipld-eth-beacon-indexer working with the fixturenet. (#36) * Use explicit image hash, not latest tag. * Better syntax * No latest * Add fixturenet setup for beacon indexer. * Don't wait for merge. * Don't wait for merge. --- compose/docker-compose-fixturenet-eth.yml | 36 ++++++++++++++++--- compose/docker-compose-ipld-eth-beacon-db.yml | 12 +++---- ...docker-compose-ipld-eth-beacon-indexer.yml | 14 ++++---- compose/docker-compose-lighthouse.yml | 17 --------- config/ipld-eth-beacon-indexer/indexer.env | 31 ++++++++++++++++ .../genesis/cl/ready.sh | 10 ++++++ .../cerc-fixturenet-eth-lighthouse/run-cl.sh | 8 ++--- 7 files changed, 89 insertions(+), 39 deletions(-) delete mode 100644 compose/docker-compose-lighthouse.yml create mode 100644 config/ipld-eth-beacon-indexer/indexer.env create mode 100755 container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/ready.sh diff --git a/compose/docker-compose-fixturenet-eth.yml b/compose/docker-compose-fixturenet-eth.yml index 459fb2ee..d105221f 100644 --- a/compose/docker-compose-fixturenet-eth.yml +++ b/compose/docker-compose-fixturenet-eth.yml @@ -14,6 +14,12 @@ services: env_file: - ../config/fixturenet-eth/fixturenet-eth.env image: cerc/fixturenet-eth-geth:local + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "8545"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s depends_on: - fixturenet-eth-bootnode-geth ports: @@ -24,6 +30,12 @@ services: environment: CERC_RUN_STATEDIFF: "true" CERC_STATEDIFF_DB_NODE_ID: 2 + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "8545"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s env_file: - ../config/fixturenet-eth/fixturenet-eth.env image: cerc/fixturenet-eth-geth:local @@ -39,6 +51,12 @@ services: fixturenet-eth-lighthouse-1: hostname: fixturenet-eth-lighthouse-1 + healthcheck: + test: ["CMD", "wget", "--tries=1", "--connect-timeout=1", "--quiet", "-O", "-", "http://localhost:8001/eth/v2/beacon/blocks/head"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 30s env_file: - ../config/fixturenet-eth/fixturenet-eth.env environment: @@ -47,13 +65,21 @@ services: EXECUTION_ENDPOINT: "http://fixturenet-eth-geth-1:8551" image: cerc/fixturenet-eth-lighthouse:local depends_on: - - fixturenet-eth-bootnode-lighthouse - - fixturenet-eth-geth-1 + fixturenet-eth-bootnode-lighthouse: + condition: service_started + fixturenet-eth-geth-1: + condition: service_healthy ports: - "8001" fixturenet-eth-lighthouse-2: hostname: fixturenet-eth-lighthouse-2 + healthcheck: + test: ["CMD", "wget", "--tries=1", "--connect-timeout=1", "--quiet", "-O", "-", "http://localhost:8001/eth/v2/beacon/blocks/head"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 30s env_file: - ../config/fixturenet-eth/fixturenet-eth.env environment: @@ -63,5 +89,7 @@ services: LIGHTHOUSE_GENESIS_STATE_URL: "http://fixturenet-eth-lighthouse-1:8001/eth/v2/debug/beacon/states/0" image: cerc/fixturenet-eth-lighthouse:local depends_on: - - fixturenet-eth-bootnode-lighthouse - - fixturenet-eth-geth-2 + fixturenet-eth-bootnode-lighthouse: + condition: service_started + fixturenet-eth-geth-2: + condition: service_healthy diff --git a/compose/docker-compose-ipld-eth-beacon-db.yml b/compose/docker-compose-ipld-eth-beacon-db.yml index 957b0b28..bb54cd1f 100644 --- a/compose/docker-compose-ipld-eth-beacon-db.yml +++ b/compose/docker-compose-ipld-eth-beacon-db.yml @@ -7,11 +7,11 @@ services: POSTGRES_USER: vdbm POSTGRES_DB: cerc_testing POSTGRES_PASSWORD: password - volumes: - - vdb_db_eth-beacon_db:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s ports: - "127.0.0.1:8076:5432" - command: ["postgres", "-c", "log_statement=all"] - -volumes: - vdb_db_eth-beacon_db: diff --git a/compose/docker-compose-ipld-eth-beacon-indexer.yml b/compose/docker-compose-ipld-eth-beacon-indexer.yml index 69b4c17e..533edf3c 100644 --- a/compose/docker-compose-ipld-eth-beacon-indexer.yml +++ b/compose/docker-compose-ipld-eth-beacon-indexer.yml @@ -3,12 +3,10 @@ services: ipld-eth-beacon-indexer: restart: unless-stopped depends_on: - - ipld-eth-beacon-db - - lighthouse + ipld-eth-beacon-db: + condition: service_healthy + fixturenet-eth-lighthouse-1: + condition: service_healthy image: cerc/ipld-eth-beacon-indexer:local - volumes: - - type: bind - source: ${eth_beacon_config_file} - target: /root/ipld-eth-beacon-config.json - environment: - CAPTURE_MODE: ${eth_beacon_capture_mode} + env_file: + - ../config/ipld-eth-beacon-indexer/indexer.env diff --git a/compose/docker-compose-lighthouse.yml b/compose/docker-compose-lighthouse.yml deleted file mode 100644 index 73d90797..00000000 --- a/compose/docker-compose-lighthouse.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "3.2" -services: - lighthouse: - restart: always - image: cerc/lighthouse:local - environment: - - NETWORK=mainnet - volumes: - - lighthouse_db:/root/.lighthouse - ports: - - 127.0.0.1:5052:5052 - - 9000:9000/udp - - 9000:9000/tcp - command: ["tail", "-f", "/dev/null"] - -volumes: - lighthouse_db: \ No newline at end of file diff --git a/config/ipld-eth-beacon-indexer/indexer.env b/config/ipld-eth-beacon-indexer/indexer.env new file mode 100644 index 00000000..b19800aa --- /dev/null +++ b/config/ipld-eth-beacon-indexer/indexer.env @@ -0,0 +1,31 @@ +# Match compose/docker-compose-ipld-eth-beacon-db.yml +POSTGRES_HOST=ipld-eth-beacon-db +POSTGRES_PORT=5432 +POSTGRES_DB=cerc_testing +POSTGRES_USER=vdbm +POSTGRES_PASSWORD=password + +# Match compose/docker-compose-fixturenet-eth.yml +LIGHTHOUSE_HOST=fixturenet-eth-lighthouse-1 +LIGHTHOUSE_PORT=8001 +LIGHTHOUSE_PROTOCOL=http + +CAPTURE_MODE=head +LOG_LEVEL=debug + +BC_MAX_HISTORIC_PROCESS_WORKER=2 +BC_UNIQUE_NODE_IDENTIFIER=1001 +BC_CHECK_DB=true +BC_BEACON_STATE_PROCESSING_ENABLED=false +BC_BEACON_BLOCK_PROCESSING_ENABLED=true +BC_MINIMUM_SLOT=0 + +KG_INCREMENT=10000 +KG_PROCESS_KNOWN_GAPS_ENABLED=true +KG_MAX_KNOWN_GAPS_WORKER=2 +KG_MINIMUM_SLOT=0 + +# Match compose/docker-compose-prometheus-grafana.yml +PROM_HOST=prometheus +PROM_PORT=9000 +PROM_METRICS_ENABLED=false diff --git a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/ready.sh b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/ready.sh new file mode 100755 index 00000000..ef0a184d --- /dev/null +++ b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/ready.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +LIGHTHOUSE_BASE_URL=http://localhost:8001 + +result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'` +if [ ! -z "$result" ] && [ $result -gt 0 ]; then + exit 0 +fi + +exit 1 diff --git a/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh b/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh index 07346e58..ee5fc55c 100755 --- a/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh +++ b/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh @@ -32,8 +32,8 @@ else sleep 5 result=`wget --no-check-certificate --quiet -O - --timeout=0 $LIGHTHOUSE_GENESIS_STATE_URL | jq -r '.data.genesis_time'` if [ ! -z "$result" ]; then - ./reset_genesis_time.sh $result - break; + ./reset_genesis_time.sh $result + break; fi done fi @@ -44,8 +44,8 @@ else sleep 5 result=`wget --no-check-certificate --quiet -O - --timeout=0 $ENR_URL` if [ ! -z "$result" ]; then - export ENR="$result" - break; + export ENR="$result" + break; fi done fi