19
19
from pydantic import BaseModel
20
20
21
21
from ethereum_test_base_types import Account , Hash
22
+ from ethereum_test_rpc .types import TransactionByHashResponse
22
23
from ethereum_test_tools import Environment , Transaction
23
24
24
25
from .request_manager import RPCRequest
@@ -39,7 +40,7 @@ class StateTestProvider(Provider):
39
40
40
41
transaction_hash : Hash
41
42
block : Optional [Environment ] = None
42
- transaction : Optional [Transaction ] = None
43
+ transaction_response : Optional [TransactionByHashResponse ] = None
43
44
state : Optional [Dict [str , Dict ]] = None
44
45
45
46
def _make_rpc_calls (self ):
@@ -48,13 +49,13 @@ def _make_rpc_calls(self):
48
49
f"Perform tx request: eth_get_transaction_by_hash({ self .transaction_hash } )" ,
49
50
file = stderr ,
50
51
)
51
- self .transaction = request .eth_get_transaction_by_hash (self .transaction_hash )
52
+ self .transaction_response = request .eth_get_transaction_by_hash (self .transaction_hash )
52
53
53
54
print ("Perform debug_trace_call" , file = stderr )
54
- self .state = request .debug_trace_call (self .transaction )
55
+ self .state = request .debug_trace_call (self .transaction_response )
55
56
56
57
print ("Perform eth_get_block_by_number" , file = stderr )
57
- self .block = request .eth_get_block_by_number (self .transaction .block_number )
58
+ self .block = request .eth_get_block_by_number (self .transaction_response .block_number )
58
59
59
60
print ("Generate py test" , file = stderr )
60
61
@@ -64,22 +65,23 @@ def _get_environment(self) -> Environment:
64
65
65
66
def _get_pre_state (self ) -> Dict [str , Account ]:
66
67
assert self .state is not None
67
- assert self .transaction is not None
68
+ assert self .transaction_response is not None
68
69
69
70
pre_state : Dict [str , Account ] = {}
70
71
for address , account_data in self .state .items ():
71
72
# TODO: Check if this is required. Ideally,
72
73
# the pre-state tracer should have the correct
73
74
# values without requiring any additional modifications.
74
- if address == self .transaction .sender :
75
- account_data ["nonce" ] = self .transaction .nonce
75
+ if address == self .transaction_response .sender :
76
+ account_data ["nonce" ] = self .transaction_response .nonce
76
77
77
78
pre_state [address ] = Account (** account_data )
78
79
return pre_state
79
80
80
81
def _get_transaction (self ) -> Transaction :
81
- assert self .transaction is not None
82
- return self .transaction
82
+ assert self .transaction_response is not None
83
+ # Validate the RPC TransactionHashResponse and convert it to a Transaction instance.
84
+ return Transaction .model_validate (self .transaction_response .model_dump ())
83
85
84
86
def get_context (self ) -> Dict [str , Any ]:
85
87
"""
0 commit comments