@@ -22,6 +22,10 @@ impl<T: Config> Pallet<T> {
22
22
let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
23
23
log:: trace!( "current_block:\n {:?}\n " , current_block) ;
24
24
25
+ // Get tempo.
26
+ let tempo: u64 = Self :: get_tempo ( netuid) . into ( ) ;
27
+ log:: trace!( "tempo: {:?}" , tempo) ;
28
+
25
29
// Get activity cutoff.
26
30
let activity_cutoff: u64 = Self :: get_activity_cutoff ( netuid) as u64 ;
27
31
log:: trace!( "activity_cutoff:\n {:?}\n " , activity_cutoff) ;
@@ -44,7 +48,7 @@ impl<T: Config> Pallet<T> {
44
48
let block_at_registration: Vec < u64 > = Self :: get_block_at_registration ( netuid) ;
45
49
log:: trace!( "Block at registration:\n {:?}\n " , & block_at_registration) ;
46
50
47
- // Outdated matrix, updated_ij =True if i has last updated (weights) after j has last registered.
51
+ // Outdated matrix, outdated_ij =True if i has last updated (weights) after j has last registered.
48
52
let outdated: Vec < Vec < bool > > = last_update
49
53
. iter ( )
50
54
. map ( |updated| {
@@ -56,6 +60,16 @@ impl<T: Config> Pallet<T> {
56
60
. collect ( ) ;
57
61
log:: trace!( "Outdated:\n {:?}\n " , & outdated) ;
58
62
63
+ // Recently registered matrix, recently_ij=True if last_tempo was *before* j was last registered.
64
+ // Mask if: the last tempo block happened *before* the registration block
65
+ // ==> last_tempo <= registered
66
+ let last_tempo: u64 = current_block. saturating_sub ( tempo) ;
67
+ let recently_registered: Vec < bool > = block_at_registration
68
+ . iter ( )
69
+ . map ( |registered| last_tempo <= * registered)
70
+ . collect ( ) ;
71
+ log:: trace!( "Recently registered:\n {:?}\n " , & recently_registered) ;
72
+
59
73
// ===========
60
74
// == Stake ==
61
75
// ===========
@@ -185,7 +199,8 @@ impl<T: Config> Pallet<T> {
185
199
186
200
// Access network bonds.
187
201
let mut bonds: Vec < Vec < I32F32 > > = Self :: get_bonds ( netuid) ;
188
- inplace_mask_matrix ( & outdated, & mut bonds) ; // mask outdated bonds
202
+ // Remove bonds referring to neurons that have registered since last tempo.
203
+ inplace_mask_cols ( & recently_registered, & mut bonds) ; // mask recently registered bonds
189
204
inplace_col_normalize ( & mut bonds) ; // sum_i b_ij = 1
190
205
log:: trace!( "B:\n {:?}\n " , & bonds) ;
191
206
@@ -386,6 +401,10 @@ impl<T: Config> Pallet<T> {
386
401
let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
387
402
log:: trace!( "current_block: {:?}" , current_block) ;
388
403
404
+ // Get tempo.
405
+ let tempo: u64 = Self :: get_tempo ( netuid) . into ( ) ;
406
+ log:: trace!( "tempo:\n {:?}\n " , tempo) ;
407
+
389
408
// Get activity cutoff.
390
409
let activity_cutoff: u64 = Self :: get_activity_cutoff ( netuid) as u64 ;
391
410
log:: trace!( "activity_cutoff: {:?}" , activity_cutoff) ;
@@ -548,12 +567,15 @@ impl<T: Config> Pallet<T> {
548
567
let mut bonds: Vec < Vec < ( u16 , I32F32 ) > > = Self :: get_bonds_sparse ( netuid) ;
549
568
log:: trace!( "B: {:?}" , & bonds) ;
550
569
551
- // Remove bonds referring to deregistered neurons.
552
- bonds = vec_mask_sparse_matrix (
570
+ // Remove bonds referring to neurons that have registered since last tempo.
571
+ // Mask if: the last tempo block happened *before* the registration block
572
+ // ==> last_tempo <= registered
573
+ let last_tempo: u64 = current_block. saturating_sub ( tempo) ;
574
+ bonds = scalar_vec_mask_sparse_matrix (
553
575
& bonds,
554
- & last_update ,
576
+ last_tempo ,
555
577
& block_at_registration,
556
- & |updated , registered| updated <= registered,
578
+ & |last_tempo , registered| last_tempo <= registered,
557
579
) ;
558
580
log:: trace!( "B (outdatedmask): {:?}" , & bonds) ;
559
581
0 commit comments