diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 905735a22..d37cb2d26 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -577,27 +577,17 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the kappa. #[pallet::call_index(16)] - #[pallet::weight(Weight::from_parts(26_210_000, 0) - .saturating_add(::DbWeight::get().reads(3_u64)) + #[pallet::weight(Weight::from_parts(15_390_000, 0) + .saturating_add(::DbWeight::get().reads(1_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_kappa(origin: OriginFor, netuid: NetUid, kappa: u16) -> DispatchResult { - let maybe_owner = pallet_subtensor::Pallet::::ensure_sn_owner_or_root_with_limits( - origin, - netuid, - &[Hyperparameter::Kappa.into()], - )?; - + ensure_root(origin)?; ensure!( pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); pallet_subtensor::Pallet::::set_kappa(netuid, kappa); log::debug!("KappaSet( netuid: {netuid:?} kappa: {kappa:?} ) "); - pallet_subtensor::Pallet::::record_owner_rl( - maybe_owner, - netuid, - &[Hyperparameter::Kappa.into()], - ); Ok(()) } @@ -1252,7 +1242,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(7_885_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), + Weight::from_parts(7_214_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes ))] diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 4e534c321..f113163c2 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -2058,7 +2058,7 @@ fn test_freeze_window_blocks_root_and_owner() { let owner: U256 = U256::from(9); SubnetOwner::::insert(netuid, owner); assert_noop!( - AdminUtils::sudo_set_kappa( + AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 77 @@ -2145,14 +2145,14 @@ fn test_owner_hyperparam_update_rate_limit_enforced() { )); // First update succeeds - assert_ok!(AdminUtils::sudo_set_kappa( + assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 11 )); // Immediate second update fails due to TxRateLimitExceeded assert_noop!( - AdminUtils::sudo_set_kappa( + AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 12 @@ -2163,7 +2163,7 @@ fn test_owner_hyperparam_update_rate_limit_enforced() { // Advance less than limit still fails run_to_block(SubtensorModule::get_current_block_as_u64() + 1); assert_noop!( - AdminUtils::sudo_set_kappa( + AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 13 @@ -2173,7 +2173,7 @@ fn test_owner_hyperparam_update_rate_limit_enforced() { // Advance one more block to pass the limit; should succeed run_to_block(SubtensorModule::get_current_block_as_u64() + 1); - assert_ok!(AdminUtils::sudo_set_kappa( + assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 14 @@ -2200,7 +2200,7 @@ fn test_hyperparam_rate_limit_enforced_by_tempo() { )); // First owner update should succeed - assert_ok!(AdminUtils::sudo_set_kappa( + assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 1 @@ -2208,13 +2208,17 @@ fn test_hyperparam_rate_limit_enforced_by_tempo() { // Immediate second update should fail due to tempo-based RL assert_noop!( - AdminUtils::sudo_set_kappa(<::RuntimeOrigin>::signed(owner), netuid, 2), + AdminUtils::sudo_set_commit_reveal_weights_interval( + <::RuntimeOrigin>::signed(owner), + netuid, + 2 + ), SubtensorError::::TxRateLimitExceeded ); // Advance 2 blocks (2 tempos with tempo=1) then succeed run_to_block(SubtensorModule::get_current_block_as_u64() + 2); - assert_ok!(AdminUtils::sudo_set_kappa( + assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 3 @@ -2244,7 +2248,7 @@ fn test_owner_hyperparam_rate_limit_independent_per_param() { )); // First update to kappa should succeed - assert_ok!(AdminUtils::sudo_set_kappa( + assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 10 @@ -2252,7 +2256,7 @@ fn test_owner_hyperparam_rate_limit_independent_per_param() { // Immediate second update to the SAME param (kappa) should be blocked by RL assert_noop!( - AdminUtils::sudo_set_kappa( + AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 11 @@ -2269,7 +2273,7 @@ fn test_owner_hyperparam_rate_limit_independent_per_param() { // kappa should still be blocked until its own RL window passes assert_noop!( - AdminUtils::sudo_set_kappa( + AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 12 @@ -2287,7 +2291,7 @@ fn test_owner_hyperparam_rate_limit_independent_per_param() { run_to_block(SubtensorModule::get_current_block_as_u64() + 2); // Now both hyperparameters can be updated again - assert_ok!(AdminUtils::sudo_set_kappa( + assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval( <::RuntimeOrigin>::signed(owner), netuid, 13