@@ -710,10 +710,8 @@ impl From<Error> for BeaconChainError {
710710mod tests {
711711 use crate :: beacon_block_streamer:: { BeaconBlockStreamer , CheckCaches } ;
712712 use crate :: test_utils:: { test_spec, BeaconChainHarness , EphemeralHarnessType } ;
713- use execution_layer:: test_utils:: { Block , DEFAULT_ENGINE_CAPABILITIES } ;
714- use execution_layer:: EngineCapabilities ;
713+ use execution_layer:: test_utils:: Block ;
715714 use std:: sync:: LazyLock ;
716- use std:: time:: Duration ;
717715 use tokio:: sync:: mpsc;
718716 use types:: {
719717 ChainSpec , Epoch , EthSpec , FixedBytesExtended , Hash256 , Keypair , MinimalEthSpec , Slot ,
@@ -864,147 +862,4 @@ mod tests {
864862 }
865863 }
866864 }
867-
868- #[ tokio:: test]
869- async fn check_fallback_altair_to_electra ( ) {
870- let slots_per_epoch = MinimalEthSpec :: slots_per_epoch ( ) as usize ;
871- let num_epochs = 10 ;
872- let bellatrix_fork_epoch = 2usize ;
873- let capella_fork_epoch = 4usize ;
874- let deneb_fork_epoch = 6usize ;
875- let electra_fork_epoch = 8usize ;
876- let num_blocks_produced = num_epochs * slots_per_epoch;
877-
878- let mut spec = test_spec :: < MinimalEthSpec > ( ) ;
879- spec. altair_fork_epoch = Some ( Epoch :: new ( 0 ) ) ;
880- spec. bellatrix_fork_epoch = Some ( Epoch :: new ( bellatrix_fork_epoch as u64 ) ) ;
881- spec. capella_fork_epoch = Some ( Epoch :: new ( capella_fork_epoch as u64 ) ) ;
882- spec. deneb_fork_epoch = Some ( Epoch :: new ( deneb_fork_epoch as u64 ) ) ;
883- spec. electra_fork_epoch = Some ( Epoch :: new ( electra_fork_epoch as u64 ) ) ;
884-
885- let harness = get_harness ( VALIDATOR_COUNT , spec) ;
886-
887- // modify execution engine so it doesn't support engine_payloadBodiesBy* methods
888- let mock_execution_layer = harness. mock_execution_layer . as_ref ( ) . unwrap ( ) ;
889- mock_execution_layer
890- . server
891- . set_engine_capabilities ( EngineCapabilities {
892- get_payload_bodies_by_hash_v1 : false ,
893- get_payload_bodies_by_range_v1 : false ,
894- ..DEFAULT_ENGINE_CAPABILITIES
895- } ) ;
896- // refresh capabilities cache
897- harness
898- . chain
899- . execution_layer
900- . as_ref ( )
901- . unwrap ( )
902- . get_engine_capabilities ( Some ( Duration :: ZERO ) )
903- . await
904- . unwrap ( ) ;
905-
906- // go to bellatrix fork
907- harness
908- . extend_slots ( bellatrix_fork_epoch * slots_per_epoch)
909- . await ;
910- // extend half an epoch
911- harness. extend_slots ( slots_per_epoch / 2 ) . await ;
912- // trigger merge
913- harness
914- . execution_block_generator ( )
915- . move_to_terminal_block ( )
916- . expect ( "should move to terminal block" ) ;
917- let timestamp = harness. get_timestamp_at_slot ( ) + harness. spec . seconds_per_slot ;
918- harness
919- . execution_block_generator ( )
920- . modify_last_block ( |block| {
921- if let Block :: PoW ( terminal_block) = block {
922- terminal_block. timestamp = timestamp;
923- }
924- } ) ;
925- // finish out merge epoch
926- harness. extend_slots ( slots_per_epoch / 2 ) . await ;
927- // finish rest of epochs
928- harness
929- . extend_slots ( ( num_epochs - 1 - bellatrix_fork_epoch) * slots_per_epoch)
930- . await ;
931-
932- let head = harness. chain . head_snapshot ( ) ;
933- let state = & head. beacon_state ;
934-
935- assert_eq ! (
936- state. slot( ) ,
937- Slot :: new( num_blocks_produced as u64 ) ,
938- "head should be at the current slot"
939- ) ;
940- assert_eq ! (
941- state. current_epoch( ) ,
942- num_blocks_produced as u64 / MinimalEthSpec :: slots_per_epoch( ) ,
943- "head should be at the expected epoch"
944- ) ;
945- assert_eq ! (
946- state. current_justified_checkpoint( ) . epoch,
947- state. current_epoch( ) - 1 ,
948- "the head should be justified one behind the current epoch"
949- ) ;
950- assert_eq ! (
951- state. finalized_checkpoint( ) . epoch,
952- state. current_epoch( ) - 2 ,
953- "the head should be finalized two behind the current epoch"
954- ) ;
955-
956- let block_roots: Vec < Hash256 > = harness
957- . chain
958- . forwards_iter_block_roots ( Slot :: new ( 0 ) )
959- . expect ( "should get iter" )
960- . map ( Result :: unwrap)
961- . map ( |( root, _) | root)
962- . collect ( ) ;
963-
964- let mut expected_blocks = vec ! [ ] ;
965- // get all blocks the old fashioned way
966- for root in & block_roots {
967- let block = harness
968- . chain
969- . get_block ( root)
970- . await
971- . expect ( "should get block" )
972- . expect ( "block should exist" ) ;
973- expected_blocks. push ( block) ;
974- }
975-
976- for epoch in 0 ..num_epochs {
977- let start = epoch * slots_per_epoch;
978- let mut epoch_roots = vec ! [ Hash256 :: zero( ) ; slots_per_epoch] ;
979- epoch_roots[ ..] . clone_from_slice ( & block_roots[ start..( start + slots_per_epoch) ] ) ;
980- let streamer = BeaconBlockStreamer :: new ( & harness. chain , CheckCaches :: No )
981- . expect ( "should create streamer" ) ;
982- let ( block_tx, mut block_rx) = mpsc:: unbounded_channel ( ) ;
983- streamer. stream ( epoch_roots. clone ( ) , block_tx) . await ;
984-
985- for ( i, expected_root) in epoch_roots. into_iter ( ) . enumerate ( ) {
986- let ( found_root, found_block_result) =
987- block_rx. recv ( ) . await . expect ( "should get block" ) ;
988-
989- assert_eq ! (
990- found_root, expected_root,
991- "expected block root should match"
992- ) ;
993- match found_block_result. as_ref ( ) {
994- Ok ( maybe_block) => {
995- let found_block = maybe_block. clone ( ) . expect ( "should have a block" ) ;
996- let expected_block = expected_blocks
997- . get ( start + i)
998- . expect ( "should get expected block" ) ;
999- assert_eq ! (
1000- found_block. as_ref( ) ,
1001- expected_block,
1002- "expected block should match found block"
1003- ) ;
1004- }
1005- Err ( e) => panic ! ( "Error retrieving block {}: {:?}" , expected_root, e) ,
1006- }
1007- }
1008- }
1009- }
1010865}
0 commit comments