Skip to content

Commit 773670c

Browse files
committed
address tests
1 parent fff2529 commit 773670c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pallets/subtensor/src/migrations/migrate_fix_pending_emission.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn migrate_pending_emissions_including_null_stake<T: Config>(
2121
new_hotkey: &T::AccountId,
2222
) -> Weight {
2323
let mut weight = T::DbWeight::get().reads(0);
24-
let null_account = DefaultAccount::<T>::get();
24+
let null_account = &DefaultAccount::<T>::get();
2525
weight.saturating_accrue(T::DbWeight::get().reads(1));
2626

2727
// Get the pending emissions for the OLD hotkey
@@ -30,18 +30,18 @@ fn migrate_pending_emissions_including_null_stake<T: Config>(
3030
weight.saturating_accrue(T::DbWeight::get().reads(1));
3131

3232
// Get the stake for the 0x000 key
33-
let null_stake = Stake::<T>::get(&old_hotkey, &null_account);
33+
let null_stake = Stake::<T>::get(&old_hotkey, null_account);
3434
weight.saturating_accrue(T::DbWeight::get().reads(1));
3535
// Remove
36-
Stake::<T>::remove(&old_hotkey, &null_account);
36+
Stake::<T>::remove(&old_hotkey, null_account);
3737
weight.saturating_accrue(T::DbWeight::get().writes(1));
3838

3939
let new_total_coldkey_stake =
40-
TotalColdkeyStake::<T>::get(old_hotkey).saturating_sub(null_stake);
40+
TotalColdkeyStake::<T>::get(null_account).saturating_sub(null_stake);
4141
if new_total_coldkey_stake == 0 {
42-
TotalColdkeyStake::<T>::remove(old_hotkey);
42+
TotalColdkeyStake::<T>::remove(null_account);
4343
} else {
44-
TotalColdkeyStake::<T>::insert(old_hotkey, new_total_coldkey_stake);
44+
TotalColdkeyStake::<T>::insert(null_account, new_total_coldkey_stake);
4545
}
4646
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1));
4747

@@ -53,8 +53,10 @@ fn migrate_pending_emissions_including_null_stake<T: Config>(
5353
}
5454
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1));
5555

56+
// Remove the stake from the total stake and total issuance (since it is re-emitted)
5657
TotalStake::<T>::put(TotalStake::<T>::get().saturating_sub(null_stake));
57-
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1));
58+
TotalIssuance::<T>::put(TotalIssuance::<T>::get().saturating_sub(null_stake));
59+
weight.saturating_accrue(T::DbWeight::get().reads_writes(2, 2));
5860

5961
// Get the pending emissions for the NEW hotkey
6062
let pending_emissions_new: u64 = PendingdHotkeyEmission::<T>::get(new_hotkey);

0 commit comments

Comments
 (0)