EIPs Explained

EIP-7698 · Stagnant · Core · 2024-04-24

EIP-7698: EOF - Creation transaction

Lets an ordinary contract-creation transaction deploy an EOF contract by sending an EOF initcontainer followed by constructor arguments, giving EOF its first way onto the chain.

What problem does it solve?

The EVM Object Format (EOF, EIP-3540 and the EIP-7692 bundle) is a new, validated container format for contract code. Inside EOF, contracts create others with EOFCREATE, and legacy CREATE/CREATE2 are not allowed to deploy EOF code. That leaves a bootstrap problem: how does the first EOF contract get deployed?

EIP-7698 answers it with the simplest option: a normal creation transaction (empty to) can carry EOF code. Because constructor arguments are still just appended to the code, existing deployment tools work unchanged.

How it works

If a creation transaction's data starts with the EOF magic 0xEF00:

  1. The usual intrinsic-gas rules and initcode limits for creation transactions (EIP-3860) apply to the whole data.
  2. The client parses the EOF header and adds up the section sizes to find where the initcontainer ends. Everything after it is calldata for the constructor.
  3. The initcontainer and all nested subcontainers are validated. The initcontainer's declared data size must match the actual data, and it must not use RETURN or STOP.
  4. If parsing or validation fails, the transaction is valid but fails: only the intrinsic cost is charged.
  5. Otherwise the initcode runs. The new address is computed from the sender's address and nonce, as for a legacy creation transaction.
  6. Success means the initcode ends with RETURNCODE, which picks a subcontainer to deploy and appends some memory ("aux data") to its data section. The result must fit the 24,576-byte code size limit, and 200 gas per deployed byte is charged.

The EIP-3541 ban on deploying code starting with 0xEF does not apply here, since this is valid EOF. All other rules (access lists, nonce bumping, value transfer, address collisions) follow legacy creation.

Sample code

Shape of the transaction data (pseudocode):

# data = initcontainer || constructor_args
data = eof_initcontainer + abi_encode(constructor_args)

assert data[:2] == b"\xef\x00"          # EOF_MAGIC triggers the new path
header = parse_eof_header(data)
init_len = header.header_size + sum(header.section_sizes)
initcontainer, calldata = data[:init_len], data[init_len:]

validate_recursively(initcontainer)     # failure => tx fails, intrinsic gas only

Deploying from ethers v6 looks exactly like a legacy deployment:

const tx = await wallet.sendTransaction({ data: eofInitcontainer + encodedArgs.slice(2) });
const receipt = await tx.wait();
console.log(receipt!.contractAddress);

Things to know

  • Status: Stagnant. It belongs to the EOF effort, which has not shipped on Ethereum mainnet.
  • An earlier design deployed a "creator contract" via an irregular state change plus a new InitcodeTransaction (TXCREATE); it was dropped to reduce scope. See EIP-7620 for EOFCREATE/RETURNCODE.
  • Constructor arguments are read with CALLDATA*, not appended to the data section, so compilers generate the same initcode whether it runs from a transaction or from EOFCREATE.
  • Legacy deployments are unaffected: any old creation transaction starting with 0xEF already failed.

#evm #eof #deployment #core

Details

Authors
Piotr Dobaczewski (@pdobacz), Andrei Maiboroda (@gumb0), Paweł Bylica (@chfast), Alex Beregszaszi (@axic)
Status
Stagnant
Type
Standards Track / Core
Created
2024-04-24
Requires
Required by

Machine-readable: Markdown · JSON