diff --git a/.github/workflows/v2-apply-scoring.yml b/.github/workflows/v2-apply-scoring.yml index 342af6df..5ea2c4f1 100644 --- a/.github/workflows/v2-apply-scoring.yml +++ b/.github/workflows/v2-apply-scoring.yml @@ -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) diff --git a/.github/workflows/v2-prepare-unstakes.yml b/.github/workflows/v2-prepare-unstakes.yml index 18605b55..df06c83f 100644 --- a/.github/workflows/v2-prepare-unstakes.yml +++ b/.github/workflows/v2-prepare-unstakes.yml @@ -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: |