Skip to content

Commit

Permalink
Remove get_min_allowed_weights 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 0fa95a0 commit 9df4157
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 @@ -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::<Test>::get(netuid);
assert_eq!(
AdminUtils::sudo_set_min_allowed_weights(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
Expand All @@ -393,13 +393,13 @@ fn test_sudo_set_min_allowed_weights() {
),
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_min_allowed_weights(netuid), init_value);
assert_eq!(MinAllowedWeights::<Test>::get(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_min_allowed_weights(
<<Test as Config>::RuntimeOrigin>::root(),
netuid,
to_be_set
));
assert_eq!(SubtensorModule::get_min_allowed_weights(netuid), to_be_set);
assert_eq!(MinAllowedWeights::<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 @@ -94,7 +94,7 @@ impl<T: Config> Pallet<T> {
let difficulty: Compact<u64> = Difficulty::<T>::get(netuid).into();
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 min_allowed_weights = MinAllowedWeights::<T>::get(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);
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<T: Config> Pallet<T> {
let difficulty: Compact<u64> = Difficulty::<T>::get(netuid).into();
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 min_allowed_weights = MinAllowedWeights::<T>::get(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);
Expand Down Expand Up @@ -233,7 +233,7 @@ impl<T: Config> Pallet<T> {
let rho = Self::get_rho(netuid);
let kappa = Kappa::<T>::get(netuid);
let immunity_period = ImmunityPeriod::<T>::get(netuid);
let min_allowed_weights = Self::get_min_allowed_weights(netuid);
let min_allowed_weights = MinAllowedWeights::<T>::get(netuid);
let max_weights_limit = MaxWeightsLimit::<T>::get(netuid);
let tempo = Self::get_tempo(netuid);
let min_difficulty = Self::get_min_difficulty(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 @@ -959,7 +959,7 @@ impl<T: Config> Pallet<T> {
/// 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::<T>::get(netuid) as usize;
let min_allowed_length: usize = Self::get_min_allowed_weights(netuid) as usize;
let min_allowed_length: usize = MinAllowedWeights::<T>::get(netuid) as usize;
let min_allowed: usize = {
if subnet_n < min_allowed_length {
subnet_n
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 @@ -396,9 +396,6 @@ impl<T: Config> Pallet<T> {
current_block.saturating_sub(registered_at) < u64::from(immunity_period)
}

pub fn get_min_allowed_weights(netuid: u16) -> u16 {
MinAllowedWeights::<T>::get(netuid)
}
pub fn set_min_allowed_weights(netuid: u16, min_allowed_weights: u16) {
MinAllowedWeights::<T>::insert(netuid, min_allowed_weights);
Self::deposit_event(Event::MinAllowedWeightSet(netuid, min_allowed_weights));
Expand Down

0 comments on commit 9df4157

Please sign in to comment.