Skip to content

Commit 6053ed5

Browse files
committed
don't clear alpha maps
1 parent 3a82a73 commit 6053ed5

File tree

3 files changed

+8
-43
lines changed

3 files changed

+8
-43
lines changed

pallets/subtensor/src/migrations/migrate_reset_unactive_sn.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,44 +134,9 @@ pub fn migrate_reset_unactive_sn<T: Config>() -> Weight {
134134

135135
// Reset pool alpha
136136
SubnetAlphaIn::<T>::insert(*netuid, pool_initial_alpha);
137-
SubnetAlphaOut::<T>::insert(*netuid, AlphaCurrency::ZERO);
138137
// Reset volume
139138
SubnetVolume::<T>::insert(*netuid, 0u128);
140139
weight = weight.saturating_add(T::DbWeight::get().writes(4));
141-
142-
// Reset Alpha stake entries for this subnet
143-
let to_reset: Vec<T::AccountId> = match to_remove_alpha_hotkeys.get(netuid) {
144-
Some(hotkeys) => hotkeys.clone(),
145-
None => Vec::new(),
146-
};
147-
148-
for hotkey in to_reset {
149-
TotalHotkeyAlpha::<T>::remove(&hotkey, *netuid);
150-
TotalHotkeyShares::<T>::remove(&hotkey, *netuid);
151-
TotalHotkeyAlphaLastEpoch::<T>::remove(&hotkey, *netuid);
152-
weight = weight.saturating_add(T::DbWeight::get().writes(3));
153-
154-
// Reset root claimable and claimed
155-
RootClaimable::<T>::mutate(&hotkey, |claimable| {
156-
claimable.remove(netuid);
157-
});
158-
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
159-
let removal_result = RootClaimed::<T>::clear_prefix((*netuid, &hotkey), u32::MAX, None);
160-
weight = weight.saturating_add(
161-
T::DbWeight::get()
162-
.reads_writes(removal_result.loops as u64, removal_result.backend as u64),
163-
);
164-
165-
let to_reset_alpha: Vec<(T::AccountId, T::AccountId)> =
166-
match to_remove_alpha_coldkeys.get(netuid) {
167-
Some(coldkeys) => coldkeys.clone(),
168-
None => Vec::new(),
169-
};
170-
for (hotkey, coldkey) in to_reset_alpha {
171-
Alpha::<T>::remove((hotkey, coldkey, netuid));
172-
weight = weight.saturating_add(T::DbWeight::get().writes(1));
173-
}
174-
}
175140
}
176141

177142
// Run total issuance migration

pallets/subtensor/src/tests/migration.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,7 @@ fn test_migrate_reset_unactive_sn() {
25812581
assert_eq!(PendingOwnerCut::<Test>::get(netuid), AlphaCurrency::ZERO);
25822582
assert_eq!(SubnetTAO::<Test>::get(netuid), initial_tao);
25832583
assert_eq!(SubnetAlphaIn::<Test>::get(netuid), initial_alpha);
2584-
assert_eq!(SubnetAlphaOut::<Test>::get(netuid), AlphaCurrency::ZERO);
2584+
assert_ne!(SubnetAlphaOut::<Test>::get(netuid), AlphaCurrency::ZERO);
25852585
assert_eq!(SubnetTaoInEmission::<Test>::get(netuid), TaoCurrency::ZERO);
25862586
assert_eq!(
25872587
SubnetAlphaInEmission::<Test>::get(netuid),
@@ -2594,23 +2594,23 @@ fn test_migrate_reset_unactive_sn() {
25942594
assert_eq!(SubnetVolume::<Test>::get(netuid), 0u128);
25952595
for hotkey in 0..10 {
25962596
let hk = U256::from(hotkey);
2597-
assert_eq!(
2597+
assert_ne!(
25982598
TotalHotkeyAlpha::<Test>::get(hk, netuid),
25992599
AlphaCurrency::ZERO
26002600
);
2601-
assert_eq!(
2601+
assert_ne!(
26022602
TotalHotkeyShares::<Test>::get(hk, netuid),
26032603
U64F64::from_num(0.0)
26042604
);
2605-
assert_eq!(
2605+
assert_ne!(
26062606
TotalHotkeyAlphaLastEpoch::<Test>::get(hk, netuid),
26072607
AlphaCurrency::ZERO
26082608
);
2609-
assert_eq!(RootClaimable::<Test>::get(hk).get(netuid), None);
2609+
assert_ne!(RootClaimable::<Test>::get(hk).get(netuid), None);
26102610
for coldkey in 0..10 {
26112611
let ck = U256::from(coldkey);
2612-
assert_eq!(Alpha::<Test>::get((hk, ck, netuid)), U64F64::from_num(0.0));
2613-
assert_eq!(RootClaimed::<Test>::get((netuid, hk, ck)), 0u128);
2612+
assert_ne!(Alpha::<Test>::get((hk, ck, netuid)), U64F64::from_num(0.0));
2613+
assert_ne!(RootClaimed::<Test>::get((netuid, hk, ck)), 0u128);
26142614
}
26152615
}
26162616

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
220220
// `spec_version`, and `authoring_version` are the same between Wasm and native.
221221
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
222222
// the compatible custom types.
223-
spec_version: 344,
223+
spec_version: 345,
224224
impl_version: 1,
225225
apis: RUNTIME_API_VERSIONS,
226226
transaction_version: 1,

0 commit comments

Comments
 (0)