Skip to content

Commit

Permalink
add migration patch; remove pending emission from old hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
camfairchild committed Sep 13, 2024
1 parent 4f3f151 commit 1a5009a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fn migrate_pending_emissions_including_null_stake<T: Config>(

// Get the pending emissions for the OLD hotkey
let pending_emissions_old: u64 = PendingdHotkeyEmission::<T>::get(old_hotkey);
PendingdHotkeyEmission::<T>::remove(old_hotkey);
weight.saturating_accrue(T::DbWeight::get().reads(1));

// Get the stake for the 0x000 key
Expand Down
14 changes: 10 additions & 4 deletions pallets/subtensor/tests/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ fn test_migrate_fix_pending_emissions() {
PendingdHotkeyEmission::<Test>::insert(datura_old_hk_account, 10_000);
// Setup the NEW Datura hotkey with a pending emission
PendingdHotkeyEmission::<Test>::insert(datura_new_hk_account, 123_456_789);
let expected_datura_new_hk_pending_emission: u64 = 123_456_789 + 10_000;
Stake::<Test>::insert(datura_old_hk_account, null_account, 123_456_789);
let expected_datura_new_hk_pending_emission: u64 = 123_456_789 + 10_000 + 123_456_789;

// Setup the old TaoStats hotkey with a pending emission
PendingdHotkeyEmission::<Test>::insert(taostats_old_hk_account, 987_654);
Expand All @@ -508,10 +509,15 @@ fn test_migrate_fix_pending_emissions() {
expected_taostats_new_hk_pending_emission
);

// Check the pending emission is added to new the Datura hotkey
// Check the pending emission is removed from old ones
assert_eq!(
PendingdHotkeyEmission::<Test>::get(datura_new_hk_account),
expected_datura_new_hk_pending_emission
PendingdHotkeyEmission::<Test>::get(datura_old_hk_account),
0
);

assert_eq!(
PendingdHotkeyEmission::<Test>::get(taostats_old_hk_account),
0
);
})
}

0 comments on commit 1a5009a

Please sign in to comment.