diff --git a/beacon-chain/Dockerfile b/beacon-chain/Dockerfile index 4882975..888811d 100644 --- a/beacon-chain/Dockerfile +++ b/beacon-chain/Dockerfile @@ -22,9 +22,13 @@ FROM gcr.io/prysmaticlabs/prysm/beacon-chain:${UPSTREAM_VERSION} ARG NETWORK ARG STAKER_SCRIPTS_VERSION ARG DATA_DIR +ARG P2P_TCP_PORT +ARG P2P_UDP_PORT ENV JWT_FILE_PATH=/jwtsecret \ BEACON_API_PORT=3500 \ + P2P_TCP_PORT=${P2P_TCP_PORT} \ + P2P_UDP_PORT=${P2P_UDP_PORT} \ DATA_DIR=${DATA_DIR} \ LUKSO_CONFIG_PATH=/configs/lukso \ LUKSO_GENESIS_FILE_PATH=${LUKSO_CONFIG_PATH}/genesis.ssz \ diff --git a/beacon-chain/entrypoint.sh b/beacon-chain/entrypoint.sh index 0fc31e6..f5ce93d 100755 --- a/beacon-chain/entrypoint.sh +++ b/beacon-chain/entrypoint.sh @@ -1,73 +1,67 @@ #!/bin/sh SUPPORTED_NETWORKS="sepolia lukso holesky mainnet" -CHECKPOINT_SYNC_FLAG_1="--checkpoint-sync-url" -CHECKPOINT_SYNC_FLAG_2="--genesis-beacon-api-url" -MEVBOOST_FLAGS="--http-mev-relay" +CHECKPOINT_SYNC_FLAG_KEY_1="--checkpoint-sync-url" +CHECKPOINT_SYNC_FLAG_KEY_2="--genesis-beacon-api-url" +MEVBOOST_FLAG_KEY="--http-mev-relay" # shellcheck disable=SC1091 # Path is relative to the Dockerfile -. /etc/profile +. /etc/profile.d/consensus_tools.sh -handle_network() { - case "$NETWORK" in - "holesky") - flags_to_set="--holesky" - ;; - "lukso") - flags_to_set="--chain-config-file=$LUKSO_CONFIG_PATH --contract-deployment-block=0 --bootstrap-node=enr:-MK4QJ-Bt9HATy4GQawPbDDTArtnt_phuWiVVoWKhS7-DSNjVzmGKBI9xKzpyRtpeCWd3qA9737FTdkKGDgtHfF4N-6GAYlzJCVRh2F0dG5ldHOIAAAAAAAAAACEZXRoMpA2ulfbQgAABP__________gmlkgnY0gmlwhCKTScGJc2VjcDI1NmsxoQJNpNUERqKhA8eDDC4tovG3a59NXVOW16JDFAWXoFFTEYhzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A","enr:-MK4QDOs4pISOkkYbVHnGYHC5EhYCsVzwguun6sFZjLTqrY6Kx_AoE-YyHvqBIHDUwyQqESC4-B3o6DigPQNfKpdhXiGAYgmPWCdh2F0dG5ldHOIAAAAAAAAAACEZXRoMpA2ulfbQgAABP__________gmlkgnY0gmlwhCIgwNOJc2VjcDI1NmsxoQNGVC8JPcsqsZPoohLP1ujAYpBfS0dBwiz4LeoUQ-k5OohzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A" - ;; - "mainnet") - flags_to_set="--mainnet" - ;; - "sepolia") - flags_to_set="--sepolia" - ;; - *) - echo "[ERROR - entrypoint] Unsupported network: $NETWORK" - exit 1 - ;; - esac +ENGINE_URL=$(get_engine_api_url "${NETWORK}" "${SUPPORTED_NETWORKS}") +VALID_FEE_RECIPIENT=$(get_valid_fee_recipient "${FEE_RECIPIENT}") +MEVBOOST_FLAG=$(get_mevboost_flag "${NETWORK}" "${MEVBOOST_FLAG_KEY}") - set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "$flags_to_set" -} +# To avoid failure for users who have added fee recipient to extra opts +EXTRA_OPTS=$(add_flag_to_extra_opts_safely "${EXTRA_OPTS}" "--suggested-fee-recipient=${VALID_FEE_RECIPIENT}") -handle_checkpoint() { - # Check if network is lukso and checkpoint sync url is empty - if [ "${NETWORK}" = "lukso" ] && [ -z "${CHECKPOINT_SYNC_URL}" ]; then - echo "[INFO - entrypoint] Syncing LUKSO chain from genesis" - add_flag_to_extra_opts "--genesis-state=${LUKSO_GENESIS_FILE_PATH}" - else - # Prysm needs these 2 flags to be set for checkpoint sync - set_checkpointsync_url "${CHECKPOINT_SYNC_FLAG_1}" "${CHECKPOINT_SYNC_URL}" - set_checkpointsync_url "${CHECKPOINT_SYNC_FLAG_2}" "${CHECKPOINT_SYNC_URL}" - fi -} +case "$NETWORK" in +"holesky") + NETWORK_FLAGS="--holesky" + ;; +"lukso") + NETWORK_FLAGS="--chain-config-file=$LUKSO_CONFIG_PATH --contract-deployment-block=0 --bootstrap-node=enr:-MK4QJ-Bt9HATy4GQawPbDDTArtnt_phuWiVVoWKhS7-DSNjVzmGKBI9xKzpyRtpeCWd3qA9737FTdkKGDgtHfF4N-6GAYlzJCVRh2F0dG5ldHOIAAAAAAAAAACEZXRoMpA2ulfbQgAABP__________gmlkgnY0gmlwhCKTScGJc2VjcDI1NmsxoQJNpNUERqKhA8eDDC4tovG3a59NXVOW16JDFAWXoFFTEYhzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A","enr:-MK4QDOs4pISOkkYbVHnGYHC5EhYCsVzwguun6sFZjLTqrY6Kx_AoE-YyHvqBIHDUwyQqESC4-B3o6DigPQNfKpdhXiGAYgmPWCdh2F0dG5ldHOIAAAAAAAAAACEZXRoMpA2ulfbQgAABP__________gmlkgnY0gmlwhCIgwNOJc2VjcDI1NmsxoQNGVC8JPcsqsZPoohLP1ujAYpBfS0dBwiz4LeoUQ-k5OohzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A" + ;; +"mainnet") + NETWORK_FLAGS="--mainnet" + ;; +"sepolia") + NETWORK_FLAGS="--sepolia" + ;; +*) + echo "[ERROR - entrypoint] Unsupported network: $NETWORK" + exit 1 + ;; +esac -run_beacon() { - echo "[INFO - entrypoint] Running beacon service" +# Check if network is lukso and checkpoint sync url is empty +if [ "${NETWORK}" = "lukso" ] && [ -z "${CHECKPOINT_SYNC_URL}" ]; then + echo "[INFO - entrypoint] Syncing LUKSO chain from genesis" + EXTRA_OPTS=$(add_flag_to_extra_opts_safely "${EXTRA_OPTS}" "--genesis-state=${LUKSO_GENESIS_FILE_PATH}") +else + # Prysm needs these 2 flags to be set for checkpoint sync + checkpoint_flag_1=$(get_checkpoint_sync_flag "${CHECKPOINT_SYNC_FLAG_KEY_1}" "${CHECKPOINT_SYNC_URL}") + checkpoint_flag_2=$(get_checkpoint_sync_flag "${CHECKPOINT_SYNC_FLAG_KEY_2}" "${CHECKPOINT_SYNC_URL}") - # shellcheck disable=SC2086 - exec /beacon-chain \ - --accept-terms-of-use \ - --datadir=${DATA_DIR} \ - --jwt-secret="${JWT_FILE_PATH}" \ - --execution-endpoint="${ENGINE_API_URL}" \ - --monitoring-host=0.0.0.0 \ - --grpc-gateway-host=0.0.0.0 \ - --grpc-gateway-port="${BEACON_API_PORT}" \ - --grpc-gateway-corsdomain="${CORSDOMAIN}" \ - --rpc-host=0.0.0.0 \ - --verbosity="${VERBOSITY}" \ - --p2p-tcp-port="${P2P_TCP_PORT}" \ - --p2p-udp-port="${P2P_UDP_PORT}" \ - --p2p-max-peers="${MAX_PEERS}" \ - --min-sync-peers="${MIN_SYNC_PEERS}" \ - --subscribe-all-subnets="${SUBSCRIBE_ALL_SUBNETS}" ${EXTRA_OPTS} -} + CHECKPOINT_SYNC_FLAGS="${checkpoint_flag_1} ${checkpoint_flag_2}" +fi -validate_fee_recipient -handle_network -handle_checkpoint -set_mevboost_flag "${MEVBOOST_FLAGS}" -add_flag_to_extra_opts "--suggested-fee-recipient=${FEE_RECIPIENT}" -run_beacon +echo "[INFO - entrypoint] Running beacon service" + +# shellcheck disable=SC2086 +exec /beacon-chain \ + --accept-terms-of-use \ + --datadir=${DATA_DIR} \ + --jwt-secret="${JWT_FILE_PATH}" \ + --execution-endpoint="${ENGINE_URL}" \ + --monitoring-host=0.0.0.0 \ + --grpc-gateway-host=0.0.0.0 \ + --grpc-gateway-port="${BEACON_API_PORT}" \ + --grpc-gateway-corsdomain="${CORSDOMAIN}" \ + --rpc-host=0.0.0.0 \ + --verbosity="${VERBOSITY}" \ + --p2p-tcp-port="${P2P_TCP_PORT}" \ + --p2p-udp-port="${P2P_UDP_PORT}" \ + --p2p-max-peers="${MAX_PEERS}" \ + --min-sync-peers="${MIN_SYNC_PEERS}" \ + --subscribe-all-subnets="${SUBSCRIBE_ALL_SUBNETS}" ${NETWORK_FLAGS} ${CHECKPOINT_SYNC_FLAGS} ${MEVBOOST_FLAG} ${EXTRA_OPTS} diff --git a/docker-compose.yml b/docker-compose.yml index ab028c7..e984385 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,9 +24,9 @@ services: args: UPSTREAM_VERSION: v5.0.4 STAKER_SCRIPTS_VERSION: v0.1.0 - DATA_DIR: /root/ + DATA_DIR: /root/.eth2validators volumes: - - "validator-data:/root/" + - "validator-data:/root/.eth2validators" restart: unless-stopped environment: LOG_TYPE: INFO diff --git a/setup-wizard.yml b/setup-wizard.yml index 1671fa3..f7d0eb6 100644 --- a/setup-wizard.yml +++ b/setup-wizard.yml @@ -17,7 +17,7 @@ fields: title: Checkpoint for fast sync description: >- To get Prysm up and running in only a few minutes, you can start Prysm from a recent finalized checkpoint state rather than syncing from genesis. This is substantially **faster** and consumes **less resources** than syncing from genesis, while still providing all the same features. Be sure you are using a trusted node for the fast sync. Check the [Prysm docs](https://docs.prylabs.network/docs/prysm-usage/checkpoint-sync) for more information. - Use the Dappnode Official endpoint `https://checkpoint-sync.dappnode.io` or get your checkpoint sync from [Infura](https://infura.io/) (i.e https://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@eth2-beacon.infura.io) + Use the Dappnode Official endpoint for your network (`https://checkpoint-sync.dappnode.io`, `https://checkpoint-sync-holesky.dappnode.io`, `https://checkpoint-sync-gnosis.dappnode.io`) or get your checkpoint sync from [Infura](https://infura.io/) (i.e https://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@eth2-beacon.infura.io) *Note - If you are going to provide your own checkpoint sync endpoint, make sure you do not use a slash `/` at the end of the URL.* required: false - id: feeRecipientAddress diff --git a/validator/Dockerfile b/validator/Dockerfile index 50937b6..7fcdf15 100644 --- a/validator/Dockerfile +++ b/validator/Dockerfile @@ -1,29 +1,33 @@ ARG UPSTREAM_VERSION FROM debian:bullseye-slim AS builder +# Use ldd to copy dependencies of grep +RUN mkdir /deps +RUN ldd /bin/grep | tr -s '[:space:]' '\n' | grep '^/' | xargs -I {} cp -v {} /deps || true + ARG UPSTREAM_VERSION FROM gcr.io/prysmaticlabs/prysm/validator:${UPSTREAM_VERSION} ARG NETWORK ARG STAKER_SCRIPTS_VERSION -ARG DATA_DIR=/root/.eth2validators -ARG WALLET_DIR=/root/.eth2validators/prysm-wallet-v2 +ARG DATA_DIR + +ENV VALIDATOR_API_PORT=3500 \ + DATA_DIR=${DATA_DIR} \ + WALLET_DIR=${DATA_DIR}/prysm-wallet-v2 \ + LUKSO_CONFIG_PATH=/configs/lukso/shared/config.yaml \ + STAKER_SCRIPTS_URL=https://github.com/dappnode/staker-package-scripts/releases/download/${STAKER_SCRIPTS_VERSION} \ + LUKSO_CONFIG_URL=https://raw.githubusercontent.com/lukso-network/network-configs/main/mainnet/shared/config.yaml COPY --from=builder /bin/sh /bin/sh +COPY --from=builder /bin/grep /bin/grep +COPY --from=builder /deps/* /lib/ RUN mkdir -p ${WALLET_DIR} COPY auth-token ${WALLET_DIR}/auth-token COPY entrypoint.sh /usr/local/bin/entrypoint.sh -ENV VALIDATOR_API_PORT=3500 \ - DATA_DIR=${DATA_DIR} \ - WALLET_DIR=${WALLET_DIR} \ - NETWORK=${NETWORK} \ - LUKSO_CONFIG_PATH=/configs/lukso/shared/config.yaml \ - STAKER_SCRIPTS_URL=https://github.com/dappnode/staker-package-scripts/releases/download/${STAKER_SCRIPTS_VERSION} \ - LUKSO_CONFIG_URL=https://raw.githubusercontent.com/lukso-network/network-configs/main/mainnet/shared/config.yaml - ADD ${STAKER_SCRIPTS_URL}/consensus_tools.sh /etc/profile.d/ RUN chmod +rx /usr/local/bin/entrypoint.sh /etc/profile.d/consensus_tools.sh @@ -33,4 +37,8 @@ RUN if [ "${NETWORK}" = "lukso" ]; then \ wget ${LUKSO_CONFIG_URL} -O ${LUKSO_CONFIG_PATH}; \ fi +# This env changes the variant +# Placed at the end to regenerate the least amount of layers +ENV NETWORK=${NETWORK} + ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] \ No newline at end of file diff --git a/validator/entrypoint.sh b/validator/entrypoint.sh index 79ecfd9..878ddfc 100755 --- a/validator/entrypoint.sh +++ b/validator/entrypoint.sh @@ -1,65 +1,56 @@ #!/bin/sh SUPPORTED_NETWORKS="sepolia lukso holesky mainnet" -MEVBOOST_FLAG="--enable-builder" +MEVBOOST_FLAG_KEY="--enable-builder" SKIP_MEVBOOST_URL="true" CLIENT="prysm" -handle_network() { - case "$NETWORK" in - "holesky") - flags_to_set="--holesky" - ;; - "lukso") - flags_to_set="--chain-config-file=${LUKSO_CONFIG_PATH}" - ;; - "mainnet") - flags_to_set="--mainnet" - ;; - "sepolia") - flags_to_set="--sepolia" - ;; - *) - echo "[ERROR - entrypoint] Unsupported network: $NETWORK" - exit 1 - ;; - esac - - set_validator_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}" "$flags_to_set" - -} - -get_beacon_rpc_url() { - - beacon_domain_and_protocol=$(echo "$BEACON_API_URL" | cut -d':' -f1,2) - - BEACON_RPC_4000="${beacon_domain_and_protocol}:4000" -} - -run_validator() { - echo "[INFO - entrypoint] Running validator service" - - # shellcheck disable=SC2086 - exec /validator \ - --datadir="${DATA_DIR}" \ - --wallet-dir="${WALLET_DIR}" \ - --monitoring-host 0.0.0.0 \ - --beacon-rpc-provider="${BEACON_API_URL}" \ - --beacon-rpc-gateway-provider="${BEACON_RPC_4000}" \ - --validators-external-signer-url="${WEB3SIGNER_API_URL}" \ - --grpc-gateway-host=0.0.0.0 \ - --grpc-gateway-port="${VALIDATOR_API_PORT}" \ - --grpc-gateway-corsdomain=http://0.0.0.0:"${VALIDATOR_API_PORT}" \ - --graffiti="${GRAFFITI}" \ - --suggested-fee-recipient="${FEE_RECIPIENT}" \ - --verbosity="${VERBOSITY}" \ - --web \ - --accept-terms-of-use \ - --enable-doppelganger ${EXTRA_OPTS} -} - -format_graffiti -handle_network -get_beacon_rpc_url -set_mevboost_flag "${MEVBOOST_FLAG}" "${SKIP_MEVBOOST_URL}" -run_validator +# shellcheck disable=SC1091 +. /etc/profile.d/consensus_tools.sh + +VALID_GRAFFITI=$(get_valid_graffiti "${GRAFFITI}") +VALID_FEE_RECIPIENT=$(get_valid_fee_recipient "${FEE_RECIPIENT}") +SIGNER_API_URL=$(get_signer_api_url "${NETWORK}" "${SUPPORTED_NETWORKS}") +BEACON_API_URL=$(get_beacon_api_url "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}") +MEVBOOST_FLAG=$(get_mevboost_flag "${MEVBOOST_FLAG_KEY}" "${SKIP_MEVBOOST_URL}") + +BEACON_API_4000="$(echo "$BEACON_API_URL" | cut -d':' -f1,2):4000" + +case "$NETWORK" in +"holesky") + NETWORK_FLAGS="--holesky" + ;; +"lukso") + NETWORK_FLAGS="--chain-config-file=${LUKSO_CONFIG_PATH}" + ;; +"mainnet") + NETWORK_FLAGS="--mainnet" + ;; +"sepolia") + NETWORK_FLAGS="--sepolia" + ;; +*) + echo "[ERROR - entrypoint] Unsupported network: $NETWORK" + exit 1 + ;; +esac + +echo "[INFO - entrypoint] Running validator service" + +# shellcheck disable=SC2086 +exec /validator \ + --datadir="${DATA_DIR}" \ + --wallet-dir="${WALLET_DIR}" \ + --monitoring-host 0.0.0.0 \ + --beacon-rpc-provider="${BEACON_API_4000}" \ + --beacon-rpc-gateway-provider="${BEACON_API_URL}" \ + --validators-external-signer-url="${SIGNER_API_URL}" \ + --grpc-gateway-host=0.0.0.0 \ + --grpc-gateway-port="${VALIDATOR_API_PORT}" \ + --grpc-gateway-corsdomain=http://0.0.0.0:"${VALIDATOR_API_PORT}" \ + --graffiti="${VALID_GRAFFITI}" \ + --suggested-fee-recipient="${VALID_FEE_RECIPIENT}" \ + --verbosity="${VERBOSITY}" \ + --web \ + --accept-terms-of-use \ + --enable-doppelganger ${NETWORK_FLAGS} ${MEVBOOST_FLAG} ${EXTRA_OPTS}