Skip to content

Commit 3392693

Browse files
committed
Remove EmissionValues, remove NetworkMaxStake
1 parent 1ff2edc commit 3392693

File tree

22 files changed

+85
-330
lines changed

22 files changed

+85
-330
lines changed

pallets/admin-utils/src/benchmarking.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,5 @@ mod benchmarks {
272272
_(RawOrigin::Root, 1u16/*netuid*/, true/*enabled*/)/*set_commit_reveal_weights_enabled*/;
273273
}
274274

275-
#[benchmark]
276-
fn sudo_set_network_max_stake() {
277-
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
278-
279-
#[extrinsic_call]
280-
_(RawOrigin::Root, 1u16/*netuid*/, 1_000_000_000_000_000u64/*max_stake*/)/*sudo_set_network_max_stake*/;
281-
}
282-
283275
//impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test);
284276
}

pallets/admin-utils/src/lib.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,22 +1155,11 @@ pub mod pallet {
11551155
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
11561156
pub fn sudo_set_network_max_stake(
11571157
origin: OriginFor<T>,
1158-
netuid: u16,
1159-
max_stake: u64,
1158+
_netuid: u16,
1159+
_max_stake: u64,
11601160
) -> DispatchResult {
11611161
// Ensure the call is made by the root account
11621162
ensure_root(origin)?;
1163-
1164-
// Set the new maximum stake for the specified network
1165-
pallet_subtensor::Pallet::<T>::set_network_max_stake(netuid, max_stake);
1166-
1167-
// Log the change
1168-
log::trace!(
1169-
"NetworkMaxStakeSet( netuid: {:?}, max_stake: {:?} )",
1170-
netuid,
1171-
max_stake
1172-
);
1173-
11741163
Ok(())
11751164
}
11761165

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ parameter_types! {
130130
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
131131
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
132132
// pub const InitialHotkeyEmissionTempo: u64 = 1; // (DEPRECATED)
133-
pub const InitialNetworkMaxStake: u64 = u64::MAX; // Maximum possible value for u64, this make the make stake infinity
133+
// pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED)
134134
pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
135135
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
136136
pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight.
@@ -195,7 +195,7 @@ impl pallet_subtensor::Config for Test {
195195
type AlphaLow = InitialAlphaLow;
196196
type LiquidAlphaOn = InitialLiquidAlphaOn;
197197
// type InitialHotkeyEmissionTempo = InitialHotkeyEmissionTempo; // (DEPRECATED)
198-
type InitialNetworkMaxStake = InitialNetworkMaxStake;
198+
// type InitialNetworkMaxStake = InitialNetworkMaxStake; // (DEPRECATED)
199199
type Preimages = ();
200200
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
201201
type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration;

pallets/subtensor/src/coinbase/root.rs

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,6 @@ impl<T: Config> Pallet<T> {
7070
false
7171
}
7272

73-
/// Sets the emission values for each netuid
74-
///
75-
pub fn set_emission_values(netuids: &[u16], emission: Vec<u64>) -> Result<(), &'static str> {
76-
log::debug!(
77-
"set_emission_values: netuids: {:?} emission:{:?}",
78-
netuids,
79-
emission
80-
);
81-
82-
// Be careful this function can fail.
83-
if Self::contains_invalid_root_uids(netuids) {
84-
log::error!("set_emission_values: contains_invalid_root_uids");
85-
return Err("Invalid netuids");
86-
}
87-
if netuids.len() != emission.len() {
88-
log::error!("set_emission_values: netuids.len() != emission.len()");
89-
return Err("netuids and emission must have the same length");
90-
}
91-
for (netuid_i, emission_i) in netuids.iter().zip(emission) {
92-
log::debug!("set netuid:{:?} emission:{:?}", netuid_i, emission_i);
93-
EmissionValues::<T>::insert(*netuid_i, emission_i);
94-
}
95-
Ok(())
96-
}
97-
9873
/// Retrieves weight matrix associated with the root network.
9974
/// Weights represent the preferences for each subnetwork.
10075
///
@@ -577,7 +552,6 @@ impl<T: Config> Pallet<T> {
577552
MaxAllowedUids::<T>::remove(netuid);
578553
ImmunityPeriod::<T>::remove(netuid);
579554
ActivityCutoff::<T>::remove(netuid);
580-
EmissionValues::<T>::remove(netuid);
581555
MaxWeightsLimit::<T>::remove(netuid);
582556
MinAllowedWeights::<T>::remove(netuid);
583557
RegistrationsThisInterval::<T>::remove(netuid);
@@ -647,55 +621,6 @@ impl<T: Config> Pallet<T> {
647621
lock_cost
648622
}
649623

650-
/// This function is used to determine which subnet to prune when the total number of networks has reached the limit.
651-
/// It iterates over all the networks and finds the oldest subnet with the minimum emission value that is not in the immunity period.
652-
///
653-
/// # Returns:
654-
/// * 'u16':
655-
/// - The uid of the network to be pruned.
656-
///
657-
pub fn get_subnet_to_prune() -> u16 {
658-
let mut netuids: Vec<u16> = vec![];
659-
let current_block = Self::get_current_block_as_u64();
660-
661-
// Even if we don't have a root subnet, this still works
662-
for netuid in NetworksAdded::<T>::iter_keys_from(NetworksAdded::<T>::hashed_key_for(0)) {
663-
if current_block.saturating_sub(Self::get_network_registered_block(netuid))
664-
< Self::get_network_immunity_period()
665-
{
666-
continue;
667-
}
668-
669-
// This iterator seems to return them in order anyways, so no need to sort by key
670-
netuids.push(netuid);
671-
}
672-
673-
// Now we sort by emission, and then by subnet creation time.
674-
netuids.sort_by(|a, b| {
675-
use sp_std::cmp::Ordering;
676-
677-
match Self::get_emission_value(*b).cmp(&Self::get_emission_value(*a)) {
678-
Ordering::Equal => {
679-
if Self::get_network_registered_block(*b)
680-
< Self::get_network_registered_block(*a)
681-
{
682-
Ordering::Less
683-
} else {
684-
Ordering::Equal
685-
}
686-
}
687-
v => v,
688-
}
689-
});
690-
691-
log::debug!("Netuids Order: {:?}", netuids);
692-
693-
match netuids.last() {
694-
Some(netuid) => *netuid,
695-
None => 0,
696-
}
697-
}
698-
699624
pub fn get_network_registered_block(netuid: u16) -> u64 {
700625
NetworkRegisteredAt::<T>::get(netuid)
701626
}

pallets/subtensor/src/lib.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,6 @@ pub mod pallet {
514514
T::InitialNetworkRateLimit::get()
515515
}
516516
#[pallet::type_value]
517-
/// Default value for emission values.
518-
pub fn DefaultEmissionValues<T: Config>() -> u64 {
519-
0
520-
}
521-
#[pallet::type_value]
522517
/// Default value for pending emission.
523518
pub fn DefaultPendingEmission<T: Config>() -> u64 {
524519
0
@@ -728,11 +723,6 @@ pub mod pallet {
728723
pub fn DefaultAlphaValues<T: Config>() -> (u16, u16) {
729724
(45875, 58982)
730725
}
731-
#[pallet::type_value]
732-
/// Default value for network max stake.
733-
pub fn DefaultNetworkMaxStake<T: Config>() -> u64 {
734-
T::InitialNetworkMaxStake::get()
735-
}
736726

737727
#[pallet::type_value]
738728
/// Default value for coldkey swap schedule duration
@@ -1152,10 +1142,6 @@ pub mod pallet {
11521142
pub type NetworkRegisteredAt<T: Config> =
11531143
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultNetworkRegisteredAt<T>>;
11541144
#[pallet::storage]
1155-
/// --- MAP ( netuid ) --> emission_values
1156-
pub type EmissionValues<T> =
1157-
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultEmissionValues<T>>;
1158-
#[pallet::storage]
11591145
/// --- MAP ( netuid ) --> pending_emission
11601146
pub type PendingEmission<T> =
11611147
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultPendingEmission<T>>;
@@ -1324,10 +1310,6 @@ pub mod pallet {
13241310
/// MAP ( netuid ) --> (alpha_low, alpha_high)
13251311
pub type AlphaValues<T> =
13261312
StorageMap<_, Identity, u16, (u16, u16), ValueQuery, DefaultAlphaValues<T>>;
1327-
/// MAP ( netuid ) --> max stake allowed on a subnet.
1328-
#[pallet::storage]
1329-
pub type NetworkMaxStake<T> =
1330-
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultNetworkMaxStake<T>>;
13311313

13321314
/// =======================================
13331315
/// ==== Subnetwork Consensus Storage ====

pallets/subtensor/src/macros/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ mod config {
198198
/// A flag to indicate if Liquid Alpha is enabled.
199199
#[pallet::constant]
200200
type LiquidAlphaOn: Get<bool>;
201-
/// Initial network max stake.
202-
#[pallet::constant]
203-
type InitialNetworkMaxStake: Get<u64>;
204201
// /// Initial hotkey emission tempo.
205202
// #[pallet::constant]
206203
// type InitialHotkeyEmissionTempo: Get<u64>;

pallets/subtensor/src/macros/events.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ mod events {
6565
AxonServed(u16, T::AccountId),
6666
/// the prometheus server information is added to the network.
6767
PrometheusServed(u16, T::AccountId),
68-
/// emission ratios for all networks is set.
69-
EmissionValuesSet(),
7068
/// a hotkey has become a delegate.
7169
DelegateAdded(T::AccountId, T::AccountId, u16),
7270
/// the default take is set.
@@ -193,8 +191,8 @@ mod events {
193191
SetChildren(T::AccountId, u16, Vec<(u64, T::AccountId)>),
194192
// /// The hotkey emission tempo has been set
195193
// HotkeyEmissionTempoSet(u64),
196-
/// The network maximum stake has been set
197-
NetworkMaxStakeSet(u16, u64),
194+
// /// The network maximum stake has been set
195+
// NetworkMaxStakeSet(u16, u64),
198196
/// The identity of a coldkey has been set
199197
ChainIdentitySet(T::AccountId),
200198
/// The identity of a subnet has been set

pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pub fn migrate_delete_subnet_21<T: Config>() -> Weight {
103103
MaxAllowedUids::<T>::remove(netuid);
104104
ImmunityPeriod::<T>::remove(netuid);
105105
ActivityCutoff::<T>::remove(netuid);
106-
EmissionValues::<T>::remove(netuid);
107106
MaxWeightsLimit::<T>::remove(netuid);
108107
MinAllowedWeights::<T>::remove(netuid);
109108
RegistrationsThisInterval::<T>::remove(netuid);

pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pub fn migrate_delete_subnet_3<T: Config>() -> Weight {
106106
MaxAllowedUids::<T>::remove(netuid);
107107
ImmunityPeriod::<T>::remove(netuid);
108108
ActivityCutoff::<T>::remove(netuid);
109-
EmissionValues::<T>::remove(netuid);
110109
MaxWeightsLimit::<T>::remove(netuid);
111110
MinAllowedWeights::<T>::remove(netuid);
112111
RegistrationsThisInterval::<T>::remove(netuid);

pallets/subtensor/src/migrations/migrate_rao.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use alloc::string::String;
33
use frame_support::IterableStorageMap;
44
use frame_support::{traits::Get, weights::Weight};
55
use sp_runtime::format;
6-
use substrate_fixed::types::I96F32;
76

87
use super::*;
98

@@ -89,12 +88,12 @@ pub fn migrate_rao<T: Config>() -> Weight {
8988

9089
let remaining_lock = lock.saturating_sub(pool_initial_tao);
9190
// Refund the owner for the remaining lock.
92-
SubnetMovingPrice::<T>::insert(
93-
netuid,
94-
I96F32::from_num(EmissionValues::<T>::get(netuid))
95-
.checked_div(I96F32::from_num(1_000_000_000))
96-
.unwrap_or(I96F32::from_num(0.0)),
97-
);
91+
// SubnetMovingPrice::<T>::insert(
92+
// netuid,
93+
// I96F32::from_num(EmissionValues::<T>::get(netuid))
94+
// .checked_div(I96F32::from_num(1_000_000_000))
95+
// .unwrap_or(I96F32::from_num(0.0)),
96+
// );
9897
Pallet::<T>::add_balance_to_coldkey_account(&owner, remaining_lock);
9998
SubnetLocked::<T>::insert(netuid, 0); // Clear lock amount.
10099
SubnetTAO::<T>::insert(netuid, pool_initial_tao);

0 commit comments

Comments
 (0)