@@ -18,7 +18,11 @@ pub struct WeightsTlockPayload {
18
18
}
19
19
20
20
impl < T : Config > Pallet < T > {
21
- pub fn get_root_divs_in_alpha ( netuid : u16 , alpha_out_emission : I96F32 ) -> I96F32 {
21
+ pub fn get_root_divs_in_alpha (
22
+ netuid : u16 ,
23
+ alpha_out_emission : I96F32 ,
24
+ validator_proportion : I96F32 ,
25
+ ) -> I96F32 {
22
26
// Get total TAO on root.
23
27
let total_root_tao: I96F32 = I96F32 :: from_num ( SubnetTAO :: < T > :: get ( 0 ) ) ;
24
28
// Get total ALPHA on subnet.
@@ -32,7 +36,8 @@ impl<T: Config> Pallet<T> {
32
36
// Get root proportion of alpha_out dividends.
33
37
let root_divs_in_alpha: I96F32 = root_proportion
34
38
. saturating_mul ( alpha_out_emission)
35
- . saturating_mul ( I96F32 :: from_num ( 0.41 ) ) ;
39
+ . saturating_mul ( validator_proportion) ; // % of emission that goes to *all* validators.
40
+
36
41
// Return
37
42
root_divs_in_alpha
38
43
}
@@ -207,9 +212,14 @@ impl<T: Config> Pallet<T> {
207
212
remaining_emission
208
213
) ;
209
214
215
+ // Validators get 50% of remaining emission.
216
+ let validator_proportion: I96F32 = I96F32 :: from_num ( 0.5 ) ;
210
217
// Get proportion of alpha out emission as root divs.
211
- let root_emission_in_alpha: I96F32 =
212
- Self :: get_root_divs_in_alpha ( * netuid, I96F32 :: from_num ( remaining_emission) ) ;
218
+ let root_emission_in_alpha: I96F32 = Self :: get_root_divs_in_alpha (
219
+ * netuid,
220
+ I96F32 :: from_num ( remaining_emission) ,
221
+ validator_proportion,
222
+ ) ;
213
223
// Subtract root divs from alpha divs.
214
224
let pending_alpha_emission: I96F32 =
215
225
I96F32 :: from_num ( remaining_emission) . saturating_sub ( root_emission_in_alpha) ;
@@ -221,10 +231,18 @@ impl<T: Config> Pallet<T> {
221
231
PendingRootDivs :: < T > :: mutate ( * netuid, |total| {
222
232
* total = total. saturating_add ( root_emission_in_tao) ;
223
233
} ) ;
234
+ // Accumulate alpha that was swapped for the pending root divs.
235
+ PendingAlphaSwapped :: < T > :: mutate ( * netuid, |total| {
236
+ * total = total. saturating_add ( root_emission_in_alpha. to_num :: < u64 > ( ) ) ;
237
+ } ) ;
224
238
// Accumulate alpha emission in pending.
225
239
PendingEmission :: < T > :: mutate ( * netuid, |total| {
226
240
* total = total. saturating_add ( pending_alpha_emission. to_num :: < u64 > ( ) ) ;
227
241
} ) ;
242
+ // Accumulate the owner cut in pending.
243
+ PendingOwnerCut :: < T > :: mutate ( * netuid, |total| {
244
+ * total = total. saturating_add ( owner_cut) ;
245
+ } ) ;
228
246
}
229
247
230
248
// --- 5. Drain pending emission through the subnet based on tempo.
@@ -247,18 +265,24 @@ impl<T: Config> Pallet<T> {
247
265
let pending_emission: u64 = PendingEmission :: < T > :: get ( netuid) ;
248
266
PendingEmission :: < T > :: insert ( netuid, 0 ) ;
249
267
250
- // 5.2.2 Get and drain the subnet pending root divs.
268
+ // 5.2.2a Get and drain the subnet pending root divs.
251
269
let pending_root_divs: u64 = PendingRootDivs :: < T > :: get ( netuid) ;
252
270
PendingRootDivs :: < T > :: insert ( netuid, 0 ) ;
253
271
254
- // 5.2.3 Get owner cut.
255
- let owner_cut: u64 = * owner_cuts. get ( & netuid) . unwrap_or ( & 0 ) ;
272
+ // 5.2.2b Get this amount as alpha that was swapped for pending root divs.
273
+ let pending_alpha_swapped: u64 = PendingAlphaSwapped :: < T > :: get ( netuid) ;
274
+ PendingAlphaSwapped :: < T > :: insert ( netuid, 0 ) ;
275
+
276
+ // 5.2.3 Get owner cut and drain.
277
+ let owner_cut: u64 = PendingOwnerCut :: < T > :: get ( netuid) ;
278
+ PendingOwnerCut :: < T > :: insert ( netuid, 0 ) ;
256
279
257
280
// 5.2.4 Drain pending root divs, alpha emission, and owner cut.
258
281
Self :: drain_pending_emission (
259
282
netuid,
260
283
pending_emission,
261
284
pending_root_divs,
285
+ pending_alpha_swapped,
262
286
owner_cut,
263
287
) ;
264
288
} else {
@@ -272,19 +296,24 @@ impl<T: Config> Pallet<T> {
272
296
netuid : u16 ,
273
297
pending_alpha_emission : u64 ,
274
298
pending_root_divs : u64 ,
299
+ pending_alpha_swapped : u64 ,
275
300
owner_cut : u64 ,
276
301
) {
277
302
log:: debug!(
278
- "Draining pending alpha emission for netuid {:?}: {:?}, with pending root divs {:?}, and owner cut {:?}" ,
303
+ "Draining pending alpha emission for netuid {:?}: {:?}, with pending root divs {:?}, pending alpha swapped {:?}, and owner cut {:?}" ,
279
304
netuid,
280
305
pending_alpha_emission,
281
306
pending_root_divs,
307
+ pending_alpha_swapped,
282
308
owner_cut
283
309
) ;
284
310
285
311
// Run the epoch() --> hotkey emission.
286
- let hotkey_emission: Vec < ( T :: AccountId , u64 , u64 ) > =
287
- Self :: epoch ( netuid, pending_alpha_emission) ;
312
+ // Needs to run on the full emission to the subnet.
313
+ let hotkey_emission: Vec < ( T :: AccountId , u64 , u64 ) > = Self :: epoch (
314
+ netuid,
315
+ pending_alpha_emission. saturating_add ( pending_alpha_swapped) ,
316
+ ) ;
288
317
log:: debug!(
289
318
"Hotkey emission for netuid {:?}: {:?}" ,
290
319
netuid,
0 commit comments