File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -722,6 +722,10 @@ impl<T: Config> Pallet<T> {
722
722
Self :: deposit_event ( Event :: NetworkLockCostReductionIntervalSet ( interval) ) ;
723
723
}
724
724
pub fn get_lock_reduction_interval ( ) -> u64 {
725
- NetworkLockReductionInterval :: < T > :: get ( )
725
+ let interval: I64F64 = I64F64 :: saturating_from_num ( NetworkLockReductionInterval :: < T > :: get ( ) ) ;
726
+ let block_emission: I64F64 = I64F64 :: saturating_from_num ( Self :: get_block_emission ( ) . unwrap_or ( 1_000_000_000 ) ) ;
727
+ let halving: I64F64 = block_emission. checked_div ( I64F64 :: saturating_from_num ( 1_000_000_000 ) ) . unwrap_or ( I64F64 :: saturating_from_num ( 0.0 ) ) ;
728
+ let halved_interval: I64F64 = interval. saturating_mul ( halving ) ;
729
+ halved_interval. saturating_to_num :: < u64 > ( )
726
730
}
727
731
}
Original file line number Diff line number Diff line change @@ -704,9 +704,9 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_am
704
704
let root_after2 = SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet (
705
705
& hotkey2, & coldkey, root,
706
706
) ;
707
- let expected_stake = I96F32 :: from_num ( stake_before) + I96F32 :: from_num ( pending_alpha) * I96F32 :: from_num ( 3 / 5 ) ;
707
+ let expected_stake = I96F32 :: from_num ( stake_before) + I96F32 :: from_num ( pending_alpha) * I96F32 :: from_num ( 3.0 / 5.0 ) ;
708
708
close ( expected_stake. to_num :: < u64 > ( ) , stake_after1, 10 ) ; // Registered gets 60% of emission
709
- let expected_stake2 = I96F32 :: from_num ( stake_before) + I96F32 :: from_num ( pending_alpha) * I96F32 :: from_num ( 2 / 5 ) ;
709
+ let expected_stake2 = I96F32 :: from_num ( stake_before) + I96F32 :: from_num ( pending_alpha) * I96F32 :: from_num ( 2.0 / 5.0 ) ;
710
710
close ( expected_stake2. to_num :: < u64 > ( ) , stake_after2, 10 ) ; // Registered gets 40% emission
711
711
let expected_root1 = I96F32 :: from_num ( 2 * stake_before) + I96F32 :: from_num ( pending_tao) * I96F32 :: from_num ( 2.0 /3.0 ) ;
712
712
close ( expected_root1. to_num :: < u64 > ( ) , root_after1, 10 ) ; // Registered gets 2/3 tao emission
You can’t perform that action at this time.
0 commit comments