Skip to content

Enforce that gas expectations match enabled pipelines#16572

Open
tavian-dev wants to merge 1 commit intoargotorg:developfrom
tavian-dev:enforce-gas-pipeline-match
Open

Enforce that gas expectations match enabled pipelines#16572
tavian-dev wants to merge 1 commit intoargotorg:developfrom
tavian-dev:enforce-gas-pipeline-match

Conversation

@tavian-dev
Copy link
Copy Markdown

Description

Addresses #16461.

Adds validation in the SemanticTest constructor to ensure that test files do not carry gas expectations for pipelines that are not enabled by their settings.

The validation checks:

  • Tests with compileViaYul: true must not have gas legacy: or gas legacyOptimized: expectations
  • Tests with compileViaYul: false must not have gas ir: or gas irOptimized: expectations
  • Tests without compileViaSSACFG: true must not have gas ssaCFG: or gas ssaCFGOptimized: expectations

If a stale gas expectation is found, a clear runtime_error is thrown identifying the offending key and the current pipeline settings.

Also removes stale gas expectations from 5 test files:

  • semanticTests/functionCall/return_size_shorter_than_expected.sol — removed gas legacy: 131966
  • semanticTests/functionCall/return_size_shorter_than_expected_evm_version_after_homestead.sol — removed gas legacy: 131966
  • semanticTests/functionCall/return_size_bigger_than_expected.sol — removed gas legacy: 131966
  • semanticTests/immutable/immutable_tag_too_large_bug.sol — removed gas legacy: 83499 and gas legacy code: 408800
  • semanticTests/array/copying/nested_dynamic_array_element_calldata_to_storage.sol — removed gas legacyOptimized: 120228

Testing

  • Built soltest and ran the full semantic test suite (1636 tests) — all pass
  • Created a temporary test file with a stale gas legacy: line on a compileViaYul: true test — validation correctly rejects it with a clear error message
  • Ran syntax tests (3551) and ASTJSON tests (72) — all pass
  • Code style check (scripts/check_style.sh) passes

Validates in the SemanticTest constructor that test files do not carry
gas expectations for pipelines that are not enabled by their settings.
For example, a test with `compileViaYul: true` should not have
`gas legacy:` or `gas legacyOptimized:` expectations, as these would
never be validated against actual compilation output.

This addresses the issue noted in PR argotorg#16369 where some tests retained
stale legacy gas expectations after being switched to Yul-only.

Changes:
- Add validation loop after parseExpectations() that checks all gas
  expectation keys against the test's pipeline configuration
- Remove stale gas expectations from 5 test files:
  - 3 functionCall tests with unused `gas legacy:` lines
  - 1 immutable test with unused `gas legacy:` and `gas legacy code:`
  - 1 array copying test with unused `gas legacyOptimized:` line

Fixes argotorg#16461
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant