Skip to content

Conversation

@MkDev11
Copy link

@MkDev11 MkDev11 commented Dec 16, 2025

Description

This PR implements a new sudo call sudo_set_emissions_disabled that 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)
    • Default value: false (emissions enabled)
    • Location: pallets/subtensor/src/lib.rs

Events

  • EmissionsDisabledSet(NetUid, bool): Emitted when emissions are enabled/disabled for a subnet
    • Location: pallets/subtensor/src/macros/events.rs

Extrinsics

  • sudo_set_emissions_disabled(origin, netuid, disabled): New sudo call in admin-utils pallet
    • Call index: 84
    • Access: Root only (ensure_root)
    • Validation: Checks subnet exists before modifying
    • Location: pallets/admin-utils/src/lib.rs

Core Logic Changes

  • get_subnets_to_emit_to: Updated to filter out subnets where EmissionsDisabled is true

    • Location: pallets/subtensor/src/coinbase/subnet_emissions.rs
  • remove_network: Added cleanup for EmissionsDisabled storage when subnet is dissolved

    • Location: pallets/subtensor/src/coinbase/root.rs

Utility Functions

  • get_emissions_disabled(netuid): Getter for EmissionsDisabled storage
  • set_emissions_disabled(netuid, disabled): Setter that also emits the event
    • Location: pallets/subtensor/src/utils/misc.rs

Related Issue(s)

Type of Change

  • New feature (non-breaking change which adds functionality)

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

  • 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

Testing

Unit Tests Added

  1. test_sudo_set_emissions_disabled (pallets/admin-utils/src/tests/mod.rs)

    • Verifies default value is false
    • Verifies non-root cannot call the extrinsic (returns BadOrigin)
    • Verifies root can disable emissions
    • Verifies root can re-enable emissions
  2. test_sudo_set_emissions_disabled_subnet_not_exist (pallets/admin-utils/src/tests/mod.rs)

    • Verifies error when subnet doesn't exist
  3. test_get_subnets_to_emit_to_filters_emissions_disabled (pallets/subtensor/src/tests/coinbase.rs)

    • Verifies subnets with emissions disabled are filtered out
    • Verifies re-enabling emissions adds subnet back to emission list

Benchmarking

  • Added benchmark for sudo_set_emissions_disabled in pallets/admin-utils/src/benchmarking.rs

Commands to Run Tests

# Run admin-utils tests
cargo test -p pallet-admin-utils test_sudo_set_emissions_disabled

# Run subtensor coinbase tests
cargo test -p pallet-subtensor test_get_subnets_to_emit_to_filters_emissions_disabled

# Run clippy
cargo clippy -p pallet-subtensor -p pallet-admin-utils -- -D warnings

# Check formatting
cargo fmt --check -p pallet-subtensor -p pallet-admin-utils

Screenshots (if applicable)

N/A - This is a backend/runtime change with no UI components.

Additional Notes

Files Modified

File Changes
pallets/subtensor/src/lib.rs Added EmissionsDisabled storage map
pallets/subtensor/src/macros/events.rs Added EmissionsDisabledSet event
pallets/subtensor/src/utils/misc.rs Added getter/setter functions
pallets/subtensor/src/coinbase/subnet_emissions.rs Added filter for disabled subnets
pallets/subtensor/src/coinbase/root.rs Added cleanup in remove_network
pallets/admin-utils/src/lib.rs Added sudo_set_emissions_disabled extrinsic
pallets/admin-utils/src/benchmarking.rs Added benchmark
pallets/subtensor/src/tests/coinbase.rs Added emission filtering test
pallets/admin-utils/src/tests/mod.rs Added sudo call tests

Usage Example

// Disable emissions for subnet 1
AdminUtils::sudo_set_emissions_disabled(
    RuntimeOrigin::root(),
    NetUid::from(1),
    true  // disabled = true
)?;

// Re-enable emissions for subnet 1
AdminUtils::sudo_set_emissions_disabled(
    RuntimeOrigin::root(),
    NetUid::from(1),
    false  // disabled = false
)?;

Contribution by Gittensor, learn more at https://gittensor.io/

@MkDev11 MkDev11 changed the base branch from main to devnet-ready December 16, 2025 10:24
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
@MkDev11 MkDev11 force-pushed the feat/sudo-disable-subnet-emissions branch from e44f1bc to d914320 Compare December 16, 2025 10:29
@MkDev11
Copy link
Author

MkDev11 commented Dec 16, 2025

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
@MkDev11
Copy link
Author

MkDev11 commented Dec 16, 2025

@open-junius Please check the update again and let me know the result.

@MkDev11
Copy link
Author

MkDev11 commented Dec 16, 2025

The cargo audit CI failed due to a Rust version mismatch - [email protected] requires rustc 1.89 but the CI runner has 1.88.0. This is a CI infrastructure issue unrelated to my changes.

@open-junius
Copy link
Contributor

The cargo audit CI failed due to a Rust version mismatch - [email protected] requires rustc 1.89 but the CI runner has 1.88.0. This is a CI infrastructure issue unrelated to my changes.
No worry, we have PR for it #2244.

@MkDev11
Copy link
Author

MkDev11 commented Dec 16, 2025

@open-junius who is another reviewer?

@MkDev11
Copy link
Author

MkDev11 commented Dec 16, 2025

@sam0x17 Can you please check the PR if you are available?

@open-junius
Copy link
Contributor

@open-junius who is another reviewer?

will add team members to review it.

@open-junius open-junius added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Dec 17, 2025
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.

Sudo call to disable emissions for a subnet

2 participants