Skip to content

Propagate price-based emissions and locked transfer flags - devnet-ready#2785

Open
gztensor wants to merge 16 commits into
devnet-readyfrom
feat/propagate-pr-2780-devnet-ready
Open

Propagate price-based emissions and locked transfer flags - devnet-ready#2785
gztensor wants to merge 16 commits into
devnet-readyfrom
feat/propagate-pr-2780-devnet-ready

Conversation

@gztensor

@gztensor gztensor commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

Back-propagates the locked-alpha transfer flag and price-based emission updates to devnet-ready.

What changed

  • Adds AccountFlags storage and the set_reject_locked_alpha extrinsic so coldkeys can opt in or out of receiving locked alpha.
  • Blocks nonzero locked-alpha receipt during stake transfers and coldkey lock swaps unless the destination coldkey has opted in.
  • Adds MinerBurned accounting for the proportion of miner incentive emission withheld from miners because it was directed to subnet owner or immune hotkeys.
  • Reweights subnet emission shares by root_proportion * price * (1 - miner_burned) and falls back to price shares if all combined weights are zero.
  • Clears MinerBurned on subnet dissolution and updates weights/tests for the new storage reads.

Behavioral impact

Coldkeys reject incoming locked alpha by default. A coldkey can call set_reject_locked_alpha(false) to accept locked alpha from stake transfers or coldkey swaps, and set_reject_locked_alpha(true) to return to the default rejection behavior.

Subnets that withhold miner incentive emission through owner or immune hotkeys receive proportionally less future chain emission, with that emission reallocated among eligible subnets.

Spec version / migration

This changes runtime behavior and requires a testnet runtime spec_version bump. The Auditor auto-fix bumped runtime/src/lib.rs from 421 to 422. The new storage maps use defaults and do not require an explicit storage migration.

Testing

The PR adds coverage for account flag defaults and setter behavior, locked-alpha rejection/allowance on stake transfer and coldkey swap paths, subnet dissolve cleanup, and emission-share reweighting for no burn, partial burn, full burn, all-full-burn fallback, and root-proportion weighting.

gztensor and others added 13 commits June 22, 2026 22:07
- Add a per-subnet MinerBurned storage holding the proportion (0..1) of each
  tempo's miner (incentive) emission that was burned during emission
  distribution because the recipient hotkey is owned by the subnet owner.
- Weight price-based emission shares by (1 - miner_burned) and renormalize, so
  subnets that burn more of their miner emission receive proportionally less
  chain emission (reallocated toward non-burning subnets).

Co-authored-by: Cursor <cursoragent@cursor.com>
- Count miner emission withheld via an owner/immune hotkey toward the burned
  proportion whether it is recycled or burned, so the emission penalty is
  independent of a subnet's RecycleOrBurn config (no Recycle bypass, no
  unique penalty for the unset default).
- Clear MinerBurned on subnet removal so a deregistered subnet leaves no stale
  proportion; extend dissolve cleanup test to cover it.
- Add active tests for the price-share reweight by (1 - miner_burned):
  no-burn, partial burn, full burn, and all-full-burn fallback to price shares.

Co-authored-by: Cursor <cursoragent@cursor.com>
Emission share is now proportional to root_proportion * price * (1 - miner_burned),
renormalized. Multiplying by root_proportion (which shrinks as a subnet's alpha
issuance grows) reallocates chain emission away from older subnets toward newer
ones, easing entrance for new subnets. Falls back to unweighted price shares when
the combined weight is zero (e.g. no root stake).

Adds get_shares tests: no-burn, partial/full burn, all-full-burn fallback, and
root_proportion favoring newer subnets.

Co-authored-by: Cursor <cursoragent@cursor.com>
Price-based emissions with miner-burn scaling (+ locked transfer flags)
- Add a per-subnet MinerBurned storage holding the proportion (0..1) of each
  tempo's miner (incentive) emission that was burned during emission
  distribution because the recipient hotkey is owned by the subnet owner.
- Weight price-based emission shares by (1 - miner_burned) and renormalize, so
  subnets that burn more of their miner emission receive proportionally less
  chain emission (reallocated toward non-burning subnets).

Co-authored-by: Cursor <cursoragent@cursor.com>
- Count miner emission withheld via an owner/immune hotkey toward the burned
  proportion whether it is recycled or burned, so the emission penalty is
  independent of a subnet's RecycleOrBurn config (no Recycle bypass, no
  unique penalty for the unset default).
- Clear MinerBurned on subnet removal so a deregistered subnet leaves no stale
  proportion; extend dissolve cleanup test to cover it.
- Add active tests for the price-share reweight by (1 - miner_burned):
  no-burn, partial burn, full burn, and all-full-burn fallback to price shares.

Co-authored-by: Cursor <cursoragent@cursor.com>
Emission share is now proportional to root_proportion * price * (1 - miner_burned),
renormalized. Multiplying by root_proportion (which shrinks as a subnet's alpha
issuance grows) reallocates chain emission away from older subnets toward newer
ones, easing entrance for new subnets. Falls back to unweighted price shares when
the combined weight is zero (e.g. no root stake).

Adds get_shares tests: no-burn, partial/full burn, all-full-burn fallback, and
root_proportion favoring newer subnets.

Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts:
#	pallets/subtensor/src/macros/dispatches.rs
#	pallets/subtensor/src/macros/errors.rs
#	pallets/subtensor/src/staking/lock.rs
#	pallets/subtensor/src/tests/coinbase.rs
@gztensor gztensor self-assigned this Jun 23, 2026
@gztensor gztensor added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: VULNERABLE

BASELINE scrutiny: author has write permission, an account older than two years, and substantial subtensor PR history; branch feat/propagate-pr-2780-devnet-ready -> devnet-ready.

Findings

Sev File Finding
HIGH runtime/src/lib.rs:237 Runtime behavior changes without a spec_version bump (off-diff)

Other findings

  • [HIGH] Runtime behavior changes without a spec_version bump (runtime/src/lib.rs:237) — This PR adds new runtime storage (AccountFlags, MinerBurned), a new dispatchable (set_reject_locked_alpha), locked-alpha transfer rejection logic, and new emission-share weighting, but runtime/src/lib.rs is unchanged in the PR diff and both base 37c7dde0... and head 33902413... still report spec_version: 421 at runtime/src/lib.rs:237. Runtime-affecting changes must bump spec_version; otherwise upgraded native runtimes can have the same spec version as the on-chain Wasm while containing different logic, which is a consensus-safety risk. Bump spec_version for this runtime change.

Prior-comment reconciliation

  • 54996eed: not addressed — The current diff still does not modify runtime/src/lib.rs, and both the PR base and head have spec_version: 421.

Conclusion

The diff looks legitimate and I found no evidence of a malicious backdoor, dependency attack, .github tampering, panic source, or origin-check bypass. It remains vulnerable because runtime-affecting pallet changes are still present while runtime/src/lib.rs keeps spec_version: 421 in both base and head.


📜 Previous run (superseded)
Sev File Finding Status
HIGH runtime/src/lib.rs:237 Runtime behavior changes without a spec_version bump ➡️ Carried forward to current findings
The current diff still does not modify runtime/src/lib.rs, and both the PR base and head have spec_version: 421.

# 🔍 AI Review — Auditor (domain review) has not yet run on this PR.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: VULNERABLE

sam0x17
sam0x17 previously approved these changes Jun 23, 2026
gztensor added 2 commits June 23, 2026 18:56
# Conflicts:
#	pallets/admin-utils/src/weights.rs
#	pallets/proxy/src/weights.rs
#	pallets/subtensor/src/weights.rs
#	pallets/utility/src/weights.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: VULNERABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants