Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,20 @@ pub mod pallet {
log::debug!("set_tao_flow_smoothing_factor( {smoothing_factor:?} ) ");
Ok(())
}

/// Sets the global maximum number of mechanisms in a subnet
#[pallet::call_index(84)]
#[pallet::weight(Weight::from_parts(15_000_000, 0)
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(1_u64))
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
pub fn sudo_set_max_mechanism_count(
origin: OriginFor<T>,
max_mechanism_count: MechId,
) -> DispatchResult {
ensure_root(origin)?;
pallet_subtensor::Pallet::<T>::do_set_max_mechanism_count(max_mechanism_count)?;
Ok(())
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2041,9 +2041,13 @@ pub mod pallet {
}
#[pallet::type_value]
/// -- ITEM (Maximum number of sub-subnets)
pub fn MaxMechanismCount<T: Config>() -> MechId {
pub fn DefaultMaxMechanismCount<T: Config>() -> MechId {
MechId::from(2)
}
#[pallet::storage]
/// ITEM( max_mechanism_count )
pub type MaxMechanismCount<T> =
StorageValue<_, MechId, ValueQuery, DefaultMaxMechanismCount<T>>;
#[pallet::type_value]
/// -- ITEM (Rate limit for mechanism count updates)
pub fn MechanismCountSetRateLimit<T: Config>() -> u64 {
Expand Down
18 changes: 17 additions & 1 deletion pallets/subtensor/src/subnets/mechanism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Set the desired valus of sub-subnet count for a subnet identified
/// Set the desired value of sub-subnet count for a subnet identified
/// by netuid
pub fn do_set_mechanism_count(netuid: NetUid, mechanism_count: MechId) -> DispatchResult {
// Make sure the subnet exists
Expand Down Expand Up @@ -124,6 +124,22 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Set the global maximum number of mechanisms per subnet
pub fn do_set_max_mechanism_count(max_mechanism_count: MechId) -> DispatchResult {
// Max count cannot be zero
ensure!(max_mechanism_count > 0.into(), Error::<T>::InvalidValue);

// Make sure we are not allowing numbers that will break the math
ensure!(
max_mechanism_count <= MechId::from(MAX_MECHANISM_COUNT_PER_SUBNET),
Error::<T>::InvalidValue
);

MaxMechanismCount::<T>::set(max_mechanism_count);

Ok(())
}

/// Update current count for a subnet identified by netuid
/// - Cleans up all sub-subnet maps if count is reduced
///
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 338,
spec_version: 339,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Loading