Skip to content

Commit c6d3ae3

Browse files
committed
add impl for replace neuron
1 parent 1019ad0 commit c6d3ae3

File tree

1 file changed

+4
-22
lines changed
  • pallets/subtensor/src/subnets

1 file changed

+4
-22
lines changed

pallets/subtensor/src/subnets/uids.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,11 @@ impl<T: Config> Pallet<T> {
4343
// 1. Get the old hotkey under this position.
4444
let old_hotkey: T::AccountId = Keys::<T>::get(netuid, uid_to_replace);
4545

46-
// Do not deregister the owner's top-stake hotkey
47-
let mut top_stake_sn_owner_hotkey: Option<T::AccountId> = None;
48-
let mut max_stake_weight: I64F64 = I64F64::from_num(-1);
49-
for neuron_uid in 0..Self::get_subnetwork_n(netuid) {
50-
if let Ok(hotkey) = Self::get_hotkey_for_net_and_uid(netuid, neuron_uid) {
51-
let coldkey = Self::get_owning_coldkey_for_hotkey(&hotkey);
52-
if Self::get_subnet_owner(netuid) != coldkey {
53-
continue;
54-
}
55-
56-
let stake_weights = Self::get_stake_weights_for_hotkey_on_subnet(&hotkey, netuid);
57-
if stake_weights.0 > max_stake_weight {
58-
max_stake_weight = stake_weights.0;
59-
top_stake_sn_owner_hotkey = Some(hotkey);
60-
}
61-
}
62-
}
63-
64-
if let Some(ref sn_owner_hotkey) = top_stake_sn_owner_hotkey {
65-
if sn_owner_hotkey == &old_hotkey {
46+
// Do not replace owner hotkey from `SubnetOwnerHotkey`
47+
if let Ok(sn_owner_hotkey) = SubnetOwnerHotkey::<T>::try_get(netuid) {
48+
if sn_owner_hotkey == old_hotkey.clone() {
6649
log::warn!(
67-
"replace_neuron: Skipped replacement because neuron belongs to the subnet owner. \
68-
And this hotkey has the highest stake weight of all the owner's hotkeys. \
50+
"replace_neuron: Skipped replacement because neuron is the subnet owner hotkey. \
6951
netuid: {:?}, uid_to_replace: {:?}, new_hotkey: {:?}, owner_hotkey: {:?}",
7052
netuid,
7153
uid_to_replace,

0 commit comments

Comments
 (0)