Skip to content

feat(test-specs): Allow automatic transaction gas-limit#9

Open
marioevz wants to merge 2 commits into
spencer-tb:eips/amsterdam/eip-8037from
marioevz:implicit-gas-limit
Open

feat(test-specs): Allow automatic transaction gas-limit#9
marioevz wants to merge 2 commits into
spencer-tb:eips/amsterdam/eip-8037from
marioevz:implicit-gas-limit

Conversation

@marioevz
Copy link
Copy Markdown
Collaborator

🗒️ Description

While reviewing ethereum#2901 I noticed that the bulk of its test changes were simply bumping the gas_limit of transactions in tests that don't actually care about the exact gas limit — they only care that the transaction executes in full without running out of gas.

This PR makes the transaction gas_limit optional. When a test omits it, the filling tool calculates it automatically:

  • Transaction.gas_limit now defaults to None instead of HexNumber(21_000). A new Transaction.with_gas_limit() helper returns a copy with a concrete limit, and signing now raises if the gas limit is still unset.
  • State tests (StateTest): an unset gas_limit is filled with the fork's transaction_gas_limit_cap(), falling back to the environment gas_limit when there is no cap. The gas-limit binary-search path was updated to read from the resolved transaction rather than self.tx.
  • Blockchain tests (BlockchainTest): the block's remaining gas (env.gas_limit minus the gas already claimed by transactions with explicit limits) is split evenly across the transactions that leave gas_limit unset, clamped to the fork's transaction gas-limit cap. It raises a clear "test correctness" error if no gas remains.
  • In both paths the cap is treated as removed when EIP-8037 is enabled.

The second commit applies this to existing tests, removing explicit gas_limit assignments from transactions across ~18 test files where the precise limit was irrelevant to what the test exercises.

Tests that should rely on the implicit gas limit are those that only need the transaction to execute fully and not run out of gas. Tests that intentionally probe gas-limit behavior continue to set it explicitly.

Open Issues

Execute command

The execute command depends on the gas limit to calculate the balance needed by the sender account. Some potential solutions:

  • Set the gas-limit to a high value, with the downside that the sender's minimum balance is going to be high.
  • Run the transaction via t8n to approximate the required gas-limit.

🔗 Related Issues or PRs

N/A.

✅ Checklist

  • All: Ran fast static checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    just static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants