Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ pub mod pallet {
/// The extrinsic will call the Subtensor pallet to set the minimum delegate take.
#[pallet::call_index(46)]
#[pallet::weight((
Weight::from_parts(5_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)),
Weight::from_parts(5_500_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)),
DispatchClass::Operational,
Pays::Yes
))]
Expand Down Expand Up @@ -1686,11 +1686,7 @@ pub mod pallet {
netuid: NetUid,
hotkey: <T as frame_system::Config>::AccountId,
) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner(origin.clone(), netuid)?;
pallet_subtensor::Pallet::<T>::set_subnet_owner_hotkey(netuid, &hotkey);

log::debug!("SubnetOwnerHotkeySet( netuid: {netuid:?}, hotkey: {hotkey:?} )");
Ok(())
pallet_subtensor::Pallet::<T>::do_set_sn_owner_hotkey(origin, netuid, &hotkey)
}

Comment on lines 1673 to 1694
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

There is another function that does the same thing in the same file, one has "sn" in the name and the other has "subnet". Do we need both? What for?

I'm not sure which one Cortex uses, I'd keep that one and remove the other one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cortex uses neither at the moment.

///
Expand Down
84 changes: 42 additions & 42 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,48 +1745,48 @@ fn test_sets_a_lower_value_clears_small_nominations() {
});
}

#[test]
fn test_sudo_set_subnet_owner_hotkey() {
new_test_ext().execute_with(|| {
let netuid = NetUid::from(1);

let coldkey: U256 = U256::from(1);
let hotkey: U256 = U256::from(2);
let new_hotkey: U256 = U256::from(3);

let coldkey_origin = <<Test as Config>::RuntimeOrigin>::signed(coldkey);
let root = RuntimeOrigin::root();
let random_account = RuntimeOrigin::signed(U256::from(123456));

pallet_subtensor::SubnetOwner::<Test>::insert(netuid, coldkey);
pallet_subtensor::SubnetOwnerHotkey::<Test>::insert(netuid, hotkey);
assert_eq!(
pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
hotkey
);

assert_ok!(AdminUtils::sudo_set_subnet_owner_hotkey(
coldkey_origin,
netuid,
new_hotkey
));

assert_eq!(
pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
new_hotkey
);

assert_noop!(
AdminUtils::sudo_set_subnet_owner_hotkey(random_account, netuid, new_hotkey),
DispatchError::BadOrigin
);

assert_noop!(
AdminUtils::sudo_set_subnet_owner_hotkey(root, netuid, new_hotkey),
DispatchError::BadOrigin
);
});
}
// #[test]
// fn test_sudo_set_subnet_owner_hotkey() {
// new_test_ext().execute_with(|| {
// let netuid = NetUid::from(1);

// let coldkey: U256 = U256::from(1);
// let hotkey: U256 = U256::from(2);
// let new_hotkey: U256 = U256::from(3);

// let coldkey_origin = <<Test as Config>::RuntimeOrigin>::signed(coldkey);
// let root = RuntimeOrigin::root();
// let random_account = RuntimeOrigin::signed(U256::from(123456));

// pallet_subtensor::SubnetOwner::<Test>::insert(netuid, coldkey);
// pallet_subtensor::SubnetOwnerHotkey::<Test>::insert(netuid, hotkey);
// assert_eq!(
// pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
// hotkey
// );

// assert_ok!(AdminUtils::sudo_set_subnet_owner_hotkey(
// coldkey_origin,
// netuid,
// new_hotkey
// ));

// assert_eq!(
// pallet_subtensor::SubnetOwnerHotkey::<Test>::get(netuid),
// new_hotkey
// );

// assert_noop!(
// AdminUtils::sudo_set_subnet_owner_hotkey(random_account, netuid, new_hotkey),
// DispatchError::BadOrigin
// );

// assert_noop!(
// AdminUtils::sudo_set_subnet_owner_hotkey(root, netuid, new_hotkey),
// DispatchError::BadOrigin
// );
// });
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// }

Trust VCS. If you'll ever need this code back, it will be in the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I commented it out instead of deleting it to make it more difficult for somebody to re-use the extrinsic index. Substrate doesn't like that.


// cargo test --package pallet-admin-utils --lib -- tests::test_sudo_set_ema_halving --exact --show-output
#[test]
Expand Down