EIP-3520 The transaction destination opcode (Transaction Destination Opcode)

No call decision · EVM & execution · EIP status Stagnant · created 2021-04-16

Adds a new instruction, ENTRYPOINT, to the EVM so that a smart contract can learn the original recipient address (to) of the transaction.

Why it is needed

Smart contracts today chain calls together to build complex interactions, but each contract can only know the contract that called it directly, not where the transaction was originally sent. As a result, contracts can only receive information through a fixed interface and have no way to trace back the overall intent of the transaction (for example, whether this call is part of supplying liquidity to a decentralized exchange, or part of setting up loan collateral). Used together with EIP-3508's ORIGINDATA family of instructions, a contract can look up both the transaction's original destination and the original data, letting it infer which call path it is part of.

What changes

Today

After EIP-3520

Who is affected

In depth

ENTRYPOINT (0x4a) specification

ENTRYPOINT takes no stack arguments and pushes the original transaction's to field onto the stack. The returned address is a 160-bit value padded to 256 bits. Its execution cost is G_base, the same as ORIGIN (0x32). If an AUTHCALL remains on the stack, it returns the to address specified by that AUTHCALL; otherwise it returns the original transaction's to field.

Interaction with AUTHCALL

EIP-3074's AUTHCALL (0xf7) replaces the transaction's ORIGIN with the context variable authorized in order to eliminate discrimination between EOAs and contracts. However, introducing ENTRYPOINT on its own would reintroduce such discrimination, since comparing ENTRYPOINT == ADDRESS would reveal whether the currently executing code was called directly by an EOA. So ENTRYPOINT's return value is also defined to be replaced by the destination of the nearest AUTHCALL, preserving both compatibility with EIP-3074 and its anti-discrimination intent.

Gas cost and instruction naming

Since ENTRYPOINT has the same behavioral structure as ORIGIN, its gas cost was set identically to ORIGIN's, at G_base. The name was chosen to clearly convey that it refers to the transaction's first point of interaction, i.e. its entry point.

Dependency on EIP-3508

The ENTRYPOINT instruction has no clear use on its own, since the same information can also be obtained via the AUTHCALL instruction. The EIP therefore states that it is only meaningful when introduced together with the ORIGINDATA* instructions defined by EIP-3508. Only by tying the original transaction data obtained via ORIGINDATALOAD and ORIGINDATACOPY to the address and interface reported by ENTRYPOINT does internal verification of which function signature and arguments were used to make the call become possible.

Security considerations: applicable only to trusted contracts

Internal checks using ENTRYPOINT and ORIGINDATA* values rely on the assumption that the contract code is unmodified and behaves correctly. Such checks should therefore only be applied to pre-approved contracts, not to contracts arbitrarily deployed by users, since user contracts can easily violate this assumption.

Security considerations: behavior during contract creation, prohibition on caller discrimination, and document status

During a contract creation transaction, ENTRYPOINT returns the zero address as the first address to interact with the transaction. Implementations should handle this similarly to how ecrecover handles invalid signatures, to prevent malfunction. In addition, the instructions defined by this EIP must not be used to distinguish EOAs from contracts, since AUTHCALL can easily break such a distinction. The source document's status is Stagnant, and the Test Cases section is left as an empty TODO, so the document has stalled without further progress.

Original EIP · ← EIPs