@@ -3679,6 +3679,68 @@ async fn ancestor_state_root_prior_to_split() {
3679
3679
assert_ne ! ( store. get_split_slot( ) , 0 ) ;
3680
3680
}
3681
3681
3682
+ // Test that the chain operates correctly when the split state is stored as a ReplayFrom.
3683
+ #[ tokio:: test]
3684
+ async fn replay_from_split_state ( ) {
3685
+ let db_path = tempdir ( ) . unwrap ( ) ;
3686
+
3687
+ let spec = test_spec :: < E > ( ) ;
3688
+
3689
+ let store_config = StoreConfig {
3690
+ prune_payloads : false ,
3691
+ hierarchy_config : HierarchyConfig :: from_str ( "5" ) . unwrap ( ) ,
3692
+ ..StoreConfig :: default ( )
3693
+ } ;
3694
+ let chain_config = ChainConfig {
3695
+ reconstruct_historic_states : false ,
3696
+ ..ChainConfig :: default ( )
3697
+ } ;
3698
+ let import_all_data_columns = false ;
3699
+
3700
+ let store = get_store_generic ( & db_path, store_config. clone ( ) , spec. clone ( ) ) ;
3701
+ let harness = get_harness_generic (
3702
+ store. clone ( ) ,
3703
+ LOW_VALIDATOR_COUNT ,
3704
+ chain_config,
3705
+ import_all_data_columns,
3706
+ ) ;
3707
+
3708
+ // Produce blocks until we finalize epoch 3 which will not be stored as a snapshot.
3709
+ let num_blocks = 5 * E :: slots_per_epoch ( ) as usize ;
3710
+
3711
+ harness
3712
+ . extend_chain (
3713
+ num_blocks,
3714
+ BlockStrategy :: OnCanonicalHead ,
3715
+ AttestationStrategy :: AllValidators ,
3716
+ )
3717
+ . await ;
3718
+
3719
+ let split = store. get_split_info ( ) ;
3720
+ let anchor_slot = store. get_anchor_info ( ) . anchor_slot ;
3721
+ assert_eq ! ( split. slot, 3 * E :: slots_per_epoch( ) ) ;
3722
+ assert_eq ! ( anchor_slot, 0 ) ;
3723
+ assert ! ( store
3724
+ . hierarchy
3725
+ . storage_strategy( split. slot, anchor_slot)
3726
+ . unwrap( )
3727
+ . is_replay_from( ) ) ;
3728
+
3729
+ // Close the database and reopen it.
3730
+ drop ( store) ;
3731
+ drop ( harness) ;
3732
+
3733
+ let store = get_store_generic ( & db_path, store_config, spec) ;
3734
+
3735
+ // Check that the split state is still accessible.
3736
+ assert_eq ! ( store. get_split_slot( ) , split. slot) ;
3737
+ let state = store
3738
+ . get_hot_state ( & split. state_root , false )
3739
+ . unwrap ( )
3740
+ . expect ( "split state should be present" ) ;
3741
+ assert_eq ! ( state. slot( ) , split. slot) ;
3742
+ }
3743
+
3682
3744
/// Checks that two chains are the same, for the purpose of these tests.
3683
3745
///
3684
3746
/// Several fields that are hard/impossible to check are ignored (e.g., the store).
0 commit comments