From f2c9af4ec6f1d7618b473b00757a9d1cd17371ac Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 1 Nov 2022 12:44:33 -0500 Subject: [PATCH] Add option to enable statediffing for the fixturenet geth. (#32) * Add option to enable statediffing for the fixturenet geth. * eol * Review comments --- compose/docker-compose-db-sharding.yml | 32 ------------------- compose/docker-compose-db.yml | 29 +++++++++++------ compose/docker-compose-fixturenet-eth.yml | 4 +++ config/fixturenet-eth/fixturenet-eth.env | 8 +++++ .../cerc-fixturenet-eth-geth/run-el.sh | 17 ++++++++-- pod-list.txt | 2 +- 6 files changed, 48 insertions(+), 44 deletions(-) delete mode 100644 compose/docker-compose-db-sharding.yml diff --git a/compose/docker-compose-db-sharding.yml b/compose/docker-compose-db-sharding.yml deleted file mode 100644 index b6117661..00000000 --- a/compose/docker-compose-db-sharding.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "3.2" - -services: - migrations: - restart: on-failure - depends_on: - ipld-eth-db: - condition: service_healthy - image: cerc/ipld-eth-db:local - environment: - DATABASE_USER: "vdbm" - DATABASE_NAME: "cerc_testing" - DATABASE_PASSWORD: "password" - DATABASE_HOSTNAME: "ipld-eth-db" - DATABASE_PORT: 5432 - - ipld-eth-db: - image: timescale/timescaledb:latest-pg14 - restart: always - command: ["postgres", "-c", "log_statement=all"] - environment: - POSTGRES_USER: "vdbm" - POSTGRES_DB: "cerc_testing" - POSTGRES_PASSWORD: "password" - healthcheck: - test: ["CMD", "nc", "-v", "localhost", "5432"] - interval: 30s - timeout: 10s - retries: 10 - start_period: 3s - ports: - - "127.0.0.1:8077:5432" diff --git a/compose/docker-compose-db.yml b/compose/docker-compose-db.yml index a984f7f0..fe7f4741 100644 --- a/compose/docker-compose-db.yml +++ b/compose/docker-compose-db.yml @@ -1,20 +1,31 @@ -# TODO: figure out if this is needed -- it doesn't seem to make sense in the context of the -# current version of cerc/ipld-eth-db/Dockerfile, which is only the migrations code, not the DB itself -# The sibling component docker-compose-db-sharding.yml looks more plausible version: "3.2" + services: - ipld-eth-db: - restart: always + migrations: + restart: on-failure + depends_on: + ipld-eth-db: + condition: service_healthy image: cerc/ipld-eth-db:local + environment: + DATABASE_USER: "vdbm" + DATABASE_NAME: "cerc_testing" + DATABASE_PASSWORD: "password" + DATABASE_HOSTNAME: "ipld-eth-db" + DATABASE_PORT: 5432 + + ipld-eth-db: + image: timescale/timescaledb:latest-pg14 + restart: always environment: POSTGRES_USER: "vdbm" POSTGRES_DB: "cerc_testing" POSTGRES_PASSWORD: "password" healthcheck: test: ["CMD", "nc", "-v", "localhost", "5432"] - interval: 5s - timeout: 3s - retries: 5 + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s ports: - "127.0.0.1:8077:5432" - command: ["postgres", "-c", "log_statement=all"] \ No newline at end of file diff --git a/compose/docker-compose-fixturenet-eth.yml b/compose/docker-compose-fixturenet-eth.yml index 00377d21..459fb2ee 100644 --- a/compose/docker-compose-fixturenet-eth.yml +++ b/compose/docker-compose-fixturenet-eth.yml @@ -21,10 +21,14 @@ services: fixturenet-eth-geth-2: hostname: fixturenet-eth-geth-2 + environment: + CERC_RUN_STATEDIFF: "true" + CERC_STATEDIFF_DB_NODE_ID: 2 env_file: - ../config/fixturenet-eth/fixturenet-eth.env image: cerc/fixturenet-eth-geth:local depends_on: + - migrations - fixturenet-eth-bootnode-geth fixturenet-eth-bootnode-lighthouse: diff --git a/config/fixturenet-eth/fixturenet-eth.env b/config/fixturenet-eth/fixturenet-eth.env index 8cb2bf4b..4467c543 100644 --- a/config/fixturenet-eth/fixturenet-eth.env +++ b/config/fixturenet-eth/fixturenet-eth.env @@ -7,4 +7,12 @@ ENODE="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13 # JWT shared by geth and lighthouse for authentication. JWT="0x6cdcac3501046a08e186730dd8bd136cfaf0fdc1fc955f6e15ad3068c0ff2af0" +# URL to download the ENR of the lighthouse bootnode (generated at first start). ENR_URL="http://fixturenet-eth-bootnode-lighthouse:3000/bootnode/enr.dat" + +# DB connection settings for statediffing (see docker-compose-db.yml) +CERC_STATEDIFF_DB_HOST="ipld-eth-db" +CERC_STATEDIFF_DB_PORT=5432 +CERC_STATEDIFF_DB_NAME="cerc_testing" +CERC_STATEDIFF_DB_USER="vdbm" +CERC_STATEDIFF_DB_PASSWORD="password" diff --git a/container-build/cerc-fixturenet-eth-geth/run-el.sh b/container-build/cerc-fixturenet-eth-geth/run-el.sh index b6d0ce83..0d0a866b 100755 --- a/container-build/cerc-fixturenet-eth-geth/run-el.sh +++ b/container-build/cerc-fixturenet-eth-geth/run-el.sh @@ -17,6 +17,19 @@ else echo -n "$JWT" > /opt/testnet/build/el/jwtsecret + STATEDIFF_OPTS="" + if [ "$CERC_RUN_STATEDIFF" == "true" ]; then + STATEDIFF_OPTS="--statediff=true \ + --statediff.db.host=$CERC_STATEDIFF_DB_HOST \ + --statediff.db.name=$CERC_STATEDIFF_DB_NAME \ + --statediff.db.nodeid=$CERC_STATEDIFF_DB_NODE_ID \ + --statediff.db.password=$CERC_STATEDIFF_DB_PASSWORD \ + --statediff.db.port=$CERC_STATEDIFF_DB_PORT \ + --statediff.db.user=$CERC_STATEDIFF_DB_USER \ + --statediff.waitforsync=true \ + --statediff.writing=true" + fi + geth \ --bootnodes="${ENODE}" \ --allow-insecure-unlock \ @@ -28,7 +41,7 @@ else --authrpc.addr="0.0.0.0" \ --authrpc.vhosts="*" \ --authrpc.jwtsecret="/opt/testnet/build/el/jwtsecret" \ - --networkid=${NETWORK_ID} \ + --networkid="${NETWORK_ID}" \ --netrestrict="${NETRESTRICT}" \ --gcmode archive \ --txlookuplimit=0 \ @@ -36,5 +49,5 @@ else --syncmode=full \ --mine \ --miner.threads=1 \ - --miner.etherbase=${ETHERBASE} 2>&1 | tee /var/log/geth.log + --miner.etherbase="${ETHERBASE}" ${STATEDIFF_OPTS} 2>&1 | tee /var/log/geth.log fi diff --git a/pod-list.txt b/pod-list.txt index d07d3d08..6a363325 100644 --- a/pod-list.txt +++ b/pod-list.txt @@ -1,5 +1,5 @@ contract -db-sharding +db eth-statediff-fill-service go-ethereum-foundry ipld-eth-beacon-db