49
49
state_root ,
50
50
)
51
51
from .transactions import (
52
+ COST_FLOOR_PER_CALLDATA_TOKEN ,
53
+ LEGACY_CALLDATA_TOKEN_COST ,
52
54
TX_ACCESS_LIST_ADDRESS_COST ,
53
55
TX_ACCESS_LIST_STORAGE_KEY_COST ,
54
56
TX_BASE_COST ,
55
57
TX_CREATE_COST ,
56
- LEGACY_CALLDATA_TOKEN_COST ,
57
- COST_FLOOR_PER_CALLDATA_TOKEN ,
58
58
AccessListTransaction ,
59
59
BlobTransaction ,
60
60
FeeMarketTransaction ,
@@ -877,17 +877,19 @@ def process_transaction(
877
877
)
878
878
879
879
output = process_message_call (message , env )
880
-
881
- floor = Uint (tokens_in_calldata * COST_FLOOR_PER_CALLDATA_TOKEN + TX_BASE_COST )
882
-
880
+
881
+ floor = Uint (
882
+ tokens_in_calldata * COST_FLOOR_PER_CALLDATA_TOKEN + TX_BASE_COST
883
+ )
884
+
883
885
legacy_cost = Uint (gas_used + tokens_in_calldata * LEGACY_TOKEN_COST )
884
-
886
+
885
887
if legacy_cost < floor :
886
888
output .gas_left -= floor - gas_used
887
889
gas_used = floor
888
890
else :
889
891
gas_used = tx .gas - output .gas_left
890
-
892
+
891
893
gas_refund = min (gas_used // 5 , output .refund_counter )
892
894
gas_refund_amount = (output .gas_left + gas_refund ) * env .gas_price
893
895
@@ -950,14 +952,14 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
950
952
The eip-7623 calldata tokens used by the transaction.
951
953
"""
952
954
data_cost = 0
953
-
955
+
954
956
zerobytes = 0
955
957
for byte in tx .data :
956
958
if byte == 0 :
957
959
zerobytes += 1
958
960
959
961
tokens_in_calldata = zerobytes + (len (tx .data ) - zerobytes ) * 4
960
-
962
+
961
963
data_cost = tokens_in_calldata * COST_FLOOR_PER_CALLDATA_TOKEN
962
964
963
965
if tx .to == Bytes0 (b"" ):
@@ -973,9 +975,10 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
973
975
access_list_cost += TX_ACCESS_LIST_ADDRESS_COST
974
976
access_list_cost += len (keys ) * TX_ACCESS_LIST_STORAGE_KEY_COST
975
977
976
- return Uint (TX_BASE_COST +
977
- data_cost +
978
- create_cost + access_list_cost ), tokens_in_calldata
978
+ return (
979
+ Uint (TX_BASE_COST + data_cost + create_cost + access_list_cost ),
980
+ tokens_in_calldata ,
981
+ )
979
982
980
983
981
984
def recover_sender (chain_id : U64 , tx : Transaction ) -> Address :
0 commit comments