Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add keys count #1913

Merged
merged 8 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ethd
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,8 @@ __keys_usage() {
echo "Call keymanager with an ACTION, one of:"
echo " list"
echo " Lists the public keys of all validators currently loaded into your validator client"
echo " count"
echo " Counts the keys currently loaded into your validator client"
echo " import"
echo " Import all keystore*.json in .eth/validator_keys while loading slashing protection data"
echo " in slashing_protection*.json files that match the public key(s) of the imported validator(s)"
Expand Down Expand Up @@ -3392,7 +3394,7 @@ __full_help() {
echo " config"
echo " configures ${__project_name} with your choice of Ethereum clients"
echo " keys ACTION [--non-interactive]"
echo " list, delete, import keys; their fee recipients; and gas fees"
echo " list, count, delete, import keys; their fee recipients; and gas fees"
echo " Run without ACTION to get help text"
echo " update [--refresh-targets] [--non-interactive]"
echo " updates all client versions and ${__project_name} itself"
Expand Down
38 changes: 38 additions & 0 deletions vc-utils/keymanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,39 @@ validator-list() {
fi
}

validator-count() {
__api_path=eth/v1/keystores
if [ "${WEB3SIGNER}" = "true" ]; then
__token=NIL
__vc_api_container=${__api_container}
__api_container=web3signer
__vc_api_port=${__api_port}
__api_port=9000
__vc_api_tls=${__api_tls}
__api_tls=false
else
get-token
fi
__validator-list-call
declare key_count=$(echo "$__result" | jq -r '.data | length')
yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
echo "Validator keys loaded into ${__service}: $key_count"

if [ "${WEB3SIGNER}" = "true" ]; then
get-token
__api_path=eth/v1/remotekeys
__api_container=${__vc_api_container}
__service=${__vc_service}
__api_port=${__vc_api_port}
__api_tls=${__vc_api_tls}
__validator-list-call
declare remote_key_count=$(echo "$__result" | jq -r '.data | length')
yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
echo "Remote Validator keys registered with ${__service}: $remote_key_count"
key_count=(key_count + remote_key_count)
yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
fi

yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
echo "Total keys: $key_count"
yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
yorickdowne marked this conversation as resolved.
Show resolved Hide resolved
}

validator-delete() {
if [ -z "${__pubkey}" ]; then
echo "Please specify a validator public key to delete, or \"all\""
Expand Down Expand Up @@ -1064,6 +1097,8 @@ usage() {
echo "Call keymanager with an ACTION, one of:"
echo " list"
echo " Lists the public keys of all validators currently loaded into your validator client"
echo " count"
echo " Counts the number of keys currently loaded into your validator client"
echo " import"
echo " Import all keystore*.json in .eth/validator_keys while loading slashing protection data"
echo " in slashing_protection*.json files that match the public key(s) of the imported validator(s)"
Expand Down Expand Up @@ -1214,6 +1249,9 @@ case "$3" in
register)
validator-register
;;
count)
validator-count
;;
get-recipient)
__pubkey=$4
recipient-get
Expand Down
Loading