Skip to content

Commit 78c1c15

Browse files
committed
Remove SubnetLimit
1 parent 3392693 commit 78c1c15

File tree

12 files changed

+14
-74
lines changed

12 files changed

+14
-74
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -910,12 +910,8 @@ pub mod pallet {
910910
DispatchClass::Operational,
911911
Pays::No
912912
))]
913-
pub fn sudo_set_subnet_limit(origin: OriginFor<T>, max_subnets: u16) -> DispatchResult {
913+
pub fn sudo_set_subnet_limit(origin: OriginFor<T>, _max_subnets: u16) -> DispatchResult {
914914
ensure_root(origin)?;
915-
pallet_subtensor::Pallet::<T>::set_max_subnets(max_subnets);
916-
917-
log::debug!("SubnetLimit( max_subnets: {:?} ) ", max_subnets);
918-
919915
Ok(())
920916
}
921917

pallets/admin-utils/src/tests/mock.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ parameter_types! {
123123
pub const InitialNetworkMinLockCost: u64 = 100_000_000_000;
124124
pub const InitialSubnetOwnerCut: u16 = 0; // 0%. 100% of rewards go to validators + miners.
125125
pub const InitialNetworkLockReductionInterval: u64 = 2; // 2 blocks.
126-
pub const InitialSubnetLimit: u16 = 10; // Max 10 subnets.
126+
// pub const InitialSubnetLimit: u16 = 10; // (DEPRECATED)
127127
pub const InitialNetworkRateLimit: u64 = 0;
128128
pub const InitialKeySwapCost: u64 = 1_000_000_000;
129129
pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default
@@ -188,14 +188,11 @@ impl pallet_subtensor::Config for Test {
188188
type InitialNetworkMinLockCost = InitialNetworkMinLockCost;
189189
type InitialSubnetOwnerCut = InitialSubnetOwnerCut;
190190
type InitialNetworkLockReductionInterval = InitialNetworkLockReductionInterval;
191-
type InitialSubnetLimit = InitialSubnetLimit;
192191
type InitialNetworkRateLimit = InitialNetworkRateLimit;
193192
type KeySwapCost = InitialKeySwapCost;
194193
type AlphaHigh = InitialAlphaHigh;
195194
type AlphaLow = InitialAlphaLow;
196195
type LiquidAlphaOn = InitialLiquidAlphaOn;
197-
// type InitialHotkeyEmissionTempo = InitialHotkeyEmissionTempo; // (DEPRECATED)
198-
// type InitialNetworkMaxStake = InitialNetworkMaxStake; // (DEPRECATED)
199196
type Preimages = ();
200197
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
201198
type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration;

pallets/admin-utils/src/tests/mod.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -850,30 +850,6 @@ fn test_sudo_set_rao_recycled() {
850850
});
851851
}
852852

853-
#[test]
854-
fn test_sudo_set_subnet_limit() {
855-
new_test_ext().execute_with(|| {
856-
let netuid: u16 = 1;
857-
let to_be_set: u16 = 10;
858-
add_network(netuid, 10);
859-
860-
let init_value: u16 = SubtensorModule::get_max_subnets();
861-
assert_eq!(
862-
AdminUtils::sudo_set_subnet_limit(
863-
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
864-
to_be_set
865-
),
866-
Err(DispatchError::BadOrigin)
867-
);
868-
assert_eq!(SubtensorModule::get_max_subnets(), init_value);
869-
assert_ok!(AdminUtils::sudo_set_subnet_limit(
870-
<<Test as Config>::RuntimeOrigin>::root(),
871-
to_be_set
872-
));
873-
assert_eq!(SubtensorModule::get_max_subnets(), to_be_set);
874-
});
875-
}
876-
877853
#[test]
878854
fn test_sudo_set_network_lock_reduction_interval() {
879855
new_test_ext().execute_with(|| {

pallets/subtensor/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,6 @@ pub mod pallet {
501501
T::InitialSubnetOwnerCut::get()
502502
}
503503
#[pallet::type_value]
504-
/// Default value for subnet limit.
505-
pub fn DefaultSubnetLimit<T: Config>() -> u16 {
506-
T::InitialSubnetLimit::get()
507-
}
508-
#[pallet::type_value]
509504
/// Default value for network rate limit.
510505
pub fn DefaultNetworkRateLimit<T: Config>() -> u64 {
511506
if cfg!(feature = "pow-faucet") {
@@ -1045,9 +1040,6 @@ pub mod pallet {
10451040
pub type MaxRegistrationsPerBlock<T> =
10461041
StorageMap<_, Identity, u16, u16, ValueQuery, DefaultMaxRegistrationsPerBlock<T>>;
10471042
#[pallet::storage]
1048-
/// --- ITEM( maximum_number_of_networks )
1049-
pub type SubnetLimit<T> = StorageValue<_, u16, ValueQuery, DefaultSubnetLimit<T>>;
1050-
#[pallet::storage]
10511043
/// --- ITEM( total_number_of_existing_networks )
10521044
pub type TotalNetworks<T> = StorageValue<_, u16, ValueQuery>;
10531045
#[pallet::storage]

pallets/subtensor/src/macros/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ mod config {
180180
/// Initial lock reduction interval.
181181
#[pallet::constant]
182182
type InitialNetworkLockReductionInterval: Get<u64>;
183-
/// Initial max allowed subnets
184-
#[pallet::constant]
185-
type InitialSubnetLimit: Get<u16>;
186183
/// Initial network creation rate limit
187184
#[pallet::constant]
188185
type InitialNetworkRateLimit: Get<u64>;

pallets/subtensor/src/macros/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ mod events {
122122
/// the network minimum locking cost is set.
123123
NetworkMinLockCostSet(u64),
124124
/// the maximum number of subnets is set
125-
SubnetLimitSet(u16),
125+
// SubnetLimitSet(u16),
126126
/// the lock cost reduction is set
127127
NetworkLockCostReductionIntervalSet(u64),
128128
/// the take for a delegate is decreased.

pallets/subtensor/src/macros/hooks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ mod hooks {
7979
// Set the min difficulty across all subnets to a new minimum
8080
.saturating_add(migrations::migrate_set_min_difficulty::migrate_set_min_difficulty::<T>())
8181
// Remove Stake map entries
82-
.saturating_add(migrations::migrate_remove_stake_map::migrate_remove_stake_map::<T>());
82+
.saturating_add(migrations::migrate_remove_stake_map::migrate_remove_stake_map::<T>())
83+
// Remove unused maps entries
84+
.saturating_add(migrations::migrate_remove_unused_maps_and_values::migrate_remove_unused_maps_and_values::<T>());
8385
weight
8486
}
8587

pallets/subtensor/src/migrations/migrate_remove_unused_maps.rs renamed to pallets/subtensor/src/migrations/migrate_remove_unused_maps_and_values.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22
use crate::HasMigrationRun;
33
use frame_support::{traits::Get, weights::Weight};
44
use scale_info::prelude::string::String;
5-
use sp_io::{KillStorageResult, hashing::twox_128, storage::clear_prefix};
5+
use sp_io::{KillStorageResult, hashing::twox_128, storage::{clear, clear_prefix}};
66

77
fn remove_prefix<T: Config>(old_map: &str, weight: &mut Weight) {
88
let mut prefix = Vec::new();
@@ -28,8 +28,8 @@ fn remove_prefix<T: Config>(old_map: &str, weight: &mut Weight) {
2828
*weight = (*weight).saturating_add(T::DbWeight::get().writes(removed_entries_count));
2929
}
3030

31-
pub fn migrate_remove_unused_maps<T: Config>() -> Weight {
32-
let migration_name = b"migrate_remove_unused_maps".to_vec();
31+
pub fn migrate_remove_unused_maps_and_values<T: Config>() -> Weight {
32+
let migration_name = b"migrate_remove_unused_maps_and_values".to_vec();
3333
let mut weight = T::DbWeight::get().reads(1);
3434

3535
if HasMigrationRun::<T>::get(&migration_name) {
@@ -51,6 +51,9 @@ pub fn migrate_remove_unused_maps<T: Config>() -> Weight {
5151
// Remove NetworkMaxStake
5252
remove_prefix::<T>("NetworkMaxStake", &mut weight);
5353

54+
// Remove SubnetLimit
55+
clear(b"SubtensorModule::SubnetLimit");
56+
5457
// Mark Migration as Completed
5558
HasMigrationRun::<T>::insert(&migration_name, true);
5659
weight = weight.saturating_add(T::DbWeight::get().writes(1));

pallets/subtensor/src/migrations/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod migrate_init_total_issuance;
1010
pub mod migrate_populate_owned_hotkeys;
1111
pub mod migrate_rao;
1212
pub mod migrate_remove_stake_map;
13-
pub mod migrate_remove_unused_maps;
13+
pub mod migrate_remove_unused_maps_and_values;
1414
pub mod migrate_set_min_burn;
1515
pub mod migrate_set_min_difficulty;
1616
pub mod migrate_stake_threshold;

pallets/subtensor/src/subnets/subnet.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@ impl<T: Config> Pallet<T> {
2525
TotalNetworks::<T>::get()
2626
}
2727

28-
/// Fetches the max number of subnet
29-
///
30-
/// This function retrieves the max number of subnet.
31-
///
32-
/// # Returns:
33-
/// * 'u16': The max number of subnet
34-
///
35-
pub fn get_max_subnets() -> u16 {
36-
SubnetLimit::<T>::get()
37-
}
38-
39-
/// Sets the max number of subnet
40-
///
41-
/// This function sets the max number of subnet.
42-
///
43-
pub fn set_max_subnets(limit: u16) {
44-
SubnetLimit::<T>::put(limit);
45-
Self::deposit_event(Event::SubnetLimitSet(limit));
46-
}
47-
4828
/// Returns true if the subnetwork exists.
4929
///
5030
/// This function checks if a subnetwork with the given UID exists.

0 commit comments

Comments
 (0)