EIP-7676 Preparing EOF address space extension (EOF - Prepare for Address Space Extension)
No call decision · EVM & execution · EIP status Stagnant · created 2024-04-03
Defines new operations for handling addresses within EOF so that, during execution, the upper 12 bytes of an address are checked as-is instead of being trimmed. This is preparatory work for the possibility of extending Ethereum addresses from 20 bytes to 32 bytes.
Why it is needed
Today's EVM silently trims the upper 12 bytes of an address value when executing address operations like BALANCE, using only the remaining 20 bytes. There have been proposals to widen Ethereum addresses from 160 bits to 256 bits to secure a larger address space, but discussion has been stuck precisely because of this trimming behavior. EXTCODESIZE, EXTCODECOPY, EXTCODEHASH, CALLCODE, and SELFDESTRUCT are already banned in EOF, and CALL-type operations are being redesigned in EIP-7069, leaving BALANCE as the only remaining problem. Since EOF is a new format not yet in use, this is an opportunity to resolve the issue in advance without breaking backward compatibility.
What changes
Today
- The BALANCE operation silently trims the upper 12 bytes of an address and uses only the remaining 20 bytes
- EXTCODESIZE, EXTCODECOPY, EXTCODEHASH, CALLCODE, and SELFDESTRUCT are already banned in EOF
- CALL, DELEGATECALL, and STATICCALL are being separately redesigned in EIP-7069
After EIP-7676
- A new operation, EXTBALANCE, is added within EOF, and an exceptional halt occurs if the upper 12 bytes of the address are nonzero
- EXTCALL, EXTDELEGATECALL, and EXTSTATICCALL also halt before the memory expansion check if the upper 96 bits of target_address are nonzero
- The existing BALANCE in legacy code continues to work unchanged, preserving backward compatibility
- If address space extension is actually adopted in the future, this halt behavior is expected to be revised again
Who is affected
- EOF contract developers: EXTBALANCE is used instead of BALANCE, and the upper bytes of addresses coming from external input must be masked directly
- Compiler and toolchain developers: Code must be generated that guarantees address masking at the ABI level to avoid unexpected halts in EXTBALANCE and EXTCALL-type calls
- Client and EVM implementation teams: The EXTBALANCE operation, the EIP-2929 gas schedule, and the address-check logic for EXTCALL-type operations must be implemented in the EOF interpreter
- Future proposers of address space extension: They can design the 32-byte address extension on top of the EOF address-handling foundation this EIP lays down
In depth
New operation: EXTBALANCE
EXTBALANCE (opcode not yet assigned) pops a single target_address from the stack and pushes that account's balance. Its behavior matches the existing BALANCE, but it is introduced as a separate operation used only within EOF, leaving legacy code's BALANCE untouched.
Exceptional halt instead of trimming
The legacy EVM trims the upper 12 bytes of the 256-bit value given to address operations and uses only the lower 20 bytes. In EOF, this trimming is removed, and if the upper 12 bytes of EXTBALANCE's target_address are nonzero, it is treated as an exceptional halt. No separate gas schedule change is needed on the implementation side.
Same check added to EXTCALL-type operations
EXTCALL, EXTDELEGATECALL, and EXTSTATICCALL (the call operations defined in EIP-7069) also get a check added, immediately before the memory expansion check, for whether the upper 96 bits of target_address are nonzero. If the upper bits are nonzero, an exceptional halt occurs on the spot.
Gas cost stays as defined in EIP-2929
EXTBALANCE's gas cost uses the same EIP-2929 schedule as BALANCE unchanged. If the address is not in accessed_addresses, 2600 gas is charged and it is added to that list; if it is already there, only 100 gas is charged. accessed_addresses is a list shared with other operations. Since BALANCE itself already goes through this check process, no additional gas change is deemed necessary.
Why already-banned operations needed no changes
EXTCODESIZE, EXTCODECOPY, EXTCODEHASH, CALLCODE, and SELFDESTRUCT are already banned within EOF. CALL, DELEGATECALL, and STATICCALL are being redesigned as EXTCALL-type operations in EIP-7069. As a result, BALANCE was the only operation left with the address trimming problem, and this EIP replaces only that one with EXTBALANCE.
Why treating it as an empty account instead of halting was rejected
Instead of halting when encountering an address with upper bits set, an alternative of simply treating that account as an empty account was also considered. This alternative was rejected for two reasons. First, it would burden the accessed_addresses list with having to track 256-bit addresses. Second, since EXTCALL-type operations can still send balance to such accounts, it would leave an inaccessible balance sitting in the Merkle trie.
Backward compatibility and current status
Because this work is confined to the scope of EOF, existing legacy contracts are entirely unaffected. However, legacy code cannot use the extended address space. The original text states that if address space extension is actually adopted in the future, the current exceptional halt behavior is expected to be revised, and that contract authors should not rely on this halt behavior. This EIP's current status is Stagnant, and since it presupposes EIP-3540, EIP-3670, and EIP-7069, which have not yet been included on mainnet, it remains on hold alongside those EOF-related EIPs. The call records contain no fork inclusion decision.