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
@@ -250,6 +259,10 @@ class Block(Header):
250259 """
251260 EIP-7928: Block-level access lists (serialized).
252261 """
262+ test_phase : TestPhase | None = None
263+ """
264+ Test phase for this block.
265+ """
253266
254267 def set_environment (self , env : Environment ) -> Environment :
255268 """
@@ -423,10 +436,11 @@ class BlockchainTest(BaseTest):
423436
424437 pre : Alloc
425438 post : Alloc
426- blocks : List [Block ]
439+ blocks : List [Block ] = Field ( default_factory = list )
427440 genesis_environment : Environment = Field (default_factory = Environment )
428441 chain_id : int = 1
429442 exclude_full_post_state_in_output : bool = False
443+ test_phase_manager : TestPhaseManager | None = None
430444 """
431445 Exclude the post state from the fixture output.
432446 In this case, the state verification is only performed based on the state root.
@@ -706,6 +720,31 @@ def verify_post_state(self, t8n, t8n_state: Alloc, expected_state: Alloc | None
706720 print_traces (t8n .get_traces ())
707721 raise e
708722
723+ def _get_test_phase_blocks (self ) -> List [Block ]:
724+ """Get additional blocks from benchmark manager setup and execution phases."""
725+ assert self .test_phase_manager is not None , "Test phase manager is not set"
726+
727+ blocks = []
728+ if self .test_phase_manager .setup_blocks :
729+ for block in self .test_phase_manager .setup_blocks :
730+ block .test_phase = TestPhase .SETUP
731+ blocks .extend (self .test_phase_manager .setup_blocks )
732+ elif self .test_phase_manager .setup_transactions :
733+ for tx in self .test_phase_manager .setup_transactions :
734+ tx .test_phase = TestPhase .SETUP
735+ blocks .append (Block (txs = self .test_phase_manager .setup_transactions ))
736+
737+ if self .test_phase_manager .execution_blocks :
738+ for block in self .test_phase_manager .execution_blocks :
739+ block .test_phase = TestPhase .EXECUTION
740+ blocks .extend (self .test_phase_manager .execution_blocks )
741+ elif self .test_phase_manager .execution_transactions :
742+ for tx in self .test_phase_manager .execution_transactions :
743+ tx .test_phase = TestPhase .EXECUTION
744+ blocks .append (Block (txs = self .test_phase_manager .execution_transactions ))
745+
746+ return blocks
747+
709748 def make_fixture (
710749 self ,
711750 t8n : TransitionTool ,
@@ -720,6 +759,10 @@ def make_fixture(
720759 env = environment_from_parent_header (genesis .header )
721760 head = genesis .header .block_hash
722761 invalid_blocks = 0
762+
763+ if self .test_phase_manager is not None :
764+ self .blocks .extend (self ._get_test_phase_blocks ())
765+
723766 for i , block in enumerate (self .blocks ):
724767 # This is the most common case, the RLP needs to be constructed
725768 # based on the transactions to be included in the block.
@@ -783,6 +826,10 @@ def make_hive_fixture(
783826 env = environment_from_parent_header (genesis .header )
784827 head_hash = genesis .header .block_hash
785828 invalid_blocks = 0
829+
830+ if self .test_phase_manager is not None :
831+ self .blocks .extend (self ._get_test_phase_blocks ())
832+
786833 for i , block in enumerate (self .blocks ):
787834 built_block = self .generate_block_data (
788835 t8n = t8n ,
@@ -904,6 +951,8 @@ def execute(
904951 """Generate the list of test fixtures."""
905952 if execute_format == TransactionPost :
906953 blocks : List [List [Transaction ]] = []
954+ if self .test_phase_manager is not None :
955+ self .blocks .extend (self ._get_test_phase_blocks ())
907956 for block in self .blocks :
908957 blocks += [block .txs ]
909958 return TransactionPost (
0 commit comments