feat: add sudo call to disable emissions for a subnet#2298
Open
MkDev11 wants to merge 4 commits intoopentensor:devnet-readyfrom
Open
feat: add sudo call to disable emissions for a subnet#2298MkDev11 wants to merge 4 commits intoopentensor:devnet-readyfrom
MkDev11 wants to merge 4 commits intoopentensor:devnet-readyfrom
Conversation
Closes opentensor#2287 This PR adds a new sudo call `sudo_set_emissions_disabled` that allows root to disable or enable emissions for a specific subnet. Changes: - Add EmissionsDisabled storage item in subtensor pallet - Add EmissionsDisabledSet event - Add getter/setter functions for EmissionsDisabled - Add sudo_set_emissions_disabled call in admin-utils pallet (call_index 84) - Update get_subnets_to_emit_to to filter out subnets with emissions disabled - Add cleanup for EmissionsDisabled in remove_network - Add benchmark for the new extrinsic - Add tests for the new functionality
e44f1bc to
d914320
Compare
open-junius
reviewed
Dec 16, 2025
Address review feedback from open-junius: - Add check to return early if the new value equals the current value - Update weight to account for additional read (2 reads total) - Add test for same value case
Contributor
Author
|
@open-junius Please check the update again and let me know the result. |
Contributor
Author
|
The |
Contributor
|
Contributor
Author
|
@sam0x17 Can you please check the PR if you are available? |
Contributor
will add team members to review it. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements a new sudo call
sudo_set_emissions_disabledthat allows root to disable or enable TAO emissions for a specific subnet. When emissions are disabled for a subnet, it will be filtered out from the list of subnets that receive emissions during the coinbase process.Closes #2287
Implementation Details
Storage
EmissionsDisabled: New storage map in subtensor pallet (MAP ( netuid ) --> bool)false(emissions enabled)pallets/subtensor/src/lib.rsEvents
EmissionsDisabledSet(NetUid, bool): Emitted when emissions are enabled/disabled for a subnetpallets/subtensor/src/macros/events.rsExtrinsics
sudo_set_emissions_disabled(origin, netuid, disabled): New sudo call in admin-utils palletensure_root)pallets/admin-utils/src/lib.rsCore Logic Changes
get_subnets_to_emit_to: Updated to filter out subnets whereEmissionsDisabledistruepallets/subtensor/src/coinbase/subnet_emissions.rsremove_network: Added cleanup forEmissionsDisabledstorage when subnet is dissolvedpallets/subtensor/src/coinbase/root.rsUtility Functions
get_emissions_disabled(netuid): Getter forEmissionsDisabledstorageset_emissions_disabled(netuid, disabled): Setter that also emits the eventpallets/subtensor/src/utils/misc.rsRelated Issue(s)
Type of Change
Breaking Change
This PR does not introduce a breaking change. The new storage item defaults to
false(emissions enabled), so existing subnets will continue to receive emissions as before. The new functionality is opt-in via the sudo call.Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyTesting
Unit Tests Added
test_sudo_set_emissions_disabled(pallets/admin-utils/src/tests/mod.rs)falseBadOrigin)test_sudo_set_emissions_disabled_subnet_not_exist(pallets/admin-utils/src/tests/mod.rs)test_get_subnets_to_emit_to_filters_emissions_disabled(pallets/subtensor/src/tests/coinbase.rs)Benchmarking
sudo_set_emissions_disabledinpallets/admin-utils/src/benchmarking.rsCommands to Run Tests
Screenshots (if applicable)
N/A - This is a backend/runtime change with no UI components.
Additional Notes
Files Modified
pallets/subtensor/src/lib.rsEmissionsDisabledstorage mappallets/subtensor/src/macros/events.rsEmissionsDisabledSeteventpallets/subtensor/src/utils/misc.rspallets/subtensor/src/coinbase/subnet_emissions.rspallets/subtensor/src/coinbase/root.rsremove_networkpallets/admin-utils/src/lib.rssudo_set_emissions_disabledextrinsicpallets/admin-utils/src/benchmarking.rspallets/subtensor/src/tests/coinbase.rspallets/admin-utils/src/tests/mod.rsUsage Example