Skip to content

PalletId-based subnet account Ids maintain subnet TAO reserves#2524

Open
gztensor wants to merge 47 commits intodevnet-readyfrom
chore/imbalances
Open

PalletId-based subnet account Ids maintain subnet TAO reserves#2524
gztensor wants to merge 47 commits intodevnet-readyfrom
chore/imbalances

Conversation

@gztensor
Copy link
Copy Markdown
Contributor

@gztensor gztensor commented Mar 19, 2026

Description

  • Every subnet will have an account ID and the subnet swap pool reserves will be stored in subnet account balance.
  • The subnet account ID is derived from SubtensorModule account ID and does not have a private key, so no transactions may be initiated by this account.
  • Use of subnet account IDs as hotkeys for staking, registration of neurons, or as a subnet owner hotkey will be forbidden.

TAO management for subnet registration

  • When a new subnet is registered, the lock cost is transferred to the subnet account and is recorded to the SubnetLocked map for the newly registered netuid.
  • When subnet is dissolved, some of the SubnetLocked amount may be returned to the subnet owner. The owner emission TAO is excluded from the returned portion. If owner emission TAO is higher than lock cost, zero is returned for lock cost and the remainder is recycled.

Checklist:

  • Derive subnet account IDs
  • Create runtime API subnetInfoRuntimeApi::getSubnetAccountId for clients to read the subnet account IDs
  • Organize all TAO balance operations, especially creating and destroying TAO, into one place: mint_tao, burn_tao, recycle_tao, transfer_tao.
    • Cover all functions with tests
  • Migration to mint TAO stored in SubnetTAO into subnet accounts. This will make balances pallet TotalIssuance match the subtensor pallet TotalIssuance.
  • Move remove_balance_from_coldkey_account and add_balance_to_coldkey_account methods to test-only code (tests+benchmarks). Convert original TAO moving logic into transfer_tao and use it inside stake_into_subnet and untake_from_subnet.
  • Use subnet accounts for storing subnet reserves for Alpha <> TAO swaps.
  • Use ballet balances mint in get_block_emission, make it return imbalance that is consumed later in run_counbase
  • Use subnet accounts for injecting of newly minted TAO (consume imbalances) in run_coinbase.
  • Handle unspent credit (error log + recycle), error-log attempts to spend more.
  • Subnet Locks
    • Use subnet accounts for subnet locks
    • Add corresponding migration: Mint TAO locked into subnet accounts
    • In rao release (v2.0.0) the lock was burned (TotalIssuance reduction), in the subsequent migration migrate_restore_subnet_locked we restored locks into SubnetLocked, but did not increase the TotalIssuance back. So, in this PR we will increase subtensor pallet TotalIssuance by total of SubnetLocked update in migrate_restore_subnet_locked.
  • Maintain subtensor pallet total issuance within tao.rs file only (consider burning TAO when balances drop below ED)
  • Test dissolving network with stakes: Make sure all TAO is distributed to stakers, sn owner, etc. and nothing remains on the sn account ID.
  • Remove adjustment of TI on every runtime upgrade
  • Deprecate sudo_set_total_issuance in admin pallet
  • Implement consistent behavior of locks: store TAO + refund on dissolution and recycle the rest.
  • Document special accounts IDs (subnets, burn)

Related Issue(s)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

gztensor added 26 commits March 25, 2026 14:50
…ldkey_account and add_balance_to_coldkey_account methods to test-only code.
@gztensor gztensor marked this pull request as ready for review April 14, 2026 17:24
@gztensor gztensor added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Apr 14, 2026
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.

1 participant