diff --git a/pallets/subspace/src/autogen_weights.rs b/pallets/subspace/src/autogen_weights.rs index ed5731bf6..1df981438 100644 --- a/pallets/subspace/src/autogen_weights.rs +++ b/pallets/subspace/src/autogen_weights.rs @@ -90,8 +90,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { /// Proof: `SubspaceModule::BurnRate` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `SubspaceModule::VotePeriod` (r:1 w:0) /// Proof: `SubspaceModule::VotePeriod` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `SubspaceModule::SubnetVoteThreshold` (r:1 w:0) - /// Proof: `SubspaceModule::SubnetVoteThreshold` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `SubspaceModule::VoteThresholdSubnet` (r:1 w:0) + /// Proof: `SubspaceModule::VoteThresholdSubnet` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `SubspaceModule::TotalSubnets` (r:1 w:1) /// Proof: `SubspaceModule::TotalSubnets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `SubspaceModule::Emission` (r:1 w:1) @@ -489,8 +489,8 @@ impl WeightInfo for () { /// Proof: `SubspaceModule::BurnRate` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `SubspaceModule::VotePeriod` (r:1 w:0) /// Proof: `SubspaceModule::VotePeriod` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `SubspaceModule::SubnetVoteThreshold` (r:1 w:0) - /// Proof: `SubspaceModule::SubnetVoteThreshold` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `SubspaceModule::VoteThresholdSubnet` (r:1 w:0) + /// Proof: `SubspaceModule::VoteThresholdSubnet` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `SubspaceModule::TotalSubnets` (r:1 w:1) /// Proof: `SubspaceModule::TotalSubnets` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `SubspaceModule::Emission` (r:1 w:1) diff --git a/pallets/subspace/src/lib.rs b/pallets/subspace/src/lib.rs index bcfcf943f..f2a9fbf09 100644 --- a/pallets/subspace/src/lib.rs +++ b/pallets/subspace/src/lib.rs @@ -350,7 +350,7 @@ pub mod pallet { #[pallet::type_value] pub fn DefaultVoteThreshold<T: Config>() -> u16 {50} // out of 100 #[pallet::storage] // --- MAP ( netuid ) --> epoch - pub type SubnetVoteThreshold<T> = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultVoteThreshold<T>>; + pub type VoteThresholdSubnet<T> = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultVoteThreshold<T>>; #[pallet::storage] // --- MAP ( netuid ) --> epoch pub type GlobalVoteThreshold<T> = StorageValue<_, u16, ValueQuery, DefaultVoteThreshold<T>>; diff --git a/pallets/subspace/src/module.rs b/pallets/subspace/src/module.rs index 20b0a024e..fb603d138 100644 --- a/pallets/subspace/src/module.rs +++ b/pallets/subspace/src/module.rs @@ -183,7 +183,7 @@ impl<T: Config> Pallet<T> { // remove the network if it is empty if N::<T>::get(netuid) == 0 { - Self::remove_network_for_netuid(netuid); + Self::remove_subnet(netuid); } // remove stake from old key and add to new key diff --git a/pallets/subspace/src/registration.rs b/pallets/subspace/src/registration.rs index fe911da16..25a43247b 100644 --- a/pallets/subspace/src/registration.rs +++ b/pallets/subspace/src/registration.rs @@ -273,7 +273,7 @@ impl<T: Config> Pallet<T> { } } ensure!(stake > min_stake , Error::<T>::NotEnoughStakeToStartNetwork); - Self::remove_network_for_netuid(min_stake_netuid); + Self::remove_subnet(min_stake_netuid); } // if we have reached the max number of subnets, then we can start a new one if the stake is // greater than the least staked network diff --git a/pallets/subspace/src/subnet.rs b/pallets/subspace/src/subnet.rs index abdb17224..6ca255228 100644 --- a/pallets/subspace/src/subnet.rs +++ b/pallets/subspace/src/subnet.rs @@ -24,7 +24,7 @@ impl<T: Config> Pallet<T> { ensure!(Self::if_subnet_netuid_exists(netuid), Error::<T>::SubnetNameAlreadyExists); ensure!(Self::is_subnet_founder(netuid, &key), Error::<T>::NotFounder); - Self::remove_network_for_netuid(netuid); + Self::remove_subnet(netuid); // --- 16. Ok and done. Ok(()) } @@ -101,7 +101,7 @@ impl<T: Config> Pallet<T> { min_stake: MinStake::<T>::get(netuid), tempo: Tempo::<T>::get(netuid), name: <Vec<u8>>::new(), - vote_threshold: SubnetVoteThreshold::<T>::get(netuid), + vote_threshold: VoteThresholdSubnet::<T>::get(netuid), vote_mode:VoteModeSubnet::<T>::get(netuid), trust_ratio: TrustRatio::<T>::get(netuid), self_vote: SelfVote::<T>::get(netuid), @@ -366,7 +366,7 @@ impl<T: Config> Pallet<T> { pub fn remove_network_for_name(name: Vec<u8>) -> u16 { let netuid = Self::get_netuid_for_name(name.clone()); - return Self::remove_network_for_netuid(netuid) + return Self::remove_subnet(netuid) } pub fn remove_netuid_stake_strorage(netuid: u16) { @@ -381,7 +381,7 @@ impl<T: Config> Pallet<T> { TotalStake::<T>::remove(netuid); } - pub fn remove_network_for_netuid(netuid: u16) -> u16 { + pub fn remove_subnet(netuid: u16) -> u16 { // --- 2. Ensure the network to be removed exists. if !Self::if_subnet_exist(netuid) { return 0 @@ -408,7 +408,7 @@ impl<T: Config> Pallet<T> { RegistrationBlock::<T>::clear_prefix(netuid, u32::max_value(), None); - // --- 2. Erase network parameters. + // --- 2. Erase subnet parameters. Founder::<T>::remove(netuid); FounderShare::<T>::remove(netuid); ImmunityPeriod::<T>::remove(netuid); @@ -419,11 +419,10 @@ impl<T: Config> Pallet<T> { MinStake::<T>::remove(netuid); SelfVote::<T>::remove(netuid); SubnetEmission::<T>::remove(netuid); - SubnetVoteThreshold::<T>::remove(netuid); - VoteModeSubnet::<T>::remove(netuid); Tempo::<T>::remove(netuid); TrustRatio::<T>::remove(netuid); - + VoteThresholdSubnet::<T>::remove(netuid); + VoteModeSubnet::<T>::remove(netuid); // Adjust the total number of subnets. and remove the subnet from the list of subnets. N::<T>::remove(netuid); @@ -531,7 +530,7 @@ impl<T: Config> Pallet<T> { // we need to prefix the voting power by the network uid pub fn set_subnet_vote_threshold(netuid: u16, vote_threshold: u16) { - SubnetVoteThreshold::<T>::insert(netuid, vote_threshold); + VoteThresholdSubnet::<T>::insert(netuid, vote_threshold); } pub fn get_vote_mode_subnet(netuid: u16) -> Vec<u8> { @@ -543,7 +542,7 @@ impl<T: Config> Pallet<T> { } pub fn get_subnet_vote_threshold(netuid: u16) -> u16 { - return SubnetVoteThreshold::<T>::get(netuid) + return VoteThresholdSubnet::<T>::get(netuid) } pub fn get_stake_for_key(netuid: u16, key: &T::AccountId) -> u64 { diff --git a/pallets/subspace/tests/test_profit_share.rs b/pallets/subspace/tests/test_profit_share.rs index 348cff0b1..b00158956 100644 --- a/pallets/subspace/tests/test_profit_share.rs +++ b/pallets/subspace/tests/test_profit_share.rs @@ -91,11 +91,6 @@ fn test_add_profit_share() { assert!(sum_profit_share_balances > miner_emission - delta || sum_profit_share_balances < miner_emission + delta, "profit share balances do not add up to the emission"); - - - - - diff --git a/pallets/subspace/tests/test_subnets.rs b/pallets/subspace/tests/test_subnets.rs index 12121b0e2..543c6f848 100644 --- a/pallets/subspace/tests/test_subnets.rs +++ b/pallets/subspace/tests/test_subnets.rs @@ -37,7 +37,7 @@ fn test_add_subnets() { } for netuid in 0..num_subnets { - SubspaceModule::remove_network_for_netuid(netuid); + SubspaceModule::remove_subnet(netuid); expected_subnets = expected_subnets.saturating_sub(1); assert_eq!( SubspaceModule::num_subnets(),