EIPs Explained

EIP-6189 · Stagnant · Core · 2022-12-20

EIP-6189: Alias Contracts

Proposed a protocol-level 'alias contract', marked by a magic nonce, that transparently forwards every call and account lookup to another address, as a building block for a Verkle-compatible SELFDESTRUCT.

What problem does it solve?

SELFDESTRUCT deletes a contract's code and storage in one step, which is hard to support in Verkle-tree state where storage cannot be cheaply wiped. EIP-6190 proposed a "functional" SELFDESTRUCT that instead moves a contract to a fresh address. For that to work, the old address has to keep pointing at the new one.

EIP-6189 supplies that pointer. On its own it only adds cost; the author describes it as useful only together with EIP-6190.

How it works

  • An account is an alias contract if its nonce is 2^64-1 and its code is exactly 0x1. That nonce value is reserved by EIP-6188, so no normal account can reach it.
  • The alias target is the address stored in the alias contract's storage slot 0.
  • Calls (CALL, CALLCODE, DELEGATECALL, STATICCALL, PAY from EIP-5920, and plain transactions) to an alias are forwarded to the target, repeating until a non-alias account is reached. CALLER is unchanged.
  • Account reads (BALANCE, EXTCODESIZE, EXTCODECOPY, EXTCODEHASH) are redirected the same way.
  • CREATE / CREATE2 that land on an alias address try to create at the target instead.
  • A transaction whose origin is an alias is treated as coming from the target.
  • Path compression: if a chain A → B → C is followed, every intermediate alias gets slot 0 rewritten to point directly at C, even inside a STATICCALL.
  • Gas: 25 per account examined (including the final one, even with no alias involved), plus 5000 per slot-0 rewrite, on top of EIP-2929 access costs. Infinite alias loops run out of gas.
  • eth_getStorageAt must return an error for alias contracts.

Sample code

Pseudocode for resolving a callee, following the spec:

ALIAS_NONCE = 2**64 - 1
ALIAS_CODE = b"\x01"

def resolve(state, addr, charge_gas):
    chain = []
    while True:
        charge_gas(25)                              # per account examined
        acct = state.get(addr)
        if acct.nonce != ALIAS_NONCE or acct.code != ALIAS_CODE:
            break
        chain.append(addr)
        addr = to_address(state.get_storage(addr, 0))   # follow slot 0
    if len(chain) > 1:                              # compress A -> B -> C to A -> C
        for a in chain:
            if to_address(state.get_storage(a, 0)) != addr:
                state.set_storage(a, 0, addr)
                charge_gas(5000)
    return addr                                     # final non-alias account

Things to know

  • Status is Stagnant. It was never scheduled for a hard fork.
  • It changes consensus rules and would require a hard fork. Existing contracts are unaffected because none have nonce 2^64-1 with code 0x1.
  • The extra per-access gas applies to every call and account read, not just aliased ones, which is a meaningful cost for a feature that matters only when combined with EIP-6190.
  • Ethereum ultimately took a different route for SELFDESTRUCT: EIP-6780 limits it to contracts destroyed in the same transaction they were created.

#evm #core #selfdestruct #verkle #accounts

Details

Authors
Gavin John (@Pandapip1)
Status
Stagnant
Type
Standards Track / Core
Created
2022-12-20
Requires
Required by

Machine-readable: Markdown · JSON