Skip to content

feat(test-benchmark): add precompile macro for precompile benchmarks#2591

Open
LouisTsai-Csie wants to merge 1 commit intoethereum:forks/amsterdamfrom
LouisTsai-Csie:precompile-macro-fixture
Open

feat(test-benchmark): add precompile macro for precompile benchmarks#2591
LouisTsai-Csie wants to merge 1 commit intoethereum:forks/amsterdamfrom
LouisTsai-Csie:precompile-macro-fixture

Conversation

@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented Mar 30, 2026

🗒️ Description

Precompile benchmark tests previously used Op.STATICCALL as target_opcode, which made the fixture metadata ambiguous: Every precompile showed the same opcode name. This PR introduces descriptive per-precompile labels (e.g. ECRECOVER, BN128_ADD, BLAKE2F) so the fixture _info.metadata.target_opcode field clearly identifies which precompile is being benchmarked.

A new OpcodeTarget dataclass pairs a display name (written into the fixture) with the underlying opcode (used for --fixed-opcode-count validation):

@dataclass(frozen=True)
class OpcodeTarget:
    name: str
    opcode: Op

This keeps OpcodeTarget general-purpose: it is not precompile-specific. Any future benchmark that needs a human-readable label while counting a different EVM opcode can reuse it.

A Precompile helper in the test helpers collects all precompile targets:

class Precompile:
    ECRECOVER = OpcodeTarget("ECRECOVER", Op.STATICCALL)
    SHA256 = OpcodeTarget("SHA2-256", Op.STATICCALL)
    ...

The _verify_target_opcode_count method resolves OpcodeTarget.opcode for the count lookup, so --fixed-opcode-count validation still works correctly against the real STATICCALL counts.

🔗 Related Issues or PRs

N/A.

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx tox -e 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-->

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.24%. Comparing base (fd1dd63) to head (9e8d00a).
⚠️ Report is 5 commits behind head on forks/amsterdam.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #2591      +/-   ##
===================================================
- Coverage            86.35%   86.24%   -0.12%     
===================================================
  Files                  599      599              
  Lines                36904    36984      +80     
  Branches              3771     3795      +24     
===================================================
+ Hits                 31868    31895      +27     
- Misses                4485     4525      +40     
- Partials               551      564      +13     
Flag Coverage Δ
unittests 86.24% <ø> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LouisTsai-Csie LouisTsai-Csie force-pushed the precompile-macro-fixture branch from eb3c6a9 to 9e8d00a Compare March 31, 2026 07:24
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review March 31, 2026 09:16
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.

1 participant