Skip to content

Conversation

unconst
Copy link
Contributor

@unconst unconst commented Aug 29, 2025

Description

Allows subnets to trim the number of active UIDs while preserving immune UIDs (temporally and owner owned), compressing the UIDs to the left and migrating/clearing associated storage.

A new extrinsic + storage item has been defined for the minimum allowed number of UIDs of a subnet and we can't trim below this limit which is set to 256 to start with and will allow gradual controlled trimming on a per subnet basis to prevent abuse.

@github-actions github-actions bot added the hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet label Aug 29, 2025
@unconst unconst changed the base branch from main to devnet-ready August 29, 2025 18:32
@opentensor opentensor deleted a comment from github-actions bot Aug 29, 2025
@sam0x17 sam0x17 added skip-cargo-audit This PR fails cargo audit but needs to be merged anyway and removed hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet labels Aug 29, 2025
@@ -107,6 +96,143 @@ impl<T: Config> Pallet<T> {
IsNetworkMember::<T>::insert(new_hotkey.clone(), netuid, true); // Fill network is member.
}

/// Appends the uid to the network.
pub fn clear_neuron(netuid: NetUid, neuron_uid: u16) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We clear weights set FOR the uid being cleared. Do we also need to clear weights set BY the uid being cleared?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure to understand, I get the impression the comment is to the wrong section maybe?

In clear_neuron it seems we only reset the value but weights are not touched, only bonds are removed.

In trim_to_max_allowed_uids we effectively clear the weights, bonds and also all connections to remaining neurons here:
https://github.com/opentensor/subtensor/pull/1998/files#diff-6e4716cd71324b7ff12eb21a83873e667f5c91b5fe9a18f64bc2fe2b8f748ff0R212

Is it about this part?

Copy link
Contributor

@gztensor gztensor Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a validator sets weights, the weights get into the state as a value-vector associated with netuid+validator_uid tuple:

(netuid, validator_uid) => [(miner_uid_1, weight_1), (miner_uid_2, weight_2), ...]

In trim_to_max_allowed_uids we make the value-vector shorter, effectively removing the unneeded miner UIDs.

But we ignore the fact that UID that is being removed could also have been the validator and have set weights, so the corresponding key (netuid, validator_uid) remains in the map, but it needs to be fully removed.

@l0r1s l0r1s removed the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Sep 9, 2025
@l0r1s l0r1s added skip-cargo-audit This PR fails cargo audit but needs to be merged anyway apply-benchmark-patch and removed apply-benchmark-patch labels Sep 10, 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.

5 participants