Skip to content

Conversation

@Dairus01
Copy link

Fix SubnetAlphaOut burn discrepancy

Fixes #2274

Problem Description

The SubnetAlphaOut storage value has been incorrectly updated since dTAO launch, causing accounting discrepancies between issued and burned alpha. This breaks the fundamental accounting equation:

total_issuance = subnet_alpha_out + subnet_alpha_in + subnet_alpha_in_provided

burn = subnet_alpha_out - SUM(total_hotkey_alpha)

Burning happens on chain in two ways:

  1. The burn extrinsic: Reduces a coldkey's stake without properly reducing subnet_alpha_out
  2. Incentive distribution: Increases subnet_alpha_out normally in run_coinbase.rs but doesn't give the alpha to keys owned by the subnet

Both scenarios create a discrepancy between the accounting storage of owned alpha on a subnet (subnet_alpha_out) and the actual stake owned by accounts (sum of total_hotkey_alpha). This has resulted in:

  • 6 subnets showing negative burn amounts (at block 6874108)
  • Root network accounting off by ~562k TAO
  • Incorrect total issuance calculations across the network

Evidence (Block 6874108)

{
  "netuid": 0,
  "diff": "-561931452490774"
},
{
  "netuid":  17,
  "diff":  "-5409469998121"
},
{
  "netuid": 32,
  "diff": "-3529669489799"
},
{
  "netuid": 55,
  "diff": "-2585186709697"
}

Solution

This PR corrects the SubnetAlphaOut updates to ensure proper accounting during:

  • Burn operations: Now correctly decreases SubnetAlphaOut when stake is burned
  • Stake decrease operations: Ensures SubnetAlphaOut accurately reflects the actual staked alpha

Changes Made

  • Modified burn extrinsic to properly update SubnetAlphaOut
  • Fixed BalanceOps::decrease_stake to maintain consistency between stake and SubnetAlphaOut
  • Added comprehensive regression tests to verify the fixes

Tests Added

Two regression tests have been added in pallets/subtensor/src/tests/regression_issue_2274.rs:

  1. test_burn_extrinsic_updates_subnet_alpha_out: Verifies that burning stake correctly reduces SubnetAlphaOut by the burned amount
  2. test_balance_ops_decrease_stake_consistency: Ensures that SubnetAlphaOut remains consistent when stake decrease operations are performed, including edge cases

Impact

This fix ensures:

  • ✅ Correct burn accounting across all subnets
  • ✅ Accurate total issuance calculations
  • ✅ Proper tracking of alpha distribution
  • ✅ Alpha halvenings will occur at the correct time
  • ✅ Max supply of 21M tokens will be respected

Contribution by Gittensor, learn more at https://gittensor.io/

sam0x17 and others added 2 commits December 19, 2025 15:42
Correct SubnetAlphaOut updates during burn and stake decrease operations
to ensure accurate tracking of burned tokens.

Fixes opentensor#2274
Copilot AI review requested due to automatic review settings December 31, 2025 19:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical accounting bug in subnet alpha tracking that has resulted in negative burn amounts on multiple subnets (including ~562k TAO discrepancy on root network). The issue arose because SubnetAlphaOut was not being properly decremented when alpha was burned through the burn extrinsic and the BalanceOps::decrease_stake interface.

Key Changes:

  • Implemented the burn_subnet_alpha function to properly decrement SubnetAlphaOut using saturating_sub
  • Fixed BalanceOps::decrease_stake to use the actual decreased amount (not requested amount) when updating SubnetAlphaOut
  • Added comprehensive regression tests to verify the fixes

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pallets/subtensor/src/staking/helpers.rs Implemented burn_subnet_alpha function to decrement SubnetAlphaOut when alpha is burned (previously was a no-op)
pallets/subtensor/src/lib.rs Fixed decrease_stake to call decrease_stake_for_hotkey_and_coldkey_on_subnet first and use the actual returned amount when updating SubnetAlphaOut
pallets/subtensor/src/tests/regression_issue_2274.rs Added two regression tests: one verifying burn extrinsic updates SubnetAlphaOut, another testing edge case of decreasing more stake than available
pallets/subtensor/src/tests/recycle_alpha.rs Updated existing test assertions to expect SubnetAlphaOut to decrease after burns (previously incorrectly expected no change)
pallets/subtensor/src/tests/mod.rs Added module declaration for new regression test file

@Dairus01
Copy link
Author

@l0r1s @bdmason @thewhaleking @basfroman

Happy Holidays, trust you are doing great, Please I'd love you to review this PR, it helps solves a critical problem

Copy link
Author

@Dairus01 Dairus01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would help solve the subnet alpha out burn discrepancy

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants