Skip to content

Commit bb11a7c

Browse files
committed
add hyperparam crv3 rate limit
1 parent 3d9e408 commit bb11a7c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,34 @@ pub mod pallet {
12091209
);
12101210
Ok(())
12111211
}
1212+
1213+
/// The extrinsic sets the commit-reveal-3 weights set rate limit for a subnet.
1214+
/// It is only callable by the root account or subnet owner.
1215+
/// The extrinsic will call the Subtensor pallet to set the weights set rate limit.
1216+
#[pallet::call_index(58)]
1217+
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_weights_set_rate_limit())]
1218+
pub fn sudo_set_commit_reveal_3_weights_set_rate_limit(
1219+
origin: OriginFor<T>,
1220+
netuid: u16,
1221+
weights_set_rate_limit: u64,
1222+
) -> DispatchResult {
1223+
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
1224+
1225+
ensure!(
1226+
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
1227+
Error::<T>::SubnetDoesNotExist
1228+
);
1229+
pallet_subtensor::Pallet::<T>::set_v3_weights_set_rate_limit(
1230+
netuid,
1231+
weights_set_rate_limit,
1232+
);
1233+
log::debug!(
1234+
"WeightsSetRateLimitSet( netuid: {:?} weights_set_rate_limit: {:?} ) ",
1235+
netuid,
1236+
weights_set_rate_limit
1237+
);
1238+
Ok(())
1239+
}
12121240
}
12131241
}
12141242

pallets/subtensor/src/utils/misc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ impl<T: Config> Pallet<T> {
397397
Self::deposit_event(Event::WeightsVersionKeySet(netuid, weights_version_key));
398398
}
399399

400+
pub fn set_v3_weights_set_rate_limit(netuid: u16, weights_set_rate_limit: u64) {
401+
V3WeightsSetRateLimit::<T>::insert(netuid, weights_set_rate_limit);
402+
}
400403
pub fn get_v3_weights_set_rate_limit(netuid: u16) -> u64 {
401404
V3WeightsSetRateLimit::<T>::get(netuid)
402405
}

0 commit comments

Comments
 (0)