From 9df4157a10e1c8a7e9b1f98f806d9e1afd3fb83f Mon Sep 17 00:00:00 2001 From: Aliaksandr Tsurko Date: Fri, 13 Dec 2024 16:42:09 +0100 Subject: [PATCH] Remove get_min_allowed_weights from pallet-subtensor::Pallet --- pallets/admin-utils/src/tests/mod.rs | 6 +++--- pallets/subtensor/src/rpc_info/subnet_info.rs | 6 +++--- pallets/subtensor/src/subnets/weights.rs | 2 +- pallets/subtensor/src/utils/misc.rs | 3 --- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 1ca556576..d240c5110 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -376,7 +376,7 @@ fn test_sudo_set_min_allowed_weights() { let netuid: u16 = 1; let to_be_set: u16 = 10; add_network(netuid, 10); - let init_value: u16 = SubtensorModule::get_min_allowed_weights(netuid); + let init_value: u16 = MinAllowedWeights::::get(netuid); assert_eq!( AdminUtils::sudo_set_min_allowed_weights( <::RuntimeOrigin>::signed(U256::from(1)), @@ -393,13 +393,13 @@ fn test_sudo_set_min_allowed_weights() { ), Err(Error::::SubnetDoesNotExist.into()) ); - assert_eq!(SubtensorModule::get_min_allowed_weights(netuid), init_value); + assert_eq!(MinAllowedWeights::::get(netuid), init_value); assert_ok!(AdminUtils::sudo_set_min_allowed_weights( <::RuntimeOrigin>::root(), netuid, to_be_set )); - assert_eq!(SubtensorModule::get_min_allowed_weights(netuid), to_be_set); + assert_eq!(MinAllowedWeights::::get(netuid), to_be_set); }); } diff --git a/pallets/subtensor/src/rpc_info/subnet_info.rs b/pallets/subtensor/src/rpc_info/subnet_info.rs index 337d86d40..5df32766f 100644 --- a/pallets/subtensor/src/rpc_info/subnet_info.rs +++ b/pallets/subtensor/src/rpc_info/subnet_info.rs @@ -94,7 +94,7 @@ impl Pallet { let difficulty: Compact = Difficulty::::get(netuid).into(); let immunity_period = ImmunityPeriod::::get(netuid); let max_allowed_validators = MaxAllowedValidators::::get(netuid); - let min_allowed_weights = Self::get_min_allowed_weights(netuid); + let min_allowed_weights = MinAllowedWeights::::get(netuid); let max_weights_limit = MaxWeightsLimit::::get(netuid); let scaling_law_power = Self::get_scaling_law_power(netuid); let subnetwork_n = SubnetworkN::::get(netuid); @@ -164,7 +164,7 @@ impl Pallet { let difficulty: Compact = Difficulty::::get(netuid).into(); let immunity_period = ImmunityPeriod::::get(netuid); let max_allowed_validators = MaxAllowedValidators::::get(netuid); - let min_allowed_weights = Self::get_min_allowed_weights(netuid); + let min_allowed_weights = MinAllowedWeights::::get(netuid); let max_weights_limit = MaxWeightsLimit::::get(netuid); let scaling_law_power = Self::get_scaling_law_power(netuid); let subnetwork_n = SubnetworkN::::get(netuid); @@ -233,7 +233,7 @@ impl Pallet { let rho = Self::get_rho(netuid); let kappa = Kappa::::get(netuid); let immunity_period = ImmunityPeriod::::get(netuid); - let min_allowed_weights = Self::get_min_allowed_weights(netuid); + let min_allowed_weights = MinAllowedWeights::::get(netuid); let max_weights_limit = MaxWeightsLimit::::get(netuid); let tempo = Self::get_tempo(netuid); let min_difficulty = Self::get_min_difficulty(netuid); diff --git a/pallets/subtensor/src/subnets/weights.rs b/pallets/subtensor/src/subnets/weights.rs index aba5ac4a4..e041ff764 100644 --- a/pallets/subtensor/src/subnets/weights.rs +++ b/pallets/subtensor/src/subnets/weights.rs @@ -959,7 +959,7 @@ impl Pallet { /// Returns True if the uids and weights are have a valid length for uid on network. pub fn check_length(netuid: u16, uid: u16, uids: &[u16], weights: &[u16]) -> bool { let subnet_n: usize = SubnetworkN::::get(netuid) as usize; - let min_allowed_length: usize = Self::get_min_allowed_weights(netuid) as usize; + let min_allowed_length: usize = MinAllowedWeights::::get(netuid) as usize; let min_allowed: usize = { if subnet_n < min_allowed_length { subnet_n diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index df2676c22..fdb86ac71 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -396,9 +396,6 @@ impl Pallet { current_block.saturating_sub(registered_at) < u64::from(immunity_period) } - pub fn get_min_allowed_weights(netuid: u16) -> u16 { - MinAllowedWeights::::get(netuid) - } pub fn set_min_allowed_weights(netuid: u16, min_allowed_weights: u16) { MinAllowedWeights::::insert(netuid, min_allowed_weights); Self::deposit_event(Event::MinAllowedWeightSet(netuid, min_allowed_weights));