Skip to content

Commit f2049fb

Browse files
spencer-tbmarioevz
andcommitted
feat(tests, spec-specs): add full cost per state byte pricing function for EIP-8037 (#2687)
Co-authored-by: marioevz <marioevz@gmail.com>
1 parent 9db6487 commit f2049fb

586 files changed

Lines changed: 771 additions & 689 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/testing/src/execution_testing/forks/base_fork.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,51 @@ def opcode_gas_map(
474474
"""
475475
pass
476476

477+
@classmethod
478+
@abstractmethod
479+
def opcode_state_map(
480+
cls,
481+
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
482+
"""
483+
Return a mapping of opcodes to their state gas costs.
484+
485+
Each entry is either:
486+
- Constants (int): Multiplier of the cost_per_state_byte
487+
- Callables: Functions that take the opcode instance with metadata and
488+
return the full state gas cost
489+
"""
490+
pass
491+
492+
@classmethod
493+
@abstractmethod
494+
def opcode_refund_map(
495+
cls,
496+
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
497+
"""
498+
Return a mapping of opcodes to their gas refunds.
499+
500+
Each entry is either:
501+
- Constants (int): Direct gas refund values
502+
- Callables: Functions that take the opcode instance with metadata and
503+
return gas refund
504+
"""
505+
pass
506+
507+
@classmethod
508+
@abstractmethod
509+
def opcode_state_refund_map(
510+
cls,
511+
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
512+
"""
513+
Return a mapping of opcodes to their state refunds.
514+
515+
Each entry is either:
516+
- Constants (int): Multiplier of the cost_per_state_byte
517+
- Callables: Functions that take the opcode instance with metadata and
518+
return the state refund
519+
"""
520+
pass
521+
477522
# Gas calculation helpers
478523
@classmethod
479524
@abstractmethod
@@ -603,9 +648,9 @@ def base_fee_change_calculator(cls) -> BaseFeeChangeCalculator:
603648

604649
@classmethod
605650
@abstractmethod
606-
def cost_per_state_byte(cls, gas_limit: int = 0) -> int:
651+
def cost_per_state_byte(cls) -> int:
607652
"""
608-
Calculate the state gas cost per byte based on the block gas limit.
653+
Calculate the state gas cost per byte based on `cls._env_gas_limit`.
609654
"""
610655
pass
611656

0 commit comments

Comments
 (0)