Skip to content

Commit

Permalink
Remove get_max_weight_limit from pallet-subtensor::Pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-otf committed Dec 13, 2024
1 parent ea61569 commit 8921325
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ fn test_sudo_set_max_weight_limit() {
let netuid: u16 = 1;
let to_be_set: u16 = 10;
add_network(netuid, 10);
let init_value: u16 = SubtensorModule::get_max_weight_limit(netuid);
let init_value: u16 = MaxWeightsLimit::<Test>::get(netuid);
assert_eq!(
AdminUtils::sudo_set_max_weight_limit(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
Expand All @@ -308,13 +308,13 @@ fn test_sudo_set_max_weight_limit() {
),
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), init_value);
assert_eq!(MaxWeightsLimit::<Test>::get(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_max_weight_limit(
<<Test as Config>::RuntimeOrigin>::root(),
netuid,
to_be_set
));
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), to_be_set);
assert_eq!(MaxWeightsLimit::<Test>::get(netuid), to_be_set);
});
}

Expand Down
6 changes: 3 additions & 3 deletions pallets/subtensor/src/rpc_info/subnet_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<T: Config> Pallet<T> {
let immunity_period = ImmunityPeriod::<T>::get(netuid);
let max_allowed_validators = MaxAllowedValidators::<T>::get(netuid);
let min_allowed_weights = Self::get_min_allowed_weights(netuid);
let max_weights_limit = Self::get_max_weight_limit(netuid);
let max_weights_limit = MaxWeightsLimit::<T>::get(netuid);
let scaling_law_power = Self::get_scaling_law_power(netuid);
let subnetwork_n = SubnetworkN::<T>::get(netuid);
let max_allowed_uids = MaxAllowedUids::<T>::get(netuid);
Expand Down Expand Up @@ -165,7 +165,7 @@ impl<T: Config> Pallet<T> {
let immunity_period = ImmunityPeriod::<T>::get(netuid);
let max_allowed_validators = MaxAllowedValidators::<T>::get(netuid);
let min_allowed_weights = Self::get_min_allowed_weights(netuid);
let max_weights_limit = Self::get_max_weight_limit(netuid);
let max_weights_limit = MaxWeightsLimit::<T>::get(netuid);
let scaling_law_power = Self::get_scaling_law_power(netuid);
let subnetwork_n = SubnetworkN::<T>::get(netuid);
let max_allowed_uids = MaxAllowedUids::<T>::get(netuid);
Expand Down Expand Up @@ -234,7 +234,7 @@ impl<T: Config> Pallet<T> {
let kappa = Kappa::<T>::get(netuid);
let immunity_period = ImmunityPeriod::<T>::get(netuid);
let min_allowed_weights = Self::get_min_allowed_weights(netuid);
let max_weights_limit = Self::get_max_weight_limit(netuid);
let max_weights_limit = MaxWeightsLimit::<T>::get(netuid);
let tempo = Self::get_tempo(netuid);
let min_difficulty = Self::get_min_difficulty(netuid);
let max_difficulty = MaxDifficulty::<T>::get(netuid);
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/subnets/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ impl<T: Config> Pallet<T> {
}

// If the max weight limit it u16 max, return true.
let max_weight_limit: u16 = Self::get_max_weight_limit(netuid);
let max_weight_limit: u16 = MaxWeightsLimit::<T>::get(netuid);
if max_weight_limit == u16::MAX {
return true;
}
Expand Down
3 changes: 0 additions & 3 deletions pallets/subtensor/src/utils/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,6 @@ impl<T: Config> Pallet<T> {
Self::deposit_event(Event::ScalingLawPowerSet(netuid, scaling_law_power));
}

pub fn get_max_weight_limit(netuid: u16) -> u16 {
MaxWeightsLimit::<T>::get(netuid)
}
pub fn set_max_weight_limit(netuid: u16, max_weight_limit: u16) {
MaxWeightsLimit::<T>::insert(netuid, max_weight_limit);
Self::deposit_event(Event::MaxWeightLimitSet(netuid, max_weight_limit));
Expand Down

0 comments on commit 8921325

Please sign in to comment.