EIP-7698 EOF creation transaction (EOF - Creation transaction)

No call decision · EVM & execution · EIP status Stagnant · created 2024-04-24

Allows deploying EOF contracts via a creation transaction with an empty to field. CREATE and CREATE2 cannot deploy EOF code, making this the only way to put the first EOF code on chain.

Why it is needed

There are three ways to deploy new code on Ethereum: a creation transaction with an empty to field, CREATE, and CREATE2. A new contract code format called EOF (EVM Object Format) is being introduced, but the legacy opcodes CREATE and CREATE2 do not allow deploying EOF code. This leaves no way to put the first EOF code on chain. This EIP makes it so that when a creation transaction's data begins with an EOF-formatted initcontainer, it is recognized, executed, and used to deploy a new contract. Constructor arguments are passed the same way as in legacy deployment, appended after the data, so existing deployment tooling can be used unchanged.

What changes

Today

After EIP-7698

Who is affected

In depth

Transaction data splitting rule

If the data of a transaction with an empty to field starts with EOF_MAGIC, the entire data is interpreted as the concatenation of an initcontainer and calldata. First, the intrinsic gas computation and size limit defined in EIP-3860 for creation transactions are applied to the entire data. Then the EOF header is parsed, the sizes of all sections are summed together with the header size to determine the full size of the initcontainer. Based on this size, the data is split into the initcontainer and the calldata that follows it.

Initcontainer validation requirements

The initcontainer and all of its sub-containers are validated recursively. In addition to the general validation rules, the initcontainer's declared data_size in the header must equal the actual size of the data_section, and it must not contain a RETURN or STOP instruction. If header parsing or full container validation fails, the transaction is valid but treated as failed; no gas is consumed for initcode execution, and only the intrinsic cost of the creation transaction is deducted.

Execution and RETURNCODE

A validated initcontainer is executed in an execution frame, similarly to when invoked via the EOFCREATE opcode. The split-off calldata is passed as execution input. Successful execution ends with the RETURNCODE{deploy_container_index}(aux_data_offset, aux_data_size) instruction. The sub-container at that container's deploy_container_index is then loaded as the contract to deploy, and the memory region (aux_data_offset, aux_data_offset + aux_data_size) is appended to its data section, updating the data size in the header.

Address computation and gas deduction

The new contract address is computed the same way as a legacy creation transaction, as keccak256(sender || sender_nonce)[12:]. If the size of the updated deployment container (deployed_code_size) exceeds MAX_CODE_SIZE (24576), the instruction halts exceptionally. On successful deployment, state[new_address].code is set to the updated deployment container, and an additional 200 * deployed_code_size gas is deducted. In this case, the EIP-3541 rule prohibiting deployment of code starting with EF does not apply.

Rules shared with legacy creation transactions

Anything not explicitly stated otherwise follows the same or similar rules as legacy creation transactions. This includes handling of accessed_addresses and address collision detection (EIP-684, EIP-2929), construction of the memory and account context of the EVM frame for initcode execution, nonce incrementing for newly created accounts (EIP-161), and balance checks and transfer of the creation deposit.

Why constructor arguments are kept outside the initcontainer

An alternative of placing constructor arguments inside the initcontainer's data section and accessing them via DATA* opcodes was also considered. However, it was rejected because existing deployment tooling could not be used without modification, because for variable-length arguments it is hard to reflect the data size in the header ahead of time, and because if a dedicated InitcodeTransaction is introduced in the future, initcode would need to be generated differently depending on context. The distinction that the data section is part of a validated code definition while calldata is arbitrary external input was also cited as a rationale.

Rejected alternative: irregular state change

Originally, it was proposed to first deploy a Creator Contract that executes the TXCREATE opcode as an irregular state change, and then use it to deploy other EOF code. This approach also required introducing a new transaction type called InitcodeTransaction, which TXCREATE depends on. To reduce the scope of changes, this approach was not adopted.

Current status and remaining items

This EIP's status is Stagnant, meaning it is not being actively worked on. The original's Security Considerations section is still marked TBA and does not contain a concrete security analysis. Creation transactions that deploy legacy code are unaffected, since data starting with EF already failed previously due to execution of an invalid instruction. The provided call records contain no decision on fork inclusion.

Original EIP · ← EIPs