EEVM.Interpreter.Instructions.System.Creation (eevm v0.1.0)

Copy Markdown View Source

Contract creation opcodes.

This module handles the most complex EVM operations — those that spawn nested execution frames and interact with the world state.

Contract Creation

  • CREATE (0xF0) — deploys a new contract at an address derived from the sender's address and nonce (RLP-encoded, then Keccak-256 hashed).
  • CREATE2 (0xF5) — deploys at a deterministic address derived from the sender, a salt value, and the initcode hash (EIP-1014).

Both enforce EIP-3860 initcode size limits (max_initcode_size = 49,152 bytes) and EIP-170 runtime code size limits (max_code_size = 24,576 bytes). Oversized initcode halts the calling frame with :initcode_too_large.

Creation fails and pushes 0 without touching the creator's nonce at the 1,024 call-depth limit, when its balance can't cover the endowment, or when its nonce is already 2^64 - 1 (EIP-2681). A collision with an existing account (EIP-684, EIP-7610) also pushes 0, but keeps the nonce bump and consumes the gas meant for the init code.

Summary

Functions

Returns true when contract creation at address collides with an existing account: one with a nonzero nonce, non-empty code (EIP-684), or non-empty storage (EIP-7610). A collision fails the creation.

Executes CREATE (0xF0) or CREATE2 (0xF5) against the current frame.

Functions

address_collision?(db, address)

@spec address_collision?(EEVM.Database.t(), non_neg_integer()) :: boolean()

Returns true when contract creation at address collides with an existing account: one with a nonzero nonce, non-empty code (EIP-684), or non-empty storage (EIP-7610). A collision fails the creation.

execute(arg1, state)

Executes CREATE (0xF0) or CREATE2 (0xF5) against the current frame.

Pushes the new contract's address on success and 0 on any creation failure (depth limit, static context, insufficient balance, address collision, or a failed or rejected initcode run). Oversized initcode (EIP-3860) halts the frame with {:error, :initcode_too_large, state}. Any other opcode halts as :invalid.