Fix(rewards): apply collateral in repo allocation#1272
Conversation
anderdc
left a comment
There was a problem hiding this comment.
Premise is correct — collateral currently has no effect on emissions; blend_emission_pools is the only weight input and it never reads the collateral-adjusted score. But the fix re-derives that score instead of reading the one finalization already computed.
finalize_miner_scores() stores the collateral-adjusted, clamped, per-repo PR score on evaluation.repo_evaluations[repo].total_score (scoring.py:166 — max(0.0, total_score - total_collateral_score)). _collect_repo_pr_scores now re-sums merged_prs[].earned_score minus open_prs[].collateral_score and re-clamps — a second copy of that formula. That is the divergence #1266 reports, recreated one layer down: the next time collateral handling changes in scoring.py, the allocator silently drifts again.
Blocker — gittensor/validator/emission_allocation.py, _collect_repo_pr_scores (lines 121-127): use evaluation.repo_evaluations.get(repo_name) and its .total_score instead of re-summing and re-clamping. It is already collateral-adjusted, clamped, repo-local, and PR-only (issue discovery writes separate repo_eval fields), and finalize_miner_scores() runs before blend_emission_pools(), so it is populated.
Blocker — tests/validator/test_blend_emission_pools.py: populate repo_evaluations on the fixtures (or run finalize_miner_scores() first, as #1266's repro describes) so the regression exercises the real finalize -> blend path.
…po-allocation-collateral
5e9a8dc to
ab01ffc
Compare
|
Hi. @anderdc Could you plz review my PR again? |
Summary
Applies finalized open-PR collateral when collecting repo-local PR allocation scores, so contributors with collateral are allocated from
merged earned_score - same-repo collateral_scoreclamped at zero.This keeps no-collateral allocation proportional to merged PR scores while making repo-bounded emission allocation agree with the collateral-adjusted scoring output.
Related Issues
Fixes #1266
Type of Change
Testing
Checklist