Skip to content

Force fork methods to use keyword arguments #1709

Open
@marioevz

Description

@marioevz

Currently, all fork methods use positional arguments for the block_number and timestamp, e.g.

@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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:forksScope: Changes ethereum_test_forks packagescope:testsScope: Changes EL client test cases in `./tests`type:choreType: Chore

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions