Skip to content

Commit

Permalink
UX improvements re key management and build targets (#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Jan 6, 2023
1 parent 12268fd commit 7c7668d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
28 changes: 23 additions & 5 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ update() {
exec "${BASH_SOURCE[0]}" update "$@"
fi

__keeptargets=0
__keeptargets=1
__targetcli=""
while :
do
Expand All @@ -241,10 +241,23 @@ update() {
fi
case "$1" in
--keep-targets)
if [ -n "${__targetcli}" ]; then
echo "Error: --keep-targets and --refresh-targets cannot be used together; use either option once only"
exit 1
fi
__keeptargets=1
__targetcli="--keep-targets"
shift
;;
--refresh-targets)
if [ -n "${__targetcli}" ]; then
echo "Error: --keep-targets and --refresh-targets cannot be used together; use either option once only"
exit 1
fi
__keeptargets=0
__targetcli="--refresh-targets"
shift
;;
*)
echo "Error: Unknown option: $1" >&2
exit 1
Expand Down Expand Up @@ -306,8 +319,8 @@ update() {
echo "Your ${ENV_FILE} configuration settings have been migrated to a fresh copy. You can \
find the original contents in ${ENV_FILE}.bak."
if [ $__keeptargets = "0" ]; then
echo "NB: If you made changes to the source or binary build targets, these have NOT \
been migrated, please recreate these changes yourself."
echo "NB: If you made changes to the source or binary build targets, these have been \
reset to defaults."
fi
echo
echo "An ./ethd up command will start using the new images and configuration."
Expand Down Expand Up @@ -959,6 +972,11 @@ keys() {
else
docompose run --rm -e OWNER_UID="${__owner_uid}" validator-keys import
fi
elif [ "${1:-}" = "create-prysm-wallet" ]; then
docompose run --rm create-wallet
docompose stop validator
docompose rm --force validator
up
else
docompose run --rm -e OWNER_UID="${__owner_uid}" validator-keys "$@"
fi
Expand Down Expand Up @@ -1680,9 +1698,9 @@ printhelp() {
echo " keys ACTION"
echo " list, delete, import keys; their fee recipients; and gas fees"
echo " Run without ACTION to get help text"
echo " update [--keep-targets] "
echo " update [--refresh-targets] "
echo " updates all client versions and eth-docker itself"
echo " --keep-targets will keep your custom build targets in .env"
echo " --refresh-targets will reset your custom build targets in .env to defaults"
echo " up (or start)"
echo " starts the Ethereum node, or restarts containers that had their image or"
echo " configuration changed"
Expand Down
18 changes: 10 additions & 8 deletions vc-utils/keymanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ recipient-set() {
__http_method=POST
call_api
case $__code in
#200 is not valid, but Lodestar does that
202|200) echo "The fee recipient for the validator with public key $__pubkey was updated."; exit 0;;
202) echo "The fee recipient for the validator with public key $__pubkey was updated."; exit 0;;
400) echo "The pubkey or address was formatted wrong. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
401) echo "No authorization token found. This is a bug. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
403) echo "The authorization token is invalid. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
Expand All @@ -123,8 +122,7 @@ recipient-delete() {
__http_method=DELETE
call_api
case $__code in
#200 is not valid, but Lodestar does that
204|200) echo "The fee recipient for the validator with public key $__pubkey was set back to default."; exit 0;;
204) echo "The fee recipient for the validator with public key $__pubkey was set back to default."; exit 0;;
401) echo "No authorization token found. This is a bug. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
403) echo "A fee recipient was found, but cannot be deleted. It may be in a configuration file. Message: $(echo "$__result" | jq -r '.message')"; exit 0;;
404) echo "The key was not found on the server, nothing to delete. Message: $(echo "$__result" | jq -r '.message')"; exit 0;;
Expand Down Expand Up @@ -169,8 +167,7 @@ gas-set() {
__http_method=POST
call_api
case $__code in
#200 is not valid, but Lodestar does that
202|200) echo "The gas limit for the validator with public key $__pubkey was updated."; exit 0;;
202) echo "The gas limit for the validator with public key $__pubkey was updated."; exit 0;;
400) echo "The pubkey or limit was formatted wrong. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
401) echo "No authorization token found. This is a bug. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
403) echo "The authorization token is invalid. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
Expand All @@ -191,8 +188,7 @@ gas-delete() {
__http_method=DELETE
call_api
case $__code in
#200 is not valid, but Lodestar does that
204|200) echo "The gas limit for the validator with public key $__pubkey was set back to default."; exit 0;;
204) echo "The gas limit for the validator with public key $__pubkey was set back to default."; exit 0;;
400) echo "The pubkey was formatted wrong. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
401) echo "No authorization token found. This is a bug. Error: $(echo "$__result" | jq -r '.message')"; exit 1;;
403) echo "A gas limit was found, but cannot be deleted. It may be in a configuration file. Message: $(echo "$__result" | jq -r '.message')"; exit 0;;
Expand Down Expand Up @@ -467,6 +463,8 @@ usage() {
echo " Print the token for the keymanager API running on port ${KEY_API_PORT:-7500}."
echo " This is also the token for the Prysm Web UI"
echo
echo " create-prysm-wallet"
echo " Create a new Prysm wallet to store keys in"
echo " get-prysm-wallet"
echo " Print Prysm's wallet password"
}
Expand All @@ -481,6 +479,10 @@ if [ "$(id -u)" = '0' ]; then
print-api-token
exit 0
;;
create-prysm-wallet)
echo "There's a bug in ethd; this command should have been handled one level higher. Please report this."
exit 1
;;
get-prysm-wallet)
get-prysm-wallet
exit 0
Expand Down

0 comments on commit 7c7668d

Please sign in to comment.