@@ -138,8 +138,10 @@ impl<T: Config> Pallet<T> {
138
138
for netuid_i in subnets. iter ( ) {
139
139
// Get alpha out.
140
140
let alpha_out_i: I96F32 = * alpha_out. get ( netuid_i) . unwrap_or ( & asfloat ! ( 0 ) ) ;
141
+ log:: debug!( "alpha_out_i: {:?}" , alpha_out_i) ;
141
142
// Calculate the owner cut.
142
143
let owner_cut_i: I96F32 = alpha_out_i. saturating_mul ( cut_percent) ;
144
+ log:: debug!( "owner_cut_i: {:?}" , owner_cut_i) ;
143
145
// Save owner cut.
144
146
* owner_cuts. entry ( * netuid_i) . or_insert ( asfloat ! ( 0 ) ) = owner_cut_i;
145
147
// Save new alpha_out.
@@ -155,24 +157,33 @@ impl<T: Config> Pallet<T> {
155
157
for netuid_i in subnets. iter ( ) {
156
158
// Get remaining alpha out.
157
159
let alpha_out_i: I96F32 = * alpha_out. get ( netuid_i) . unwrap_or ( & asfloat ! ( 0.0 ) ) ;
160
+ log:: debug!( "alpha_out_i: {:?}" , alpha_out_i) ;
158
161
// Get total TAO on root.
159
162
let root_tao: I96F32 = asfloat ! ( SubnetTAO :: <T >:: get( 0 ) ) ;
163
+ log:: debug!( "root_tao: {:?}" , root_tao) ;
160
164
// Get total ALPHA on subnet.
161
165
let alpha_issuance: I96F32 = asfloat ! ( Self :: get_alpha_issuance( * netuid_i) ) ;
166
+ log:: debug!( "alpha_issuance: {:?}" , alpha_issuance) ;
162
167
// Get tao_weight
163
168
let tao_weight: I96F32 = root_tao. saturating_mul ( Self :: get_tao_weight ( ) ) ;
169
+ log:: debug!( "tao_weight: {:?}" , tao_weight) ;
164
170
// Get root proportional dividends.
165
171
let root_proportion: I96F32 = tao_weight
166
172
. checked_div ( tao_weight. saturating_add ( alpha_issuance) )
167
173
. unwrap_or ( asfloat ! ( 0.0 ) ) ;
174
+ log:: debug!( "root_proportion: {:?}" , root_proportion) ;
168
175
// Get root proportion of alpha_out dividends.
169
176
let root_alpha: I96F32 = root_proportion
170
177
. saturating_mul ( alpha_out_i) // Total alpha emission per block remaining.
171
178
. saturating_mul ( asfloat ! ( 0.5 ) ) ; // 50% to validators.
172
179
// Remove root alpha from alpha_out.
180
+ log:: debug!( "root_alpha: {:?}" , root_alpha) ;
181
+ // Get pending alpha as original alpha_out - root_alpha.
173
182
let pending_alpha: I96F32 = alpha_out_i. saturating_sub ( root_alpha) ;
183
+ log:: debug!( "pending_alpha: {:?}" , pending_alpha) ;
174
184
// Sell root emission through the pool.
175
185
let root_tao: u64 = Self :: swap_alpha_for_tao ( * netuid_i, tou64 ! ( root_alpha) ) ;
186
+ log:: debug!( "root_tao: {:?}" , root_tao) ;
176
187
// Accumulate alpha emission in pending.
177
188
PendingAlphaSwapped :: < T > :: mutate ( * netuid_i, |total| {
178
189
* total = total. saturating_add ( tou64 ! ( root_alpha) ) ;
@@ -238,6 +249,11 @@ impl<T: Config> Pallet<T> {
238
249
BlocksSinceLastStep :: < T > :: mutate ( netuid, |total| * total = total. saturating_add ( 1 ) ) ;
239
250
}
240
251
}
252
+
253
+ // --- 8. Apply pending childkeys of this subnet for the next epoch
254
+ for netuid in subnets. iter ( ) {
255
+ Self :: do_set_pending_children ( * netuid) ;
256
+ }
241
257
}
242
258
243
259
pub fn drain_pending_emission (
@@ -261,6 +277,7 @@ impl<T: Config> Pallet<T> {
261
277
// Run the epoch.
262
278
let hotkey_emission: Vec < ( T :: AccountId , u64 , u64 ) > =
263
279
Self :: epoch ( netuid, pending_alpha. saturating_add ( pending_swapped) ) ;
280
+ log:: debug!( "hotkey_emission: {:?}" , hotkey_emission) ;
264
281
265
282
// Accumulate emission of dividends and incentive per hotkey.
266
283
let mut incentives: BTreeMap < T :: AccountId , u64 > = BTreeMap :: new ( ) ;
@@ -282,8 +299,10 @@ impl<T: Config> Pallet<T> {
282
299
. or_insert ( asfloat ! ( parent_div) ) ;
283
300
}
284
301
}
302
+ log:: debug!( "incentives: {:?}" , incentives) ;
303
+ log:: debug!( "dividends: {:?}" , dividends) ;
285
304
286
- // Accumulate root divs and alpha_divs. For each hotkye we compute their
305
+ // Accumulate root divs and alpha_divs. For each hotkey we compute their
287
306
// local and root dividend proportion based on their alpha_stake/root_stake
288
307
let mut total_root_divs: I96F32 = asfloat ! ( 0 ) ;
289
308
let mut root_dividends: BTreeMap < T :: AccountId , I96F32 > = BTreeMap :: new ( ) ;
@@ -300,19 +319,15 @@ impl<T: Config> Pallet<T> {
300
319
let root_alpha: I96F32 = root_stake. saturating_mul ( Self :: get_tao_weight ( ) ) ;
301
320
// Get total from root and local
302
321
let total_alpha: I96F32 = alpha_stake. saturating_add ( root_alpha) ;
303
- // Compute alpha prop.
304
- let alpha_prop: I96F32 = alpha_stake. checked_div ( total_alpha) . unwrap_or ( zero) ;
305
322
// Copmute root prop.
306
323
let root_prop: I96F32 = root_alpha. checked_div ( total_alpha) . unwrap_or ( zero) ;
307
- // Compute alpha dividends
308
- let alpha_divs: I96F32 = dividend. saturating_mul ( alpha_prop) ;
309
324
// Compute root dividends
310
325
let root_divs: I96F32 = dividend. saturating_mul ( root_prop) ;
311
326
// Record the root dividends.
312
327
alpha_dividends
313
328
. entry ( hotkey. clone ( ) )
314
- . and_modify ( |e| * e = e. saturating_add ( alpha_divs ) )
315
- . or_insert ( alpha_divs ) ;
329
+ . and_modify ( |e| * e = e. saturating_add ( dividend ) )
330
+ . or_insert ( dividend ) ;
316
331
// Record the alpha_dividends.
317
332
root_dividends
318
333
. entry ( hotkey. clone ( ) )
@@ -321,6 +336,8 @@ impl<T: Config> Pallet<T> {
321
336
// Accumulate total root divs.
322
337
total_root_divs = total_root_divs. saturating_add ( root_divs) ;
323
338
}
339
+ log:: debug!( "alpha_dividends: {:?}" , alpha_dividends) ;
340
+ log:: debug!( "root_dividends: {:?}" , root_dividends) ;
324
341
325
342
// Compute root divs as TAO. Here we take
326
343
let mut tao_dividends: BTreeMap < T :: AccountId , I96F32 > = BTreeMap :: new ( ) ;
@@ -335,6 +352,7 @@ impl<T: Config> Pallet<T> {
335
352
. and_modify ( |e| * e = root_tao)
336
353
. or_insert ( root_tao) ;
337
354
}
355
+ log:: debug!( "tao_dividends: {:?}" , tao_dividends) ;
338
356
339
357
// Distribute the owner cut.
340
358
if let Ok ( owner_coldkey) = SubnetOwner :: < T > :: try_get ( netuid) {
@@ -363,6 +381,8 @@ impl<T: Config> Pallet<T> {
363
381
// Distribute alpha divs.
364
382
let _ = AlphaDividendsPerSubnet :: < T > :: clear_prefix ( netuid, u32:: MAX , None ) ;
365
383
for ( hotkey, mut alpha_divs) in alpha_dividends {
384
+ log:: debug!( "hotkey: {:?} alpha_divs: {:?}" , hotkey, alpha_divs) ;
385
+
366
386
// Get take prop
367
387
let alpha_take: I96F32 =
368
388
Self :: get_hotkey_take_float ( & hotkey) . saturating_mul ( alpha_divs) ;
@@ -386,6 +406,7 @@ impl<T: Config> Pallet<T> {
386
406
// Distribute root tao divs.
387
407
let _ = TaoDividendsPerSubnet :: < T > :: clear_prefix ( netuid, u32:: MAX , None ) ;
388
408
for ( hotkey, mut root_tao) in tao_dividends {
409
+ log:: debug!( "hotkey: {:?} root_tao: {:?}" , hotkey, root_tao) ;
389
410
// Get take prop
390
411
let tao_take: I96F32 = Self :: get_hotkey_take_float ( & hotkey) . saturating_mul ( root_tao) ;
391
412
// Remove take prop from root_tao
0 commit comments