51
51
)
52
52
from ethereum_test_fixtures .common import FixtureBlobSchedule
53
53
from 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
+ )
55
64
from ethereum_test_types .block_access_list import BlockAccessList , BlockAccessListExpectation
56
65
57
66
from .base import BaseTest , OpMode , verify_result
@@ -250,6 +259,10 @@ class Block(Header):
250
259
"""
251
260
EIP-7928: Block-level access lists (serialized).
252
261
"""
262
+ test_phase : TestPhase | None = None
263
+ """
264
+ Test phase for this block.
265
+ """
253
266
254
267
def set_environment (self , env : Environment ) -> Environment :
255
268
"""
@@ -423,10 +436,11 @@ class BlockchainTest(BaseTest):
423
436
424
437
pre : Alloc
425
438
post : Alloc
426
- blocks : List [Block ]
439
+ blocks : List [Block ] = Field ( default_factory = list )
427
440
genesis_environment : Environment = Field (default_factory = Environment )
428
441
chain_id : int = 1
429
442
exclude_full_post_state_in_output : bool = False
443
+ test_phase_manager : TestPhaseManager | None = None
430
444
"""
431
445
Exclude the post state from the fixture output.
432
446
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
706
720
print_traces (t8n .get_traces ())
707
721
raise e
708
722
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
+
709
748
def make_fixture (
710
749
self ,
711
750
t8n : TransitionTool ,
@@ -720,6 +759,10 @@ def make_fixture(
720
759
env = environment_from_parent_header (genesis .header )
721
760
head = genesis .header .block_hash
722
761
invalid_blocks = 0
762
+
763
+ if self .test_phase_manager is not None :
764
+ self .blocks .extend (self ._get_test_phase_blocks ())
765
+
723
766
for i , block in enumerate (self .blocks ):
724
767
# This is the most common case, the RLP needs to be constructed
725
768
# based on the transactions to be included in the block.
@@ -783,6 +826,10 @@ def make_hive_fixture(
783
826
env = environment_from_parent_header (genesis .header )
784
827
head_hash = genesis .header .block_hash
785
828
invalid_blocks = 0
829
+
830
+ if self .test_phase_manager is not None :
831
+ self .blocks .extend (self ._get_test_phase_blocks ())
832
+
786
833
for i , block in enumerate (self .blocks ):
787
834
built_block = self .generate_block_data (
788
835
t8n = t8n ,
@@ -904,6 +951,8 @@ def execute(
904
951
"""Generate the list of test fixtures."""
905
952
if execute_format == TransactionPost :
906
953
blocks : List [List [Transaction ]] = []
954
+ if self .test_phase_manager is not None :
955
+ self .blocks .extend (self ._get_test_phase_blocks ())
907
956
for block in self .blocks :
908
957
blocks += [block .txs ]
909
958
return TransactionPost (
0 commit comments