Add rank-pinned emission gate bar (EmissionBarRank) as alternative to q-mass quantile - #3014
Add rank-pinned emission gate bar (EmissionBarRank) as alternative to q-mass quantile#3014unarbos wants to merge 4 commits into
Conversation
A fixed EmissionBarQuantile drifts as the demand distribution shifts: q=0.75 was tuned to land the bar at rank 32 but already crosses at rank 28, and deep in the tail the valid q band for a target rank is only ~0.003 wide. When the policy intent is "top N subnets", express it directly: EmissionBarRank (N > 0) pins theta to the Nth-largest positive demand share, self-adjusting as the distribution moves. Default 0 keeps quantile mode; no behavior change until root sets the rank via sudo_set_emission_bar_rank. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🛡️ AI Review — Skeptic (security review)VERDICT: SAFE MEDIUM scrutiny: 4-month-old account with repository write access and extensive substantive merged history; disclosed Cursor/review-bot commits; no Gittensor association found; feat/emission-bar-rank -> main. Static analysis found rank selection bounded by the existing share set, without panic-prone indexing or unchecked arithmetic. The setter remains root-authorized, migration accounting is bounded, the runtime version is bumped, and no dependency, CI, or AI-review trust-boundary files changed. FindingsNo findings. ConclusionNo malicious behavior or security vulnerability was identified in the current PR delta. 🔍 AI Review — Auditor (domain review)VERDICT: 👍 UNKNOWN Gittensor association; established contributor with repository write access and extensive merged history. The prior coverage gap is addressed by dedicated tests for rank selection, zero-share exclusion, ties, fewer-than-N fallback, default configuration, setter-triggered recomputation, and migration idempotence. The required PR #3013 targets the same rank-64 policy through a fixed quantile. This PR is the better candidate; recommend closing #3013 because rank selection directly expresses the policy and adapts to distribution changes. Targeted tests could not be rerun because rustup attempted to write beneath the read-only runner home; static inspection confirms the added tests exercise the previously uncovered branch. FindingsNo findings. Prior-comment reconciliation
ConclusionThe implementation matches its description and now has appropriate boundary and migration coverage. No substantive issues remain. 📜 Previous run (superseded)
|
| if cumulative >= q { | ||
| break; | ||
| let rank = EmissionBarRank::<T>::get(); | ||
| let theta = if rank > 0 { |
There was a problem hiding this comment.
[HIGH] Add tests for the new economic rank path
This introduces a new emission-selection formula without dedicated tests. Existing gate tests only exercise the unchanged quantile path. Add coverage proving the selected theta for rank 1 and an interior rank, the fallback when rank exceeds the number of positive shares, zero-share handling, ties at the boundary, rank 0 compatibility, and that the root setter stores the rank and invalidates EmissionGateBar. Economic logic requires explicit boundary coverage.
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👎 |
Rank mode activates at upgrade: theta pins to the 64th-largest demand share instead of the q=0.75 quantile crossing (rank 28 on the current distribution and drifting tighter as emissions concentrate price shares). Tests that assert quantile gate math now pin EmissionBarRank to 0 explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
| if cumulative >= q { | ||
| break; | ||
| let rank = EmissionBarRank::<T>::get(); | ||
| let theta = if rank > 0 { |
There was a problem hiding this comment.
[HIGH] Add tests for the new economic rank path
This remains untested: the added test changes all explicitly set EmissionBarRank to 0, so none execute this branch even though rank 64 is now the runtime default. Add focused coverage proving selection at rank 1 and an interior rank, fallback when rank exceeds the positive-share count, exclusion of zero shares, and recomputation after sudo_set_emission_bar_rank clears the cached bar. This changes emission allocation at upgrade and requires boundary tests.
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👎 |
…indings - migrate_reset_emission_gate_bar kills the stale quantile theta so the rank-64 bar applies from the first recompute after the upgrade instead of waiting out the 360-block cadence - cover the rank path: default-64 guard, Nth-largest selection, zero-share exclusion, ties at the bar, fewer-than-N fallback (the live mainnet shape), and setter kill-and-recompute mid-interval - add the three emission gate setters (quantile, rank, exponent) to the RootConfigCalls proxy group; the first two were missed in v440 and have been failing call-group coverage on every PR since - regenerate SDK wire layer for spec 441 with sudo_set_emission_bar_rank and the EmissionBarRank storage item; mark the gate setters raw-only Co-authored-by: Cursor <cursoragent@cursor.com>
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👍 |
|
Like this overall, think having buybacks capped at unburned miner emissions is better implementation for similiar effect |
|
here updated PR for capping chainbuys at unburned miner emissions - #3017 (comment) |
Summary
EmissionBarRank(u16, default 64): the emission gate bar theta is pinned to the Nth-largest positive demand share instead of being derived from theEmissionBarQuantileq-mass crossing. Setting 0 restores quantile mode.migrate_reset_emission_gate_bar) that kills the stale quantile-derived bar means the rank-64 bar applies from the first recompute after the runtime upgrade — no 360-block cadence delay, no separate sudo call.sudo_set_emission_bar_rank(call index 102) in admin-utils, with weights and benchmark. The setter killsEmissionGateBarso a changed rank takes effect on the next block, same as the quantile setter.RootConfigCallsproxy group (the first two were missed in v440 and have been failing call-group coverage on every PR since), and the Python SDK wire layer regenerated for spec 441.Motivation
A fixed q approximates a "top N" policy but decays as the demand distribution shifts:
Rank mode expresses "the top N subnets carry the gate midpoint" directly and self-adjusts. Everything downstream is untouched: Hill gate shape,
h, the 360-block recompute cadence, and the underflow fallback.Expected effect at N=64, h=3 against live Finney state: theta = 0.00339, gate passes 0.927 at rank 32, 0.500 at rank 64, 0.087 at rank 80; post-gate emission mass top4 = 32.5%, top32 = 84.9%, top64 = 98.5%. Compared to today's rank-28 bar, this keeps concentration at the top while giving the 33-64 band a real gradient to climb.
If fewer than N subnets have positive demand, theta falls back to the smallest positive share so emissions are never stranded.
Test plan
tests/subnet_emissions.rs: default-64 guard, Nth-largest selection, zero-share exclusion, ties at the bar, fewer-than-N fallback (the everyone-passes path), setter kill-and-recompute mid-intervaltest_migrate_reset_emission_gate_bar): stale bar killed, idempotent on second runpallet-subtensorsuite green (1332+ tests); quantile-mode tests pinEmissionBarRank = 0explicitlyproxy_filtersruntime tests green includingall_call_groups_cover_runtime_call_metadatacodegen.check --coverage,--names, pytest (984 passed)cargo check -p pallet-subtensor -p pallet-admin-utils --features runtime-benchmarks