Skip to content

Auto CK root validators on subnet registration. #2503

Open
shamil-gadelshin wants to merge 5 commits intodevnet-readyfrom
auto-ck-root-validators
Open

Auto CK root validators on subnet registration. #2503
shamil-gadelshin wants to merge 5 commits intodevnet-readyfrom
auto-ck-root-validators

Conversation

@shamil-gadelshin
Copy link
Collaborator

Summary

  • Add do_set_root_validators_for_subnet function that automatically establishes parent-child relationships between all root network validators and a subnet owner's hotkey, enabling the subnet owner to inherit stake from root
    validators and meet the StakeThreshold required to call set_weights
  • Integrate the function into do_register_network so relationships are scheduled automatically at subnet creation time
  • Each root validator becomes a parent of the subnet owner hotkey on the new subnet with full proportion (u64::MAX), using the existing do_schedule_children flow (with PendingChildKeys cooldown)

New tests

  • test_root_children_enable_subnet_owner_set_weights — verifies the function directly: subnet owner cannot set weights before, then can after root validator children are activated
  • test_register_network_schedules_root_validators — verifies end-to-end from register_network: pending children are automatically scheduled during subnet registration, activate after cooldown, and the subnet owner can then set weights
    via inherited stake

@shamil-gadelshin shamil-gadelshin added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Mar 17, 2026
@shamil-gadelshin shamil-gadelshin force-pushed the auto-ck-root-validators branch from 2113e28 to 8b25e71 Compare March 17, 2026 10:27
evgeny-s
evgeny-s previously approved these changes Mar 18, 2026
Copy link
Collaborator

@evgeny-s evgeny-s left a comment

Choose a reason for hiding this comment

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

The implementation looks good, but the fact that we add subnet hotkey to all the root validators as a child without them knowing this not good, I think.

I think we might consider more options.

  • We do it on subnet registration, but for a short period of time (N days)
  • We require validator hotkey owners to confirm it during this period, otherwise it will be reverted back.

Another option for to providing the emission flow to the subnet, maybe it can be dedicated from the protocol, instead of using validators stake.

TDB

// Cannot set children on root network itself.
ensure!(
!netuid.is_root(),
Error::<T>::RegistrationNotPermittedOnRootSubnet
Copy link
Contributor

Choose a reason for hiding this comment

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

need a different error type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems close enough. Also, I don't expect errors here at all because it's called only during subnet registration with concrete netuid. What do you suggest instead?


// Get the subnet owner hotkey.
let subnet_owner_hotkey =
SubnetOwnerHotkey::<T>::try_get(netuid).map_err(|_| Error::<T>::SubnetNotExists)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

need a different error type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we have a better one? It seems appropriate. We don't have subnet owner hotkey only when it doesn't exist. What do you suggest?

sam0x17
sam0x17 previously approved these changes Mar 20, 2026
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