@@ -310,6 +310,7 @@ def _calculate_sstore_state_gas(
310310 Calculate updated SSTORE state gas cost.
311311 """
312312 del gas_costs
313+ STATE_BYTES_PER_STORAGE_SET = 64 # noqa: N806
313314 metadata = opcode .metadata
314315 cpsb = cls .cost_per_state_byte ()
315316
@@ -324,7 +325,7 @@ def _calculate_sstore_state_gas(
324325 and current_value != new_value
325326 and original_value == 0
326327 ):
327- return 64 * cpsb
328+ return STATE_BYTES_PER_STORAGE_SET * cpsb
328329 return 0
329330
330331 @classmethod
@@ -373,6 +374,7 @@ def _calculate_sstore_state_refund(
373374 to zero within the transaction; otherwise return 0.
374375 """
375376 del gas_costs
377+ STATE_BYTES_PER_STORAGE_SET = 64 # noqa: N806
376378 metadata = opcode .metadata
377379 cpsb = cls .cost_per_state_byte ()
378380
@@ -384,7 +386,7 @@ def _calculate_sstore_state_refund(
384386 if current_value != new_value :
385387 if original_value == new_value :
386388 if original_value == 0 :
387- return 64 * cpsb
389+ return STATE_BYTES_PER_STORAGE_SET * cpsb
388390 return 0
389391
390392 @classmethod
@@ -400,6 +402,8 @@ def _calculate_selfdestruct_state_refund(
400402 Code deposit: len(code) × cost_per_state_byte
401403 """
402404 del gas_costs
405+ STATE_BYTES_PER_NEW_ACCOUNT = 120 # noqa: N806
406+ STATE_BYTES_PER_STORAGE_SET = 64 # noqa: N806
403407 metadata = opcode .metadata
404408 cpsb = cls .cost_per_state_byte ()
405409
@@ -412,9 +416,11 @@ def _calculate_selfdestruct_state_refund(
412416 ]
413417 state_refund = 0
414418 if self_destructed_account :
415- state_refund = 120 * cpsb
419+ state_refund = STATE_BYTES_PER_NEW_ACCOUNT * cpsb
416420 state_refund += (
417- 64 * cpsb * self_destructed_account_storage_slot_count
421+ STATE_BYTES_PER_STORAGE_SET
422+ * cpsb
423+ * self_destructed_account_storage_slot_count
418424 )
419425 state_refund += cpsb * self_destructed_account_code_deposit
420426 return state_refund
0 commit comments