@@ -22,6 +22,10 @@ impl<T: Config> Pallet<T> {
2222 let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
2323 log:: trace!( "current_block:\n {:?}\n " , current_block) ;
2424
25+ // Get tempo.
26+ let tempo: u64 = Self :: get_tempo ( netuid) . into ( ) ;
27+ log:: trace!( "tempo: {:?}" , tempo) ;
28+
2529 // Get activity cutoff.
2630 let activity_cutoff: u64 = Self :: get_activity_cutoff ( netuid) as u64 ;
2731 log:: trace!( "activity_cutoff:\n {:?}\n " , activity_cutoff) ;
@@ -44,7 +48,7 @@ impl<T: Config> Pallet<T> {
4448 let block_at_registration: Vec < u64 > = Self :: get_block_at_registration ( netuid) ;
4549 log:: trace!( "Block at registration:\n {:?}\n " , & block_at_registration) ;
4650
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.
4852 let outdated: Vec < Vec < bool > > = last_update
4953 . iter ( )
5054 . map ( |updated| {
@@ -56,6 +60,16 @@ impl<T: Config> Pallet<T> {
5660 . collect ( ) ;
5761 log:: trace!( "Outdated:\n {:?}\n " , & outdated) ;
5862
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+
5973 // ===========
6074 // == Stake ==
6175 // ===========
@@ -185,7 +199,8 @@ impl<T: Config> Pallet<T> {
185199
186200 // Access network bonds.
187201 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
189204 inplace_col_normalize ( & mut bonds) ; // sum_i b_ij = 1
190205 log:: trace!( "B:\n {:?}\n " , & bonds) ;
191206
@@ -386,6 +401,10 @@ impl<T: Config> Pallet<T> {
386401 let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
387402 log:: trace!( "current_block: {:?}" , current_block) ;
388403
404+ // Get tempo.
405+ let tempo: u64 = Self :: get_tempo ( netuid) . into ( ) ;
406+ log:: trace!( "tempo:\n {:?}\n " , tempo) ;
407+
389408 // Get activity cutoff.
390409 let activity_cutoff: u64 = Self :: get_activity_cutoff ( netuid) as u64 ;
391410 log:: trace!( "activity_cutoff: {:?}" , activity_cutoff) ;
@@ -548,12 +567,15 @@ impl<T: Config> Pallet<T> {
548567 let mut bonds: Vec < Vec < ( u16 , I32F32 ) > > = Self :: get_bonds_sparse ( netuid) ;
549568 log:: trace!( "B: {:?}" , & bonds) ;
550569
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 (
553575 & bonds,
554- & last_update ,
576+ last_tempo ,
555577 & block_at_registration,
556- & |updated , registered| updated <= registered,
578+ & |last_tempo , registered| last_tempo <= registered,
557579 ) ;
558580 log:: trace!( "B (outdatedmask): {:?}" , & bonds) ;
559581
0 commit comments