From bb4288cc60f830a94c61c717caf072dd6286b19a Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 28 Oct 2022 14:21:02 -0600 Subject: [PATCH 1/7] Fixturenet for laconicd --- .../docker-compose-fixturenet-laconicd.yml | 21 +++++++++++++++++++ compose/docker-compose-laconicd.yml | 4 ---- .../create-fixturenet.sh | 2 +- pod-list.txt | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 compose/docker-compose-fixturenet-laconicd.yml rename config/{laconicd => fixturenet-laconicd}/create-fixturenet.sh (97%) diff --git a/compose/docker-compose-fixturenet-laconicd.yml b/compose/docker-compose-fixturenet-laconicd.yml new file mode 100644 index 00000000..997063db --- /dev/null +++ b/compose/docker-compose-fixturenet-laconicd.yml @@ -0,0 +1,21 @@ +version: "3.2" +services: + laconicd: + restart: unless-stopped + image: cerc/laconicd:local + command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] + volumes: + # TODO: look at folding this script into the container + - ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh + # TODO: determine which of the ports below is really needed + ports: + - "6060" + - "26657" + - "26656" + - "9473" + - "8545" + - "8546" + - "9090" + - "9091" + - "1317" + diff --git a/compose/docker-compose-laconicd.yml b/compose/docker-compose-laconicd.yml index 4d021ed6..753283bd 100644 --- a/compose/docker-compose-laconicd.yml +++ b/compose/docker-compose-laconicd.yml @@ -3,10 +3,6 @@ services: laconicd: restart: unless-stopped image: cerc/laconicd:local - command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] - volumes: - # TODO: look at folding this script into the container - - ../config/laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh # TODO: determine which of the ports below is really needed ports: - "6060" diff --git a/config/laconicd/create-fixturenet.sh b/config/fixturenet-laconicd/create-fixturenet.sh similarity index 97% rename from config/laconicd/create-fixturenet.sh rename to config/fixturenet-laconicd/create-fixturenet.sh index 8d5115be..1bc22cef 100644 --- a/config/laconicd/create-fixturenet.sh +++ b/config/fixturenet-laconicd/create-fixturenet.sh @@ -115,4 +115,4 @@ if [[ $1 == "pending" ]]; then fi # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -laconicd start --mode validator --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground +laconicd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable diff --git a/pod-list.txt b/pod-list.txt index 09a7baa5..614a3476 100644 --- a/pod-list.txt +++ b/pod-list.txt @@ -8,4 +8,5 @@ ipld-eth-server lighthouse prometheus-grafana laconicd +fixturenet-laconicd fixturenet-eth -- 2.45.2 From 88d38c780102444174d04a0ec8acf16853fb9743 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 28 Oct 2022 16:05:20 -0600 Subject: [PATCH 2/7] Enable GraphQL --- config/fixturenet-laconicd/create-fixturenet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/fixturenet-laconicd/create-fixturenet.sh b/config/fixturenet-laconicd/create-fixturenet.sh index 1bc22cef..a4c8b73c 100644 --- a/config/fixturenet-laconicd/create-fixturenet.sh +++ b/config/fixturenet-laconicd/create-fixturenet.sh @@ -115,4 +115,4 @@ if [[ $1 == "pending" ]]; then fi # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -laconicd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable +laconicd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground -- 2.45.2 From 2aae7dd59fee37c2e1560d36ff184bdaa3a26c4c Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 30 Oct 2022 20:41:05 -0600 Subject: [PATCH 3/7] Simple container for testing stack orchestrator --- compose/docker-compose-test.yml | 5 +++++ container-build/cerc-test-container/Dockerfile | 5 +++++ container-build/cerc-test-container/build.sh | 4 ++++ container-build/cerc-test-container/run.sh | 16 ++++++++++++++++ container-image-list.txt | 3 ++- pod-list.txt | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 compose/docker-compose-test.yml create mode 100644 container-build/cerc-test-container/Dockerfile create mode 100755 container-build/cerc-test-container/build.sh create mode 100755 container-build/cerc-test-container/run.sh diff --git a/compose/docker-compose-test.yml b/compose/docker-compose-test.yml new file mode 100644 index 00000000..058b2b3b --- /dev/null +++ b/compose/docker-compose-test.yml @@ -0,0 +1,5 @@ +version: "3.2" +services: + test: + image: cerc/test-container:local + restart: always diff --git a/container-build/cerc-test-container/Dockerfile b/container-build/cerc-test-container/Dockerfile new file mode 100644 index 00000000..29b42a84 --- /dev/null +++ b/container-build/cerc-test-container/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:latest + +COPY run.sh /app/run.sh + +ENTRYPOINT ["/app/run.sh"] diff --git a/container-build/cerc-test-container/build.sh b/container-build/cerc-test-container/build.sh new file mode 100755 index 00000000..1595645c --- /dev/null +++ b/container-build/cerc-test-container/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Build cerc/test-container +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +docker build -t cerc/test-container:local -f ${SCRIPT_DIR}/Dockerfile $SCRIPT_DIR \ No newline at end of file diff --git a/container-build/cerc-test-container/run.sh b/container-build/cerc-test-container/run.sh new file mode 100755 index 00000000..5f59acab --- /dev/null +++ b/container-build/cerc-test-container/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Test if the container's filesystem is old (run previously) or new +EXISTSFILENAME=/var/exists +echo "Test container starting" +if [[ -f "$EXISTSFILENAME" ]]; +then + TIMESTAMP = `cat $EXISTSFILENAME` + echo "Filesystem is old, created: $TIMESTAMP" +else + echo "Filesystem is fresh" + echo `date` > $EXISTSFILENAME +fi + +# Sleep forever to keep docker happy +while true; do sleep 10; done \ No newline at end of file diff --git a/container-image-list.txt b/container-image-list.txt index fd2fe645..80cef725 100644 --- a/container-image-list.txt +++ b/container-image-list.txt @@ -11,4 +11,5 @@ cerc/ipld-eth-server cerc/laconicd cerc/laconic-cns-cli cerc/fixturenet-eth-geth -cerc/fixturenet-eth-lighthouse \ No newline at end of file +cerc/fixturenet-eth-lighthouse +cerc/test-container diff --git a/pod-list.txt b/pod-list.txt index 09a7baa5..d07d3d08 100644 --- a/pod-list.txt +++ b/pod-list.txt @@ -9,3 +9,4 @@ lighthouse prometheus-grafana laconicd fixturenet-eth +test -- 2.45.2 From 01fd7e251a44cb0d802c717fa9175b200f2da3ab Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Mon, 31 Oct 2022 12:43:49 -0500 Subject: [PATCH 4/7] Remove fixed IPs and separate network for fixturenet. (#30) * Remove fixed IPs and separate network for fixturenet. * Remove static port mapping. * Add helper script for checking your fxiturenet status * Sleep 1 second * Fix spacing * Fix for latest genesis generator. * run as archive node --- compose/docker-compose-fixturenet-eth.yml | 23 ------- config/fixturenet-eth/fixturenet-eth.env | 3 +- .../genesis/accounts/mnemonic_to_csv.py | 2 +- .../genesis/el/build_el.sh | 5 +- .../genesis/el/el-config.yaml | 9 ++- .../cerc-fixturenet-eth-geth/run-el.sh | 4 ++ .../genesis/cl/beacon_node.sh | 5 +- .../genesis/cl/bootnode.sh | 16 +++++ .../genesis/cl/build_cl.sh | 15 ----- .../genesis/cl/vars.env | 12 ++-- .../cerc-fixturenet-eth-lighthouse/run-cl.sh | 20 +++++- .../scripts/status.sh | 65 +++++++++++++++++++ 12 files changed, 121 insertions(+), 58 deletions(-) create mode 100755 container-build/cerc-fixturenet-eth-lighthouse/scripts/status.sh diff --git a/compose/docker-compose-fixturenet-eth.yml b/compose/docker-compose-fixturenet-eth.yml index ad79814c..00377d21 100644 --- a/compose/docker-compose-fixturenet-eth.yml +++ b/compose/docker-compose-fixturenet-eth.yml @@ -8,9 +8,6 @@ services: environment: RUN_BOOTNODE: "true" image: cerc/fixturenet-eth-geth:local - networks: - fixturenet-eth-net: - ipv4_address: 172.16.254.10 fixturenet-eth-geth-1: hostname: fixturenet-eth-geth-1 @@ -21,8 +18,6 @@ services: - fixturenet-eth-bootnode-geth ports: - "8545" - networks: - fixturenet-eth-net: fixturenet-eth-geth-2: hostname: fixturenet-eth-geth-2 @@ -31,17 +26,12 @@ services: image: cerc/fixturenet-eth-geth:local depends_on: - fixturenet-eth-bootnode-geth - networks: - fixturenet-eth-net: fixturenet-eth-bootnode-lighthouse: hostname: fixturenet-eth-bootnode-lighthouse environment: RUN_BOOTNODE: "true" image: cerc/fixturenet-eth-lighthouse:local - networks: - fixturenet-eth-net: - ipv4_address: 172.16.254.11 fixturenet-eth-lighthouse-1: hostname: fixturenet-eth-lighthouse-1 @@ -57,8 +47,6 @@ services: - fixturenet-eth-geth-1 ports: - "8001" - networks: - fixturenet-eth-net: fixturenet-eth-lighthouse-2: hostname: fixturenet-eth-lighthouse-2 @@ -73,14 +61,3 @@ services: depends_on: - fixturenet-eth-bootnode-lighthouse - fixturenet-eth-geth-2 - networks: - fixturenet-eth-net: - -networks: - # When the bootnode ENR is generated during the build, it requires a specific IP. - # The easiest way to do that is to use a private network. - fixturenet-eth-net: - driver: bridge - ipam: - config: - - subnet: 172.16.254.0/28 diff --git a/config/fixturenet-eth/fixturenet-eth.env b/config/fixturenet-eth/fixturenet-eth.env index c4088e69..8cb2bf4b 100644 --- a/config/fixturenet-eth/fixturenet-eth.env +++ b/config/fixturenet-eth/fixturenet-eth.env @@ -7,5 +7,4 @@ ENODE="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13 # JWT shared by geth and lighthouse for authentication. JWT="0x6cdcac3501046a08e186730dd8bd136cfaf0fdc1fc955f6e15ad3068c0ff2af0" -# Should match the definition of fixturenet-eth-net. -NETRESTRICT="172.16.254.0/28" +ENR_URL="http://fixturenet-eth-bootnode-lighthouse:3000/bootnode/enr.dat" diff --git a/container-build/cerc-fixturenet-eth-geth/genesis/accounts/mnemonic_to_csv.py b/container-build/cerc-fixturenet-eth-geth/genesis/accounts/mnemonic_to_csv.py index 730426bd..365c3775 100644 --- a/container-build/cerc-fixturenet-eth-geth/genesis/accounts/mnemonic_to_csv.py +++ b/container-build/cerc-fixturenet-eth-geth/genesis/accounts/mnemonic_to_csv.py @@ -12,6 +12,6 @@ if len(sys.argv) > 1: with open(testnet_config_path) as stream: data = yaml.safe_load(stream) -for key, value in data['eth1_premine'].items(): +for key, value in data['el_premine'].items(): acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='') print("%s,%s,%s" % (key, acct.address, acct.key.hex())) 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 5eeeba51..0070707d 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 @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -e # See: https://github.com/skylenet/ethereum-genesis-generator/blob/master/entrypoint.sh @@ -8,5 +9,7 @@ mkdir -p ../build/el tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) envsubst < el-config.yaml > $tmp_dir/genesis-config.yaml -python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml > ../build/el/geth.json +ttd=`cat $tmp_dir/genesis-config.yaml | grep terminal_total_difficulty | awk '{ print $2 }'` + +python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml | jq ".config.terminalTotalDifficulty=$ttd" > ../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 7beb9c80..ed8d4885 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 @@ -1,17 +1,16 @@ mnemonic: "viable ketchup woman library opinion copy rhythm attend rose knock penalty practice photo bundle budget dentist enter round bind holiday useful arch danger lobster" -eth1_premine: +el_premine: "m/44'/60'/0'/0/0": 10000000ETH "m/44'/60'/0'/0/1": 10000000ETH "m/44'/60'/0'/0/2": 10000000ETH "m/44'/60'/0'/0/3": 10000000ETH "m/44'/60'/0'/0/4": 10000000ETH "m/44'/60'/0'/0/5": 10000000ETH -eth1_premine_addrs: {} +el_premine_addrs: {} chain_id: 1212 deposit_contract_address: "0x1212121212121212121212121212121212121212" -eth1_genesis_timestamp: 0 -terminal_total_difficulty: 10000000 -mergeForkBlock: 100 +genesis_timestamp: 0 +terminal_total_difficulty: 1000 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 84ff72f4..b6d0ce83 100755 --- a/container-build/cerc-fixturenet-eth-geth/run-el.sh +++ b/container-build/cerc-fixturenet-eth-geth/run-el.sh @@ -2,6 +2,7 @@ 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}'` if [ "true" == "$RUN_BOOTNODE" ]; then geth \ @@ -29,6 +30,9 @@ else --authrpc.jwtsecret="/opt/testnet/build/el/jwtsecret" \ --networkid=${NETWORK_ID} \ --netrestrict="${NETRESTRICT}" \ + --gcmode archive \ + --txlookuplimit=0 \ + --cache.preimages \ --syncmode=full \ --mine \ --miner.threads=1 \ diff --git a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/beacon_node.sh b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/beacon_node.sh index 026d40e1..6fa1d8d4 100755 --- a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/beacon_node.sh +++ b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/beacon_node.sh @@ -10,7 +10,7 @@ set -Eeuo pipefail source ./vars.env SUBSCRIBE_ALL_SUBNETS= -DEBUG_LEVEL=${DEBUG_LEVEL:-info} +DEBUG_LEVEL=${DEBUG_LEVEL:-debug} # Get positional arguments data_dir=$DATADIR/node_${NODE_NUMBER} @@ -18,9 +18,6 @@ network_port=9001 http_port=8001 authrpc_port=8551 -ENR=`cat $DATADIR/bootnode/enr.dat` -ENR_IP=`ip addr | grep 172 | awk '{print $2}' | cut -d '/' -f1` - exec lighthouse \ --debug-level $DEBUG_LEVEL \ bn \ diff --git a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh index 50d460fc..f6f5cc73 100755 --- a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh +++ b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/bootnode.sh @@ -13,6 +13,22 @@ DEBUG_LEVEL=${1:-info} echo "Starting bootnode" +if [ ! -f "$DATADIR/bootnode/enr.dat" ]; then + echo "Generating bootnode enr" + lcli \ + generate-bootnode-enr \ + --ip $ENR_IP \ + --udp-port $BOOTNODE_PORT \ + --tcp-port $BOOTNODE_PORT \ + --genesis-fork-version $GENESIS_FORK_VERSION \ + --output-dir $DATADIR/bootnode + + 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" +fi + exec lighthouse boot_node \ --testnet-dir $TESTNET_DIR \ --port $BOOTNODE_PORT \ diff --git a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh index 32b3e6f4..92018d7a 100755 --- a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh +++ b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh @@ -57,18 +57,3 @@ lcli \ $GENESIS_VALIDATOR_COUNT echo Created genesis state in $TESTNET_DIR - -echo "Generating bootnode enr" - -lcli \ - generate-bootnode-enr \ - --ip $BOOTNODE_IP \ - --udp-port $BOOTNODE_PORT \ - --tcp-port $BOOTNODE_PORT \ - --genesis-fork-version $GENESIS_FORK_VERSION \ - --output-dir $DATADIR/bootnode - -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" diff --git a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/vars.env b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/vars.env index b7e2a939..d68cbdcc 100644 --- a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/vars.env +++ b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/vars.env @@ -4,6 +4,8 @@ DATADIR=${DATADIR:-../build/cl} # Directory for the eth2 config TESTNET_DIR=${TESTNET_DIR:-$DATADIR/testnet} JWTSECRET=${JWTSECRET:-$DATADIR/jwtsecret} +ENR=${ENR:="SET_AT_RUNTIME"} +ENR_IP=`ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1` GENESIS_FORK_VERSION=${GENESIS_FORK_VERSION:-0x12121212} @@ -22,12 +24,11 @@ VC_COUNT=${VC_COUNT:-$BN_COUNT} GENESIS_DELAY=${GENESIS_DELAY:-0} # Port for P2P communication with bootnode -BOOTNODE_IP=${BOOTNODE_IP:-172.16.254.11} BOOTNODE_PORT=${BOOTNODE_PORT:-4242} # Hard fork configuration -ALTAIR_FORK_EPOCH=${ALTAIR_FORK_EPOCH:-1} -MERGE_FORK_EPOCH=${MERGE_FORK_EPOCH:-2} +ALTAIR_FORK_EPOCH=${ALTAIR_FORK_EPOCH:-0} +MERGE_FORK_EPOCH=${MERGE_FORK_EPOCH:-0} # Spec version (mainnet or minimal) SPEC_PRESET=${SPEC_PRESET:-mainnet} @@ -43,10 +44,11 @@ VC_ARGS=${VC_ARGS:-""} EXECUTION_ENDPOINT=${EXECUTION_ENDPOINT:-http://localhost:8551} +ETH1_GENESIS_JSON=${ETH1_GENESIS_JSON:-"../build/el/geth.json"} ETH1_CONFIG_YAML=${ETH1_CONFIG_YAML:-"../el/el-config.yaml"} -ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_CONFIG_YAML | grep 'chain_id' | awk '{ print $2 }'`} -ETH1_TTD=${ETH1_TTD:-`cat $ETH1_CONFIG_YAML | grep 'terminal_total_difficulty' | awk '{ print $2 }'`} +ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_GENESIS_JSON | jq -r '.config.chainId'`} +ETH1_TTD=${ETH1_TTD:-`cat $ETH1_GENESIS_JSON | jq -r '.config.terminalTotalDifficulty'`} ETH1_DEPOSIT_CONTRACT_ADDRESS=${ETH1_DEPOSIT_CONTRACT_ADDRESS:-`cat $ETH1_CONFIG_YAML | grep 'deposit_contract_address' | awk '{ print $2 }' | sed 's/"//g'`} ETH1_DEPOSIT_CONTRACT_BLOCK=${ETH1_DEPOSIT_CONTRACT_BLOCK:-0x0} SUGGESTED_FEE_RECIPIENT=`cat ../build/el/accounts.csv | head -1 | cut -d',' -f2` diff --git a/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh b/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh index 9e7c653e..07346e58 100755 --- a/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh +++ b/container-build/cerc-fixturenet-eth-lighthouse/run-cl.sh @@ -1,18 +1,22 @@ #!/bin/bash if [ "true" == "$RUN_BOOTNODE" ]; then + cd /opt/testnet/build/cl + python3 -m http.server 3000 & + + cd /opt/testnet/cl ./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log else while [ 1 -eq 1 ]; do - echo "Waiting on DAG ..." + echo "Waiting on geth ..." sleep 5 result=`wget --no-check-certificate --quiet \ -O - \ --method POST \ --timeout=0 \ --header 'Content-Type: application/json' \ - --body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x3", false] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'` + --body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": [] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'` if [ ! -z "$result" ] && [ "null" != "$result" ]; then break fi @@ -34,6 +38,18 @@ else done fi + if [ ! -z "$ENR_URL" ]; then + while [ 1 -eq 1 ]; do + echo "Waiting on ENR for boot node..." + sleep 5 + result=`wget --no-check-certificate --quiet -O - --timeout=0 $ENR_URL` + if [ ! -z "$result" ]; then + export ENR="$result" + break; + fi + done + fi + export JWTSECRET="/opt/testnet/build/cl/jwtsecret" echo -n "$JWT" > $JWTSECRET diff --git a/container-build/cerc-fixturenet-eth-lighthouse/scripts/status.sh b/container-build/cerc-fixturenet-eth-lighthouse/scripts/status.sh new file mode 100755 index 00000000..e02fc14b --- /dev/null +++ b/container-build/cerc-fixturenet-eth-lighthouse/scripts/status.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +STATUSES=("geth to generate DAG" "beacon phase0" "beacon altair" "beacon bellatrix pre-merge" "beacon bellatrix merge") +STATUS=0 + + +LIGHTHOUSE_BASE_URL=${LIGHTHOUSE_BASE_URL} +GETH_BASE_URL=${GETH_BASE_URL} + +if [ -z "$LIGHTHOUSE_BASE_URL" ]; then + LIGHTHOUSE_PORT=`docker ps -f "name=fixturenet-eth-lighthouse-1-1" --format "{{.Ports}}" | head -1 | cut -d':' -f2 | cut -d'-' -f1` + LIGHTHOUSE_BASE_URL="http://localhost:${LIGHTHOUSE_PORT}" +fi + +if [ -z "$GETH_BASE_URL" ]; then + GETH_PORT=`docker ps -f "name=fixturenet-eth-geth-1-1" --format "{{.Ports}}" | head -1 | cut -d':' -f2 | cut -d'-' -f1` + GETH_BASE_URL="http://localhost:${GETH_PORT}" +fi + +function inc_status() { + echo " DONE!" + STATUS=$((STATUS + 1)) + if [ $STATUS -lt ${#STATUSES[@]} ]; then + echo -n "Waiting for ${STATUSES[$STATUS]}..." + fi +} + +echo -n "Waiting for ${STATUSES[$STATUS]}..." +while [ $STATUS -lt ${#STATUSES[@]} ]; do + sleep 1 + echo -n "." + case $STATUS in + 0) + result=`wget --no-check-certificate --quiet -O - --method POST --header 'Content-Type: application/json' \ + --body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x3", false] }' $GETH_BASE_URL | jq -r '.result'` + if [ ! -z "$result" ] && [ "null" != "$result" ]; then + inc_status + fi + ;; + 1) + result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.slot'` + if [ ! -z "$result" ] && [ $result -gt 0 ]; then + inc_status + fi + ;; + 2) + result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'` + if [ ! -z "$result" ] && ([ "$result" == "altair" ] || [ "$result" == "bellatrix" ]); then + inc_status + fi + ;; + 3) + result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'` + if [ ! -z "$result" ] && [ "$result" == "bellatrix" ]; then + inc_status + fi + ;; + 4) + 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 + inc_status + fi + ;; + esac +done -- 2.45.2 From f2c9af4ec6f1d7618b473b00757a9d1cd17371ac Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 1 Nov 2022 12:44:33 -0500 Subject: [PATCH 5/7] 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 -- 2.45.2 From 99fa08ed67b9dc63b2e395631394ec68fd48c3f5 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 1 Nov 2022 17:53:32 -0500 Subject: [PATCH 6/7] Use explicit image hash, not latest tag. (#33) * Use explicit image hash, not latest tag. * Better syntax * No latest --- container-build/cerc-fixturenet-eth-geth/Dockerfile | 2 +- container-build/cerc-fixturenet-eth-lighthouse/Dockerfile | 4 ++-- container-build/cerc-lighthouse/Dockerfile | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/container-build/cerc-fixturenet-eth-geth/Dockerfile b/container-build/cerc-fixturenet-eth-geth/Dockerfile index 068291a2..72c03039 100644 --- a/container-build/cerc-fixturenet-eth-geth/Dockerfile +++ b/container-build/cerc-fixturenet-eth-geth/Dockerfile @@ -1,4 +1,4 @@ -FROM skylenet/ethereum-genesis-generator AS ethgen +FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen FROM cerc/go-ethereum:local RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash diff --git a/container-build/cerc-fixturenet-eth-lighthouse/Dockerfile b/container-build/cerc-fixturenet-eth-lighthouse/Dockerfile index 08de5537..6e8add4a 100644 --- a/container-build/cerc-fixturenet-eth-lighthouse/Dockerfile +++ b/container-build/cerc-fixturenet-eth-lighthouse/Dockerfile @@ -1,5 +1,5 @@ -FROM sigp/lcli AS lcli -FROM skylenet/ethereum-genesis-generator AS ethgen +FROM sigp/lcli:v3.2.1 AS lcli +FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen FROM cerc/fixturenet-eth-geth:local AS fnetgeth FROM cerc/lighthouse:local diff --git a/container-build/cerc-lighthouse/Dockerfile b/container-build/cerc-lighthouse/Dockerfile index 9acefb48..14f0a2ae 100644 --- a/container-build/cerc-lighthouse/Dockerfile +++ b/container-build/cerc-lighthouse/Dockerfile @@ -1,4 +1,4 @@ -FROM sigp/lighthouse:latest-modern +FROM sigp/lighthouse:v3.2.1-modern RUN apt-get update; apt-get install bash netcat curl less jq -y; -- 2.45.2 From 8e0f1f7e35d14c2aa3b7293709d0ad3c5c0ba542 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Tue, 1 Nov 2022 18:45:21 -0600 Subject: [PATCH 7/7] Add note on benign container build warning messages --- .../cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh index 92018d7a..ab3ad2af 100755 --- a/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh +++ b/container-build/cerc-fixturenet-eth-lighthouse/genesis/cl/build_cl.sh @@ -20,6 +20,7 @@ NOW=`date +%s` GENESIS_TIME=`expr $NOW + $GENESIS_DELAY` echo "Creating testnet ..." +echo "(Note: errors of the form 'WARN: Scrypt parameters are too weak...' below can be safely ignored)" lcli \ new-testnet \ --spec $SPEC_PRESET \ -- 2.45.2