Skip to content

Commit

Permalink
fix apply scores
Browse files Browse the repository at this point in the history
  • Loading branch information
butonium committed Mar 28, 2024
1 parent 5d8e25f commit c7604a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/v2-apply-scoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
scores_csv=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep scores.csv)
params_json=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep params.json)
scoring_run_ui_id=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | head -2 | tail -1 | awk -F / '{print $2}')
scoring_run_ui_id=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | head -3 | tail -1 | awk -F / '{print $2}')
epoch=$(<<<"$scoring_run_ui_id" awk -F . '{print $1}')
weightVoteCredits=$(jq '.weightVoteCredits' $params_json)
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/v2-prepare-unstakes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,21 @@ jobs:

- name: Merge unstakes
run: |
jq --slurpfile json1 "/tmp/snapshot/unstake-hints.json" --slurpfile json2 "${{ env.unstake_hints_json }}" '.[0].unstake_hints as $json1_unstakes | .[1].unstake_hints as $json2_unstakes | [$json1_unstakes[] | .hints += ($json2_unstakes[] | select(.vote_account == $json1_unstakes[].vote_account).hints) | .hints |= unique] ' <<< '{}' > "${{ env.unstake_hints_json }}"
file1="/tmp/snapshot/unstake-hints.json"
file2="${{ env.unstake_hints_json }}"
output="merged.json"
temp=$(mktemp)
accounts=$(jq -r '.unstake_hints[].vote_account' "$file1" "$file2" | sort -u)
echo '{"unstake_hints": []}' > "$output"
echo "$accounts" | while read -r account; do
[[ -z "$account" ]] && continue
hints1=$(jq -r --arg account "$account" '.unstake_hints[] | select(.vote_account == $account) | .hints[]' "$file1")
hints2=$(jq -r --arg account "$account" '.unstake_hints[] | select(.vote_account == $account) | .hints[]' "$file2")
hints_merged=$(echo -e "$hints1\n$hints2" | grep -v '^$' | sort | uniq | jq -R . | jq -s .)
validator_json=$(jq -n --arg account "$account" --argjson hints "$hints_merged" '{vote_account: $account, hints: $hints}')
jq --argjson validator "$validator_json" '.unstake_hints += [$validator]' "$output" > "$temp" && mv "$temp" "$output"
done
mv merged.json "${{ env.unstake_hints_json }}"
- name: Make a Pull Request
run: |
Expand Down

0 comments on commit c7604a1

Please sign in to comment.