From 778b62ca48eee7c4fd715d09e516d8549c4bde19 Mon Sep 17 00:00:00 2001 From: DROO Date: Sat, 24 Aug 2024 19:00:30 +0200 Subject: [PATCH 1/8] add keys count --- ethd | 4 +++- vc-utils/keymanager.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ethd b/ethd index 0d427d5b..a9de3f31 100755 --- a/ethd +++ b/ethd @@ -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)" @@ -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" diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index d8a62482..5fc11e3b 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -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') + 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') + echo "Remote Validator keys registered with ${__service}: $remote_key_count" + key_count=(key_count + remote_key_count) + fi + + echo "Total keys: $key_count" +} + validator-delete() { if [ -z "${__pubkey}" ]; then echo "Please specify a validator public key to delete, or \"all\"" @@ -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)" @@ -1214,6 +1249,9 @@ case "$3" in register) validator-register ;; + count) + validator-count + ;; get-recipient) __pubkey=$4 recipient-get From 8c2d4145166ee8fe3e9763aa97c136b6d8eebeff Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:44:01 -0400 Subject: [PATCH 2/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index 5fc11e3b..ab72df4e 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -499,7 +499,7 @@ validator-count() { get-token fi __validator-list-call - declare key_count=$(echo "$__result" | jq -r '.data | length') + key_count=$(echo "$__result" | jq -r '.data | length') echo "Validator keys loaded into ${__service}: $key_count" if [ "${WEB3SIGNER}" = "true" ]; then From 4742bd6e0c379f1cbab6dfdac0c266064d41fd05 Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:44:11 -0400 Subject: [PATCH 3/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index ab72df4e..3dc4574b 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -510,7 +510,7 @@ validator-count() { __api_port=${__vc_api_port} __api_tls=${__vc_api_tls} __validator-list-call - declare remote_key_count=$(echo "$__result" | jq -r '.data | length') + remote_key_count=$(echo "$__result" | jq -r '.data | length') echo "Remote Validator keys registered with ${__service}: $remote_key_count" key_count=(key_count + remote_key_count) fi From f8c9d552b0dbb4ab66696517856b0fd25f1083fb Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:47:10 -0400 Subject: [PATCH 4/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index 3dc4574b..0588b5e5 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -512,7 +512,9 @@ validator-count() { __validator-list-call remote_key_count=$(echo "$__result" | jq -r '.data | length') echo "Remote Validator keys registered with ${__service}: $remote_key_count" - key_count=(key_count + remote_key_count) + if [ "${key_count}" -ne "${remote_key_count)" ]; then + echo "WARNING: The number of keys loaded into Web3signer and registered with the validator client differ." + echo "Please run \"./ethd keys register\"" fi echo "Total keys: $key_count" From ca496e92fa429ada1c571719888008d04d0f7a89 Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:47:15 -0400 Subject: [PATCH 5/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index 0588b5e5..a85480fe 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -516,7 +516,6 @@ validator-count() { echo "WARNING: The number of keys loaded into Web3signer and registered with the validator client differ." echo "Please run \"./ethd keys register\"" fi - echo "Total keys: $key_count" } From 84e11fc457c21f0b79d5ece25172d1f8dcc20bd1 Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:47:20 -0400 Subject: [PATCH 6/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index a85480fe..fb23a30b 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -516,7 +516,6 @@ validator-count() { echo "WARNING: The number of keys loaded into Web3signer and registered with the validator client differ." echo "Please run \"./ethd keys register\"" fi - echo "Total keys: $key_count" } validator-delete() { From 9a1ecf68f246733587406e083292aac81685e1ec Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:49:09 -0400 Subject: [PATCH 7/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index fb23a30b..cd1e59c1 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -515,6 +515,7 @@ validator-count() { if [ "${key_count}" -ne "${remote_key_count)" ]; then echo "WARNING: The number of keys loaded into Web3signer and registered with the validator client differ." echo "Please run \"./ethd keys register\"" + fi fi } From a3ab67d744d2a602718a870e9d966c106a131639 Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:50:07 -0400 Subject: [PATCH 8/8] Update vc-utils/keymanager.sh --- vc-utils/keymanager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index cd1e59c1..d33922bd 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -512,7 +512,7 @@ validator-count() { __validator-list-call remote_key_count=$(echo "$__result" | jq -r '.data | length') echo "Remote Validator keys registered with ${__service}: $remote_key_count" - if [ "${key_count}" -ne "${remote_key_count)" ]; then + if [ "${key_count}" -ne "${remote_key_count}" ]; then echo "WARNING: The number of keys loaded into Web3signer and registered with the validator client differ." echo "Please run \"./ethd keys register\"" fi