|
| 1 | +--- |
| 2 | +title: "Subnet Deregistration" |
| 3 | +--- |
| 4 | + |
| 5 | +# Subnet Deregistration |
| 6 | + |
| 7 | +This page details the process by which subnets can become deregistered from Bittensor network, with an eye to the implementation of the functionality in the Subtensor codebase that makes up Bittensor's blockchain layer. |
| 8 | + |
| 9 | +See also [Learn Bittensor: Subnet Deregistration](https://learnbittensor.org/concepts/dynamic-tao/subnet-deregistration) |
| 10 | + |
| 11 | +Subnet deregistration is a mechanism that manages the lifecycle of subnets within the Bittensor network. It ensures network quality by removing underperforming subnets, clearing room for new subnet registrations within the 128 subnet limit. |
| 12 | + |
| 13 | +:::info Deployment Timeline |
| 14 | +The subnet deregistration feature deployed on September 17, 2025, with a 7-day delay before the first registrations can occur. |
| 15 | +::: |
| 16 | + |
| 17 | +Subnet deregistration addresses network efficiency issues: |
| 18 | +- Removes underperforming subnets that consume TAO emissions without providing value. |
| 19 | +- Unlocks TAO resources locked in underperforming subnet pools |
| 20 | + |
| 21 | +| Parameter | Value | Description | |
| 22 | +|-----------|-------|-------------| |
| 23 | +| **Subnet Limit** | 128 | Maximum number of occupied subnet slots | |
| 24 | +| **Immunity Period** | 4 months (864000 blocks) | Protection period from subnet deregistration |
| 25 | +| **Rate Limiting** | 4 days (28800 blocks) | Minimum time between registrations/deregistrations | |
| 26 | + |
| 27 | +## The Automated Deregistration Process |
| 28 | + |
| 29 | +### Trigger |
| 30 | + |
| 31 | +The process begins when the subnet limit is reached and a new subnet attempts to register. |
| 32 | + |
| 33 | +Source: [`do_register_network()`](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/subnets/subnet.rs#L146-158) |
| 34 | + |
| 35 | +### Selection Criteria |
| 36 | +The subnet to deregister is the subnet with lowest EMA (Exponential Moving Average) price among non-immune subnets. |
| 37 | + |
| 38 | +Source code: [`get_network_to_prune()`](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/coinbase/root.rs#L753-795) |
| 39 | + |
| 40 | +The subnet price EMA uses the standard EMA formula: |
| 41 | +$$ |
| 42 | +\mathrm{EMA}^{(t)} = \alpha \times \mathrm{current\_price} + (1 - \alpha) \times \mathrm{EMA}^{(t-1)} |
| 43 | +$$ |
| 44 | + |
| 45 | +Where $\alpha$ is calculated dynamically based on subnet age: |
| 46 | +$$ |
| 47 | +\alpha = \frac{\mathrm{base\_alpha} \times \mathrm{blocks\_since\_start}}{\mathrm{blocks\_since\_start} + \mathrm{halving\_blocks}} |
| 48 | +$$ |
| 49 | + |
| 50 | +- **base_alpha**: ~0.0003 for Bittensor mainnet ("finney") |
| 51 | +- **blocks_since_start**: Number of blocks since subnet registration |
| 52 | +- **halving_blocks**: Halving period for the subnet |
| 53 | + |
| 54 | +This EMA value is recalculated for the subnet each time the coinbase function runs. |
| 55 | + |
| 56 | +See also: |
| 57 | +- [Navigating Subtensor Codebase: Coinbase Implementation](../navigating-subtensor/emissions-coinbase) |
| 58 | +- [Exponential Moving Averages (EMAs) in Bittensor](../learn/ema.md). |
| 59 | + |
| 60 | + |
| 61 | +### Immunity Protection |
| 62 | +Network immunity period is currently 4 months from registration block. |
| 63 | + - Formula: `current_block < registered_at + network_immunity_period` |
| 64 | + - Source code: [Immunity check](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/coinbase/root.rs#L768-770) |
| 65 | +### Rate Limiting |
| 66 | +Deregistration can occur at most every once every 4 days (coordinated with registration rate). |
| 67 | + - Block-based timing: 28800 blocks ≈ 4 days at 12s/block |
| 68 | + - [Source code](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/utils/rate_limiting.rs#L27) |
| 69 | + |
| 70 | +## Special Cases and Edge Conditions |
| 71 | + |
| 72 | +### All Subnets Immune |
| 73 | +If all subnets are still within their immunity period, the system will: |
| 74 | +1. Return `None` from [`get_network_to_prune()`](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/coinbase/root.rs#L753-795) |
| 75 | +2. Registration fails with `SubnetLimitReached` error |
| 76 | +3. No subnet is deregistered until at least one becomes eligible |
| 77 | + |
| 78 | +### Tied EMA Prices |
| 79 | + |
| 80 | +When multiple subnets have identical EMA prices: |
| 81 | +1. Select the subnet with the earliest registration timestamp |
| 82 | +2. Implementation: [Tie-breaking logic](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/coinbase/root.rs#L774-781) |
| 83 | + |
| 84 | +## Token Liquidation |
| 85 | + |
| 86 | +When a subnet is deregistered, all alpha tokens in that subnet are liquidated and the subnet's TAO pool is distributed to alpha holders and to refunding the subnet owner for their lock cost minus the emissions they've received. |
| 87 | + |
| 88 | +### Takeaways |
| 89 | + |
| 90 | +**Distribution Method**: Largest-remainder for fair rounding |
| 91 | +**Owner Protection**: Owner gets refund minus emissions already received |
| 92 | +**Immediate Effect**: All alpha tokens are destroyed and cannot be recovered |
| 93 | + |
| 94 | +### Liquidation Steps |
| 95 | + |
| 96 | +1. **Dissolve Liquidity Pools**: All liquidity pools in the subnet's AMM pools are dissolved |
| 97 | +2. **Calculate Owner Refund**: The subnet owner's refund is calculated as: |
| 98 | + ``` |
| 99 | + refund = max(0, lock_cost - owner_received_emission_in_tao) |
| 100 | + ``` |
| 101 | + Where `owner_received_emission_in_tao` is the TAO value of the owner's cut of all emissions received during the subnet's lifetime. |
| 102 | + |
| 103 | +3. **Enumerate alpha Holders**: All alpha token holders and their stake amounts are collected |
| 104 | + |
| 105 | +4. **Extract TAO Pool**: The subnet's TAO pool (`SubnetTAO`) is extracted for distribution |
| 106 | + |
| 107 | +5. **Distribution**: TAO is distributed proportionally to alpha holders: |
| 108 | + - Each holder receives: `(holder_alpha_value / total_alpha_value) * pool_tao` |
| 109 | + - TAO is credited directly to each holder's coldkey free balance |
| 110 | + |
| 111 | +**Source Code**: |
| 112 | +- [`destroy_alpha_in_out_stakes()`](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/staking/remove_stake.rs#L444-623) |
| 113 | +- [`prune_network()`](https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/coinbase/root.rs#L377) |
0 commit comments