From 5c62fe2626ba202a34bb49bf1d0ff6857bb1a647 Mon Sep 17 00:00:00 2001 From: Ayden Brewer Date: Mon, 11 Dec 2023 14:18:44 -0800 Subject: [PATCH 1/6] Remove old Y1 hyperparam extrinsics, limit some subnet hyperparams access --- pallets/admin-utils/src/lib.rs | 52 +++++----------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index bdb794672..459d0aa99 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -203,7 +203,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::sudo_set_adjustment_interval())] pub fn sudo_set_adjustment_interval(origin: OriginFor, netuid: u16, adjustment_interval: u16) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), @@ -228,7 +228,7 @@ pub mod pallet { ))] pub fn sudo_set_adjustment_alpha(origin: OriginFor, netuid: u16, adjustment_alpha: u64) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), @@ -242,44 +242,6 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(10)] - #[pallet::weight(T::WeightInfo::sudo_set_validator_prune_len())] - pub fn sudo_set_validator_prune_len(origin: OriginFor, netuid: u16, validator_prune_len: u64) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; - - ensure!( - T::Subtensor::if_subnet_exist(netuid), - Error::::NetworkDoesNotExist - ); - T::Subtensor::set_validator_prune_len(netuid, validator_prune_len); - log::info!( - "ValidatorPruneLenSet( netuid: {:?} validator_prune_len: {:?} ) ", - netuid, - validator_prune_len - ); - Ok(()) - } - - #[pallet::call_index(11)] - #[pallet::weight(T::WeightInfo::sudo_set_scaling_law_power())] - pub fn sudo_set_scaling_law_power(origin: OriginFor, netuid: u16, scaling_law_power: u16) -> DispatchResult - { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; - - ensure!( - T::Subtensor::if_subnet_exist(netuid), - Error::::NetworkDoesNotExist - ); - ensure!(scaling_law_power <= 100, Error::::StorageValueOutOfRange); // The scaling law power must be between 0 and 100 => 0% and 100% - T::Subtensor::set_scaling_law_power(netuid, scaling_law_power); - log::info!( - "ScalingLawPowerSet( netuid: {:?} scaling_law_power: {:?} ) ", - netuid, - scaling_law_power - ); - Ok(()) - } - #[pallet::call_index(12)] #[pallet::weight(T::WeightInfo::sudo_set_max_weight_limit())] pub fn sudo_set_max_weight_limit(origin: OriginFor, netuid: u16, max_weight_limit: u16) -> DispatchResult { @@ -362,7 +324,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::sudo_set_kappa())] pub fn sudo_set_kappa(origin: OriginFor, netuid: u16, kappa: u16) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), @@ -377,7 +339,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::sudo_set_rho())] pub fn sudo_set_rho(origin: OriginFor, netuid: u16, rho: u16) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), @@ -450,7 +412,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::sudo_set_target_registrations_per_interval())] pub fn sudo_set_target_registrations_per_interval(origin: OriginFor, netuid: u16, target_registrations_per_interval: u16) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), @@ -549,7 +511,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::sudo_set_bonds_moving_average())] pub fn sudo_set_bonds_moving_average(origin: OriginFor, netuid: u16, bonds_moving_average: u64) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), @@ -568,7 +530,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::sudo_set_max_registrations_per_block())] pub fn sudo_set_max_registrations_per_block(origin: OriginFor, netuid: u16, max_registrations_per_block: u16) -> DispatchResult { - T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?; + ensure_root(origin)?; ensure!( T::Subtensor::if_subnet_exist(netuid), From 85dfd756436d469683a8d717ca375bb3fbc57bbb Mon Sep 17 00:00:00 2001 From: welikethestock Date: Thu, 7 Dec 2023 00:49:27 +0000 Subject: [PATCH 2/6] add missing hyperparams to listing --- pallets/subtensor/src/subnet_info.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/subnet_info.rs b/pallets/subtensor/src/subnet_info.rs index 40875b9bd..cddae3d2c 100644 --- a/pallets/subtensor/src/subnet_info.rs +++ b/pallets/subtensor/src/subnet_info.rs @@ -47,6 +47,8 @@ pub struct SubnetHyperparams { max_burn: Compact, bonds_moving_avg: Compact, max_regs_per_block: Compact, + serving_rate_limit: Compact, + max_validators: Compact } impl Pallet { @@ -145,6 +147,8 @@ impl Pallet { let max_burn = Self::get_max_burn_as_u64(netuid); let bonds_moving_avg = Self::get_bonds_moving_average(netuid); let max_regs_per_block = Self::get_max_registrations_per_block(netuid); + let serving_rate_limit = Self::get_serving_rate_limit(netuid); + let max_validators = Self::get_max_allowed_validators(netuid); return Some(SubnetHyperparams { rho: rho.into(), @@ -164,7 +168,9 @@ impl Pallet { min_burn: min_burn.into(), max_burn: max_burn.into(), bonds_moving_avg: bonds_moving_avg.into(), - max_regs_per_block: max_regs_per_block.into() + max_regs_per_block: max_regs_per_block.into(), + serving_rate_limit: serving_rate_limit.into(), + max_validators: max_validators.into() }); } } From 5027ec9698d23aac3df07f9f7c741801392a7ba3 Mon Sep 17 00:00:00 2001 From: Ayden Brewer Date: Mon, 4 Dec 2023 13:53:24 -0600 Subject: [PATCH 3/6] Enable hotkey swapping --- pallets/subtensor/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 05ade21ea..bb2495799 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1529,8 +1529,7 @@ pub mod pallet { #[pallet::call_index(70)] #[pallet::weight((0, DispatchClass::Operational, Pays::No))] pub fn swap_hotkey(origin: OriginFor, hotkey: T::AccountId, new_hotkey: T::AccountId) -> DispatchResultWithPostInfo { - //Self::do_swap_hotkey(origin, &hotkey, &new_hotkey) - Ok(().into()) + Self::do_swap_hotkey(origin, &hotkey, &new_hotkey) } // ---- SUDO ONLY FUNCTIONS ------------------------------------------------------------ From 8b0ad22baf72023b32b12e9d4fa7fb16bbcfcf98 Mon Sep 17 00:00:00 2001 From: Ala Shaabana Date: Tue, 12 Dec 2023 12:26:16 -0500 Subject: [PATCH 4/6] Removed unnecessary tests --- pallets/admin-utils/tests/tests.rs | 66 ------------------------------ 1 file changed, 66 deletions(-) diff --git a/pallets/admin-utils/tests/tests.rs b/pallets/admin-utils/tests/tests.rs index 7b207da2c..6b040e7df 100644 --- a/pallets/admin-utils/tests/tests.rs +++ b/pallets/admin-utils/tests/tests.rs @@ -286,72 +286,6 @@ fn test_sudo_subnet_owner_cut() { }); } -#[test] -fn test_sudo_validator_prune_len() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u64 = 10; - add_network(netuid, 10, 0); - let init_value: u64 = SubtensorModule::get_validator_prune_len(netuid); - assert_eq!( - AdminUtils::sudo_set_validator_prune_len( - <::RuntimeOrigin>::signed(U256::from(1)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - AdminUtils::sudo_set_validator_prune_len( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!(SubtensorModule::get_validator_prune_len(netuid), init_value); - assert_ok!(AdminUtils::sudo_set_validator_prune_len( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!(SubtensorModule::get_validator_prune_len(netuid), to_be_set); - }); -} - -#[test] -fn test_sudo_set_scaling_law_power() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 50; - add_network(netuid, 10, 0); - let init_value: u16 = SubtensorModule::get_scaling_law_power(netuid); - assert_eq!( - AdminUtils::sudo_set_scaling_law_power( - <::RuntimeOrigin>::signed(U256::from(1)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - AdminUtils::sudo_set_scaling_law_power( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!(SubtensorModule::get_scaling_law_power(netuid), init_value); - assert_ok!(AdminUtils::sudo_set_scaling_law_power( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!(SubtensorModule::get_scaling_law_power(netuid), to_be_set); - }); -} - #[test] fn test_sudo_set_max_weight_limit() { new_test_ext().execute_with(|| { From baad729ba7dba280a964e09c6854ca601221366f Mon Sep 17 00:00:00 2001 From: Ala Shaabana Date: Tue, 12 Dec 2023 13:29:26 -0500 Subject: [PATCH 5/6] Removed benchmark tests --- pallets/admin-utils/src/benchmarking.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pallets/admin-utils/src/benchmarking.rs b/pallets/admin-utils/src/benchmarking.rs index f3dca7dcb..1ea3cae93 100644 --- a/pallets/admin-utils/src/benchmarking.rs +++ b/pallets/admin-utils/src/benchmarking.rs @@ -172,24 +172,6 @@ mod benchmarks { _(RawOrigin::Root, 1u16/*netuid*/, 10u16/*max_allowed_uids*/)/*sudo_set_min_allowed_weights*/; } - #[benchmark] - fn sudo_set_validator_prune_len() - { - T::Subtensor::init_new_network(1u16/*netuid*/, 1u16/*tempo*/); - - #[extrinsic_call] - _(RawOrigin::Root, 1u16/*netuid*/, 10u64/*prune_len*/)/*sudo_set_validator_prune_len*/; - } - - #[benchmark] - fn sudo_set_scaling_law_power() - { - T::Subtensor::init_new_network(1u16/*netuid*/, 1u16/*tempo*/); - - #[extrinsic_call] - _(RawOrigin::Root, 1u16/*netuid*/, 100u16/*scaling_law_power*/)/*sudo_set_scaling_law_power*/; - } - #[benchmark] fn sudo_set_immunity_period() { From 2b0c3ae8ec0451921646a669b45b2471c72afa9d Mon Sep 17 00:00:00 2001 From: Ayden Brewer Date: Tue, 12 Dec 2023 11:27:20 -0800 Subject: [PATCH 6/6] Up spec version to 139 --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 0ffc7ed46..6a4b5c3a0 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -120,7 +120,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 136, + spec_version: 139, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,