{"eip":7960,"title":"EOF - Extended types section","description":"Extend EOF container's types section with an extra type parameter.","authors":["Wei Tang (@sorpaas)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2025-05-28","requires":[3540],"discussionsTo":"https://ethereum-magicians.org/t/eip-series-evm64/23794","repo":"EIPs","label":"EIP-7960","officialUrl":"https://eips.ethereum.org/EIPS/eip-7960","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7960.md","url":"https://eips.huatuo.xyz/eip-7960/","tldr":{"en":"Adds a per-code-section type byte to the EOF container, so one contract could mix normal EVM code with other execution modes such as EVM64, and bumps the EOF version to 0x02.","ja":"EOF コンテナにコードセクションごとの type バイトを追加し、1 つのコントラクト内で通常の EVM コードと EVM64 などの他の実行モードを混在できるようにする。あわせて EOF のバージョンを 0x02 に上げる。","ko":"EOF 컨테이너에 코드 섹션별 type 바이트를 추가해, 한 컨트랙트 안에서 일반 EVM 코드와 EVM64 같은 다른 실행 모드를 섞어 쓸 수 있게 하고, EOF 버전을 0x02로 올린다.","zh":"为 EOF 容器的每个代码段增加一个 type 字节，使同一个合约可以混用普通 EVM 代码与 EVM64 等其他执行模式，并把 EOF 版本升到 0x02。"},"tags":["eof","evm","evm64","bytecode","core"],"explainers":{"en":{"lang":"en","tldr":"Adds a per-code-section type byte to the EOF container, so one contract could mix normal EVM code with other execution modes such as EVM64, and bumps the EOF version to 0x02.","tags":["eof","evm","evm64","bytecode","core"],"related":[3540,7692],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7960/","markdown":"## What problem does it solve?\n\nThe EVM Object Format (EOF, [EIP-3540](/eip-3540/)) splits contract bytecode into a structured container with separate code sections, each described by an entry in a `types_section` (inputs, outputs, maximum stack growth). Every code section is assumed to be ordinary EVM code.\n\nSome proposals want parts of a contract to run under a different interpreter. The motivating example is EVM64, a variant with 64-bit arithmetic that is faster for heavy computation but cannot work directly with addresses and balances. Later, the same hook could allow other code types such as RISC-V. EIP-7960 adds a field so the interpreter knows how to run each section.\n\n## How it works\n\nEach `types_section` entry changes from\n\n```\n(inputs: uint8, outputs: uint8, max_stack_increase: uint16)        // 32 bits\n```\n\nto\n\n```\n(type: uint8, reserved: 24 bits, inputs: uint8, outputs: uint8, max_stack_increase: uint16)  // 64 bits\n```\n\n- `type = 0x01` is the only type defined here. Other EIPs may define more.\n- `reserved` keeps the entry aligned to 64 bits and must be all zeros.\n- The EOF container `version` becomes `0x02`; version `0x01` is now invalid.\n\nNew validation rules: an unknown `type` fails validation, and a non-zero `reserved` field fails validation.\n\nThe intended pattern is that a contract keeps its state-handling logic (storage, balances, calls) in normal EVM sections and moves number-crunching into sections of a faster type, switching between them with ordinary EOF function calls.\n\n## Sample code\n\nEncoding one `types_section` entry under this EIP (Python):\n\n```python\nimport struct\n\ndef encode_type_entry(code_type: int, inputs: int, outputs: int, max_stack_increase: int) -\u003e bytes:\n    assert code_type == 0x01, \"only type 0x01 is defined by EIP-7960\"\n    reserved = b\"\\x00\\x00\\x00\"\n    return (\n        bytes([code_type]) + reserved\n        + struct.pack(\"\u003eBBH\", inputs, outputs, max_stack_increase)\n    )\n\nentry = encode_type_entry(0x01, inputs=0, outputs=0x80, max_stack_increase=2)\nprint(entry.hex())  # 0100000000800002  -\u003e 8 bytes per entry\n```\n\n(`outputs = 0x80` marks a non-returning section in EOF.)\n\n## Things to know\n\n- **Status: Draft.** Test cases, reference implementation and security analysis are all still \"to be added\".\n- EOF itself is not live on Ethereum mainnet: it was removed from the Fusaka upgrade, and the core EOF specs ([EIP-3540](/eip-3540/), [EIP-7692](/eip-7692/)) are Stagnant. This EIP only matters if EOF returns.\n- The version bump to `0x02` is to avoid clashing with any third-party chain that may already have deployed EOF version 1.\n- Code written in a non-EVM section type, such as EVM64, would not be able to access addresses and balances directly; that work stays in type `0x01` sections.\n"},"ja":{"lang":"ja","tldr":"EOF コンテナにコードセクションごとの type バイトを追加し、1 つのコントラクト内で通常の EVM コードと EVM64 などの他の実行モードを混在できるようにする。あわせて EOF のバージョンを 0x02 に上げる。","tags":["eof","evm","evm64","bytecode","core"],"related":[3540,7692],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7960/","markdown":"## 何を解決するのか\n\nEVM Object Format（EOF、[EIP-3540](/eip-3540/)）は、コントラクトのバイトコードを、個別のコードセクションを持つ構造化されたコンテナに分割します。各セクションは `types_section` のエントリ（入力、出力、スタックの最大増加量）で記述されます。すべてのコードセクションは通常の EVM コードであると想定されています。\n\n一部の提案では、コントラクトの一部を別のインタープリターで実行したいと考えています。動機となる例が EVM64 です。これは 64 ビット演算を持つ変種で、重い計算には速い一方、アドレスや残高を直接扱えません。将来的には、同じフックによって RISC-V のような他のコード型も許容できるかもしれません。EIP-7960 は、インタープリターが各セクションをどう実行するかを判断できるよう、フィールドを 1 つ追加します。\n\n## 仕組み\n\n各 `types_section` エントリは、次の形式から\n\n```\n(inputs: uint8, outputs: uint8, max_stack_increase: uint16)        // 32 bits\n```\n\n次の形式に変わります。\n\n```\n(type: uint8, reserved: 24 bits, inputs: uint8, outputs: uint8, max_stack_increase: uint16)  // 64 bits\n```\n\n- `type = 0x01` は、ここで定義される唯一の type です。他の EIP がさらに定義するかもしれません。\n- `reserved` はエントリを 64 ビットにアラインさせるためのもので、すべてゼロでなければなりません。\n- EOF コンテナの `version` は `0x02` になり、バージョン `0x01` は無効になります。\n\n新しい検証ルール: 未知の `type` は検証に失敗し、ゼロでない `reserved` フィールドも検証に失敗します。\n\n想定されているパターンは、コントラクトが状態を扱うロジック（ストレージ、残高、呼び出し）を通常の EVM セクションに置き、数値計算をより高速な type のセクションに移して、通常の EOF の関数呼び出しで両者を切り替えるというものです。\n\n## サンプルコード\n\nこの EIP における `types_section` エントリ 1 つのエンコード（Python）:\n\n```python\nimport struct\n\ndef encode_type_entry(code_type: int, inputs: int, outputs: int, max_stack_increase: int) -\u003e bytes:\n    assert code_type == 0x01, \"only type 0x01 is defined by EIP-7960\"\n    reserved = b\"\\x00\\x00\\x00\"\n    return (\n        bytes([code_type]) + reserved\n        + struct.pack(\"\u003eBBH\", inputs, outputs, max_stack_increase)\n    )\n\nentry = encode_type_entry(0x01, inputs=0, outputs=0x80, max_stack_increase=2)\nprint(entry.hex())  # 0100000000800002  -\u003e 8 bytes per entry\n```\n\n（`outputs = 0x80` は、EOF では戻らないセクションを表します。）\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** テストケース、リファレンス実装、セキュリティ分析は、いずれもまだ「追加予定」です。\n- EOF 自体は Ethereum メインネットでは稼働していません。Fusaka アップグレードから外され、EOF のコア仕様（[EIP-3540](/eip-3540/)、[EIP-7692](/eip-7692/)）は Stagnant です。この EIP が意味を持つのは、EOF が復活した場合だけです。\n- バージョンを `0x02` に上げるのは、すでに EOF バージョン 1 をデプロイしているかもしれないサードパーティのチェーンとの衝突を避けるためです。\n- EVM64 のような EVM 以外のセクション type で書かれたコードは、アドレスや残高に直接アクセスできません。その処理は type `0x01` のセクションに残ります。\n"},"ko":{"lang":"ko","tldr":"EOF 컨테이너에 코드 섹션별 type 바이트를 추가해, 한 컨트랙트 안에서 일반 EVM 코드와 EVM64 같은 다른 실행 모드를 섞어 쓸 수 있게 하고, EOF 버전을 0x02로 올린다.","tags":["eof","evm","evm64","bytecode","core"],"related":[3540,7692],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7960/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM Object Format(EOF, [EIP-3540](/eip-3540/))은 컨트랙트 바이트코드를 별도의 코드 섹션을 가진 구조화된 컨테이너로 나누고, 각 섹션은 `types_section`의 항목(입력, 출력, 최대 스택 증가량)으로 설명합니다. 모든 코드 섹션은 일반 EVM 코드라고 가정합니다.\n\n일부 제안은 컨트랙트의 일부를 다른 인터프리터에서 실행하길 원합니다. 동기가 된 예가 EVM64로, 64비트 연산을 가진 변종이어서 무거운 계산에는 더 빠르지만 주소와 잔액을 직접 다루지 못합니다. 나중에는 같은 훅으로 RISC-V 같은 다른 코드 유형도 허용할 수 있습니다. EIP-7960은 인터프리터가 각 섹션을 어떻게 실행해야 하는지 알 수 있도록 필드 하나를 추가합니다.\n\n## 어떻게 동작하나요?\n\n각 `types_section` 항목이 다음 형식에서\n\n```\n(inputs: uint8, outputs: uint8, max_stack_increase: uint16)        // 32 bits\n```\n\n다음 형식으로 바뀝니다.\n\n```\n(type: uint8, reserved: 24 bits, inputs: uint8, outputs: uint8, max_stack_increase: uint16)  // 64 bits\n```\n\n- `type = 0x01`은 여기서 정의되는 유일한 type입니다. 다른 EIP가 더 정의할 수 있습니다.\n- `reserved`는 항목을 64비트로 정렬하기 위한 것이며 모두 0이어야 합니다.\n- EOF 컨테이너의 `version`은 `0x02`가 되고, 버전 `0x01`은 이제 유효하지 않습니다.\n\n새 검증 규칙: 알 수 없는 `type`은 검증에 실패하고, 0이 아닌 `reserved` 필드도 검증에 실패합니다.\n\n의도된 사용 패턴은 컨트랙트가 상태를 다루는 로직(스토리지, 잔액, 호출)은 일반 EVM 섹션에 두고, 수치 계산은 더 빠른 type의 섹션으로 옮기며, 둘 사이를 일반 EOF 함수 호출로 전환하는 것입니다.\n\n## 샘플 코드\n\n이 EIP에 따라 `types_section` 항목 하나를 인코딩하는 코드(Python):\n\n```python\nimport struct\n\ndef encode_type_entry(code_type: int, inputs: int, outputs: int, max_stack_increase: int) -\u003e bytes:\n    assert code_type == 0x01, \"only type 0x01 is defined by EIP-7960\"\n    reserved = b\"\\x00\\x00\\x00\"\n    return (\n        bytes([code_type]) + reserved\n        + struct.pack(\"\u003eBBH\", inputs, outputs, max_stack_increase)\n    )\n\nentry = encode_type_entry(0x01, inputs=0, outputs=0x80, max_stack_increase=2)\nprint(entry.hex())  # 0100000000800002  -\u003e 8 bytes per entry\n```\n\n(`outputs = 0x80`은 EOF에서 반환하지 않는 섹션을 나타냅니다.)\n\n## 알아둘 점\n\n- **상태: Draft.** 테스트 케이스, 레퍼런스 구현, 보안 분석은 모두 아직 \"추가 예정\"입니다.\n- EOF 자체는 이더리움 메인넷에서 가동 중이지 않습니다. Fusaka 업그레이드에서 빠졌고, EOF 핵심 스펙([EIP-3540](/eip-3540/), [EIP-7692](/eip-7692/))은 Stagnant입니다. 이 EIP는 EOF가 돌아올 때만 의미가 있습니다.\n- 버전을 `0x02`로 올리는 이유는 이미 EOF 버전 1을 배포했을 수 있는 서드파티 체인과의 충돌을 피하기 위해서입니다.\n- EVM64 같은 비 EVM 섹션 type으로 작성된 코드는 주소와 잔액에 직접 접근할 수 없습니다. 그 작업은 type `0x01` 섹션에 남습니다.\n"},"zh":{"lang":"zh","tldr":"为 EOF 容器的每个代码段增加一个 type 字节，使同一个合约可以混用普通 EVM 代码与 EVM64 等其他执行模式，并把 EOF 版本升到 0x02。","tags":["eof","evm","evm64","bytecode","core"],"related":[3540,7692],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7960/","markdown":"## 它解决什么问题？\n\nEVM 对象格式（EOF，[EIP-3540](/eip-3540/)）把合约字节码拆分成一个带有独立代码段的结构化容器，每个代码段由 `types_section` 中的一个条目描述（输入、输出、最大栈增长）。每个代码段都被假定为普通的 EVM 代码。\n\n有些提案希望合约的某些部分在不同的解释器下运行。其动机示例是 EVM64，这是一种带 64 位算术的变体，进行繁重计算时更快，但无法直接处理地址和余额。以后，同样的钩子还可以支持 RISC-V 等其他代码类型。EIP-7960 增加了一个字段，让解释器知道如何运行每个代码段。\n\n## 它如何运作\n\n每个 `types_section` 条目从\n\n```\n(inputs: uint8, outputs: uint8, max_stack_increase: uint16)        // 32 bits\n```\n\n变为\n\n```\n(type: uint8, reserved: 24 bits, inputs: uint8, outputs: uint8, max_stack_increase: uint16)  // 64 bits\n```\n\n- `type = 0x01` 是这里定义的唯一类型。其他 EIP 可能会定义更多。\n- `reserved` 使条目保持 64 位对齐，且必须全为零。\n- EOF 容器的 `version` 变为 `0x02`；版本 `0x01` 从此无效。\n\n新的验证规则：未知的 `type` 验证失败，非零的 `reserved` 字段也验证失败。\n\n预期的使用模式是：合约把处理状态的逻辑（存储、余额、调用）放在普通 EVM 代码段中，把数值计算放进更快类型的代码段，并通过普通的 EOF 函数调用在两者之间切换。\n\n## 示例代码\n\n按本 EIP 编码一个 `types_section` 条目（Python）：\n\n```python\nimport struct\n\ndef encode_type_entry(code_type: int, inputs: int, outputs: int, max_stack_increase: int) -\u003e bytes:\n    assert code_type == 0x01, \"only type 0x01 is defined by EIP-7960\"\n    reserved = b\"\\x00\\x00\\x00\"\n    return (\n        bytes([code_type]) + reserved\n        + struct.pack(\"\u003eBBH\", inputs, outputs, max_stack_increase)\n    )\n\nentry = encode_type_entry(0x01, inputs=0, outputs=0x80, max_stack_increase=2)\nprint(entry.hex())  # 0100000000800002  -\u003e 8 bytes per entry\n```\n\n（`outputs = 0x80` 在 EOF 中表示不返回的代码段。）\n\n## 需要注意\n\n- **状态：Draft。** 测试用例、参考实现和安全分析目前都还是\"待补充\"。\n- EOF 本身并未在以太坊主网上线：它已从 Fusaka 升级中移除，EOF 核心规范（[EIP-3540](/eip-3540/)、[EIP-7692](/eip-7692/)）处于 Stagnant 状态。只有在 EOF 回归时，这个 EIP 才有意义。\n- 版本升到 `0x02`，是为了避免与可能已经部署了 EOF 版本 1 的第三方链冲突。\n- 用 EVM64 等非 EVM 代码段类型编写的代码无法直接访问地址和余额；这部分工作仍留在 type `0x01` 的代码段中。\n"}},"requiredBy":[7961]}
