@@ -1875,9 +1875,32 @@ impl Bank {
1875
1875
let ( parent_epoch, mut parent_slot_index) =
1876
1876
self . get_epoch_and_slot_index ( self . parent_slot ( ) ) ;
1877
1877
1878
+ let should_enable = match self . operating_mode ( ) {
1879
+ OperatingMode :: Development => true ,
1880
+ OperatingMode :: Preview => current_epoch >= Epoch :: max_value ( ) ,
1881
+ OperatingMode :: Stable => {
1882
+ #[ cfg( not( test) ) ]
1883
+ let should_enable = current_epoch >= Epoch :: max_value ( ) ;
1884
+
1885
+ // needed for test_rent_eager_across_epoch_with_gap_under_multi_epoch_cycle,
1886
+ // which depends on OperatingMode::Stable
1887
+ #[ cfg( test) ]
1888
+ let should_enable = true ;
1889
+
1890
+ should_enable
1891
+ }
1892
+ } ;
1893
+
1878
1894
let mut partitions = vec ! [ ] ;
1879
1895
if parent_epoch < current_epoch {
1880
- if current_slot_index > 0 {
1896
+ // this needs to be gated because this potentially can change the behavior
1897
+ // (= bank hash) at each start of epochs
1898
+ let slot_skipped = if should_enable {
1899
+ ( self . slot ( ) - self . parent_slot ( ) ) > 1
1900
+ } else {
1901
+ current_slot_index > 0
1902
+ } ;
1903
+ if slot_skipped {
1881
1904
// Generate special partitions because there are skipped slots
1882
1905
// exactly at the epoch transition.
1883
1906
@@ -1890,24 +1913,9 @@ impl Bank {
1890
1913
parent_epoch,
1891
1914
) ) ;
1892
1915
1893
- let should_enable = match self . operating_mode ( ) {
1894
- OperatingMode :: Development => true ,
1895
- OperatingMode :: Preview => current_epoch >= Epoch :: max_value ( ) ,
1896
- OperatingMode :: Stable => {
1897
- #[ cfg( not( test) ) ]
1898
- let should_enable = current_epoch >= Epoch :: max_value ( ) ;
1899
-
1900
- // needed for test_rent_eager_across_epoch_with_gap_under_multi_epoch_cycle,
1901
- // which depends on OperatingMode::Stable
1902
- #[ cfg( test) ]
1903
- let should_enable = true ;
1904
-
1905
- should_enable
1906
- }
1907
- } ;
1908
1916
// this needs to be gated because this potentially can change the behavior
1909
1917
// (= bank hash) at each start of epochs
1910
- if should_enable {
1918
+ if should_enable && current_slot_index > 0 {
1911
1919
// ... for current epoch
1912
1920
partitions. push ( self . partition_from_slot_indexes_with_gapped_epochs (
1913
1921
0 ,
@@ -3642,7 +3650,7 @@ mod tests {
3642
3650
}
3643
3651
3644
3652
#[ test]
3645
- fn test_rent_eager_across_epoch_with_gap ( ) {
3653
+ fn test_rent_eager_across_epoch_with_full_gap ( ) {
3646
3654
let ( genesis_config, _mint_keypair) = create_genesis_config ( 1 ) ;
3647
3655
3648
3656
let mut bank = Arc :: new ( Bank :: new ( & genesis_config) ) ;
@@ -3659,6 +3667,30 @@ mod tests {
3659
3667
bank. rent_collection_partitions( ) ,
3660
3668
vec![ ( 14 , 31 , 32 ) , ( 0 , 0 , 64 ) , ( 0 , 17 , 64 ) ]
3661
3669
) ;
3670
+ bank = Arc :: new ( new_from_parent ( & bank) ) ;
3671
+ assert_eq ! ( bank. rent_collection_partitions( ) , vec![ ( 17 , 18 , 64 ) ] ) ;
3672
+ }
3673
+
3674
+ #[ test]
3675
+ fn test_rent_eager_across_epoch_with_half_gap ( ) {
3676
+ let ( genesis_config, _mint_keypair) = create_genesis_config ( 1 ) ;
3677
+
3678
+ let mut bank = Arc :: new ( Bank :: new ( & genesis_config) ) ;
3679
+ assert_eq ! ( bank. rent_collection_partitions( ) , vec![ ( 0 , 0 , 32 ) ] ) ;
3680
+
3681
+ bank = Arc :: new ( new_from_parent ( & bank) ) ;
3682
+ assert_eq ! ( bank. rent_collection_partitions( ) , vec![ ( 0 , 1 , 32 ) ] ) ;
3683
+ for _ in 2 ..15 {
3684
+ bank = Arc :: new ( new_from_parent ( & bank) ) ;
3685
+ }
3686
+ assert_eq ! ( bank. rent_collection_partitions( ) , vec![ ( 13 , 14 , 32 ) ] ) ;
3687
+ bank = Arc :: new ( Bank :: new_from_parent ( & bank, & Pubkey :: default ( ) , 32 ) ) ;
3688
+ assert_eq ! (
3689
+ bank. rent_collection_partitions( ) ,
3690
+ vec![ ( 14 , 31 , 32 ) , ( 0 , 0 , 64 ) ]
3691
+ ) ;
3692
+ bank = Arc :: new ( new_from_parent ( & bank) ) ;
3693
+ assert_eq ! ( bank. rent_collection_partitions( ) , vec![ ( 0 , 1 , 64 ) ] ) ;
3662
3694
}
3663
3695
3664
3696
#[ test]
0 commit comments