Skip to content

Commit ecad2d4

Browse files
committed
fix(tests): compose EIP-7976 floor cost via calldata_gas_calculator
Override `calldata_gas_calculator` (floor mode only) instead of `transaction_data_floor_cost_calculator`. The previous override shadowed EIP-7981's `transaction_data_floor_cost_calculator` in the Amsterdam MRO (auto-loader sorts by EIP number ascending, so EIP7976 is more derived and its method wins without calling super), dropping the access list floor contribution. Routing the change through `calldata_gas_calculator` lets EIP-7623's data floor calculator pick it up, which EIP-7981 then extends via super.
1 parent a255109 commit ecad2d4

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • packages/testing/src/execution_testing/forks/forks/eips/amsterdam

packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_7976.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from execution_testing.base_types import Bytes
1313
from execution_testing.base_types.conversions import BytesConvertible
1414

15-
from ....base_fork import BaseFork, TransactionDataFloorCostCalculator
15+
from ....base_fork import BaseFork, CalldataGasCalculator
1616
from ....gas_costs import GasCosts
1717

1818

@@ -28,20 +28,20 @@ def gas_costs(cls) -> GasCosts:
2828
)
2929

3030
@classmethod
31-
def transaction_data_floor_cost_calculator(
32-
cls,
33-
) -> TransactionDataFloorCostCalculator:
31+
def calldata_gas_calculator(cls) -> CalldataGasCalculator:
3432
"""
35-
The data floor uses floor tokens based on calldata bytes:
36-
``4 * bytes`` (64/64 per byte), not EIP-7623 calldata tokens.
33+
In floor mode, count four tokens per calldata byte uniformly so
34+
the data floor cost becomes ``4 * bytes * TX_DATA_TOKEN_FLOOR``
35+
(64/64 gas per byte). Standard mode keeps EIP-7623 semantics so
36+
that composition with downstream EIPs (e.g. EIP-7981) stays
37+
intact via ``super().transaction_data_floor_cost_calculator()``.
3738
"""
39+
super_fn = super(EIP7976, cls).calldata_gas_calculator()
3840
gas_costs = cls.gas_costs()
3941

40-
def fn(*, data: BytesConvertible) -> int:
41-
floor_tokens = len(Bytes(data)) * 4
42-
return (
43-
floor_tokens * gas_costs.TX_DATA_TOKEN_FLOOR
44-
+ gas_costs.TX_BASE
45-
)
42+
def fn(*, data: BytesConvertible, floor: bool = False) -> int:
43+
if floor:
44+
return len(Bytes(data)) * 4 * gas_costs.TX_DATA_TOKEN_FLOOR
45+
return super_fn(data=data, floor=False)
4646

4747
return fn

0 commit comments

Comments
 (0)