1919from ....base_fork import BaseFork
2020from ....gas_costs import GasCosts
2121
22+ # EIP-8037 state byte sizes (mirrors EELS amsterdam/vm/gas.py).
23+ STATE_BYTES_PER_NEW_ACCOUNT = 120
24+ STATE_BYTES_PER_STORAGE_SET = 64
25+ STATE_BYTES_PER_AUTH_BASE = 23
26+
27+ # EIP-8037 regular gas base costs.
28+ PER_AUTH_BASE_COST = 7_500
29+ REGULAR_GAS_CREATE = 9_000
30+
2231
2332class EIP8037 (BaseFork ):
2433 """EIP-8037 class."""
@@ -33,7 +42,6 @@ def cost_per_state_byte(cls) -> int:
3342 @classmethod
3443 def sstore_state_gas (cls ) -> int :
3544 """Return state gas for a zero-to-nonzero SSTORE (EIP-8037)."""
36- STATE_BYTES_PER_STORAGE_SET = 64 # noqa: N806
3745 return STATE_BYTES_PER_STORAGE_SET * cls .cost_per_state_byte ()
3846
3947 @classmethod
@@ -57,13 +65,6 @@ def gas_costs(cls) -> GasCosts:
5765 """
5866 cpsb = cls .cost_per_state_byte ()
5967 parent = super (EIP8037 , cls ).gas_costs ()
60- # EIP-8037 state byte sizes (EELS amsterdam/vm/gas.py)
61- STATE_BYTES_PER_STORAGE_SET = 64 # noqa: N806
62- STATE_BYTES_PER_NEW_ACCOUNT = 120 # noqa: N806
63- STATE_BYTES_PER_AUTH_BASE = 23 # noqa: N806
64- # EIP-8037 regular gas base costs
65- PER_AUTH_BASE_COST = 7_500 # noqa: N806
66- REGULAR_GAS_CREATE = 9_000 # noqa: N806
6768 new_acct = STATE_BYTES_PER_NEW_ACCOUNT * cpsb
6869 return replace (
6970 parent ,
@@ -258,8 +259,6 @@ def transaction_intrinsic_state_gas(
258259 - Auth: (NEW_ACCOUNT + AUTH_BASE) * cpsb
259260 """
260261 cpsb = cls .cost_per_state_byte ()
261- STATE_BYTES_PER_NEW_ACCOUNT = 120 # noqa: N806
262- STATE_BYTES_PER_AUTH_BASE = 23 # noqa: N806
263262 state_gas = 0
264263 if contract_creation :
265264 state_gas += STATE_BYTES_PER_NEW_ACCOUNT * cpsb
@@ -324,7 +323,7 @@ def _calculate_sstore_state_gas(
324323 and current_value != new_value
325324 and original_value == 0
326325 ):
327- return 64 * cpsb
326+ return STATE_BYTES_PER_STORAGE_SET * cpsb
328327 return 0
329328
330329 @classmethod
@@ -384,7 +383,7 @@ def _calculate_sstore_state_refund(
384383 if current_value != new_value :
385384 if original_value == new_value :
386385 if original_value == 0 :
387- return 64 * cpsb
386+ return STATE_BYTES_PER_STORAGE_SET * cpsb
388387 return 0
389388
390389 @classmethod
@@ -412,9 +411,11 @@ def _calculate_selfdestruct_state_refund(
412411 ]
413412 state_refund = 0
414413 if self_destructed_account :
415- state_refund = 120 * cpsb
414+ state_refund = STATE_BYTES_PER_NEW_ACCOUNT * cpsb
416415 state_refund += (
417- 64 * cpsb * self_destructed_account_storage_slot_count
416+ STATE_BYTES_PER_STORAGE_SET
417+ * cpsb
418+ * self_destructed_account_storage_slot_count
418419 )
419420 state_refund += cpsb * self_destructed_account_code_deposit
420421 return state_refund
0 commit comments