@@ -1875,9 +1875,32 @@ impl Bank {
18751875 let ( parent_epoch, mut parent_slot_index) =
18761876 self . get_epoch_and_slot_index ( self . parent_slot ( ) ) ;
18771877
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+
18781894 let mut partitions = vec ! [ ] ;
18791895 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 {
18811904 // Generate special partitions because there are skipped slots
18821905 // exactly at the epoch transition.
18831906
@@ -1890,24 +1913,9 @@ impl Bank {
18901913 parent_epoch,
18911914 ) ) ;
18921915
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- } ;
19081916 // this needs to be gated because this potentially can change the behavior
19091917 // (= bank hash) at each start of epochs
1910- if should_enable {
1918+ if should_enable && current_slot_index > 0 {
19111919 // ... for current epoch
19121920 partitions. push ( self . partition_from_slot_indexes_with_gapped_epochs (
19131921 0 ,
@@ -3642,7 +3650,7 @@ mod tests {
36423650 }
36433651
36443652 #[ test]
3645- fn test_rent_eager_across_epoch_with_gap ( ) {
3653+ fn test_rent_eager_across_epoch_with_full_gap ( ) {
36463654 let ( genesis_config, _mint_keypair) = create_genesis_config ( 1 ) ;
36473655
36483656 let mut bank = Arc :: new ( Bank :: new ( & genesis_config) ) ;
@@ -3659,6 +3667,30 @@ mod tests {
36593667 bank. rent_collection_partitions( ) ,
36603668 vec![ ( 14 , 31 , 32 ) , ( 0 , 0 , 64 ) , ( 0 , 17 , 64 ) ]
36613669 ) ;
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 ) ] ) ;
36623694 }
36633695
36643696 #[ test]
0 commit comments