-
Notifications
You must be signed in to change notification settings - Fork 261
feat: add sudo call to disable emissions for a subnet #2298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devnet-ready
Are you sure you want to change the base?
feat: add sudo call to disable emissions for a subnet #2298
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
|
Hi @sam0x17 please check this PR and let me know the result. |
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
|
@open-junius Please check the update again and let me know the result. |
|
The |
|
|
@open-junius who is another reviewer? |
|
@sam0x17 Can you please check the PR if you are available? |
will add team members to review it. |
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
Contribution by Gittensor, learn more at https://gittensor.io/