-
Notifications
You must be signed in to change notification settings - Fork 1
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
SV: Easy way to recongnize pending votes #65
Comments
Fwiw I think a Prometheus metric would work for a lot of folks as well |
May work for some. We'd rather not use system operations tooling for business related features. |
The following script can be used as a temporary semi-manual solution #!/usr/bin/env bash
set -euo pipefail
curl_auth() {
[[ -z ${SV_AUTH-} ]] && read -srp "SV_AUTH: " SV_AUTH && { echo; echo; } >&2
curl -H "Authorization: $SV_AUTH" "$@"
}
rules_diff() {
local dso=$1
local voterequests=$2
local voterequests_tag=$3
local voterequests_action_tag=$4
local voterequests_action_tag_path=$5
local dso_data_path=$6
local voterequests_data_path=$7
local voterequest_indexes; voterequest_indexes=(
$(echo "$voterequests" |
jq --arg tag "$voterequests_tag" --arg action_tag "$voterequests_action_tag" "
.dso_rules_vote_requests
| map(.payload.action | .tag == \$tag and .value$voterequests_action_tag_path == \$action_tag)
| indices(true)[]
"
)
)
echo "Found ${#voterequest_indexes[@]} vote requests for $voterequests_tag with action $voterequests_action_tag"
echo
local svs_count; svs_count=$(echo "$dso" | jq '.dso_rules.contract.payload.svs | length')
local config; config=$(echo "$dso" | jq -S "$dso_data_path")
local request_data config_new requester tracking_cid
for i in "${voterequest_indexes[@]}"; do
request_data=$(echo "$voterequests" | jq -S --arg i "$i" '.dso_rules_vote_requests[$i | tonumber]')
votes_count=$(echo "$request_data" | jq -r '.payload.votes | length')
config_new=$(echo "$request_data" | jq -r ".payload.action.value$voterequests_data_path")
requester=$(echo "$request_data" | jq -r '.payload.requester')
vote_before=$(echo "$request_data" | jq -r '.payload.voteBefore')
reason_body=$(echo "$request_data" | jq -r '.payload.reason.body')
reason_url=$(echo "$request_data" | jq -r '.payload.reason.url')
tracking_cid=$(echo "$request_data" | jq -r '.payload.trackingCid // .contract_id')
echo "Diff for vote request id $i by $requester"
echo "Tracking Cid: $tracking_cid"
echo "Expires At: $vote_before"
echo "Votes: $votes_count / $svs_count"
echo "Summary: $reason_body $reason_url"
diff --color --label current --label new -u <(echo "$config") <(echo "$config_new") || true
echo
done
}
main() {
local sv_url; [[ -z ${SV_URL-} ]] && read -rp "SV_URL: " sv_url || sv_url=$SV_URL
local dso_url="$sv_url/api/sv/v0/dso"
echo "Fetching current configuration from $dso_url ..."
local dso; dso=$(curl -fsS "$dso_url")
echo
local voterequests_url="$sv_url/api/sv/v0/admin/sv/voterequests"
echo "Fetching vote requests from $voterequests_url ..."
local voterequests; voterequests=$(curl_auth -fsS "$voterequests_url")
echo
echo "Total vote requests in progress: $(echo "$voterequests" | jq '.dso_rules_vote_requests | length')"
echo
rules_diff "$dso" "$voterequests" \
ARC_AmuletRules CRARC_AddFutureAmuletConfigSchedule \
'.amuletRulesAction.tag' '.amulet_rules.contract.payload.configSchedule.initialValue' '.amuletRulesAction.value.newScheduleItem._2'
rules_diff "$dso" "$voterequests" \
ARC_DsoRules SRARC_SetConfig \
'.dsoAction.tag' '.dso_rules.contract.payload.config' '.dsoAction.value.newConfig'
rules_diff "$dso" "$voterequests" \
ARC_DsoRules SRARC_GrantFeaturedAppRight \
'.dsoAction.tag' 'null' '.dsoAction.value'
rules_diff "$dso" "$voterequests" \
ARC_DsoRules SRARC_OffboardSv \
'.dsoAction.tag' 'null' '.dsoAction.value'
rules_diff "$dso" "$voterequests" \
ARC_DsoRules SRARC_UpdateSvRewardWeight \
'.dsoAction.tag' 'null' '.dsoAction.value'
}
main "$@" |
A UX-based solution to this issue is in the current UX plan for Digital Asset CN engineering |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SV user can't easily recognize new pending votes which require actions. Possible solutions:
The text was updated successfully, but these errors were encountered: