Fix subnet alpha out burn discrepancy#2329
Fix subnet alpha out burn discrepancy#2329Dairus01 wants to merge 13 commits intoopentensor:devnet-readyfrom
Conversation
mainnet deploy 12/19/2025
Correct SubnetAlphaOut updates during burn and stake decrease operations to ensure accurate tracking of burned tokens. Fixes opentensor#2274
There was a problem hiding this comment.
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_alphafunction to properly decrementSubnetAlphaOutusingsaturating_sub - Fixed
BalanceOps::decrease_staketo use the actual decreased amount (not requested amount) when updatingSubnetAlphaOut - 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 |
|
@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 |
Dairus01
left a comment
There was a problem hiding this comment.
This would help solve the subnet alpha out burn discrepancy
Updated burn_subnet_alpha function to do nothing and added a TODO comment.
Fix missing newline at end of file
|
@bdmason please take a look now |
Fix SubnetAlphaOut burn discrepancy
Fixes #2274
Problem Description
The
SubnetAlphaOutstorage 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_providedburn = subnet_alpha_out - SUM(total_hotkey_alpha)Burning happens on chain in two ways:
subnet_alpha_outsubnet_alpha_outnormally inrun_coinbase.rsbut doesn't give the alpha to keys owned by the subnetBoth 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 oftotal_hotkey_alpha). This has resulted in:Evidence (Block 6874108)
{ "netuid": 0, "diff": "-561931452490774" }, { "netuid": 17, "diff": "-5409469998121" }, { "netuid": 32, "diff": "-3529669489799" }, { "netuid": 55, "diff": "-2585186709697" }Solution
This PR corrects the
SubnetAlphaOutupdates to ensure proper accounting during:SubnetAlphaOutwhen stake is burnedSubnetAlphaOutaccurately reflects the actual staked alphaChanges Made
SubnetAlphaOutBalanceOps::decrease_staketo maintain consistency between stake andSubnetAlphaOutTests Added
Two regression tests have been added in
pallets/subtensor/src/tests/regression_issue_2274.rs:test_burn_extrinsic_updates_subnet_alpha_out: Verifies that burning stake correctly reducesSubnetAlphaOutby the burned amounttest_balance_ops_decrease_stake_consistency: Ensures thatSubnetAlphaOutremains consistent when stake decrease operations are performed, including edge casesImpact
This fix ensures:
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=201190161