Skip to content

Commit

Permalink
Better web3signer handling for Teku and Prysm (eth-educators#1387)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored May 9, 2023
1 parent 08e4204 commit eb5cd1c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 7 deletions.
2 changes: 2 additions & 0 deletions prysm-vc-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
- VC_EXTRAS=${VC_EXTRAS:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
<<: *logging
entrypoint:
- docker-entrypoint-vc.sh
Expand Down Expand Up @@ -80,6 +81,7 @@ services:
user: prysmvalidator
environment:
- NETWORK=${NETWORK}
- WEB3SIGNER=${WEB3SIGNER:-false}
volumes:
- prysmvalidator-data:/var/lib/prysm
- /etc/localtime:/etc/localtime:ro
Expand Down
2 changes: 2 additions & 0 deletions prysm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ services:
- VC_EXTRAS=${VC_EXTRAS:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
<<: *logging
entrypoint:
- docker-entrypoint-vc.sh
Expand Down Expand Up @@ -145,6 +146,7 @@ services:
user: prysmvalidator
environment:
- NETWORK=${NETWORK}
- WEB3SIGNER=${WEB3SIGNER:-false}
volumes:
- prysmvalidator-data:/var/lib/prysm
- /etc/localtime:/etc/localtime:ro
Expand Down
9 changes: 8 additions & 1 deletion prysm/create-wallet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ __password=$(head -c 8 /dev/urandom | od -A n -t u8 | tr -d '[:space:]' | sha256
echo "$__password" >/tmp/password.txt
echo "Wallet password created"
set +e
__result=$(validator --datadir=/var/lib/prysm wallet create --"${NETWORK}" --wallet-dir=/var/lib/prysm --keymanager-kind=imported --accept-terms-of-use --wallet-password-file=/tmp/password.txt 2>&1)
if [ "${WEB3SIGNER}" = "true" ]; then
__kind=web3signer
echo "No need to create a permanent wallet when using web3signer with Prysm. Aborting."
exit 0
else
__kind=imported
fi
__result=$(validator --datadir=/var/lib/prysm wallet create --"${NETWORK}" --wallet-dir=/var/lib/prysm --keymanager-kind=${__kind} --accept-terms-of-use --wallet-password-file=/tmp/password.txt 2>&1)
if echo "$__result" | grep -qi error; then
echo "An error occurred while attempting to create a Prysm wallet"
echo "$__result"
Expand Down
11 changes: 9 additions & 2 deletions prysm/docker-entrypoint-vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ else
__doppel=""
fi

# Web3signer URL
if [ "${WEB3SIGNER}" = "true" ]; then
__w3s_url="--validators-external-signer-url http://web3signer:9000"
else
__w3s_url=""
fi

if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--graffiti" "${GRAFFITI}" ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" "--graffiti" "${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
fi
2 changes: 2 additions & 0 deletions teku-cl-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ services:
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=true
- WEB3SIGNER=false
- EMBEDDED_VC=false
ports:
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp
Expand Down
1 change: 1 addition & 0 deletions teku-vc-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- DOPPELGANGER=${DOPPELGANGER:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
<<: *logging
entrypoint:
- docker-entrypoint-vc.sh
Expand Down
2 changes: 2 additions & 0 deletions teku.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ services:
- DOPPELGANGER=${DOPPELGANGER:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
- EMBEDDED_VC=true
ports:
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp
Expand Down
11 changes: 9 additions & 2 deletions teku/docker-entrypoint-vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ else
__mev_boost=""
fi

# Web3signer URL
if [ "${WEB3SIGNER}" = "true" ]; then
__w3s_url="--validators-external-signer-url http://web3signer:9000"
else
__w3s_url=""
fi

if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--validators-graffiti=${GRAFFITI}" ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" "--validators-graffiti=${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
fi
11 changes: 9 additions & 2 deletions teku/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,19 @@ else
__prune="--data-storage-mode=MINIMAL"
fi

# Web3signer URL
if [[ "${EMBEDDED_VC}" = "true" && "${WEB3SIGNER}" = "true" ]]; then
__w3s_url="--validators-external-signer-url http://web3signer:9000"
else
__w3s_url=""
fi

if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__mev_boost} ${__rapid_sync} ${__prune} ${__beacon_stats} ${__doppel} ${CL_EXTRAS} ${VC_EXTRAS}
exec "$@" ${__w3s_url} ${__mev_boost} ${__rapid_sync} ${__prune} ${__beacon_stats} ${__doppel} ${CL_EXTRAS} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--validators-graffiti=${GRAFFITI}" ${__mev_boost} ${__rapid_sync} ${__prune} ${__beacon_stats} ${__doppel} ${CL_EXTRAS} ${VC_EXTRAS}
exec "$@" "--validators-graffiti=${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__rapid_sync} ${__prune} ${__beacon_stats} ${__doppel} ${CL_EXTRAS} ${VC_EXTRAS}
fi

0 comments on commit eb5cd1c

Please sign in to comment.