From bd9aaebe3d44eb6c6e25c97f9783d7a90a21446d Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 6 Dec 2022 11:10:38 -0600 Subject: [PATCH] eth-probe with fixturenet (#57) * eth-probe with fixturenet * Add ability to wait on geth to be up and minting blocks before launching the probe. --- app/data/container-image-list.txt | 1 + app/data/pod-list.txt | 1 + app/data/repository-list.txt | 1 + compose/docker-compose-eth-probe.yml | 59 +++++++++++++++++++ compose/docker-compose-fixturenet-eth.yml | 3 + config/fixturenet-eth/fixturenet-eth.env | 1 + container-build/cerc-eth-probe/build.sh | 3 + .../genesis/el/build_el.sh | 25 +++++++- .../genesis/el/el-config.yaml | 11 ++++ .../cerc-fixturenet-eth-geth/run-el.sh | 8 ++- 10 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 compose/docker-compose-eth-probe.yml create mode 100755 container-build/cerc-eth-probe/build.sh diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 65c1c54f..47c488dc 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -14,3 +14,4 @@ cerc/fixturenet-eth-geth cerc/fixturenet-eth-lighthouse cerc/watcher-mobymask cerc/test-container +cerc/eth-probe diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index c0635c4e..342e3018 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -12,3 +12,4 @@ fixturenet-laconicd fixturenet-eth watcher-mobymask test +eth-probe diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index 6bc5970d..a57b00dc 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -12,3 +12,4 @@ cerc-io/laconic-cns-cli cerc-io/mobymask-watcher cerc-io/watcher-ts vulcanize/assemblyscript +vulcanize/eth-probe diff --git a/compose/docker-compose-eth-probe.yml b/compose/docker-compose-eth-probe.yml new file mode 100644 index 00000000..8051db20 --- /dev/null +++ b/compose/docker-compose-eth-probe.yml @@ -0,0 +1,59 @@ +version: '3.2' + +services: + eth-probe-db: + restart: always + image: timescale/timescaledb:latest-pg14 + environment: + POSTGRES_USER: "probe" + POSTGRES_DB: "probe" + POSTGRES_PASSWORD: "probe" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + volumes: + - ../../eth-probe/db/schema.sql:/docker-entrypoint-initdb.d/init.sql + ports: + - 5432 + eth-probe-mq: + restart: always + image: cerc/eth-probe:local + environment: + MODE: "mq" + PROBE_DEV: "false" + PGPORT: 5432 + PGPASSWORD: "probe" + DB_USER: "probe" + PROBE_DB_NAME: "probe" + PROBE_DB_LOCATION: "eth-probe-db" + MQ_HOST: "0.0.0.0" + MQ_PORT: 33333 + DEBUG: "vulcanize:*,cerc:*" + healthcheck: + test: [ "CMD", "nc", "-v", "localhost", "33333" ] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + depends_on: + eth-probe-db: + condition: service_healthy + eth-probe-probe: + restart: always + image: cerc/eth-probe:local + environment: + MODE: "probe" + PROBE_DEV: "false" + MQ_HOST: "eth-probe-mq" + MQ_PORT: 33333 + PROBE_ID: 0 + GETH_HOST: "fixturenet-eth-geth-1" + GETH_MIN_BLOCK: 5 + GETHJSON_URL: "http://fixturenet-eth-geth-1:9898/geth.json" + DEBUG: "vulcanize:*,cerc:*,-vulcanize:sniffer:dpt:error" + depends_on: + eth-probe-mq: + condition: service_healthy diff --git a/compose/docker-compose-fixturenet-eth.yml b/compose/docker-compose-fixturenet-eth.yml index d105221f..96e3d2ba 100644 --- a/compose/docker-compose-fixturenet-eth.yml +++ b/compose/docker-compose-fixturenet-eth.yml @@ -8,6 +8,9 @@ services: environment: RUN_BOOTNODE: "true" image: cerc/fixturenet-eth-geth:local + ports: + - "9898" + - "30303" fixturenet-eth-geth-1: hostname: fixturenet-eth-geth-1 diff --git a/config/fixturenet-eth/fixturenet-eth.env b/config/fixturenet-eth/fixturenet-eth.env index 4467c543..9ec6742e 100644 --- a/config/fixturenet-eth/fixturenet-eth.env +++ b/config/fixturenet-eth/fixturenet-eth.env @@ -2,6 +2,7 @@ ACCOUNT_PASSWORD=secret1212 # ENODE of the geth bootnode. +BOOTNODE_KEY="b0ac22adcad37213c7c565810a50f1772291e7b0ce53fb73e7ec2a3c75bc13b5" ENODE="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13786620d5953738762afa13711d4ffb3b19aa5de772d8af72f851f7e9c5b164a@fixturenet-eth-bootnode-geth:30303" # JWT shared by geth and lighthouse for authentication. diff --git a/container-build/cerc-eth-probe/build.sh b/container-build/cerc-eth-probe/build.sh new file mode 100755 index 00000000..4f211307 --- /dev/null +++ b/container-build/cerc-eth-probe/build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Build cerc/eth-probe +docker build -t cerc/eth-probe:local ${CERC_REPO_BASE_DIR}/eth-probe diff --git a/container-build/cerc-fixturenet-eth-geth/genesis/el/build_el.sh b/container-build/cerc-fixturenet-eth-geth/genesis/el/build_el.sh index 0070707d..76b43daf 100755 --- a/container-build/cerc-fixturenet-eth-geth/genesis/el/build_el.sh +++ b/container-build/cerc-fixturenet-eth-geth/genesis/el/build_el.sh @@ -10,6 +10,29 @@ tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) envsubst < el-config.yaml > $tmp_dir/genesis-config.yaml ttd=`cat $tmp_dir/genesis-config.yaml | grep terminal_total_difficulty | awk '{ print $2 }'` +homestead_block=`cat $tmp_dir/genesis-config.yaml | grep homestead_block | awk '{ print $2 }'` +eip150_block=`cat $tmp_dir/genesis-config.yaml | grep eip150_block | awk '{ print $2 }'` +eip155_block=`cat $tmp_dir/genesis-config.yaml | grep eip155_block | awk '{ print $2 }'` +eip158_block=`cat $tmp_dir/genesis-config.yaml | grep eip158_block | awk '{ print $2 }'` +byzantium_block=`cat $tmp_dir/genesis-config.yaml | grep byzantium_block | awk '{ print $2 }'` +constantinople_block=`cat $tmp_dir/genesis-config.yaml | grep constantinople_block | awk '{ print $2 }'` +petersburg_block=`cat $tmp_dir/genesis-config.yaml | grep petersburg_block | awk '{ print $2 }'` +istanbul_block=`cat $tmp_dir/genesis-config.yaml | grep istanbul_block | awk '{ print $2 }'` +berlin_block=`cat $tmp_dir/genesis-config.yaml | grep berlin_block | awk '{ print $2 }'` +london_block=`cat $tmp_dir/genesis-config.yaml | grep london_block | awk '{ print $2 }'` +merge_fork_block=`cat $tmp_dir/genesis-config.yaml | grep merge_fork_block | awk '{ print $2 }'` -python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml | jq ".config.terminalTotalDifficulty=$ttd" > ../build/el/geth.json +python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml | \ + jq ".config.terminalTotalDifficulty=$ttd" | \ + jq ".config.homesteadBlock=$homestead_block" | \ + jq ".config.eip150Block=$eip150_block" | \ + jq ".config.eip155Block=$eip155_block" | \ + jq ".config.eip158Block=$eip158_block" | \ + jq ".config.byzantiumBlock=$byzantium_block" | \ + jq ".config.constantinopleBlock=$constantinople_block" | \ + jq ".config.petersburgBlock=$petersburg_block" | \ + jq ".config.istanbulBlock=$istanbul_block" | \ + jq ".config.berlinBlock=$berlin_block" | \ + jq ".config.londonBlock=$london_block" | \ + jq ".config.mergeForkBlock=$merge_fork_block" > ../build/el/geth.json python3 ../accounts/mnemonic_to_csv.py $tmp_dir/genesis-config.yaml > ../build/el/accounts.csv diff --git a/container-build/cerc-fixturenet-eth-geth/genesis/el/el-config.yaml b/container-build/cerc-fixturenet-eth-geth/genesis/el/el-config.yaml index ed8d4885..8bcb0fac 100644 --- a/container-build/cerc-fixturenet-eth-geth/genesis/el/el-config.yaml +++ b/container-build/cerc-fixturenet-eth-geth/genesis/el/el-config.yaml @@ -11,6 +11,17 @@ chain_id: 1212 deposit_contract_address: "0x1212121212121212121212121212121212121212" genesis_timestamp: 0 terminal_total_difficulty: 1000 +homestead_block: 1 +eip150_block: 1 +eip155_block: 1 +eip158_block: 1 +byzantium_block: 1 +constantinople_block: 1 +petersburg_block: 1 +istanbul_block: 1 +berlin_block: 1 +london_block: 1 +merge_fork_block: 1 clique: enabled: false diff --git a/container-build/cerc-fixturenet-eth-geth/run-el.sh b/container-build/cerc-fixturenet-eth-geth/run-el.sh index 0d0a866b..caf14070 100755 --- a/container-build/cerc-fixturenet-eth-geth/run-el.sh +++ b/container-build/cerc-fixturenet-eth-geth/run-el.sh @@ -4,9 +4,14 @@ ETHERBASE=`cat /opt/testnet/build/el/accounts.csv | head -1 | cut -d',' -f2` NETWORK_ID=`cat /opt/testnet/el/el-config.yaml | grep 'chain_id' | awk '{ print $2 }'` NETRESTRICT=`ip addr | grep inet | grep -v '127.0' | awk '{print $2}'` +HOME_DIR=`pwd` +cd /opt/testnet/build/el +python3 -m http.server 9898 & +cd $HOME_DIR + if [ "true" == "$RUN_BOOTNODE" ]; then geth \ - --nodekeyhex="b0ac22adcad37213c7c565810a50f1772291e7b0ce53fb73e7ec2a3c75bc13b5" \ + --nodekeyhex="${BOOTNODE_KEY}" \ --nodiscover \ --ipcdisable \ --networkid=${NETWORK_ID} \ @@ -49,5 +54,6 @@ else --syncmode=full \ --mine \ --miner.threads=1 \ + --verbosity=5 \ --miner.etherbase="${ETHERBASE}" ${STATEDIFF_OPTS} 2>&1 | tee /var/log/geth.log fi