Skip to content

fix(test-vm): Revert module-level cache to instance#2185

Merged
marioevz merged 1 commit intoethereum:forks/amsterdamfrom
fselmo:fix/revert-module-level-cache
Feb 11, 2026
Merged

fix(test-vm): Revert module-level cache to instance#2185
marioevz merged 1 commit intoethereum:forks/amsterdamfrom
fselmo:fix/revert-module-level-cache

Conversation

@fselmo
Copy link
Contributor

@fselmo fselmo commented Feb 11, 2026

🗒️ Description

Revert the module-level @cache on _bytecode_gas_cost() and _bytecode_refund() back to instance-level caching

What's happening here is the module-level @cache refactor I introduced in #2184 relies on __hash__ / __eq__ to deduplicate across instances. However, Bytecode.__hash__ / __eq__ only considers bytes and stack properties, and Opcode.__hash__ / __eq__ only considers the byte value. Neither accounts for metadata... so bytecode with identical bytes but different metadata collide in the cache, returning incorrect gas costs. We sort of yeeted that last commit in assuming things would pass but this seems to have revealed a bug in these methods.

I think the "proper" / non-bandaid fix would be updating __hash__ / __eq__ to include metadata, but Opcode intentionally compares by byte value only and the opcode_gas_map relies on this for lookups. Changing it is a larger refactor.

I opted for the bandaid fix here but we should talk about the way we want hash and eq to ultimately behave.

✅ 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).

Cute Animal Picture

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

@fselmo fselmo added C-bug Category: this is a bug, deviation, or other problem A-test-vm Area: execution_testing.vm labels Feb 11, 2026
@fselmo fselmo changed the title fix(test): Revert module-level cache to instance fix(test-vm): Revert module-level cache to instance Feb 11, 2026
@fselmo fselmo requested a review from marioevz February 11, 2026 03:13
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.07%. Comparing base (658e388) to head (9f3ab7e).
⚠️ Report is 2 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2185   +/-   ##
================================================
  Coverage            86.07%   86.07%           
================================================
  Files                  599      599           
  Lines                39472    39472           
  Branches              3780     3780           
================================================
  Hits                 33977    33977           
  Misses                4862     4862           
  Partials               633      633           
Flag Coverage Δ
unittests 86.07% <ø> (ø)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marioevz marioevz merged commit a82b1f6 into ethereum:forks/amsterdam Feb 11, 2026
18 checks passed
@fselmo fselmo deleted the fix/revert-module-level-cache branch February 11, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-vm Area: execution_testing.vm C-bug Category: this is a bug, deviation, or other problem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants