Skip to content

Reject 0xEF code prefix in CREATE/CREATE2 (EIP-3541) #72

@mw2000

Description

@mw2000

Summary

CREATE and CREATE2 must reject deployment of code whose first byte is 0xEF. This prefix is reserved for the future EOF (EVM Object Format). Introduced in the London hardfork.

Specification

  • When CREATE or CREATE2 init code returns runtime bytecode, check if the first byte is 0xEF
  • If yes, the deployment fails — push 0 to stack, consume gas for the init code execution, but do NOT deploy the code
  • This does NOT apply to init code itself — only to the deployed (runtime) bytecode returned by RETURN

Implementation Guide

  1. In lib/eevm/opcodes/system/creation.ex, after init code executes and returns runtime code:
    if byte_size(runtime_code) > 0 and :binary.first(runtime_code) == 0xEF do
      # Deployment fails — push 0, do not store code
    end
  2. This check goes AFTER the EIP-170 code size check and AFTER init code execution succeeds
  3. Gas for init code execution is still consumed — only the code deposit is prevented

Acceptance Criteria

  • CREATE rejects code starting with 0xEF
  • CREATE2 rejects code starting with 0xEF
  • Init code starting with 0xEF is allowed (only runtime code is checked)
  • Empty runtime code (<<>>) is allowed
  • Failed deployment pushes 0 to stack
  • Gas for init code is consumed
  • Tests pass

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore EVM functionalityeipEIP specification implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions