Skip to content

Commit

Permalink
Implement sending change-operations.json (eth-educators#1186)
Browse files Browse the repository at this point in the history
* Implement sending change-operations.json

* Check for ethdo on send-address-change
  • Loading branch information
yorickdowne authored Feb 15, 2023
1 parent df3911f commit a7b1f73
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
9 changes: 8 additions & 1 deletion ethd
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,14 @@ keys() {
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 ./.eth/ethdo/README.md for details"
elif [ "${1:-}" = "send-address-change" ]; then
echo "This has not been implemented yet"
var="COMPOSE_FILE"
value=$(sed -n -e "s/^${var}=\(.*\)/\1/p" ".env" || true)
if [[ ! "${value}" =~ "ethdo.yml" ]]; then
echo "Please make sure ethdo.yml is part of COMPOSE_FILE in .env"
echo "Without it, this step cannot be run"
exit 1
fi
docompose run --rm ethdo validator credentials set --timeout 2m
else
docompose run --rm -e OWNER_UID="${__owner_uid}" validator-keys "$@"
fi
Expand Down
2 changes: 2 additions & 0 deletions ethdo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
image: ethdo:local
volumes:
- ./.eth:/app/.eth
environment:
- NETWORK=${NETWORK}
entrypoint:
- docker-entrypoint.sh
- /app/ethdo
Expand Down
38 changes: 37 additions & 1 deletion ethdo/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,48 @@ for var in "$@"; do
ARGS+=("$var")
done

__sending=0
if [[ "$@" =~ "validator credentials set" ]] && [[ ! "$@" =~ "--prepare-offline" ]]; then
if [ -f "/app/.eth/ethdo/change-operations.json" ]; then
__sending=1
cp /app/.eth/ethdo/change-operations.json /app
chown ethdo:ethdo /app/change-operations.json
__address=$(jq -r .[0].message.to_execution_address < /app/change-operations.json)
__count=$(jq '. | length' < /app/change-operations.json)
echo "You are about to change the withdrawal address of ${__count} validators to Ethereum address ${__address}"
echo "Please make TRIPLY sure that you control this address."
echo
read -rp "I have verified that I control ${__address}, change the withdrawal address (No/Yes): " yn
case $yn in
[Yy][Ee][Ss] ) ;;
* ) echo "Aborting"; exit 0;;
esac
else
echo "No change-operations.json found in ./.eth/ethdo. Aborting."
exit 0
fi
fi

gosu ethdo "${ARGS[@]}"
__result=$?
if [ "${__sending}" -eq 1 ]; then
if [ "${__result}" -eq 0 ]; then
echo "Change sent successfully"
else
# We actually won't get to here because of the set -e, but just in case
echo "Something went wrong when sending the change, error code ${__result}"
fi
fi

if [[ "$@" =~ "--prepare-offline" ]]; then
if [ "${NETWORK}" = "mainnet" ]; then
__butta="https://beaconcha.in"
else
__butta="https://${NETWORK}.beaconcha.in"
fi
cp -rp /app/offline-preparation.json /app/.eth/ethdo/
chown "$uid":"$uid" /app/.eth/ethdo/offline-preparation.json
echo "The preparation file has been copied to ./.eth/ethdo/offline-preparation.json"
echo "It contains $(jq .validators[].index </app/.eth/ethdo/offline-preparation.json | wc -l) validators."
echo "Please verify that this matches what you see on https://beaconcha.in"
echo "Please verify that this matches what you see on ${__butta}/validators"
fi

0 comments on commit a7b1f73

Please sign in to comment.