Skip to content

fix(evm,jit): reject Amsterdam CREATE pre-access failures before child frames - #366

Merged
rakita merged 3 commits into
alloy-rs:mainfrom
0xalpharush:agent/amsterdam-create-preaccess-v2
Sep 4, 2026
Merged

rakita merged 3 commits into
alloy-rs:mainfrom
0xalpharush:agent/amsterdam-create-preaccess-v2

Conversation

@0xalpharush

Copy link
Copy Markdown
Contributor

Summary

  • reject Amsterdam CREATE/CREATE2 when the caller cannot fund the endowment or its nonce is exhausted
  • return zero and clear returndata before deriving/accessing the destination or constructing a child message
  • mirror the pre-access path in the interpreter and JIT builtins, with inspector regressions for both failure modes

Divergence

Under EIP-8037, revm performs the caller balance and nonce checks in the CREATE opcode before yielding a child frame. evm2 already used those checks to suppress destination state-gas access, but still split child gas, constructed a create message, and invoked the host/inspector. That produced a spurious CREATE/CREATE2 inspector frame for an operation revm completed locally.

This keeps the opcode charge and caller load, then matches revm by clearing returndata, pushing zero, and returning immediately. The destination remains untouched and no child gas split or inspector hook occurs.

The earlier CALL runtime-OOG candidate is intentionally excluded: the frame-preparation changes from #315 already charge runtime gas before host/inspector execution, and its saved artifact passes.

Validation

  • cargo test -p evm2 --lib (480 passed)
  • LLVM_SYS_221_PREFIX=/usr/lib/llvm-22 cargo test -p evm2-jit-builtins --lib (7 passed)
  • LLVM_SYS_221_PREFIX=/usr/lib/llvm-22 cargo clippy -p evm2 -p evm2-jit-builtins --all-targets -- -D warnings
  • cargo +nightly fmt --all -- --check
  • replayed structured_compare_amsterdam/crash-32ae6735a8cc706d748eb11f591a96e9bb24d096
  • replayed bytecode_compare_amsterdam/crash-3fd99af48ccd1bbe3ef5a22fe6f9580add92ab9a
  • replayed bytecode_compare_amsterdam/crash-f97ed6c8940d4ebaf809c86eeb31dd32af83455e

Built as one commit from a48e281c76f5fd0011b7f13f17c32d3db0ffbf11.

@0xalpharush
0xalpharush marked this pull request as ready for review August 28, 2026 12:55
// pass: a create that early-fails on those never accesses the destination, so reading it
// here would leak it into the EIP-7928 block access list (and warm the address). The
// early-fail itself (pushing 0) is handled by the child frame below.
if depth <= CALL_DEPTH_LIMIT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was a bug, depth needed to be checked every time.

Fortunately this can't be triggered as with 16M gas limit, 1024 call depth will never be hit (max is around 400-500calls iirc)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what this did, it skipped loading of target here, so it can be loaded later in subcall. This kinda worked but it is brittle.

if let Some(caller_info) = caller_info.as_ref().filter(|_| state.feature(EvmFeatures::EIP8037))
&& (caller_info.balance < value || caller_info.nonce == u64::MAX)
{
state.clear_return_data();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was previously fine for consensus, but path was not great, it would skip loading of account and do subcall and in essence call inspector.

@rakita rakita left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rakita

rakita commented Aug 31, 2026

Copy link
Copy Markdown
Member

@decofe audit

@rakita

rakita commented Aug 31, 2026

Copy link
Copy Markdown
Member

cyclops audit

@rakita rakita closed this Aug 31, 2026
@rakita rakita reopened this Aug 31, 2026
@rakita
rakita merged commit b9e92bf into alloy-rs:main Sep 4, 2026
69 checks passed

This branch was previously deployed

1 inactive deployment
codspeed — 275d5ee9 Deployed Sep 1, 2026 by rakita via codspeed #660
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