Skip to content

feat(semantic-tests): add per-test // optimize: filter for semantic tests#219

Merged
cdrappi merged 3 commits intoseismicfrom
cdai__optimize-filter
Apr 8, 2026
Merged

feat(semantic-tests): add per-test // optimize: filter for semantic tests#219
cdrappi merged 3 commits intoseismicfrom
cdai__optimize-filter

Conversation

@drappi-ai
Copy link
Copy Markdown
Contributor

Summary

  • Add // optimize: flag support in semantic test .sol files to control which optimizer configurations a test runs under
  • // optimize: false / // optimize: [] — skip when optimizer is enabled
  • // optimize: 200 — only run when --optimizer-runs 200
  • // optimize: [1, 200] — only run when --optimizer-runs is 1 or 200
  • When optimizer is off, test always runs regardless of this flag
  • Also fixes SkipCounts array size to derive from SkipReason::ALL.len() instead of hardcoded 7

Motivation: The RNG precompile now uses gas-remaining as entropy, so tests with exact expected values produce different results across optimizer settings. This flag lets tests pin to specific optimizer configs.

Test plan

  • Verified cargo check -p revme compiles clean
  • Verified skip logic works: // optimize: false tests are skipped with --optimize, run without
  • Verified skip summary prints correctly: "optimizer config excluded by // optimize: filter"
  • Tested with RNG precompile semantic tests across all 4 CI configurations

Add support for a `// optimize:` flag in semantic test files that
controls which optimizer configurations the test runs under.

Syntax:
  - `// optimize: false` or `// optimize: []` — skip when optimizer is on
  - `// optimize: 200` — only run with --optimizer-runs 200
  - `// optimize: [1, 200]` — only run with --optimizer-runs 1 or 200
  - (not present) — no filtering, run with any config

When the optimizer is off, the test always runs regardless of this flag.

Motivation: the RNG precompile now uses gas-remaining as entropy, so
tests with exact expected values produce different results across
optimizer settings. This flag lets tests pin to specific configs.
@drappi-ai drappi-ai requested a review from cdrappi as a code owner April 8, 2026 18:30
When `// optimize: [200]` is set, the test should only run with
--optimize --optimizer-runs 200. Previously it also ran when the
optimizer was off, producing wrong expected values.
drappi-ai added a commit to SeismicSystems/seismic-solidity that referenced this pull request Apr 8, 2026
The RNG precompile uses gas-remaining as entropy, producing different
results across optimizer/via-ir configurations. Split the single test
into 4 files, each pinned to a specific config via `// compileViaYul:`
and `// optimize:` flags (requires SeismicSystems/seismic-revm#219).

- RngPrecompile.sol: no optimizer, no via-ir
- RngPrecompileViaIR.sol: no optimizer, via-ir
- RngPrecompileOptimized.sol: optimizer 200, no via-ir
- RngPrecompileOptimizedViaIR.sol: optimizer 200, via-ir
@cdrappi cdrappi changed the title feat: add per-test // optimize: filter for semantic tests feat(semantic-tests): add per-test // optimize: filter for semantic tests Apr 8, 2026
@cdrappi cdrappi merged commit dc05eec into seismic Apr 8, 2026
6 checks passed
@cdrappi cdrappi deleted the cdai__optimize-filter branch April 8, 2026 18:43
cdrappi added a commit to SeismicSystems/seismic-solidity that referenced this pull request Apr 8, 2026
#257)

## Summary
- The RNG precompile now uses gas-remaining as entropy
(SeismicSystems/seismic-revm#189), so different optimizer/via-ir
settings produce different RNG output
- Split the single `RngPrecompile.sol` test into 4 config-specific files
using `// compileViaYul:` and `// optimize:` flags
- Each file is pinned to exactly one compilation config with its own
expected values
- Both `seismicRng()` (no personalization) and `seismicRngPers(bytes32)`
are tested in all 4 files

| File | via-ir | optimizer |
|------|--------|-----------|
| `RngPrecompile.sol` | off | off |
| `RngPrecompileViaIR.sol` | on | off |
| `RngPrecompileOptimized.sol` | off | 200 runs |
| `RngPrecompileOptimizedViaIR.sol` | on | 200 runs |

**Depends on:** SeismicSystems/seismic-revm#219 (merged) which adds the
`// optimize:` per-test filter.

## Test plan
- [x] All 4 semantic test configurations pass locally against merged
seismic-revm

---------

Co-authored-by: daltoncoder <daltoncoder2@gmail.com>
Co-authored-by: Samuel Laferriere <9342524+samlaf@users.noreply.github.com>
Co-authored-by: Christian Drappi <c@seismic.systems>
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