Skip to content

Commit b7a4f96

Browse files
committed
add a min activity cutoff and default
1 parent 6f431ac commit b7a4f96

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,12 @@ pub mod pallet {
500500
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
501501
Error::<T>::SubnetDoesNotExist
502502
);
503+
504+
ensure!(
505+
activity_cutoff >= pallet_subtensor::MinActivityCutoff::<T>::get(),
506+
pallet_subtensor::Error::<T>::ActivityCutoffTooLow
507+
);
508+
503509
pallet_subtensor::Pallet::<T>::set_activity_cutoff(netuid, activity_cutoff);
504510
log::debug!(
505511
"ActivityCutoffSet( netuid: {:?} activity_cutoff: {:?} ) ",

pallets/subtensor/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,16 @@ pub mod pallet {
794794
I96F32::saturating_from_num(10_000_000)
795795
}
796796

797+
#[pallet::type_value]
798+
/// Default value for minimum activity cutoff
799+
pub fn DefaultMinActivityCutoff<T: Config>() -> u16 {
800+
360
801+
}
802+
803+
#[pallet::storage]
804+
pub type MinActivityCutoff<T: Config> =
805+
StorageValue<_, u16, ValueQuery, DefaultMinActivityCutoff<T>>;
806+
797807
#[pallet::storage]
798808
pub type ColdkeySwapScheduleDuration<T: Config> =
799809
StorageValue<_, BlockNumberFor<T>, ValueQuery, DefaultColdkeySwapScheduleDuration<T>>;

pallets/subtensor/src/macros/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,7 @@ mod errors {
191191
SlippageTooHigh,
192192
/// Subnet disallows transfer.
193193
TransferDisallowed,
194+
/// Activity cutoff is being set too low.
195+
ActivityCutoffTooLow,
194196
}
195197
}

0 commit comments

Comments
 (0)