Skip to content

Commit

Permalink
Remove get_serving_rate_limit from pallet-subtensor::Pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-otf committed Dec 17, 2024
1 parent d4729f2 commit 30c03f6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 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 @@ -41,7 +41,7 @@ fn test_sudo_set_serving_rate_limit() {
new_test_ext().execute_with(|| {
let netuid: u16 = 3;
let to_be_set: u64 = 10;
let init_value: u64 = SubtensorModule::get_serving_rate_limit(netuid);
let init_value: u64 = ServingRateLimit::<Test>::get(netuid);
assert_eq!(
AdminUtils::sudo_set_serving_rate_limit(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
Expand All @@ -50,13 +50,13 @@ fn test_sudo_set_serving_rate_limit() {
),
Err(DispatchError::BadOrigin)
);
assert_eq!(SubtensorModule::get_serving_rate_limit(netuid), init_value);
assert_eq!(ServingRateLimit::<Test>::get(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_serving_rate_limit(
<<Test as Config>::RuntimeOrigin>::root(),
netuid,
to_be_set
));
assert_eq!(SubtensorModule::get_serving_rate_limit(netuid), to_be_set);
assert_eq!(ServingRateLimit::<Test>::get(netuid), to_be_set);
});
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/rpc_info/subnet_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl<T: Config> Pallet<T> {
let max_burn = MaxBurn::<T>::get(netuid);
let bonds_moving_avg = BondsMovingAverage::<T>::get(netuid);
let max_regs_per_block = MaxRegistrationsPerBlock::<T>::get(netuid);
let serving_rate_limit = Self::get_serving_rate_limit(netuid);
let serving_rate_limit = ServingRateLimit::<T>::get(netuid);
let max_validators = MaxAllowedValidators::<T>::get(netuid);
let adjustment_alpha = AdjustmentAlpha::<T>::get(netuid);
let difficulty = Difficulty::<T>::get(netuid);
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/subnets/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<T: Config> Pallet<T> {
prev_axon_info: &AxonInfoOf,
current_block: u64,
) -> bool {
let rate_limit: u64 = Self::get_serving_rate_limit(netuid);
let rate_limit: u64 = ServingRateLimit::<T>::get(netuid);
let last_serve = prev_axon_info.block;
rate_limit == 0 || last_serve == 0 || current_block.saturating_sub(last_serve) >= rate_limit
}
Expand All @@ -242,7 +242,7 @@ impl<T: Config> Pallet<T> {
prev_prometheus_info: &PrometheusInfoOf,
current_block: u64,
) -> bool {
let rate_limit: u64 = Self::get_serving_rate_limit(netuid);
let rate_limit: u64 = ServingRateLimit::<T>::get(netuid);
let last_serve = prev_prometheus_info.block;
rate_limit == 0 || last_serve == 0 || current_block.saturating_sub(last_serve) >= rate_limit
}
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 @@ -306,9 +306,6 @@ impl<T: Config> Pallet<T> {
Self::deposit_event(Event::MaxChildKeyTakeSet(take));
}

pub fn get_serving_rate_limit(netuid: u16) -> u64 {
ServingRateLimit::<T>::get(netuid)
}
pub fn set_serving_rate_limit(netuid: u16, serving_rate_limit: u64) {
ServingRateLimit::<T>::insert(netuid, serving_rate_limit);
Self::deposit_event(Event::ServingRateLimitSet(netuid, serving_rate_limit));
Expand Down

0 comments on commit 30c03f6

Please sign in to comment.