Skip to content

fix: expand memory before slicing initcode in CREATE2 wrapper #296

Merged
RealiCZ merged 1 commit into
mainfrom
cz/fix/create2-forward-port
May 11, 2026
Merged

fix: expand memory before slicing initcode in CREATE2 wrapper #296
RealiCZ merged 1 commit into
mainfrom
cz/fix/create2-forward-port

Conversation

@RealiCZ
Copy link
Copy Markdown
Collaborator

@RealiCZ RealiCZ commented May 11, 2026

Forward-port of #293 onto main. Same diff, same intent — bringing the CREATE2 memory-expansion fix into the active development line. #293 was originally merged onto release-v1.5.2 (based on v1.5.1), this PR carries it forward without the 1.5.2 bump or other release-branch commits.

@RealiCZ RealiCZ added comp:core Changes to the `mega-evm` core crate spec:unchanged No change to any `mega-evm`'s behavior api:unchanged No change to the public interface or API labels May 11, 2026
@RealiCZ RealiCZ requested a review from Troublor as a code owner May 11, 2026 06:23
@RealiCZ RealiCZ added the rust Pull requests that update rust code label May 11, 2026
@RealiCZ RealiCZ added spec:stable Touches stable spec code — must not change behavior and removed spec:unchanged No change to any `mega-evm`'s behavior labels May 11, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.5%. Comparing base (09ceb5d) to head (af2b1c8).

☔ 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.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 11, 2026

Review: LGTM

The fix is correct and well-tested. A few notes from the review:

Correctness

  • resize_memory! on the OOG path returns early from the function (via the macro's internal return), so slice_len is never reached on unallocated memory — that is exactly the bug being fixed.
  • Deferred compute_gas! recording is the right approach: the canonical compute_gas_ext::create2 path captures gas via a gas_before/gas_after window, but when this wrapper's resize_memory! runs first, the inner revm resize_memory! becomes a no-op, causing that window to silently miss the expansion gas. Recording it separately after a successful inner CREATE2 fills that gap correctly.
  • All three leakage paths from CLAUDE.md are handled: (1) inner CREATE2 OOGs → run_inner_instruction_or_abort! skips the deferred recording, (2) compute gas limit exceeded by resize_gas → interpreter halts after the fact, consistent with other compute gas halts, (3) resize_gas == 0 short-circuits the borrow entirely.

Tests

The three tests cover the three important scenarios cleanly: no panic, correct accounting on success, and correct skip on OOG. The < 50 delta tolerances are generous relative to the actual differences (~1-3 gas for a PUSH opcode), but that is fine.

No issues to block merge.

@RealiCZ RealiCZ merged commit 12c0e07 into main May 11, 2026
61 of 62 checks passed
@RealiCZ RealiCZ deleted the cz/fix/create2-forward-port branch May 11, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:unchanged No change to the public interface or API comp:core Changes to the `mega-evm` core crate rust Pull requests that update rust code spec:stable Touches stable spec code — must not change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants