Open
Description
Currently, all fork methods use positional arguments for the block_number
and timestamp
, e.g.
execution-spec-tests/src/ethereum_test_forks/base_fork.py
Lines 237 to 246 in 351c4a1
But this is a footgun because the tester could pass do this:
ShanghaiToCancunAt15k.calldata_gas_calculator(15_000)
and expect the function to return the value of Cancun, but it will return Shanghai because we are specifying block_number=15_000
instead of the expected timestamp=15_000
.
We should change the abstract definitions and actual definitions to force keyword arguments:
@classmethod
@abstractmethod
def calldata_gas_calculator(
cls, *, block_number: int = 0, timestamp: int = 0
) -> CalldataGasCalculator:
"""
Return callable that calculates the transaction gas cost for its calldata
depending on its contents.
"""
pass
Note the *
before the arguments which denotes keyword arguments must always be used.