Skip to content

Commit f516593

Browse files
committed
fix rate limit
1 parent 97efc75 commit f516593

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,15 +1924,15 @@ pub mod pallet {
19241924
let maybe_owner = pallet_subtensor::Pallet::<T>::ensure_sn_owner_or_root_with_limits(
19251925
origin.clone(),
19261926
netuid,
1927-
&[TransactionType::SetMaxAllowedUids],
1927+
&[TransactionType::MaxUidsTrimming],
19281928
)?;
19291929

19301930
pallet_subtensor::Pallet::<T>::trim_to_max_allowed_uids(netuid, max_n)?;
19311931

19321932
pallet_subtensor::Pallet::<T>::record_owner_rl(
19331933
maybe_owner,
19341934
netuid,
1935-
&[TransactionType::SetMaxAllowedUids],
1935+
&[TransactionType::MaxUidsTrimming],
19361936
);
19371937
Ok(())
19381938
}
@@ -1948,7 +1948,8 @@ pub mod pallet {
19481948
netuid: NetUid,
19491949
min_allowed_uids: u16,
19501950
) -> DispatchResult {
1951-
ensure_root(origin)?;
1951+
pallet_subtensor::Pallet::<T>::ensure_root_with_rate_limit(origin, netuid)?;
1952+
19521953
ensure!(
19531954
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
19541955
Error::<T>::SubnetDoesNotExist

pallets/subtensor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub mod pallet {
619619
}
620620
#[pallet::type_value]
621621
/// -- Rate limit for set max allowed UIDs
622-
pub fn SetMaxAllowedUidsRateLimit<T: Config>() -> u64 {
622+
pub fn MaxUidsTrimmingRateLimit<T: Config>() -> u64 {
623623
prod_or_fast!(30 * 7200, 1)
624624
}
625625
#[pallet::type_value]

pallets/subtensor/src/utils/rate_limiting.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum TransactionType {
1515
OwnerHyperparamUpdate(Hyperparameter),
1616
SubsubnetCountUpdate,
1717
SubsubnetEmission,
18-
SetMaxAllowedUids,
18+
MaxUidsTrimming,
1919
}
2020

2121
impl TransactionType {
@@ -27,7 +27,7 @@ impl TransactionType {
2727
Self::RegisterNetwork => NetworkRateLimit::<T>::get(),
2828
Self::SubsubnetCountUpdate => SubsubnetCountSetRateLimit::<T>::get(),
2929
Self::SubsubnetEmission => SubsubnetEmissionRateLimit::<T>::get(),
30-
30+
Self::MaxUidsTrimming => MaxUidsTrimmingRateLimit::<T>::get(),
3131
Self::Unknown => 0, // Default to no limit for unknown types (no limit)
3232
_ => 0,
3333
}
@@ -140,7 +140,7 @@ impl From<TransactionType> for u16 {
140140
TransactionType::OwnerHyperparamUpdate(_) => 6,
141141
TransactionType::SubsubnetCountUpdate => 7,
142142
TransactionType::SubsubnetEmission => 8,
143-
TransactionType::SetMaxAllowedUids => 9,
143+
TransactionType::MaxUidsTrimming => 9,
144144
}
145145
}
146146
}
@@ -157,7 +157,7 @@ impl From<u16> for TransactionType {
157157
6 => TransactionType::OwnerHyperparamUpdate(Hyperparameter::Unknown),
158158
7 => TransactionType::SubsubnetCountUpdate,
159159
8 => TransactionType::SubsubnetEmission,
160-
9 => TransactionType::SetMaxAllowedUids,
160+
9 => TransactionType::MaxUidsTrimming,
161161
_ => TransactionType::Unknown,
162162
}
163163
}

0 commit comments

Comments
 (0)