Skip to content

Commit

Permalink
Update 2025-01 - Add CC names in action summaries
Browse files Browse the repository at this point in the history
- 00_common.sh now includes a likst of CC-ColdHashes and there council names. This is set for Mainnet and PreProd-Testnet

- 24a_genVote.sh and 24c_queryVote.sh are now showing the names of CC members that have voted with there CC-Hot-Keys. The names appear in the YES, NO, ABSTAIN columns right below the counts.

- The CC total voting power calculation has been optimized to actually count authorized and active CC members

- cardano-cli version is currently limited to max. 10.3.99, because most likely 10.4.0.0 will introduce a breaking change in the stake-address-info query output
  • Loading branch information
gitmachtl committed Jan 27, 2025
1 parent c20f2d0 commit 46459c7
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 16 deletions.
27 changes: 25 additions & 2 deletions cardano/mainnet/00_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,16 @@ case "${network,,}" in
_lightModeParametersURL="https://uptime.live/data/cardano/parms/mainnet-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
_guardrailScriptUTXO="dc06746a898fd230f164f47a3d749348b65655b8fb388ff275f54d62891653e2#0"
_guardrailScriptSize=2132
;;
_ccMemberColdHashNames='{
"scriptHash-349e55f83e9af24813e6cb368df6a80d38951b2a334dfcdf26815558": "CAC",
"scriptHash-84aebcfd3e00d0f87af918fc4b5e00135f407e379893df7e7d392c6a": "ECC",
"scriptHash-b6012034ba0a7e4afbbf2c7a1432f8824aee5299a48e38e41a952686": "CF",
"scriptHash-ce8b37a72b178a37bbd3236daa7b2c158c9d3604e7aa667e6c6004b7": "Emurgo",
"scriptHash-df0e83bde65416dade5b1f97e7f115cc1ff999550ad968850783fe50": "IOG",
"scriptHash-e8165b3328027ee0d74b1f07298cb092fd99aa7697a1436f5997f625": "CJC",
"scriptHash-f0dc2c00d92a45521267be2d5de1c485f6f9d14466d7e16062897cf7": "ICC"
}'
;;


"preprod"|"pre-prod" )
Expand All @@ -207,6 +216,15 @@ case "${network,,}" in
_adahandleAPI="https://preprod.api.handle.me" #Adahandle-API URLs -> autoresolve into ${adahandleAPI}
_catalystAPI="https://api.testnet.projectcatalyst.io/api/v1" #Catalyst-API URLs -> autoresolve into ${catalystAPI}
_lightModeParametersURL="https://uptime.live/data/cardano/parms/preprod-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
_ccMemberColdHashNames='{
"scriptHash-5098dfd0deba725fadd692198fc33ee959fbe7e6edf1b5a695e06e61": "CAC",
"scriptHash-5a71f17f4ce4c1c0be053575d717ade6ad8a1d5453d02a65ce40d4b1": "ECC",
"scriptHash-6095e643ea6f1cccb6e463ec34349026b3a48621aac5d512655ab1bf": "CF",
"scriptHash-94c0de47e7ae32e3f7234ada5cf976506b68e3bb88c54dc53b4ba984": "ICC"
"scriptHash-94f51c795a6c11adb9c1e30f0b6def4230cbd0b8bc800098e2d2307b": "Emurgo",
"scriptHash-a6a5e006fd4e8f51062dc431362369b2a43140abced8aa2ff2256d7b": "IOG",
"scriptHash-2f4a6c6f098e20ee4bfd5b39942c164575f8ceb348e754df5d0ec04f": "CJC"
}'
;;


Expand All @@ -224,6 +242,7 @@ case "${network,,}" in
_lightModeParametersURL="https://uptime.live/data/cardano/parms/preview-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
_guardrailScriptUTXO="f3f61635034140e6cec495a1c69ce85b22690e65ab9553ef408d524f58183649#0"
_guardrailScriptSize=2132
_ccMemberColdHashNames='{}'
;;


Expand All @@ -239,6 +258,7 @@ case "${network,,}" in
_adahandleAPI=
_catalystAPI= #Catalyst-API URLs -> autoresolve into ${catalystAPI}
_lightModeParametersURL= #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
_ccMemberColdHashNames='{}'
;;


Expand All @@ -256,6 +276,7 @@ case "${network,,}" in
_lightModeParametersURL="https://uptime.live/data/cardano/parms/sanchonet-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
# _guardrailScriptUTXO="8b9163fa38914b45470a5426c27939cfb77628f0c54d08b0b61b9905c2cbfc2b#0"
_guardrailScriptSize=2132
_ccMemberColdHashNames='{}'
;;


Expand All @@ -271,6 +292,7 @@ case "${network,,}" in
_adahandleAPI=
_catalystAPI= #Catalyst-API URLs -> autoresolve into ${catalystAPI}
_lightModeParametersURL= #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
_ccMemberColdHashNames='{}'
;;

esac
Expand All @@ -289,6 +311,7 @@ catalystAPI=${catalystAPI:-"${_catalystAPI}"}
lightModeParametersURL=${lightModeParametersURL:-"${_lightModeParametersURL}"}
guardrailScriptUTXO=${guardrailScriptUTXO:-"${_guardrailScriptUTXO}"}
guardrailScriptSize=${guardrailScriptSize:-"${_guardrailScriptSize}"}
ccMemberColdHashNames=${ccMemberColdHashNames:-"${_ccMemberColdHashNames}"}


#Check about the / at the end of the URLs
Expand All @@ -303,7 +326,7 @@ if [[ "${magicparam}" == "" || ${addrformat} == "" || ${byronToShelleyEpochs} =

#Don't allow to overwrite the needed Versions, so we set it after the overwrite part
minCliVersion="10.2.0" #minimum allowed cli version for this script-collection version
maxCliVersion="99.99.9" #maximum allowed cli version, 99.99.9 = no limit so far
maxCliVersion="10.3.99" #maximum allowed cli version, 99.99.9 = no limit so far
minNodeVersion="10.1.4" #minimum allowed node version for this script-collection version
maxNodeVersion="99.99.9" #maximum allowed node version, 99.99.9 = no limit so far
minLedgerCardanoAppVersion=${ENV_MINLEDGERCARDANOAPPVERSION:-"7.1.1"} #minimum version for the cardano-app on the Ledger HW-Wallet
Expand Down
53 changes: 47 additions & 6 deletions cardano/mainnet/24a_genVote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,12 @@ case ${workMode} in
poolPowerTotal=$(jq -r '[ .[][1] ] | add // 0' <<< "${poolStakeDistributionJSON}" 2> /dev/null)

#Get the committee power distribution -> Generate an Array of CommitteeHotHashes and there Votingpower (MembersAuthorized count as 1, all others like MemberNotAuthorized or MemberResigned count as 0)
committeePowerDistributionJSON=$(${cardanocli} ${cliEra} query committee-state | jq -r "[ .committee | ( to_entries[] | select(.value.hotCredsAuthStatus.tag == \"MemberAuthorized\" and .value.status == \"Active\") | [ \"\(.value.hotCredsAuthStatus.contents |keys[0])-\(.value.hotCredsAuthStatus.contents.keyHash // .value.hotCredsAuthStatus.contents.scriptHash)\", 1 ] ) ]" 2> /dev/null)
committeeStateJSON=$(${cardanocli} ${cliEra} query committee-state | jq -r "[ .committee | to_entries[] | select(.value.hotCredsAuthStatus.tag == \"MemberAuthorized\" and .value.status == \"Active\") ]" 2> /dev/null)
committeePowerDistributionJSON=$(jq -r "[ ( .[] | [ \"\(.value.hotCredsAuthStatus.contents |keys[0])-\(.value.hotCredsAuthStatus.contents.keyHash // .value.hotCredsAuthStatus.contents.scriptHash)\", 1 ] ) ]" <<< "${committeeStateJSON}" 2> /dev/null)
if [[ ${committeePowerDistributionJSON} == "" ]]; then committeePowerDistributionJSON="[]"; fi #in case there is no committee yet

#Get the total committee power -> only authorized and active keys in the list, so the totalPower is just the length of the array
committeePowerTotal=$(jq -r "length // 0" <<< ${committeePowerDistributionJSON} 2> /dev/null)
committeePowerTotal=$(jq -r "length // 0" <<< ${committeeStateJSON} 2> /dev/null)

#Get the current committee member voting threshold
{ read committeePowerThreshold; } <<< $(jq -r '"\(.committee.threshold)" // 0' <<< ${govStateJSON} 2> /dev/null)
Expand All @@ -320,14 +321,21 @@ case ${workMode} in
"number")
committeePowerThreshold=$(bc <<< "scale=2; 100.00 * ${committeePowerThreshold}") #scale it to 0.00-100.00%
;;

*) #if any other type, throw an error
echo -e "\e[35mERROR - Could not handle committeeThresholdType = ${committeeThresholdType}\e[0m\n"; exit 1
;;
esac

#Generate the JSON of all committeeHotHashes and there names, depending on the committeeColdHashes
ccMemberHotHashNamesJSON=$(jq -r "[ .[] | { \"\(.value.hotCredsAuthStatus.contents | keys[0])-\(.value.hotCredsAuthStatus.contents | flatten[0])\": (${ccMemberColdHashNames}[.key]) } ] | reduce .[] as \$o ({}; . * \$o)" <<< ${committeeStateJSON} 2> /dev/null)

#Get the current protocolParameters for the dRep and pool voting thresholds
protocolParametersJSON=$(${cardanocli} ${cliEra} query protocol-parameters)
;;


"light")
"light")
voterID="" #disable filtering
showProcessAnimation "Query Governance-Action Info-LightMode: " &
actionStateJSON=$(queryLight_actionState "${govActionUTXO}" "${govActionIdx}" "${voterID}")
Expand All @@ -336,21 +344,37 @@ case ${workMode} in
#strip the outter array for now
actionStateJSON=$(jq -r ".[]" 2> /dev/null <<< "${actionStateJSON}")

#Get the committeeState -> only use active and authorized members -> use it to generate the CC names for hotHashes
showProcessAnimation "Query Committee-State LightMode: " &
committeeStateLightJSON=$(queryLight_committeeState "")
if [ $? -ne 0 ]; then stopProcessAnimation; echo -e "\e[35mERROR - ${committeeStateLightJSON}\e[0m\n"; exit $?; else stopProcessAnimation; fi;
committeeStateJSON=$(jq -r "[ .committee | to_entries[] | select(.value.hotCredsAuthStatus.tag == \"MemberAuthorized\" and .value.status == \"Active\") ]" <<< "${committeeStateLightJSON}" 2> /dev/null)
if [ $? -ne 0 ]; then stopProcessAnimation; echo -e "\e[35mERROR - Could not generate committeeStateJSON\e[0m\n"; exit $?; else stopProcessAnimation; fi;
#Generate the JSON of all committeeHotHashes and there names, depending on the committeeColdHashes
ccMemberHotHashNamesJSON=$(jq -r "[ .[] | { \"\(.value.hotCredsAuthStatus.contents | keys[0])-\(.value.hotCredsAuthStatus.contents | flatten[0])\": (${ccMemberColdHashNames}[.key]) } ] | reduce .[] as \$o ({}; . * \$o)" <<< ${committeeStateJSON} 2> /dev/null)

#Get the current protocolParameters for the dRep, pool and committee voting thresholds
protocolParametersJSON=${lightModeParametersJSON} #lightmode

#Get the total committee power -> only authorized and active keys in the list, so the totalPower is just the length of the array
committeePowerTotal=$(jq -r "length // 0" <<< ${committeeStateJSON} 2> /dev/null)

#Get the current committee member count and voting threshold
{ read committeePowerTotal; read committeeThreshold; } <<< $(jq -r '(.committee.members | length) // 0, "\(.committee.threshold)" // 0' 2> /dev/null <<< "${protocolParametersJSON}")
committeeThreshold=$(jq -r '"\(.threshold)" // 0' 2> /dev/null <<< "${committeeStateLightJSON}")
committeeThresholdType=$(jq -r "type" <<< "${committeeThreshold}" 2> /dev/null)
case ${committeeThresholdType} in
"object")
{ read numerator; read denominator; } <<< $(jq -r '.numerator // "-", .denominator // "-"' <<< "${committeeThreshold}")
committeePowerThreshold=$(bc <<< "scale=2; 100 * ${numerator} / ${denominator}")
;;
;;

"number")
committeePowerThreshold=$(bc <<< "scale=2; 100 * ${committeeThreshold}")
;;
;;

*) #if any other type, throw an error
echo -e "\e[35mERROR - Could not handle committeeThresholdType = ${committeeThresholdType}\e[0m\n"; exit 1
;;
esac
;;

Expand Down Expand Up @@ -497,6 +521,11 @@ do
.[0].pool_yes_vote_power // 0,
.[0].pool_active_no_vote_power // 0,
.[0].pool_active_abstain_vote_power // 0 ' <<< ${actionVotesSummaryJSON})

#Generate lists with the committee hashes that have voted yes, no or abstain.
{ read committeeHashYes; read committeeHashNo; read committeeHashAbstain; } <<< $(jq -r '"\(.committeeVotes | with_entries(select(.value | contains("Yes"))) | keys )",
"\(.committeeVotes | with_entries(select(.value | contains("No"))) | keys)",
"\(.committeeVotes | with_entries(select(.value | contains("Abstain"))) | keys)"' <<< ${actionEntry} 2> /dev/null)
;;
esac

Expand Down Expand Up @@ -926,6 +955,18 @@ do
else
printf "\e[90m%13s\e[90m │ \e[90m%10s\e[90m │ \e[90m%10s\e[90m │ \e[90m%10s\e[90m │ \e[90m%10s\e[90m │ \e[90m%7s %%\e[90m │ \e[90m%6s %%\e[90m │ %b \e[0m\n" "Committee" "-" "-" "-" "" "-" "-"
fi

#show CC names that have voted -> replace the hotHash with the name from the ccMemberHotHashNames-JSON, convert linebreaks into spaces (make it a line), wordwrap the line, trimstrim each line, make it an array
readarray -t committeeNamesYes <<< $(jq -r ".[] | ${ccMemberHotHashNamesJSON}[.] // \"Unknown?\"" <<< "${committeeHashYes}" 2> /dev/null | tr '\n' ' ' | fold -w 11 -s | awk '{$1=$1};1')
readarray -t committeeNamesNo <<< $(jq -r ".[] | ${ccMemberHotHashNamesJSON}[.] // \"Unknown?\"" <<< "${committeeHashNo}" 2> /dev/null | tr '\n' ' ' | fold -w 11 -s | awk '{$1=$1};1')
readarray -t committeeNamesAbstain <<< $(jq -r ".[] | ${ccMemberHotHashNamesJSON}[.] // \"Unknown?\"" <<< "${committeeHashAbstain}" 2> /dev/null | tr '\n' ' ' | fold -w 11 -s | awk '{$1=$1};1')
tmpCnt2=0
while [[ "${committeeNamesYes[${tmpCnt2}]}${committeeNamesNo[${tmpCnt2}]}${committeeNamesAbstain[${tmpCnt2}]}" != "" ]]; do
printf "\e[94m%13s\e[90m │ \e[32m%10s\e[90m │ \e[91m%10s\e[90m │ \e[33m%10s\e[90m │ \e[90m%10s\e[90m │ \e[0m%7s \e[90m │ \e[97m%6s \e[90m │ \e[0m\n" "" "${committeeNamesYes[${tmpCnt2}]}" "${committeeNamesNo[${tmpCnt2}]}" "${committeeNamesAbstain[${tmpCnt2}]}" "" "" ""
tmpCnt2=$(( ${tmpCnt2} + 1 ))
done
unset committeeNamesYes committeeNamesNo committeeNamesAbstain tmpCnt2

printf "\e[90m──────────────┴────────────┴────────────┴────────────┴────────────┴───────────┴──────────┼────────\e[0m\n"
case "${totalAccept}" in
*"N/A"*) totalAcceptIcon="N/A";;
Expand Down
Loading

0 comments on commit 46459c7

Please sign in to comment.