5151)
5252from  ethereum_test_fixtures .common  import  FixtureBlobSchedule 
5353from  ethereum_test_forks  import  Fork 
54- from  ethereum_test_types  import  Alloc , Environment , Removable , Requests , Transaction , Withdrawal 
54+ from  ethereum_test_types  import  (
55+     Alloc ,
56+     Environment ,
57+     Removable ,
58+     Requests ,
59+     TestPhase ,
60+     TestPhaseManager ,
61+     Transaction ,
62+     Withdrawal ,
63+ )
5564from  ethereum_test_types .block_access_list  import  BlockAccessList , BlockAccessListExpectation 
5665
5766from  .base  import  BaseTest , OpMode , verify_result 
@@ -232,7 +241,13 @@ class Block(Header):
232241    expected_post_state : Alloc  |  None  =  None 
233242    """Post state for verification after block execution in BlockchainTest""" 
234243    block_access_list : Bytes  |  None  =  Field (None )
235-     """EIP-7928: Block-level access lists (serialized).""" 
244+     """ 
245+         EIP-7928: Block-level access lists (serialized). 
246+     """ 
247+     test_phase : TestPhase  |  None  =  None 
248+     """ 
249+     Test phase for this block. 
250+     """ 
236251
237252    def  set_environment (self , env : Environment ) ->  Environment :
238253        """ 
@@ -404,10 +419,11 @@ class BlockchainTest(BaseTest):
404419
405420    pre : Alloc 
406421    post : Alloc 
407-     blocks : List [Block ]
422+     blocks : List [Block ]  =   Field ( default_factory = list ) 
408423    genesis_environment : Environment  =  Field (default_factory = Environment )
409424    chain_id : int  =  1 
410425    exclude_full_post_state_in_output : bool  =  False 
426+     test_phase_manager : TestPhaseManager  |  None  =  None 
411427    """ 
412428    Exclude the post state from the fixture output. In this case, the state 
413429    verification is only performed based on the state root. 
@@ -698,6 +714,31 @@ def verify_post_state(self, t8n, t8n_state: Alloc, expected_state: Alloc | None
698714            print_traces (t8n .get_traces ())
699715            raise  e 
700716
717+     def  _get_test_phase_blocks (self ) ->  List [Block ]:
718+         """Get additional blocks from benchmark manager setup and execution phases.""" 
719+         assert  self .test_phase_manager  is  not None , "Test phase manager is not set" 
720+ 
721+         blocks  =  []
722+         if  self .test_phase_manager .setup_blocks :
723+             for  block  in  self .test_phase_manager .setup_blocks :
724+                 block .test_phase  =  TestPhase .SETUP 
725+             blocks .extend (self .test_phase_manager .setup_blocks )
726+         elif  self .test_phase_manager .setup_transactions :
727+             for  tx  in  self .test_phase_manager .setup_transactions :
728+                 tx .test_phase  =  TestPhase .SETUP 
729+             blocks .append (Block (txs = self .test_phase_manager .setup_transactions ))
730+ 
731+         if  self .test_phase_manager .execution_blocks :
732+             for  block  in  self .test_phase_manager .execution_blocks :
733+                 block .test_phase  =  TestPhase .EXECUTION 
734+             blocks .extend (self .test_phase_manager .execution_blocks )
735+         elif  self .test_phase_manager .execution_transactions :
736+             for  tx  in  self .test_phase_manager .execution_transactions :
737+                 tx .test_phase  =  TestPhase .EXECUTION 
738+             blocks .append (Block (txs = self .test_phase_manager .execution_transactions ))
739+ 
740+         return  blocks 
741+ 
701742    def  make_fixture (
702743        self ,
703744        t8n : TransitionTool ,
@@ -712,6 +753,10 @@ def make_fixture(
712753        env  =  environment_from_parent_header (genesis .header )
713754        head  =  genesis .header .block_hash 
714755        invalid_blocks  =  0 
756+ 
757+         if  self .test_phase_manager  is  not None :
758+             self .blocks .extend (self ._get_test_phase_blocks ())
759+ 
715760        for  i , block  in  enumerate (self .blocks ):
716761            # This is the most common case, the RLP needs to be constructed 
717762            # based on the transactions to be included in the block. 
@@ -776,6 +821,10 @@ def make_hive_fixture(
776821        env  =  environment_from_parent_header (genesis .header )
777822        head_hash  =  genesis .header .block_hash 
778823        invalid_blocks  =  0 
824+ 
825+         if  self .test_phase_manager  is  not None :
826+             self .blocks .extend (self ._get_test_phase_blocks ())
827+ 
779828        for  i , block  in  enumerate (self .blocks ):
780829            built_block  =  self .generate_block_data (
781830                t8n = t8n ,
@@ -897,6 +946,8 @@ def execute(
897946        """Generate the list of test fixtures.""" 
898947        if  execute_format  ==  TransactionPost :
899948            blocks : List [List [Transaction ]] =  []
949+             if  self .test_phase_manager  is  not None :
950+                 self .blocks .extend (self ._get_test_phase_blocks ())
900951            for  block  in  self .blocks :
901952                blocks  +=  [block .txs ]
902953            return  TransactionPost (
0 commit comments