11
11
Tuple ,
12
12
Type ,
13
13
TYPE_CHECKING ,
14
+ Union ,
14
15
)
15
16
from uuid import UUID
16
17
34
35
from eth .tools .logging import (
35
36
TraceLogger ,
36
37
)
38
+ from eth .typing import (
39
+ BaseOrSpoofTransaction ,
40
+ )
37
41
from eth .utils .datatypes import (
38
42
Configurable ,
39
43
)
49
53
from eth .rlp .transactions import ( # noqa: F401
50
54
BaseTransaction ,
51
55
)
56
+
52
57
from eth .vm .transaction_context import ( # noqa: F401
53
58
BaseTransactionContext ,
54
59
)
@@ -250,7 +255,8 @@ def apply_transaction(self, transaction: 'BaseTransaction') -> Tuple[bytes, 'Bas
250
255
def get_transaction_executor (self ) -> 'BaseTransactionExecutor' :
251
256
return self .transaction_executor (self )
252
257
253
- def costless_execute_transaction (self , transaction : 'BaseTransaction' ) -> 'BaseComputation' :
258
+ def costless_execute_transaction (self ,
259
+ transaction : BaseOrSpoofTransaction ) -> 'BaseComputation' :
254
260
with self .override_transaction_context (gas_price = transaction .gas_price ):
255
261
free_transaction = transaction .copy (gas_price = 0 )
256
262
return self .execute_transaction (free_transaction )
@@ -270,15 +276,16 @@ def get_custom_transaction_context(transaction: 'BaseTransaction') -> 'BaseTrans
270
276
self .get_transaction_context = original_context # type: ignore # Remove ignore if https://github.com/python/mypy/issues/708 is fixed. # noqa: E501
271
277
272
278
@abstractmethod
273
- def execute_transaction (self , transaction : 'BaseTransaction' ) -> 'BaseComputation' :
279
+ def execute_transaction (self , transaction : BaseOrSpoofTransaction ) -> 'BaseComputation' :
274
280
raise NotImplementedError ()
275
281
276
282
@abstractmethod
277
- def validate_transaction (self , transaction : 'BaseTransaction' ) -> None :
283
+ def validate_transaction (self , transaction : BaseOrSpoofTransaction ) -> None :
278
284
raise NotImplementedError
279
285
280
286
@classmethod
281
- def get_transaction_context (cls , transaction : 'BaseTransaction' ) -> 'BaseTransactionContext' :
287
+ def get_transaction_context (cls ,
288
+ transaction : BaseOrSpoofTransaction ) -> 'BaseTransactionContext' :
282
289
return cls .get_transaction_context_class ()(
283
290
gas_price = transaction .gas_price ,
284
291
origin = transaction .sender ,
@@ -289,29 +296,29 @@ class BaseTransactionExecutor(ABC):
289
296
def __init__ (self , vm_state : BaseState ) -> None :
290
297
self .vm_state = vm_state
291
298
292
- def __call__ (self , transaction : 'BaseTransaction' ) -> 'BaseComputation' :
299
+ def __call__ (self , transaction : BaseOrSpoofTransaction ) -> 'BaseComputation' :
293
300
valid_transaction = self .validate_transaction (transaction )
294
301
message = self .build_evm_message (valid_transaction )
295
302
computation = self .build_computation (message , valid_transaction )
296
303
finalized_computation = self .finalize_computation (valid_transaction , computation )
297
304
return finalized_computation
298
305
299
306
@abstractmethod
300
- def validate_transaction (self , transaction : 'BaseTransaction' ) -> 'BaseTransaction' :
307
+ def validate_transaction (self , transaction : BaseOrSpoofTransaction ) -> BaseOrSpoofTransaction :
301
308
raise NotImplementedError
302
309
303
310
@abstractmethod
304
- def build_evm_message (self , transaction : 'BaseTransaction' ) -> Message :
311
+ def build_evm_message (self , transaction : BaseOrSpoofTransaction ) -> Message :
305
312
raise NotImplementedError ()
306
313
307
314
@abstractmethod
308
315
def build_computation (self ,
309
316
message : Message ,
310
- transaction : 'BaseTransaction' ) -> 'BaseComputation' :
317
+ transaction : BaseOrSpoofTransaction ) -> 'BaseComputation' :
311
318
raise NotImplementedError ()
312
319
313
320
@abstractmethod
314
321
def finalize_computation (self ,
315
- transaction : 'BaseTransaction' ,
322
+ transaction : BaseOrSpoofTransaction ,
316
323
computation : 'BaseComputation' ) -> 'BaseComputation' :
317
324
raise NotImplementedError ()
0 commit comments