From a82462b9ef37bc0e9828d05c2834b6a1643553ec Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:49:13 -0400 Subject: [PATCH] Manual v6 enr (#1941) * V6 manual ENRs * discv5 --- besu.yml | 1 + besu/docker-entrypoint.sh | 10 +++++++++- default.env | 4 +++- grandine/docker-entrypoint.sh | 8 ++++++++ lighthouse/docker-entrypoint.sh | 8 ++++++++ lodestar-cl-only.yml | 4 +++- lodestar.yml | 4 +++- lodestar/Dockerfile.binary | 3 ++- lodestar/Dockerfile.source | 3 ++- lodestar/docker-entrypoint.sh | 10 +++++++++- nethermind.yml | 2 ++ teku-allin1.yml | 4 ++++ teku-cl-only.yml | 4 +++- teku.yml | 4 +++- teku/docker-entrypoint.sh | 20 +++++++++++++++++++- 15 files changed, 79 insertions(+), 10 deletions(-) diff --git a/besu.yml b/besu.yml index 6cb6db41..740685e6 100644 --- a/besu.yml +++ b/besu.yml @@ -27,6 +27,7 @@ services: - EL_EXTRAS=${EL_EXTRAS:-} - ARCHIVE_NODE=${ARCHIVE_NODE:-} - NETWORK=${NETWORK} + - IPV6=${IPV6:-false} volumes: - besu-el-data:/var/lib/besu - besu-eth1-data:/var/lib/besu-og diff --git a/besu/docker-entrypoint.sh b/besu/docker-entrypoint.sh index 5fa93b13..2aee7d17 100755 --- a/besu/docker-entrypoint.sh +++ b/besu/docker-entrypoint.sh @@ -72,6 +72,14 @@ else __datadir="--data-path /var/lib/besu" fi +# DiscV5 for IPV6 +if [ "${IPV6:-false}" = "true" ]; then + echo "Configuring Besu for discv5 for IPv6 advertisements" + __ipv6="--Xv5-discovery-enabled" +else + __ipv6="" +fi + if [ -f /var/lib/besu/prune-marker ]; then rm -f /var/lib/besu/prune-marker if [ "${ARCHIVE_NODE}" = "true" ]; then @@ -84,5 +92,5 @@ if [ -f /var/lib/besu/prune-marker ]; then else # Word splitting is desired for the command line parameters # shellcheck disable=SC2086 - exec "$@" ${__datadir} ${__network} ${__prune} ${__spec} ${EL_EXTRAS} + exec "$@" ${__datadir} ${__network} ${__ipv6} ${__prune} ${__spec} ${EL_EXTRAS} fi diff --git a/default.env b/default.env index ae0e17c1..ef926943 100644 --- a/default.env +++ b/default.env @@ -89,6 +89,8 @@ CL_P2P_PORT=9000 PRYSM_PORT=9000 PRYSM_UDP_PORT=9000 CL_QUIC_PORT=9001 +# Some clients need a separate port for IPv6 +CL_IPV6_P2P_PORT=9090 # Local grafana dashboard port. Do not expose to Internet, it is insecure http GRAFANA_PORT=3000 # Local Siren UI port @@ -331,4 +333,4 @@ DDNS_TAG=v2 NODE_EXPORTER_IGNORE_MOUNT_REGEX='^/(dev|proc|sys|run|var/lib/docker/.+)($|/)' # Used by ethd update - please do not adjust -ENV_VERSION=16 +ENV_VERSION=17 diff --git a/grandine/docker-entrypoint.sh b/grandine/docker-entrypoint.sh index 8aafac91..5a0f62ee 100755 --- a/grandine/docker-entrypoint.sh +++ b/grandine/docker-entrypoint.sh @@ -83,6 +83,14 @@ if [ "${IPV6}" = "true" ]; then echo "Configuring Grandine to listen on IPv6 ports" __ipv6="--listen-address-ipv6 :: --libp2p-port-ipv6 ${CL_P2P_PORT:-9000} --discovery-port-ipv6 ${CL_P2P_PORT:-9000} \ --quic-port-ipv6 ${CL_QUIC_PORT:-9001}" +# ENR discovery on v6 is not yet working, likely too few peers. Manual for now + __ipv6_pattern="^[0-9A-Fa-f]{1,4}:" # Sufficient to check the start + set +e + __public_v6=$(curl -s -6 ifconfig.me) + set -e + if [[ "$__public_v6" =~ $__ipv6_pattern ]]; then + __ipv6+=" --enr-address-ipv6 ${__public_v6} --enr-tcp-port-ipv6 ${CL_P2P_PORT:-9000} --enr-udp-port-ipv6 ${CL_P2P_PORT:-9000}" + fi else __ipv6="" fi diff --git a/lighthouse/docker-entrypoint.sh b/lighthouse/docker-entrypoint.sh index 324f21ef..af7c9262 100755 --- a/lighthouse/docker-entrypoint.sh +++ b/lighthouse/docker-entrypoint.sh @@ -88,6 +88,14 @@ fi if [ "${IPV6}" = "true" ]; then echo "Configuring Lighthouse to listen on IPv6 ports" __ipv6="--listen-address :: --port6 ${CL_P2P_PORT:-9000} --quic-port6 ${CL_QUIC_PORT:-9001}" +# ENR discovery on v6 is not yet working, likely too few peers. Manual for now + __ipv6_pattern="^[0-9A-Fa-f]{1,4}:" # Sufficient to check the start + set +e + __public_v6=$(wget -6 -q -O- ifconfig.me) + set -e + if [[ "$__public_v6" =~ $__ipv6_pattern ]]; then + __ipv6+=" --enr-address ${__public_v6}" + fi else __ipv6="" fi diff --git a/lodestar-cl-only.yml b/lodestar-cl-only.yml index 9509fdeb..06e69b4a 100644 --- a/lodestar-cl-only.yml +++ b/lodestar-cl-only.yml @@ -39,11 +39,13 @@ services: - ARCHIVE_NODE=${ARCHIVE_NODE:-} - NETWORK=${NETWORK} - IPV6=${IPV6:-false} - - CL_P2P_PORT=${CL_P2P_PORT:-9000} + - CL_IPV6_P2P_PORT=${CL_IPV6_P2P_PORT:-9090} - NODE_OPTIONS=${LODESTAR_HEAP:---max-old-space-size=8192} ports: - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/tcp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/udp networks: default: aliases: diff --git a/lodestar.yml b/lodestar.yml index 91991958..4ec4204b 100644 --- a/lodestar.yml +++ b/lodestar.yml @@ -39,11 +39,13 @@ services: - ARCHIVE_NODE=${ARCHIVE_NODE:-} - NETWORK=${NETWORK} - IPV6=${IPV6:-false} - - CL_P2P_PORT=${CL_P2P_PORT:-9000} + - CL_IPV6_P2P_PORT=${CL_IPV6_P2P_PORT:-9090} - NODE_OPTIONS=${LODESTAR_HEAP:---max-old-space-size=8192} ports: - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/tcp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/udp networks: default: aliases: diff --git a/lodestar/Dockerfile.binary b/lodestar/Dockerfile.binary index 2323f00a..e5cf2a03 100644 --- a/lodestar/Dockerfile.binary +++ b/lodestar/Dockerfile.binary @@ -7,7 +7,8 @@ FROM ${DOCKER_REPO}:${DOCKER_TAG} ARG BUILD_TARGET ARG SRC_REPO -RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata bash gosu git && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata bash gosu git wget \ + && apt-get clean && rm -rf /var/lib/apt/lists/* ARG USER=lsconsensus ARG UID=10002 diff --git a/lodestar/Dockerfile.source b/lodestar/Dockerfile.source index dc5a2f3f..0a9fcf2b 100644 --- a/lodestar/Dockerfile.source +++ b/lodestar/Dockerfile.source @@ -18,7 +18,8 @@ RUN bash -c "cd .. && rm -rf app && git clone ${SRC_REPO} app && cd app && git c FROM node:22.4-slim -RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata bash gosu git && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata bash gosu git wget \ + && apt-get clean && rm -rf /var/lib/apt/lists/* ARG USER=lsconsensus ARG UID=10002 diff --git a/lodestar/docker-entrypoint.sh b/lodestar/docker-entrypoint.sh index 2b2b915f..7660cc99 100755 --- a/lodestar/docker-entrypoint.sh +++ b/lodestar/docker-entrypoint.sh @@ -85,7 +85,15 @@ fi if [ "${IPV6}" = "true" ]; then echo "Configuring Lodestar to listen on IPv6 ports" - __ipv6="--listenAddress6 :: --port6 ${CL_P2P_PORT:-9000}" + __ipv6="--listenAddress 0.0.0.0 --listenAddress6 :: --port6 ${CL_IPV6_P2P_PORT:-9090}" +# ENR discovery on v6 is not yet working, likely too few peers. Manual for now + __ipv6_pattern="^[0-9A-Fa-f]{1,4}:" # Sufficient to check the start + set +e + __public_v6=$(wget -6 -q -O- ifconfig.me) + set -e + if [[ "$__public_v6" =~ $__ipv6_pattern ]]; then + __ipv6+=" --enr.ip6 ${__public_v6}" + fi else __ipv6="" fi diff --git a/nethermind.yml b/nethermind.yml index 0a233b2c..d20630a6 100644 --- a/nethermind.yml +++ b/nethermind.yml @@ -81,6 +81,8 @@ services: - "6060" - --Pruning.FullPruningCompletionBehavior - AlwaysShutdown + - --Discovery.Discv5Enabled + - "true" - --log - ${LOG_LEVEL} labels: diff --git a/teku-allin1.yml b/teku-allin1.yml index e8f32679..fa59e2c9 100644 --- a/teku-allin1.yml +++ b/teku-allin1.yml @@ -47,9 +47,13 @@ services: - EMBEDDED_VC=true - NETWORK=${NETWORK} - ENABLE_DIST_ATTESTATION_AGGR=${ENABLE_DIST_ATTESTATION_AGGR:-false} + - IPV6=${IPV6:-false} + - CL_IPV6_P2P_PORT=${CL_IPV6_P2P_PORT:-9090} ports: - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/tcp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/udp networks: default: aliases: diff --git a/teku-cl-only.yml b/teku-cl-only.yml index f62386d9..2c907aa4 100644 --- a/teku-cl-only.yml +++ b/teku-cl-only.yml @@ -46,10 +46,12 @@ services: - WEB3SIGNER=false - NETWORK=${NETWORK} - IPV6=${IPV6:-false} - - CL_P2P_PORT=${CL_P2P_PORT:-9000} + - CL_IPV6_P2P_PORT=${CL_IPV6_P2P_PORT:-9090} ports: - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/tcp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/udp networks: default: aliases: diff --git a/teku.yml b/teku.yml index 8cd11c92..01dee369 100644 --- a/teku.yml +++ b/teku.yml @@ -46,10 +46,12 @@ services: - EMBEDDED_VC=false - NETWORK=${NETWORK} - IPV6=${IPV6:-false} - - CL_P2P_PORT=${CL_P2P_PORT:-9000} + - CL_IPV6_P2P_PORT=${CL_IPV6_P2P_PORT:-9090} ports: - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp - ${HOST_IP:-}:${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/tcp + - ${HOST_IP:-}:${CL_IPV6_P2P_PORT:-9090}:${CL_IPV6_P2P_PORT:-9090}/udp networks: default: aliases: diff --git a/teku/docker-entrypoint.sh b/teku/docker-entrypoint.sh index 3c0488bf..68570c63 100755 --- a/teku/docker-entrypoint.sh +++ b/teku/docker-entrypoint.sh @@ -133,7 +133,25 @@ fi if [ "${IPV6}" = "true" ]; then echo "Configuring Teku to listen on IPv6 ports" - __ipv6="--p2p-interface 0.0.0.0,:: --p2p-port-ipv6 ${CL_P2P_PORT:-9000}" + __ipv6="--p2p-interface 0.0.0.0,:: --p2p-port-ipv6 ${CL_IPV6_P2P_PORT:-9090}" +# ENR discovery on v6 is not yet working, likely too few peers. Manual for now + __ipv4_pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$" + __ipv6_pattern="^[0-9A-Fa-f]{1,4}:" # Sufficient to check the start + set +e + __public_v4=$(curl -s -4 ifconfig.me) + __public_v6=$(curl -s -6 ifconfig.me) + set -e + __valid_v4=0 + if [[ "$__public_v4" =~ $__ipv4_pattern ]]; then + __valid_v4=1 + fi + if [[ "$__public_v6" =~ $__ipv6_pattern ]]; then + if [ "${__valid_v4}" -eq 1 ]; then + __ipv6+=" --p2p-advertised-ips ${__public_v4},${__public_v6}" + else + __ipv6+=" --p2p-advertised-ip ${__public_v6}" + fi + fi else __ipv6="" fi