Skip to content

Commit

Permalink
Improve sending change message with ethdo
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Feb 1, 2025
1 parent ef1815b commit 6861b48
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 30 deletions.
35 changes: 23 additions & 12 deletions .eth/ethdo/create-withdrawal-change.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
#!/usr/bin/env bash
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
set -e
echo "Copying ethdo to home directory, ~/ethdo"
mkdir -p ~/ethdo
cp ethdo ~/ethdo/
cp ethdo-arm64 ~/ethdo/
chmod +x ~/ethdo/*
set +e

__arch=$(uname -m)

if [ "${__arch}" = "aarch64" ]; then
__ethdo=~/ethdo/ethdo-arm64
if [[ "${__arch}" = "aarch64" || "${__arch}" = "arm64" ]]; then
__arch_dir=arm64
elif [ "${__arch}" = "x86_64" ]; then
__ethdo=~/ethdo/ethdo
__arch_dir=amd64
else
echo "Architecture ${__arch} not recognized - unsure which ethdo to use. Aborting."
exit 1
fi

__ethdo=~/bin/ethdo
__jq=~/bin/jq

set -e
echo "Copying ethdo and jq to home directory, ~/bin"
mkdir -p ~/bin
cp "${__arch_dir}/ethdo" ~/bin/
cp "${__arch_dir}/jq" ~/bin/
chmod +x ~/bin/*
set +e

if [ ! -f "${__ethdo}" ]; then
echo "Unable to find ethdo executable at \"${BASH_SOURCE[0]}/${__ethdo}\". Aborting."
echo "Unable to find ethdo executable at \"${__ethdo}\". Aborting."
exit 1
fi
echo "Checking whether Bluetooth is enabled"
Expand Down Expand Up @@ -56,6 +60,7 @@ while true; do
done
echo "MAKE SURE YOU CONTROL THE WITHDRAWAL ADDRESS"
echo "This can only be changed once."
echo
while true; do
read -rp "What is your validator mnemonic? : " __mnemonic
if [ ! "$(echo "$__mnemonic" | wc -w)" -eq 24 ] && [ ! "$(echo "$__mnemonic" | wc -w)" -eq 12 ]; then
Expand All @@ -65,6 +70,7 @@ while true; do
break
fi
done
echo
echo "You may have used a 25th word for the mnemonic. This is not the passphrase for the"
echo "validator signing keys. When in doubt, say no to the next question."
echo
Expand All @@ -90,6 +96,7 @@ esac
__advancedCommand=""
read -rp "Did you use a third party such as StakeFish/Staked.us or know that multiple validators share credentials? This is uncommon. (no/yes) : " __advancedCommand

echo
echo "Creating change-operations.json"
case "${__advancedCommand}" in
[Yy]* )
Expand All @@ -114,3 +121,7 @@ echo "change-operations.json can be found on your USB drive"
echo
echo "Please shut down this machine and continue online, with the created change-operations.json file"
echo "You can submit it to https://beaconcha.in/tools/broadcast, for example"
echo
if [ -f "${__jq}" ]; then
echo "There are change messages for $(${__jq} 'length' change-operations.json) validators in change-operations.json"
fi
53 changes: 35 additions & 18 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,35 @@ __keys_usage() {
}


__get_github_release() {
# Call with repo and expected suffix as well as directory and target name.

local __repo=$1
local __suffix=$2
local __dirname=$3
local __targetname=$4

${__as_owner} mkdir -p "${__dirname}"
if [ "${__targetname}" = "__untar__" ]; then
wget -q -O- https://api.github.com/repos/"${__repo}"/releases/latest | grep "browser_download_url.*${__suffix}" \
| head -1 \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi- -O- \
| ${__as_owner} tar zxf - -C "${__dirname}" \
|| echo "-> Could not download the latest version of '${__suffix}' from github '${__repo}'."
else
wget -q -O- https://api.github.com/repos/"${__repo}"/releases/latest | grep "browser_download_url.*${__suffix}" \
| head -1 \
| cut -d : -f 2,3 \
| tr -d \" \
| ${__as_owner} wget -qi- -O "${__dirname}/${__targetname}" \
| ${__as_owner} chmod +x "${__dirname}/${__targetname}" \
|| echo "-> Could not download the latest version of '${__suffix}' from github '${__repo}'."
fi
}


keys() {
if [[ "$#" -eq 0 || "$1" == "help" || "$1" == "-h" || "$1" == "--help" ]]; then
__keys_usage
Expand Down Expand Up @@ -2511,24 +2540,12 @@ keys() {
fi
echo
echo "Downloading ethdo"
__repo="wealdtech/ethdo"; \
wget -q -O- https://api.github.com/repos/${__repo}/releases/latest | grep "browser_download_url.*linux-amd64.tar.gz" \
| head -1 \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi- -O- \
| ${__as_owner} tar zxf - -C ./.eth/ethdo/ \
|| echo "-> Could not download the latest version of '${__repo}' for amd64."
${__as_owner} mkdir -p ./.eth/ethdo/arm64
wget -q -O- https://api.github.com/repos/${__repo}/releases/latest | grep "browser_download_url.*linux-arm64.tar.gz" \
| head -1 \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi- -O- \
| ${__as_owner} tar zxf - -C ./.eth/ethdo/arm64 \
|| echo "-> Could not download the latest version of '${__repo}' for arm64."
${__as_owner} mv ./.eth/ethdo/arm64/ethdo ./.eth/ethdo/ethdo-arm64
${__as_owner} rm -rf ./.eth/ethdo/arm64
__get_github_release wealdtech/ethdo linux-amd64.tar.gz ./.eth/ethdo/amd64 __untar__
__get_github_release wealdtech/ethdo linux-arm64.tar.gz ./.eth/ethdo/arm64 __untar__
echo
echo "Downloading jq"
__get_github_release jqlang/jq jq-linux-amd64 ./.eth/ethdo/amd64 jq
__get_github_release jqlang/jq jq-linux-arm64 ./.eth/ethdo/arm64 jq
echo
echo "Copy the contents of ./.eth/ethdo to a USB drive, and prepare a Linux Live USB to safely enter your mnemonic."
echo "Please see https://ethdocker.com/Support/ChangingWithdrawalCredentials for details"
Expand Down
1 change: 1 addition & 0 deletions ethdo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- docker-entrypoint.sh
- /app/ethdo
- --allow-insecure-connections
- --debug

volumes:
ethdo-wallet:

0 comments on commit 6861b48

Please sign in to comment.