Skip to content

Commit cf27022

Browse files
committed
add logging
1 parent 9eed8c2 commit cf27022

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pallets/subtensor/src/migrations/migrate_dissolve_sn73.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
3030
// Get the subnet TAO
3131
let subnet_tao = I96F32::from_num(SubnetTAO::<T>::get(this_netuid));
3232
weight = weight.saturating_add(T::DbWeight::get().reads(1));
33+
log::debug!("Subnet TAO: {}", subnet_tao);
3334

3435
let mut total_alpha: I96F32 = I96F32::from_num(0);
3536
// Iterate over every hotkey and sum up the total alpha
@@ -43,26 +44,29 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
4344
hotkeys_to_remove.push(hotkey);
4445
total_alpha = total_alpha.saturating_add(I96F32::from_num(total_hotkey_alpha));
4546
}
47+
log::debug!("Total alpha: {}", total_alpha);
4648

4749
// Iterate over every hotkey and distribute the TAO from the pool
4850
// using previous total alpha as the denominator
49-
for (hotkey, netuid_i, total_hotkey_alpha_i) in TotalHotkeyAlpha::<T>::iter() {
50-
if netuid_i != this_netuid {
51-
continue;
52-
}
51+
for hotkey in hotkeys_to_remove.iter() {
52+
log::debug!("Hotkey: {}", hotkey);
5353

54+
let total_hotkey_alpha_i = TotalHotkeyAlpha::<T>::get(hotkey.clone(), this_netuid);
5455
let total_hotkey_alpha = I96F32::from_num(total_hotkey_alpha_i);
5556
weight = weight.saturating_add(T::DbWeight::get().reads(1));
5657

5758
// Get the total hotkey shares
5859
let total_hotkey_shares =
5960
I96F32::from_num(TotalHotkeyShares::<T>::get(hotkey.clone(), this_netuid));
6061
weight = weight.saturating_add(T::DbWeight::get().reads(1));
62+
log::debug!("Total hotkey shares: {}", total_hotkey_shares);
6163

6264
// Get the equivalent amount of TAO
6365
let hotkey_tao: I96F32 = total_hotkey_alpha
6466
.saturating_div(total_alpha)
6567
.saturating_mul(subnet_tao);
68+
log::debug!("Total hotkey alpha: {}", total_hotkey_alpha);
69+
log::debug!("Hotkey TAO: {}", hotkey_tao);
6670

6771
let mut coldkeys_to_remove: Vec<T::AccountId> = Vec::new();
6872
// Distribute the TAO to each of the stakers to the hotkey
@@ -74,10 +78,13 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
7478

7579
coldkeys_to_remove.push(coldkey.clone());
7680

77-
let alpha = I96F32::from_num(alpha_i);
78-
let coldkey_share: I96F32 = alpha.saturating_div(total_hotkey_shares);
81+
let alpha_shares = I96F32::from_num(alpha_i);
82+
let coldkey_share: I96F32 = alpha_shares.saturating_div(total_hotkey_shares);
7983
let coldkey_tao = coldkey_share.saturating_mul(hotkey_tao);
8084
let coldkey_alpha = coldkey_share.saturating_mul(total_hotkey_alpha);
85+
log::debug!("Alpha shares: {}", alpha_shares);
86+
log::debug!("Coldkey share: {}", coldkey_share);
87+
log::debug!("Coldkey TAO: {}", coldkey_tao);
8188

8289
// Distribute the TAO to the coldkey
8390
let as_tao: u64 = coldkey_tao.saturating_to_num::<u64>();

0 commit comments

Comments
 (0)