Skip to content

Commit

Permalink
Use latest staker package scripts version
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Jul 22, 2024
1 parent 474c9a5 commit 5e868da
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 84 deletions.
21 changes: 12 additions & 9 deletions beacon-chain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ ARG UPSTREAM_VERSION
FROM statusim/nimbus-eth2:multiarch-${UPSTREAM_VERSION}

ARG NETWORK
ARG P2P_PORT
ARG STAKER_SCRIPTS_VERSION

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY jwtsecret.hex /jwtsecret
ARG DATA_DIR
ARG P2P_PORT

ENV JWT_SECRET_FILE=/jwtsecret \
NETWORK=${NETWORK} \
VALIDATOR_PORT=3500 \
DATA_DIR=${DATA_DIR} \
P2P_PORT=${P2P_PORT} \
NIMBUS_BIN="/home/user/nimbus_beacon_node" \
DATA_DIR="/home/user/nimbus-eth2/build/data" \
STAKER_SCRIPTS_URL=https://github.com/dappnode/staker-package-scripts/releases/download/${STAKER_SCRIPTS_VERSION}

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

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

USER root
RUN apt-get update && apt-get install -y curl && apt-get clean
USER user

RUN chmod +rx /usr/local/bin/entrypoint.sh /etc/profile.d/consensus_tools.sh
RUN apt-get update && apt-get --yes install curl && apt-get clean && \
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" ]
79 changes: 35 additions & 44 deletions beacon-chain/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
#!/bin/sh

SUPPORTED_NETWORKS="gnosis holesky mainnet"
MEVBOOST_FLAGS="--payload-builder=true --payload-builder-url"
MEVBOOST_FLAG_KEYS="--payload-builder=true --payload-builder-url"

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

handle_checkpoint() {
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_KEYS}")

if [ -n "$(ls -A "${DATA_DIR}/db" 2>/dev/null)" ]; then
echo "[INFO - entrypoint] Data directory has already been initialized, skipping checkpoint sync."
return
fi
if [ -n "$(ls -A "${DATA_DIR}/db" 2>/dev/null)" ]; then
echo "[INFO - entrypoint] Data directory has already been initialized, skipping checkpoint sync."

# Run checkpoint sync script if provided
if [ -n "${CHECKPOINT_SYNC_URL}" ]; then
echo "[INFO - entrypoint] Running checkpoint sync script"
elif [ -n "${CHECKPOINT_SYNC_URL}" ]; then
echo "[INFO - entrypoint] Running checkpoint sync script"

${NIMBUS_BIN} trustedNodeSync \
--network="${NETWORK}" \
--trusted-node-url="${CHECKPOINT_SYNC_URL}" \
--backfill=false \
--data-dir="${DATA_DIR}"
else
echo "[WARN - entrypoint] No checkpoint sync script provided. Syncing from genesis."
fi
}

run_beacon() {
echo "[INFO - entrypoint] Running beacon node service"

# shellcheck disable=SC2086
exec ${NIMBUS_BIN} \
${NIMBUS_BIN} trustedNodeSync \
--network="${NETWORK}" \
--data-dir="${DATA_DIR}" \
--tcp-port="${P2P_PORT}" \
--udp-port="${P2P_PORT}" \
--log-level="${LOG_TYPE}" \
--rest \
--rest-port=3500 \
--rest-address=0.0.0.0 \
--metrics \
--metrics-address=0.0.0.0 \
--metrics-port=8008 \
--jwt-secret=/jwtsecret \
--web3-url="${ENGINE_API_URL}" \
--suggested-fee-recipient="${FEE_RECIPIENT}" ${EXTRA_OPTS}
}

format_graffiti
set_beacon_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}"
handle_checkpoint
set_mevboost_flag "${MEVBOOST_FLAGS}" # MEV-Boost: https://chainsafe.github.io/lodestar/usage/mev-integration/
run_beacon
--trusted-node-url="${CHECKPOINT_SYNC_URL}" \
--backfill=false \
--data-dir="${DATA_DIR}"

else
echo "[WARN - entrypoint] No checkpoint sync script provided. Syncing from genesis."
fi

echo "[INFO - entrypoint] Running beacon node service"

# shellcheck disable=SC2086
exec ${NIMBUS_BIN} \
--network="${NETWORK}" \
--data-dir="${DATA_DIR}" \
--tcp-port="${P2P_PORT}" \
--udp-port="${P2P_PORT}" \
--log-level="${LOG_TYPE}" \
--rest \
--rest-port=3500 \
--rest-address=0.0.0.0 \
--metrics \
--metrics-address=0.0.0.0 \
--metrics-port=8008 \
--jwt-secret=/jwtsecret \
--web3-url="${ENGINE_URL}" \
--suggested-fee-recipient="${VALID_FEE_RECIPIENT}" ${MEVBOOST_FLAG} ${EXTRA_OPTS}
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
args:
UPSTREAM_VERSION: v24.6.0
STAKER_SCRIPTS_VERSION: v0.1.0
DATA_DIR: /home/user/nimbus-eth2/build/data
environment:
LOG_TYPE: INFO
FEE_RECIPIENT: ""
Expand All @@ -30,14 +31,18 @@ services:
args:
UPSTREAM_VERSION: v24.6.0
STAKER_SCRIPTS_VERSION: v0.1.0
DATA_DIR: /home/user/nimbus-eth2/build/data
environment:
LOG_TYPE: INFO
GRAFFITI: validating_from_DAppNode
FEE_RECIPIENT: ""
ENABLE_DOPPELGANGER: "true"
EXTRA_OPTS: ""
volumes:
- nimbus-validators-data:/home/user/nimbus-eth2/build/data

restart: unless-stopped
stop_grace_period: 1m
volumes:
nimbus-data: {}
nimbus-validators-data: {}
21 changes: 14 additions & 7 deletions validator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@ FROM statusim/nimbus-validator-client:multiarch-${UPSTREAM_VERSION}

ARG NETWORK
ARG STAKER_SCRIPTS_VERSION
ARG VALIDATOR_API_TOKEN_PATH=/security/auth-token
ARG DATA_DIR

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

ENV NETWORK=${NETWORK} \
VALIDATOR_API_TOKEN_PATH=${VALIDATOR_API_TOKEN_PATH} \
ENV DATA_DIR=${DATA_DIR} \
VALIDATOR_API_TOKEN_PATH=/security/auth-token \
NIMBUS_BIN="/home/user/nimbus_validator_client" \
STAKER_SCRIPTS_URL=https://github.com/dappnode/staker-package-scripts/releases/download/${STAKER_SCRIPTS_VERSION}

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

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

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

RUN apt-get update && apt-get --yes install curl && apt-get clean && \
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" ]
48 changes: 24 additions & 24 deletions validator/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ CLIENT="nimbus"
# shellcheck disable=SC1091
. /etc/profile

run_validator() {
echo "[INFO - entrypoint] Running validator service"
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}")

# shellcheck disable=SC2086
exec ${NIMBUS_BIN} \
--log-level="${LOG_TYPE}" \
--doppelganger-detection="${ENABLE_DOPPELGANGER}" \
--non-interactive=true \
--web3-signer-url="${WEB3SIGNER_API_URL}" \
--suggested-fee-recipient="${FEE_RECIPIENT}" \
--keymanager=true \
--keymanager-port=3500 \
--keymanager-address=0.0.0.0 \
--keymanager-allow-origin=* \
--keymanager-token-file="${VALIDATOR_API_TOKEN_PATH}" \
--metrics=true \
--metrics-address=0.0.0.0 \
--metrics-port=8008 \
--graffiti="${GRAFFITI}" \
--beacon-node="${BEACON_API_URL}" ${EXTRA_OPTS}
}
echo "[INFO - entrypoint] Running validator service"

format_graffiti
set_validator_config_by_network "${NETWORK}" "${SUPPORTED_NETWORKS}" "${CLIENT}"
set_mevboost_flag "${MEVBOOST_FLAG}" "${SKIP_MEVBOOST_URL}" # MEV-Boost: https://chainsafe.github.io/lodestar/usage/mev-integration/
run_validator
# shellcheck disable=SC2086
exec ${NIMBUS_BIN} \
--log-level="${LOG_TYPE}" \
--data-dir="${DATA_DIR}" \
--doppelganger-detection="${ENABLE_DOPPELGANGER}" \
--non-interactive \
--web3-signer-url="${SIGNER_API_URL}" \
--suggested-fee-recipient="${VALID_FEE_RECIPIENT}" \
--keymanager=true \
--keymanager-port=3500 \
--keymanager-address=0.0.0.0 \
--keymanager-allow-origin=* \
--keymanager-token-file="${VALIDATOR_API_TOKEN_PATH}" \
--metrics=true \
--metrics-address=0.0.0.0 \
--metrics-port=8008 \
--graffiti="${VALID_GRAFFITI}" \
--beacon-node="${BEACON_API_URL}" ${MEVBOOST_FLAG} ${EXTRA_OPTS}

0 comments on commit 5e868da

Please sign in to comment.