88import textwrap
99import time
1010from abc import abstractmethod
11- from dataclasses import dataclass , field
11+ from dataclasses import dataclass
1212from pathlib import Path
1313from typing import Any , Dict , List , Mapping , Optional , Type
1414from urllib .parse import urlencode
1717from requests .exceptions import ConnectionError as RequestsConnectionError
1818from requests_unixsocket import Session # type: ignore
1919
20+ from ethereum_test_base_types import BlobSchedule
2021from ethereum_test_exceptions import ExceptionMapper
2122from ethereum_test_fixtures import FixtureFormat , FixtureVerifier
2223from ethereum_test_forks import Fork
2324from ethereum_test_types import Alloc , Environment , Transaction
2425
2526from .ethereum_cli import EthereumCLI
2627from .file_utils import dump_files_to_directory , write_json_file
27- from .types import TransactionReceipt , TransitionToolInput , TransitionToolOutput
28+ from .types import (
29+ TransactionReceipt ,
30+ TransitionToolInput ,
31+ TransitionToolOutput ,
32+ TransitionToolPost ,
33+ TransitionToolState ,
34+ )
2835
2936model_dump_config : Mapping = {"by_alias" : True , "exclude_none" : True }
3037
@@ -130,9 +137,10 @@ class TransitionToolData:
130137 txs : List [Transaction ]
131138 env : Environment
132139 fork_name : str
133- chain_id : int = field (default = 1 )
134- reward : int = field (default = 0 )
135- state_test : bool = field (default = False )
140+ chain_id : int
141+ reward : int
142+ blob_schedule : BlobSchedule | None
143+ state_test : bool
136144
137145 def to_input (self ) -> TransitionToolInput :
138146 """Convert the data to a TransactionToolInput object."""
@@ -142,6 +150,18 @@ def to_input(self) -> TransitionToolInput:
142150 env = self .env ,
143151 )
144152
153+ def get_post (self ) -> TransitionToolPost :
154+ """Convert the data to a TransitionToolState object."""
155+ return TransitionToolPost (
156+ state = TransitionToolState (
157+ fork = self .fork_name ,
158+ chain_id = self .chain_id ,
159+ reward = self .reward ,
160+ blob_schedule = self .blob_schedule ,
161+ ),
162+ input = self .to_input (),
163+ )
164+
145165 def _evaluate_filesystem (
146166 self ,
147167 * ,
@@ -298,37 +318,29 @@ def _evaluate_server(
298318 timeout : int ,
299319 ) -> TransitionToolOutput :
300320 """Execute the transition tool sending inputs and outputs via a server."""
301- input_contents = t8n_data .to_input ()
302- input_json = input_contents .model_dump (mode = "json" , ** model_dump_config )
303- post_data = {
304- "state" : {
305- "fork" : t8n_data .fork_name ,
306- "chainid" : t8n_data .chain_id ,
307- "reward" : t8n_data .reward ,
308- },
309- "input" : input_json ,
310- }
321+ post_data = t8n_data .get_post ()
322+ post_json = post_data .model_dump (mode = "json" , ** model_dump_config )
311323
312324 if debug_output_path :
313325 request_info = (
314326 f"Server URL: { self .server_url } \n \n "
315- f"Request Data:\n { json .dumps (post_data , indent = 2 )} \n "
327+ f"Request Data:\n { json .dumps (post_json , indent = 2 )} \n "
316328 )
317329 dump_files_to_directory (
318330 debug_output_path ,
319331 {
320- "input/alloc.json" : input_contents .alloc ,
321- "input/env.json" : input_contents .env ,
332+ "input/alloc.json" : post_data . input .alloc ,
333+ "input/env.json" : post_data . input .env ,
322334 "input/txs.json" : [
323335 tx .model_dump (mode = "json" , ** model_dump_config )
324- for tx in input_contents .txs
336+ for tx in post_data . input .txs
325337 ],
326338 "request_info.txt" : request_info ,
327339 },
328340 )
329341
330342 response = self ._server_post (
331- data = post_data , url_args = self ._generate_post_args (t8n_data ), timeout = timeout
343+ data = post_json , url_args = self ._generate_post_args (t8n_data ), timeout = timeout
332344 )
333345 output : TransitionToolOutput = TransitionToolOutput .model_validate (response .json ())
334346
@@ -465,8 +477,9 @@ def evaluate(
465477 txs : List [Transaction ],
466478 env : Environment ,
467479 fork : Fork ,
468- chain_id : int = 1 ,
469- reward : int = 0 ,
480+ chain_id : int ,
481+ reward : int ,
482+ blob_schedule : BlobSchedule | None ,
470483 eips : Optional [List [int ]] = None ,
471484 debug_output_path : str = "" ,
472485 state_test : bool = False ,
@@ -493,6 +506,7 @@ def evaluate(
493506 fork_name = fork_name ,
494507 chain_id = chain_id ,
495508 reward = reward ,
509+ blob_schedule = blob_schedule ,
496510 state_test = state_test ,
497511 )
498512
0 commit comments