2828)
2929from .fork_types import Authorization , VersionedHash
3030
31- GAS_TX_BASE = Uint (21000 )
32- """
33- Base cost of a transaction in gas units. This is the minimum amount of gas
34- required to execute a transaction.
35- """
36-
37- GAS_TX_DATA_TOKEN_FLOOR = Uint (10 )
38- """
39- Minimum gas cost per byte of calldata as per [EIP-7623]. Used to calculate
40- the minimum gas cost for transactions that include calldata.
41-
42- [EIP-7623]: https://eips.ethereum.org/EIPS/eip-7623
43- """
44-
45- GAS_TX_DATA_TOKEN_STANDARD = Uint (4 )
46- """
47- Gas cost per byte of calldata as per [EIP-7623]. Used to calculate the
48- gas cost for transactions that include calldata.
49-
50- [EIP-7623]: https://eips.ethereum.org/EIPS/eip-7623
51- """
52-
53- GAS_TX_CREATE = Uint (32000 )
54- """
55- Additional gas cost for creating a new contract.
56- """
57-
58- GAS_TX_ACCESS_LIST_ADDRESS = Uint (2400 )
59- """
60- Gas cost for including an address in the access list of a transaction.
61- """
62-
63- GAS_TX_ACCESS_LIST_STORAGE_KEY = Uint (1900 )
64- """
65- Gas cost for including a storage key in the access list of a transaction.
66- """
67-
6831TX_MAX_GAS_LIMIT = Uint (16_777_216 )
6932
7033
@@ -608,7 +571,7 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
608571 for all operations to be implemented.
609572
610573 The intrinsic cost includes:
611- 1. Base cost (`GAS_TX_BASE `)
574+ 1. Base cost (`TX_BASE `)
612575 2. Cost for data (zero and non-zero bytes)
613576 3. Cost for contract creation (if applicable)
614577 4. Cost for access list entries (if applicable)
@@ -619,33 +582,34 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
619582 gas cost of the transaction and the minimum gas cost used by the
620583 transaction based on the calldata size.
621584 """
622- from .vm .eoa_delegation import GAS_AUTH_PER_EMPTY_ACCOUNT
623- from .vm .gas import init_code_cost
585+ from .vm .gas import GasCosts , init_code_cost
624586
625587 tokens_in_calldata = count_tokens_in_data (tx .data )
626588
627- data_cost = tokens_in_calldata * GAS_TX_DATA_TOKEN_STANDARD
589+ data_cost = tokens_in_calldata * GasCosts . TX_DATA_TOKEN_STANDARD
628590
629591 if tx .to == Bytes0 (b"" ):
630- create_cost = GAS_TX_CREATE + init_code_cost (ulen (tx .data ))
592+ create_cost = GasCosts . TX_CREATE + init_code_cost (ulen (tx .data ))
631593 else :
632594 create_cost = Uint (0 )
633595
634596 access_list_cost = Uint (0 )
635597 tokens_in_access_list = Uint (0 )
636598 if has_access_list (tx ):
637599 for access in tx .access_list :
638- access_list_cost += GAS_TX_ACCESS_LIST_ADDRESS
600+ access_list_cost += GasCosts . TX_ACCESS_LIST_ADDRESS
639601 access_list_cost += (
640- ulen (access .slots ) * GAS_TX_ACCESS_LIST_STORAGE_KEY
602+ ulen (access .slots ) * GasCosts . TX_ACCESS_LIST_STORAGE_KEY
641603 )
642604
643605 # Data token floor cost for access list bytes.
644606 access_list_cost += tokens_in_access_list * GAS_TX_DATA_TOKEN_FLOOR
645607
646608 auth_cost = Uint (0 )
647609 if isinstance (tx , SetCodeTransaction ):
648- auth_cost += Uint (GAS_AUTH_PER_EMPTY_ACCOUNT * len (tx .authorizations ))
610+ auth_cost += Uint (
611+ GasCosts .AUTH_PER_EMPTY_ACCOUNT * len (tx .authorizations )
612+ )
649613
650614 # Floor tokens from calldata.
651615 floor_tokens_in_calldata = tokens_in_calldata
@@ -660,7 +624,7 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
660624
661625 return (
662626 Uint (
663- GAS_TX_BASE
627+ GasCosts . TX_BASE
664628 + data_cost
665629 + create_cost
666630 + access_list_cost
0 commit comments