@@ -36,6 +36,18 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
36
36
weight = weight. saturating_add ( T :: DbWeight :: get ( ) . reads ( 1 ) ) ;
37
37
log:: debug!( "Subnet TAO: {}" , subnet_tao) ;
38
38
39
+ // Adjust total stake and total issuance
40
+ TotalStake :: < T > :: mutate ( |total| {
41
+ * total = total. saturating_sub ( subnet_tao. saturating_to_num :: < u64 > ( ) ) ;
42
+ } ) ;
43
+ TotalIssuance :: < T > :: mutate ( |total| {
44
+ * total = total. saturating_sub ( subnet_tao. saturating_to_num :: < u64 > ( ) ) ;
45
+ } ) ;
46
+ weight = weight. saturating_add ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ) ;
47
+
48
+ // Record for total issuance tracking
49
+ let mut total_swapped: u64 = 0 ;
50
+
39
51
let mut total_alpha: I96F32 = I96F32 :: from_num ( 0 ) ;
40
52
// Iterate over every hotkey and sum up the total alpha
41
53
let mut hotkeys_to_remove: Vec < T :: AccountId > = Vec :: new ( ) ;
@@ -96,6 +108,7 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
96
108
97
109
if as_tao > 0 {
98
110
Pallet :: < T > :: add_balance_to_coldkey_account ( & coldkey, as_tao) ;
111
+ total_swapped = total_swapped. saturating_add ( as_tao) ;
99
112
weight = weight. saturating_add ( T :: DbWeight :: get ( ) . reads_writes ( 1 , 1 ) ) ;
100
113
101
114
// Emit event
@@ -115,6 +128,23 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
115
128
}
116
129
}
117
130
131
+ // Update total issuance
132
+ TotalIssuance :: < T > :: mutate ( |v| * v = v. saturating_add ( total_swapped) ) ;
133
+ weight = weight. saturating_add ( T :: DbWeight :: get ( ) . reads_writes ( 1 , 1 ) ) ;
134
+
135
+ // Verify total issuance change is correct
136
+ if subnet_tao
137
+ . saturating_to_num :: < u64 > ( )
138
+ . abs_diff ( total_swapped)
139
+ >= 100_000
140
+ {
141
+ log:: info!(
142
+ "Total issuance change is incorrect: {} != {}" ,
143
+ subnet_tao. saturating_to_num:: <u64 >( ) ,
144
+ total_swapped
145
+ ) ;
146
+ }
147
+
118
148
// === Clear storage entries ===
119
149
// Clear subnet owner and hotkey
120
150
SubnetOwner :: < T > :: remove ( this_netuid) ;
@@ -154,12 +184,6 @@ pub fn migrate_dissolve_sn73<T: Config>() -> Weight {
154
184
let clear_results_1 = TaoDividendsPerSubnet :: < T > :: clear_prefix ( this_netuid, u32:: MAX , None ) ;
155
185
weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( clear_results_1. unique . into ( ) ) ) ;
156
186
157
- // Adjust total stake
158
- TotalStake :: < T > :: mutate ( |total| {
159
- * total = total. saturating_sub ( subnet_tao. saturating_to_num :: < u64 > ( ) ) ;
160
- } ) ;
161
- weight = weight. saturating_add ( T :: DbWeight :: get ( ) . reads_writes ( 1 , 1 ) ) ;
162
-
163
187
// Clear subnet volume
164
188
SubnetVolume :: < T > :: remove ( this_netuid) ;
165
189
weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
0 commit comments