Add remote debugging support to fixturenet-geth. #113

Merged
telackey merged 3 commits from telackey/dbg into main 2023-01-11 18:54:22 +00:00
3 changed files with 22 additions and 8 deletions

View File

@ -14,6 +14,12 @@ services:
fixturenet-eth-geth-1: fixturenet-eth-geth-1:
hostname: fixturenet-eth-geth-1 hostname: fixturenet-eth-geth-1
cap_add:
- SYS_PTRACE
environment:
CERC_REMOTE_DEBUG: "true"
CERC_RUN_STATEDIFF: "detect"
CERC_STATEDIFF_DB_NODE_ID: 1
env_file: env_file:
- ../config/fixturenet-eth/fixturenet-eth.env - ../config/fixturenet-eth/fixturenet-eth.env
image: cerc/fixturenet-eth-geth:local image: cerc/fixturenet-eth-geth:local
@ -27,12 +33,10 @@ services:
- fixturenet-eth-bootnode-geth - fixturenet-eth-bootnode-geth
ports: ports:
- "8545" - "8545"
- "40000"
fixturenet-eth-geth-2: fixturenet-eth-geth-2:
hostname: fixturenet-eth-geth-2 hostname: fixturenet-eth-geth-2
environment:
CERC_RUN_STATEDIFF: "detect"
CERC_STATEDIFF_DB_NODE_ID: 2
healthcheck: healthcheck:
test: ["CMD", "nc", "-v", "localhost", "8545"] test: ["CMD", "nc", "-v", "localhost", "8545"]
interval: 30s interval: 30s

View File

@ -1,8 +1,13 @@
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
FROM golang:1.18-alpine as delve
Review

Not important for this builder base image, but if possible we would like to standardize on Ubuntu base images, not alpine.

Not important for this builder base image, but if possible we would like to standardize on Ubuntu base images, not alpine.
Review

I was deliberately matching it to the version used to build geth: https://github.com/cerc-io/go-ethereum/blob/v1.10.26-statediff-v4/Dockerfile#L7

I was afraid of running into glibc / musl issues if they didn't match.

I was deliberately matching it to the version used to build geth: https://github.com/cerc-io/go-ethereum/blob/v1.10.26-statediff-v4/Dockerfile#L7 I was afraid of running into glibc / musl issues if they didn't match.
Review

Let me add a comment....

Let me add a comment....
RUN go install github.com/go-delve/delve/cmd/dlv@latest
FROM cerc/go-ethereum:local FROM cerc/go-ethereum:local
RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash bind-tools postgresql-client RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash bind-tools postgresql-client
COPY --from=delve /go/bin/dlv /
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools
COPY --from=ethgen /apps /apps COPY --from=ethgen /apps /apps

View File

@ -9,13 +9,18 @@ cd /opt/testnet/build/el
python3 -m http.server 9898 & python3 -m http.server 9898 &
cd $HOME_DIR cd $HOME_DIR
START_CMD="geth"
if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/dlv" ]; then
START_CMD="/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/geth --continue --"
fi
if [ "true" == "$RUN_BOOTNODE" ]; then if [ "true" == "$RUN_BOOTNODE" ]; then
geth \ $START_CMD \
--nodekeyhex="${BOOTNODE_KEY}" \ --nodekeyhex="${BOOTNODE_KEY}" \
--nodiscover \ --nodiscover \
--ipcdisable \ --ipcdisable \
--networkid=${NETWORK_ID} \ --networkid=${NETWORK_ID} \
--netrestrict="${NETRESTRICT}" 2>&1 | tee /var/log/geth_bootnode.log --netrestrict="${NETRESTRICT}"
else else
cd /opt/testnet/accounts cd /opt/testnet/accounts
./import_keys.sh ./import_keys.sh
@ -60,7 +65,7 @@ else
--statediff.writing=true" --statediff.writing=true"
fi fi
geth \ $START_CMD \
--bootnodes="${ENODE}" \ --bootnodes="${ENODE}" \
--allow-insecure-unlock \ --allow-insecure-unlock \
--http \ --http \
@ -80,5 +85,5 @@ else
--mine \ --mine \
--miner.threads=1 \ --miner.threads=1 \
--verbosity=5 \ --verbosity=5 \
--miner.etherbase="${ETHERBASE}" ${STATEDIFF_OPTS} 2>&1 | tee /var/log/geth.log --miner.etherbase="${ETHERBASE}" ${STATEDIFF_OPTS}
fi fi