{"eip":7676,"title":"EOF - Prepare for Address Space Extension","description":"Update EOF opcodes so addresses are not trimmed during execution","authors":["Danno Ferrin (@shemnon)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2024-04-03","requires":[3540,3670,7069],"discussionsTo":"https://ethereum-magicians.org/t/eof-prepare-for-address-space-extension/19537","repo":"EIPs","label":"EIP-7676","officialUrl":"https://eips.ethereum.org/EIPS/eip-7676","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7676.md","url":"https://eips.huatuo.xyz/eip-7676/","tldr":{"en":"Makes EOF contracts reject addresses with non-zero upper 12 bytes instead of silently trimming them, leaving room for a future move from 20-byte to 32-byte addresses.","ja":"EOF コントラクトで、上位 12 バイトが 0 でないアドレスを黙って切り詰めずに拒否する。将来 20 バイトから 32 バイトのアドレスへ移行する余地を残す。","ko":"EOF 컨트랙트가 상위 12바이트가 0이 아닌 주소를 조용히 잘라내지 않고 거부하게 한다. 나중에 20바이트 주소에서 32바이트 주소로 옮겨 갈 여지를 남긴다.","zh":"让 EOF 合约拒绝高 12 字节非零的地址，而不是悄悄截断，为将来从 20 字节地址迁移到 32 字节地址留出空间。"},"tags":["eof","evm","addresses","opcodes","core"],"explainers":{"en":{"lang":"en","tldr":"Makes EOF contracts reject addresses with non-zero upper 12 bytes instead of silently trimming them, leaving room for a future move from 20-byte to 32-byte addresses.","tags":["eof","evm","addresses","opcodes","core"],"related":[3540,7069,2929,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7676/","markdown":"## What problem does it solve?\n\nEVM addresses are 20 bytes, but stack words are 32 bytes. When a legacy opcode such as `BALANCE` or `CALL` takes an address from the stack, it quietly throws away the top 12 bytes and uses only the low 20. Reference tests even check for this behaviour.\n\nThat masking is a roadblock for any plan to widen addresses to 32 bytes (ideas like \"address space extension\" for state expiry). If old code already treats `0xFFFF…\u003c20 bytes\u003e` as the same account as `0x0000…\u003c20 bytes\u003e`, you cannot later give the upper bytes a meaning without changing what existing contracts do.\n\nThe EVM Object Format (EOF, [EIP-3540](/eip-3540/)) is a fresh container format, so it can bake in stricter rules from day one without breaking legacy contracts. This EIP does exactly that for address operands.\n\n## How it works\n\nMost address-taking opcodes are already gone or replaced in EOF: `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALLCODE` and `SELFDESTRUCT` are banned, and the call family is replaced by `EXTCALL`, `EXTDELEGATECALL` and `EXTSTATICCALL` ([EIP-7069](/eip-7069/)). The remaining gap is `BALANCE`.\n\nThe proposal:\n\n- **Adds `EXTBALANCE`** (opcode number still \"tbd\" in the spec). It pops an address and pushes that account's balance. Gas follows the [EIP-2929](/eip-2929/) `BALANCE` schedule: 2600 for a cold address (which is then added to `accessed_addresses`), 100 for a warm one.\n- **Halts on dirty addresses.** If any of the high 12 bytes of the operand are non-zero, `EXTBALANCE` causes an exceptional halt that consumes all gas in the frame.\n- **Adds the same check to `EXTCALL`, `EXTDELEGATECALL`, `EXTSTATICCALL`**, performed just before the memory expansion check.\n\nThe legacy `BALANCE` opcode is left alone, so it behaves identically in legacy and EOF code. The spec rejects the alternative of treating dirty addresses as \"empty accounts\", because that would force clients to track 256-bit addresses in the access list and could strand ETH sent to unreachable accounts.\n\n## Sample code\n\nIllustrative behaviour (pseudocode for the new address check):\n\n```python\ndef check_address(operand: int) -\u003e int:\n    # operand is a 256-bit stack word\n    if operand \u003e\u003e 160 != 0:\n        raise ExceptionalHalt  # all remaining gas in the frame is consumed\n    return operand            # no masking: the value is used as-is\n\n# EXTBALANCE\naddr = check_address(stack.pop())\ncharge_gas(100 if addr in accessed_addresses else 2600)\naccessed_addresses.add(addr)\nstack.push(state.get_balance(addr))\n```\n\nCompilers are expected to clean addresses that come from calldata before using them, the way Solidity already does for the `address` type:\n\n```solidity\n// Solidity masks to 160 bits when decoding an `address` parameter,\n// so `who` can never carry dirty upper bytes into EXTBALANCE / EXTCALL.\nfunction balanceOfAccount(address who) external view returns (uint256) {\n    return who.balance;\n}\n```\n\n## Things to know\n\n- **Status: Stagnant.** No work has happened on it recently, and the opcode number was never assigned.\n- It depends entirely on EOF ([EIP-3540](/eip-3540/), [EIP-3670](/eip-3670/), [EIP-7069](/eip-7069/)); it has no effect on legacy contracts.\n- The halt is meant as a placeholder. The spec says future address-extension EIPs will likely change it, so contracts should not rely on the halt.\n- Old contracts would keep working but may never be able to talk to addresses in an extended space.\n"},"ja":{"lang":"ja","tldr":"EOF コントラクトで、上位 12 バイトが 0 でないアドレスを黙って切り詰めずに拒否する。将来 20 バイトから 32 バイトのアドレスへ移行する余地を残す。","tags":["eof","evm","addresses","opcodes","core"],"related":[3540,7069,2929,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7676/","markdown":"## 何を解決するのか\n\nEVM のアドレスは 20 バイトですが、スタックのワードは 32 バイトです。`BALANCE` や `CALL` などのレガシー opcode はスタックからアドレスを取り出すとき、上位 12 バイトを黙って捨て、下位 20 バイトだけを使います。リファレンステストでもこの挙動が検証されています。\n\nこのマスク処理は、アドレスを 32 バイトに拡張する計画（ステート期限切れのための「アドレス空間拡張」など）の障害になります。既存のコードがすでに `0xFFFF…\u003c20 バイト\u003e` を `0x0000…\u003c20 バイト\u003e` と同じアカウントとして扱っているなら、既存コントラクトの動作を変えずに上位バイトへ意味を持たせることはできません。\n\nEVM Object Format（EOF、[EIP-3540](/eip-3540/)）は新しいコンテナ形式なので、レガシーコントラクトを壊さずに最初から厳格なルールを組み込めます。この EIP はアドレスのオペランドについてそれを行います。\n\n## 仕組み\n\nアドレスを受け取る opcode の多くは、EOF ではすでに廃止または置き換えられています。`EXTCODESIZE`、`EXTCODECOPY`、`EXTCODEHASH`、`CALLCODE`、`SELFDESTRUCT` は禁止され、call 系は `EXTCALL`、`EXTDELEGATECALL`、`EXTSTATICCALL`（[EIP-7069](/eip-7069/)）に置き換えられています。残る隙間は `BALANCE` です。\n\n提案の内容は次のとおりです。\n\n- **`EXTBALANCE` を追加**（opcode 番号は仕様上まだ「tbd」）。アドレスをポップし、そのアカウントの残高をプッシュします。ガスは [EIP-2929](/eip-2929/) の `BALANCE` と同じ体系に従い、cold アドレスは 2600（その後 `accessed_addresses` に追加）、warm は 100 です。\n- **汚れたアドレスでは停止。** オペランドの上位 12 バイトのいずれかが 0 でない場合、`EXTBALANCE` は例外的停止を起こし、そのフレームの残りガスをすべて消費します。\n- **`EXTCALL`、`EXTDELEGATECALL`、`EXTSTATICCALL` にも同じチェックを追加**。メモリ拡張チェックの直前に行われます。\n\nレガシーの `BALANCE` opcode には手を加えないため、レガシーコードと EOF コードで同じ動作をします。仕様は、汚れたアドレスを「空のアカウント」として扱う案を退けています。クライアントが access list で 256 ビットのアドレスを追跡する必要が生じ、到達不能なアカウントに送られた ETH が取り出せなくなる恐れがあるためです。\n\n## サンプルコード\n\n挙動の例示（新しいアドレスチェックの擬似コード）:\n\n```python\ndef check_address(operand: int) -\u003e int:\n    # operand is a 256-bit stack word\n    if operand \u003e\u003e 160 != 0:\n        raise ExceptionalHalt  # all remaining gas in the frame is consumed\n    return operand            # no masking: the value is used as-is\n\n# EXTBALANCE\naddr = check_address(stack.pop())\ncharge_gas(100 if addr in accessed_addresses else 2600)\naccessed_addresses.add(addr)\nstack.push(state.get_balance(addr))\n```\n\nコンパイラは、Solidity が `address` 型で行っているように、calldata 由来のアドレスを使う前にクリーンにすることが期待されます。\n\n```solidity\n// Solidity masks to 160 bits when decoding an `address` parameter,\n// so `who` can never carry dirty upper bytes into EXTBALANCE / EXTCALL.\nfunction balanceOfAccount(address who) external view returns (uint256) {\n    return who.balance;\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** 最近は作業が行われておらず、opcode 番号も割り当てられていません。\n- EOF（[EIP-3540](/eip-3540/)、[EIP-3670](/eip-3670/)、[EIP-7069](/eip-7069/)）に完全に依存しており、レガシーコントラクトには影響しません。\n- この停止はプレースホルダーとして意図されたものです。将来のアドレス拡張 EIP でおそらく変更されると仕様に記されているため、コントラクトはこの停止に依存すべきではありません。\n- 古いコントラクトは動き続けますが、拡張された空間のアドレスとはやり取りできないままになる可能性があります。\n"},"ko":{"lang":"ko","tldr":"EOF 컨트랙트가 상위 12바이트가 0이 아닌 주소를 조용히 잘라내지 않고 거부하게 한다. 나중에 20바이트 주소에서 32바이트 주소로 옮겨 갈 여지를 남긴다.","tags":["eof","evm","addresses","opcodes","core"],"related":[3540,7069,2929,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7676/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM 주소는 20바이트이지만 스택 워드는 32바이트입니다. `BALANCE`나 `CALL` 같은 레거시 opcode는 스택에서 주소를 꺼낼 때 상위 12바이트를 조용히 버리고 하위 20바이트만 사용합니다. 레퍼런스 테스트에서도 이 동작을 검사합니다.\n\n이런 마스킹은 주소를 32바이트로 넓히려는 계획(상태 만료를 위한 \"주소 공간 확장\" 같은 아이디어)에 걸림돌이 됩니다. 기존 코드가 이미 `0xFFFF…\u003c20바이트\u003e`를 `0x0000…\u003c20바이트\u003e`와 같은 계정으로 취급하고 있다면, 기존 컨트랙트의 동작을 바꾸지 않고서는 나중에 상위 바이트에 의미를 부여할 수 없습니다.\n\nEVM Object Format(EOF, [EIP-3540](/eip-3540/))은 새로운 컨테이너 형식이므로 레거시 컨트랙트를 깨뜨리지 않고 처음부터 더 엄격한 규칙을 넣을 수 있습니다. 이 EIP는 주소 피연산자에 대해 바로 그 일을 합니다.\n\n## 어떻게 동작하나요?\n\n주소를 받는 opcode 대부분은 EOF에서 이미 제거되었거나 대체되었습니다. `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALLCODE`, `SELFDESTRUCT`는 금지되고, call 계열은 `EXTCALL`, `EXTDELEGATECALL`, `EXTSTATICCALL`([EIP-7069](/eip-7069/))로 대체됩니다. 남은 빈틈은 `BALANCE`입니다.\n\n제안 내용은 다음과 같습니다.\n\n- **`EXTBALANCE` 추가**(opcode 번호는 명세에서 아직 \"tbd\"). 주소를 pop하고 해당 계정의 잔액을 push합니다. 가스는 [EIP-2929](/eip-2929/)의 `BALANCE` 체계를 따라, cold 주소는 2600(이후 `accessed_addresses`에 추가), warm 주소는 100입니다.\n- **오염된 주소에서는 중단.** 피연산자의 상위 12바이트 중 하나라도 0이 아니면 `EXTBALANCE`는 예외적 중단을 일으키며 해당 프레임의 남은 가스를 모두 소모합니다.\n- **`EXTCALL`, `EXTDELEGATECALL`, `EXTSTATICCALL`에도 같은 검사를 추가**하며, 메모리 확장 검사 직전에 수행합니다.\n\n레거시 `BALANCE` opcode는 건드리지 않으므로 레거시 코드와 EOF 코드에서 동일하게 동작합니다. 명세는 오염된 주소를 \"빈 계정\"으로 취급하는 대안을 거부합니다. 클라이언트가 access list에서 256비트 주소를 추적해야 하고, 도달할 수 없는 계정으로 보낸 ETH가 묶일 수 있기 때문입니다.\n\n## 샘플 코드\n\n동작 예시(새 주소 검사의 의사 코드):\n\n```python\ndef check_address(operand: int) -\u003e int:\n    # operand is a 256-bit stack word\n    if operand \u003e\u003e 160 != 0:\n        raise ExceptionalHalt  # all remaining gas in the frame is consumed\n    return operand            # no masking: the value is used as-is\n\n# EXTBALANCE\naddr = check_address(stack.pop())\ncharge_gas(100 if addr in accessed_addresses else 2600)\naccessed_addresses.add(addr)\nstack.push(state.get_balance(addr))\n```\n\n컴파일러는 Solidity가 `address` 타입에 이미 하는 것처럼, calldata에서 온 주소를 사용하기 전에 정리해야 합니다.\n\n```solidity\n// Solidity masks to 160 bits when decoding an `address` parameter,\n// so `who` can never carry dirty upper bytes into EXTBALANCE / EXTCALL.\nfunction balanceOfAccount(address who) external view returns (uint256) {\n    return who.balance;\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 최근 작업이 없으며 opcode 번호도 배정된 적이 없습니다.\n- 전적으로 EOF([EIP-3540](/eip-3540/), [EIP-3670](/eip-3670/), [EIP-7069](/eip-7069/))에 의존하며 레거시 컨트랙트에는 영향이 없습니다.\n- 이 중단은 임시 자리표시자로 의도된 것입니다. 명세는 향후 주소 확장 EIP가 이를 바꿀 가능성이 높다고 밝히고 있으므로, 컨트랙트는 이 중단에 의존해서는 안 됩니다.\n- 오래된 컨트랙트는 계속 동작하겠지만, 확장된 공간의 주소와는 끝내 통신하지 못할 수도 있습니다.\n"},"zh":{"lang":"zh","tldr":"让 EOF 合约拒绝高 12 字节非零的地址，而不是悄悄截断，为将来从 20 字节地址迁移到 32 字节地址留出空间。","tags":["eof","evm","addresses","opcodes","core"],"related":[3540,7069,2929,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7676/","markdown":"## 它解决什么问题？\n\nEVM 地址是 20 字节，而栈字是 32 字节。当 `BALANCE` 或 `CALL` 等旧版 opcode 从栈中取地址时，会悄悄丢弃高 12 字节，只使用低 20 字节。参考测试甚至会检查这种行为。\n\n这种掩码处理会阻碍把地址扩展到 32 字节的计划（例如为状态过期而提出的\"地址空间扩展\"）。如果旧代码已经把 `0xFFFF…\u003c20 字节\u003e` 与 `0x0000…\u003c20 字节\u003e` 视为同一个账户，那么以后就无法在不改变现有合约行为的前提下，赋予高位字节任何含义。\n\nEVM 对象格式（EOF，[EIP-3540](/eip-3540/)）是全新的容器格式，因此可以从第一天起内置更严格的规则，而不会破坏旧版合约。本 EIP 针对地址操作数正是这样做的。\n\n## 它如何运作\n\n大多数接收地址的 opcode 在 EOF 中已被移除或替换：`EXTCODESIZE`、`EXTCODECOPY`、`EXTCODEHASH`、`CALLCODE` 和 `SELFDESTRUCT` 被禁用，call 系列被 `EXTCALL`、`EXTDELEGATECALL` 和 `EXTSTATICCALL`（[EIP-7069](/eip-7069/)）取代。剩下的缺口是 `BALANCE`。\n\n提案内容：\n\n- **新增 `EXTBALANCE`**（规范中 opcode 编号仍为\"tbd\"）。它弹出一个地址并压入该账户的余额。gas 沿用 [EIP-2929](/eip-2929/) 中 `BALANCE` 的规则：cold 地址 2600（随后加入 `accessed_addresses`），warm 地址 100。\n- **遇到脏地址即停机。** 如果操作数的高 12 字节中有任何一个非零，`EXTBALANCE` 会引发异常停机，并耗尽当前帧的全部 gas。\n- **对 `EXTCALL`、`EXTDELEGATECALL`、`EXTSTATICCALL` 增加同样的检查**，在内存扩展检查之前执行。\n\n旧版 `BALANCE` opcode 保持不变，因此在旧版代码和 EOF 代码中行为一致。规范否决了把脏地址当作\"空账户\"处理的替代方案，因为那会迫使客户端在 access list 中跟踪 256 位地址，并可能使发往不可达账户的 ETH 无法取回。\n\n## 示例代码\n\n行为示意（新地址检查的伪代码）：\n\n```python\ndef check_address(operand: int) -\u003e int:\n    # operand is a 256-bit stack word\n    if operand \u003e\u003e 160 != 0:\n        raise ExceptionalHalt  # all remaining gas in the frame is consumed\n    return operand            # no masking: the value is used as-is\n\n# EXTBALANCE\naddr = check_address(stack.pop())\ncharge_gas(100 if addr in accessed_addresses else 2600)\naccessed_addresses.add(addr)\nstack.push(state.get_balance(addr))\n```\n\n编译器应在使用来自 calldata 的地址之前先将其清理干净，就像 Solidity 对 `address` 类型已经做的那样：\n\n```solidity\n// Solidity masks to 160 bits when decoding an `address` parameter,\n// so `who` can never carry dirty upper bytes into EXTBALANCE / EXTCALL.\nfunction balanceOfAccount(address who) external view returns (uint256) {\n    return who.balance;\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 近期没有任何进展，opcode 编号也从未分配。\n- 它完全依赖 EOF（[EIP-3540](/eip-3540/)、[EIP-3670](/eip-3670/)、[EIP-7069](/eip-7069/)），对旧版合约没有影响。\n- 这里的停机只是占位设计。规范指出，未来的地址扩展 EIP 很可能会改变它，因此合约不应依赖这种停机行为。\n- 旧合约可以继续运行，但可能永远无法与扩展空间中的地址交互。\n"}}}
