Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Jul 11, 2024
1 parent 4f85423 commit 6090b1a
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 24 deletions.
30 changes: 22 additions & 8 deletions beacon-chain/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ARG UPSTREAM_VERSION
FROM debian:bullseye-slim AS builder

ARG NETWORK
Expand All @@ -18,20 +19,33 @@ RUN mkdir -p ${LUKSO_CONFIG_PATH} && \
ARG UPSTREAM_VERSION
FROM gcr.io/prysmaticlabs/prysm/beacon-chain:${UPSTREAM_VERSION}

COPY jwtsecret.hex /jwtsecret
ARG NETWORK
ARG STAKER_SCRIPTS_VERSION
ARG DATA_DIR

ENV JWT_FILE_PATH=/jwtsecret \
BEACON_API_PORT=3500 \
DATA_DIR=${DATA_DIR} \
LUKSO_CONFIG_PATH=/configs/lukso \
LUKSO_GENESIS_FILE_PATH=${LUKSO_CONFIG_PATH}/genesis.ssz \
LUKSO_CHAIN_CONFIG_FILE_PATH=${LUKSO_CONFIG_PATH}/config.yaml \
STAKER_SCRIPTS_URL=https://github.com/dappnode/staker-package-scripts/releases/download/${STAKER_SCRIPTS_VERSION}

COPY jwtsecret.hex ${JWT_FILE_PATH}
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

ADD ${STAKER_SCRIPTS_URL}/consensus_tools.sh /etc/profile.d/

COPY --from=builder /bin/sh /bin/sh
COPY --from=builder /bin/grep /bin/grep
COPY --from=builder /deps/* /lib/

ENV JWT_PATH=/jwtsecret \
VALIDATOR_PORT=3500 \
DATA_DIR=/data \
LUKSO_CONFIG_PATH=/configs/lukso \
LUKSO_GENESIS_FILE_PATH=${LUKSO_CONFIG_PATH}/genesis.ssz \
LUKSO_CHAIN_CONFIG_FILE_PATH=${LUKSO_CONFIG_PATH}/config.yaml

COPY --from=builder /configs /configs

RUN chmod +rx /usr/local/bin/entrypoint.sh /etc/profile.d/consensus_tools.sh

# 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" ]
23 changes: 14 additions & 9 deletions beacon-chain/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ CHECKPOINT_SYNC_FLAG_1="--checkpoint-sync-url"
CHECKPOINT_SYNC_FLAG_2="--genesis-beacon-api-url"
MEVBOOST_FLAGS="--http-mev-relay"

# shellcheck disable=SC1091 # Path is relative to the Dockerfile
. /etc/profile

handle_network() {
case "$NETWORK" in
"holesky")
set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "--holesky"
flags_to_set="--holesky"
;;
"lukso")
set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "--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"
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")
set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "--mainnet"
flags_to_set="--mainnet"
;;
"sepolia")
set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "--sepolia"
flags_to_set="--sepolia"
;;
*)
echo "[ERROR - entrypoint] Unsupported network: $NETWORK"
exit 1
;;
esac

set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "$flags_to_set"
}

handle_checkpoint() {
Expand All @@ -45,19 +50,19 @@ run_beacon() {
exec /beacon-chain \
--accept-terms-of-use \
--datadir=${DATA_DIR} \
--jwt-secret="${JWT_PATH}" \
--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="${VALIDATOR_PORT}" \
--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}
--p2p-max-peers="${MAX_PEERS}" \
--min-sync-peers="${MIN_SYNC_PEERS}" \
--subscribe-all-subnets="${SUBSCRIBE_ALL_SUBNETS}" ${EXTRA_OPTS}
}

validate_fee_recipient
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
args:
UPSTREAM_VERSION: v5.0.4
STAKER_SCRIPTS_VERSION: v0.1.0
DATA_DIR: /data
volumes:
- "beacon-chain-data:/data"
restart: unless-stopped
Expand All @@ -23,6 +24,7 @@ services:
args:
UPSTREAM_VERSION: v5.0.4
STAKER_SCRIPTS_VERSION: v0.1.0
DATA_DIR: /root/
volumes:
- "validator-data:/root/"
restart: unless-stopped
Expand Down
9 changes: 9 additions & 0 deletions package_variants/sepolia/dappnode_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "prysm-sepolia.dnp.dappnode.eth",
"version": "0.1.2",
"links": {
"homepage": "https://prysmaticlabs.com/",
"readme": "https://github.com/dappnode/DAppNodePackage-prysm-generic",
"docs": "https://docs.prylabs.network/docs/getting-started"
}
}
18 changes: 18 additions & 0 deletions package_variants/sepolia/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.5"
services:
beacon-chain:
build:
args:
NETWORK: sepolia
P2P_TCP_PORT: 19114
ports:
- 19114:19114/tcp
- 19114:19114/udp
environment:
CORSDOMAIN: "http://prysm-sepolia.dappnode"
validator:
build:
args:
NETWORK: sepolia
BEACON_RPC_PROVIDER: "beacon-chain.prysm-sepolia.dappnode:4000"
BEACON_RPC_GATEWAY_PROVIDER: "beacon-chain.prysm-sepolia.dappnode:3500"
20 changes: 20 additions & 0 deletions package_variants/sepolia/prometheus-targets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"labels": {
"package": "prysm-sepolia.dnp.dappnode.eth",
"service": "beacon-chain.prysm-sepolia.dappnode"
},
"targets": [
"beacon-chain.prysm-sepolia.dappnode:8080"
]
},
{
"labels": {
"package": "prysm-sepolia.dnp.dappnode.eth",
"service": "validator.prysm-sepolia.dappnode"
},
"targets": [
"validator.prysm-sepolia.dappnode:8081"
]
}
]
7 changes: 6 additions & 1 deletion validator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ARG UPSTREAM_VERSION
FROM debian:bullseye-slim AS builder

ARG UPSTREAM_VERSION
FROM gcr.io/prysmaticlabs/prysm/validator:${UPSTREAM_VERSION}

Expand All @@ -6,12 +9,14 @@ ARG STAKER_SCRIPTS_VERSION
ARG DATA_DIR=/root/.eth2validators
ARG WALLET_DIR=/root/.eth2validators/prysm-wallet-v2

COPY --from=builder /bin/sh /bin/sh

RUN mkdir -p ${WALLET_DIR}

COPY auth-token ${WALLET_DIR}/auth-token
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

ENV VALIDATOR_PORT=3500 \
ENV VALIDATOR_API_PORT=3500 \
DATA_DIR=${DATA_DIR} \
WALLET_DIR=${WALLET_DIR} \
NETWORK=${NETWORK} \
Expand Down
15 changes: 9 additions & 6 deletions validator/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ CLIENT="prysm"
handle_network() {
case "$NETWORK" in
"holesky")
set_validator_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}" "--holesky"
flags_to_set="--holesky"
;;
"lukso")
set_validator_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}" "--chain-config-file=$LUKSO_CONFIG_PATH"
flags_to_set="--chain-config-file=${LUKSO_CONFIG_PATH}"
;;
"mainnet")
set_validator_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}" "--mainnet"
flags_to_set="--mainnet"
;;
"sepolia")
set_validator_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}" "--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() {
Expand All @@ -45,8 +48,8 @@ run_validator() {
--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_PORT}" \
--grpc-gateway-corsdomain=http://0.0.0.0:"${VALIDATOR_PORT}" \
--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}" \
Expand Down

0 comments on commit 6090b1a

Please sign in to comment.