{"eip":8304,"title":"Trustless log and transaction index","description":"Store the root hashes of index tables in a system contract to allow efficient trustless proofs of log and transaction lookups","authors":["Zsolt Felföldi (@zsfelfoldi)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2026-06-17","requires":[4788],"discussionsTo":"https://ethereum-magicians.org/t/eip-8304-trustless-log-and-transaction-index/28824","repo":"EIPs","label":"EIP-8304","officialUrl":"https://eips.ethereum.org/EIPS/eip-8304","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8304.md","url":"https://eips.huatuo.xyz/eip-8304/","tldr":{"en":"Proposes that every block commits sorted index tables of its transactions and logs into a system contract, so anyone can get compact proofs that a log or transaction lookup result is correct and complete.","ja":"すべてのブロックが、そのトランザクションとログのソート済みインデックステーブルをシステムコントラクトにコミットすることを提案する。これにより、ログやトランザクションの検索結果が正しく、かつ漏れがないことについて、誰でもコンパクトな証明を得られる。","ko":"모든 블록이 자신의 트랜잭션과 로그에 대한 정렬된 인덱스 테이블을 시스템 컨트랙트에 커밋하도록 제안한다. 이렇게 하면 로그나 트랜잭션 조회 결과가 정확하고 누락이 없다는 것을 누구나 간결한 증명으로 얻을 수 있다.","zh":"提出让每个区块把其交易和日志的有序索引表提交到一个系统合约中，使任何人都能获得紧凑的证明，证明某次日志或交易查询的结果既正确又完整。"},"tags":["logs","indexing","light-clients","proofs","core"],"explainers":{"en":{"lang":"en","tldr":"Proposes that every block commits sorted index tables of its transactions and logs into a system contract, so anyone can get compact proofs that a log or transaction lookup result is correct and complete.","tags":["logs","indexing","light-clients","proofs","core"],"related":[7745,4788,7708,8141],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8304/","markdown":"## What problem does it solve?\n\nLogs (events) are cheap to emit, but the protocol gives no efficient way to *search* them. The per-block bloom filters in headers are oversaturated and practically useless today. So users ask an RPC provider \"give me all `Transfer` events to my address\", and must simply trust the answer: the provider cannot prove the result is correct, or that nothing was left out.\n\nEIP-8304 adds a cheap-to-maintain index that supports trustless query proofs. The spec also points to cross-chain messaging (prove logs emitted on another chain from a known block hash) and, later, using logs as a cheap, easily expired form of state.\n\n## How it works\n\n- **Index entries.** For each block the client derives entries for every transaction hash, every log's address and each of its topics, and (one block late) the parent block hash. Each entry is `type ‖ value ‖ position` in big-endian bytes, e.g. a `log.address` entry is `0x0002 ‖ address ‖ block number ‖ tx index ‖ log index` (38 bytes).\n- **Index tables.** Entries are sorted lexicographically and hashed: each entry is SHA-256'd and the table root is the SSZ root of that `List[Hash32]`. Sorting is what makes *exclusion* provable: you can show there are no further matching entries.\n- **Levels.** Tables exist for 1, 4, 16, 64 and 256 blocks. Larger tables are merged from four tables of the level below and are committed with a delay of `table_size / 4` blocks, so merging can happen in the background.\n- **System contract.** After each block, a system call stores `(first_block, table_size, table_root)`. Each level keeps a 1024-entry ring buffer, so roughly the last 2^18 blocks are covered by in-protocol tables. Anyone can call `get(first_block, table_size)` to read a root.\n- **Older history** is expected to be covered by much larger tables built off-protocol and proven with ZK proofs in separate \"history index contracts\" sharing the same `get` interface.\n\nBlock header blooms are left unchanged, and `LOG` gas costs do not increase.\n\n## Sample code\n\nEncoding a `log.topics[0]` entry and reading a table root (the contract address is still TBD in the spec):\n\n```python\ndef topic0_entry(topic: bytes, block: int, tx_index: int, log_index: int) -\u003e bytes:\n    # type 3 = log.topics[0]; 2 + 32 + 8 + 4 + 4 = 50 bytes\n    return (3).to_bytes(2, \"big\") + topic + block.to_bytes(8, \"big\") \\\n        + tx_index.to_bytes(4, \"big\") + log_index.to_bytes(4, \"big\")\n\nentry_hash = sha256(topic0_entry(TRANSFER_TOPIC, 42, 0, 1))\n```\n\n```solidity\n// get(): 64 bytes of calldata -\u003e 32-byte table root, reverts if unknown/overwritten\nfunction tableRoot(address index, uint256 firstBlock, uint256 tableSize) view returns (bytes32) {\n    (bool ok, bytes memory ret) = index.staticcall(abi.encode(firstBlock, tableSize));\n    require(ok, \"no root\");\n    return abi.decode(ret, (bytes32));\n}\n```\n\n## Things to know\n\n- Status is **Draft**. The contract address and deployment details are still TBD.\n- [EIP-7745](/eip-7745/), by the same author and with the same title, is an earlier, different design that replaces header bloom filters; this proposal leaves blooms alone and focuses on low per-block processing cost.\n- After syncing, a client needs at most the last 319 blocks to rebuild the tables it must commit next; no sync protocol change is needed.\n- If [EIP-8141](/eip-8141/) frame transactions activate, a 2-byte frame index is added to log positions. After [EIP-7708](/eip-7708/), history could be re-indexed with ETH transfer logs in an alternative index contract.\n- Query proofs are larger than state proofs; the spec expects a typical query to need tens of individual table proofs.\n"},"ja":{"lang":"ja","tldr":"すべてのブロックが、そのトランザクションとログのソート済みインデックステーブルをシステムコントラクトにコミットすることを提案する。これにより、ログやトランザクションの検索結果が正しく、かつ漏れがないことについて、誰でもコンパクトな証明を得られる。","tags":["logs","indexing","light-clients","proofs","core"],"related":[7745,4788,7708,8141],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8304/","markdown":"## 何を解決するのか\n\nログ（イベント）は発行するのは安価ですが、プロトコルには、それを*検索*する効率的な方法がありません。ヘッダー内のブロックごとの bloom フィルターは飽和状態で、現在では実質的に役に立ちません。そのためユーザーは RPC プロバイダーに「自分のアドレス宛の `Transfer` イベントをすべて教えて」と頼み、答えをただ信じるしかありません。プロバイダーは、結果が正しいことも、何も漏れていないことも証明できません。\n\nEIP-8304 は、維持コストが安く、トラストレスなクエリ証明をサポートするインデックスを追加します。仕様は、クロスチェーンメッセージング（既知のブロックハッシュから、別のチェーンで発行されたログを証明する）や、後にはログを安価で簡単に期限切れにできる形のステートとして使うことも挙げています。\n\n## 仕組み\n\n- **インデックスエントリ。** ブロックごとに、クライアントはすべてのトランザクションハッシュ、各ログのアドレスと各トピック、そして（1 ブロック遅れで）親ブロックのハッシュについてエントリを導出します。各エントリは、ビッグエンディアンのバイト列で `type ‖ value ‖ position` です。たとえば `log.address` のエントリは `0x0002 ‖ address ‖ block number ‖ tx index ‖ log index`（38 バイト）です。\n- **インデックステーブル。** エントリは辞書順にソートされ、ハッシュ化されます。各エントリは SHA-256 され、テーブルルートはその `List[Hash32]` の SSZ ルートです。ソートによって、*除外*を証明できるようになります。それ以上一致するエントリがないことを示せるのです。\n- **レベル。** テーブルは 1、4、16、64、256 ブロックの単位で存在します。大きなテーブルは、1 つ下のレベルの 4 つのテーブルから統合され、`table_size / 4` ブロックの遅延でコミットされるため、統合をバックグラウンドで行えます。\n- **システムコントラクト。** 各ブロックの後、システムコールが `(first_block, table_size, table_root)` を保存します。各レベルは 1024 エントリのリングバッファを保持するため、およそ直近 2^18 ブロックがプロトコル内のテーブルでカバーされます。誰でも `get(first_block, table_size)` を呼び出してルートを読み取れます。\n- **それより古い履歴**は、プロトコル外で構築されたはるかに大きなテーブルでカバーされ、同じ `get` インターフェースを共有する別個の「履歴インデックスコントラクト」で ZK 証明によって証明されることが想定されています。\n\nブロックヘッダーの bloom は変更されず、`LOG` のガスコストも増えません。\n\n## サンプルコード\n\n`log.topics[0]` エントリのエンコードと、テーブルルートの読み取り（コントラクトアドレスは仕様ではまだ TBD です）:\n\n```python\ndef topic0_entry(topic: bytes, block: int, tx_index: int, log_index: int) -\u003e bytes:\n    # type 3 = log.topics[0]; 2 + 32 + 8 + 4 + 4 = 50 bytes\n    return (3).to_bytes(2, \"big\") + topic + block.to_bytes(8, \"big\") \\\n        + tx_index.to_bytes(4, \"big\") + log_index.to_bytes(4, \"big\")\n\nentry_hash = sha256(topic0_entry(TRANSFER_TOPIC, 42, 0, 1))\n```\n\n```solidity\n// get(): 64 bytes of calldata -\u003e 32-byte table root, reverts if unknown/overwritten\nfunction tableRoot(address index, uint256 firstBlock, uint256 tableSize) view returns (bytes32) {\n    (bool ok, bytes memory ret) = index.staticcall(abi.encode(firstBlock, tableSize));\n    require(ok, \"no root\");\n    return abi.decode(ret, (bytes32));\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。コントラクトアドレスとデプロイの詳細はまだ TBD です。\n- 同じ作者による、同じタイトルの [EIP-7745](/eip-7745/) は、ヘッダーの bloom フィルターを置き換える、以前の別の設計です。この提案は bloom には手を付けず、ブロックごとの処理コストを低く抑えることに焦点を当てています。\n- 同期後、クライアントが次にコミットしなければならないテーブルを再構築するのに必要なのは、最大でも直近 319 ブロックだけです。同期プロトコルの変更は不要です。\n- [EIP-8141](/eip-8141/) のフレームトランザクションが有効化された場合、ログの位置に 2 バイトのフレームインデックスが追加されます。[EIP-7708](/eip-7708/) の後は、別のインデックスコントラクトで、ETH 転送ログを含めて履歴を再インデックスできる可能性があります。\n- クエリ証明はステート証明より大きく、仕様は、典型的なクエリに数十個の個別のテーブル証明が必要になると見込んでいます。\n"},"ko":{"lang":"ko","tldr":"모든 블록이 자신의 트랜잭션과 로그에 대한 정렬된 인덱스 테이블을 시스템 컨트랙트에 커밋하도록 제안한다. 이렇게 하면 로그나 트랜잭션 조회 결과가 정확하고 누락이 없다는 것을 누구나 간결한 증명으로 얻을 수 있다.","tags":["logs","indexing","light-clients","proofs","core"],"related":[7745,4788,7708,8141],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8304/","markdown":"## 어떤 문제를 해결하나요?\n\n로그(이벤트)는 발생시키는 비용이 싸지만, 프로토콜에는 이를 *검색*할 효율적인 방법이 없습니다. 헤더에 있는 블록별 블룸 필터는 포화 상태여서 오늘날 사실상 쓸모가 없습니다. 그래서 사용자는 RPC 제공자에게 \"내 주소로 온 `Transfer` 이벤트를 전부 달라\"고 요청하고 답을 그냥 믿을 수밖에 없습니다. 제공자는 결과가 정확하다는 것도, 아무것도 빠지지 않았다는 것도 증명할 수 없습니다.\n\nEIP-8304는 유지 비용이 싸고 신뢰 없는 쿼리 증명을 지원하는 인덱스를 추가합니다. 명세는 체인 간 메시징(알려진 블록 해시로부터 다른 체인에서 발생한 로그를 증명), 그리고 이후 로그를 저렴하고 쉽게 만료되는 형태의 상태로 쓰는 것도 언급합니다.\n\n## 어떻게 동작하나요?\n\n- **인덱스 항목.** 블록마다 클라이언트는 모든 트랜잭션 해시, 각 로그의 주소와 각 토픽, 그리고 (한 블록 늦게) 부모 블록 해시에 대한 항목을 도출합니다. 각 항목은 빅엔디언 바이트로 `type ‖ value ‖ position`입니다. 예를 들어 `log.address` 항목은 `0x0002 ‖ address ‖ block number ‖ tx index ‖ log index`(38바이트)입니다.\n- **인덱스 테이블.** 항목은 사전순으로 정렬되고 해시됩니다. 각 항목은 SHA-256되고 테이블 루트는 그 `List[Hash32]`의 SSZ 루트입니다. 정렬 덕분에 *제외*를 증명할 수 있습니다. 더 이상 일치하는 항목이 없음을 보일 수 있습니다.\n- **레벨.** 테이블은 1, 4, 16, 64, 256개 블록 단위로 존재합니다. 더 큰 테이블은 한 단계 아래 레벨의 테이블 4개를 병합해 만들며 `table_size / 4`개 블록의 지연을 두고 커밋되므로, 병합을 백그라운드에서 할 수 있습니다.\n- **시스템 컨트랙트.** 각 블록 후 시스템 호출이 `(first_block, table_size, table_root)`를 저장합니다. 각 레벨은 1024개 항목의 링 버퍼를 유지하므로, 대략 최근 2^18개 블록이 프로토콜 내 테이블로 커버됩니다. 누구든 `get(first_block, table_size)`를 호출해 루트를 읽을 수 있습니다.\n- **더 오래된 기록**은 프로토콜 밖에서 만든 훨씬 큰 테이블로 커버하고, 같은 `get` 인터페이스를 공유하는 별도의 \"히스토리 인덱스 컨트랙트\"에서 ZK 증명으로 증명할 것으로 예상됩니다.\n\n블록 헤더의 블룸은 그대로 두며 `LOG` 가스 비용도 늘지 않습니다.\n\n## 샘플 코드\n\n`log.topics[0]` 항목을 인코딩하고 테이블 루트 읽기(컨트랙트 주소는 명세에서 아직 TBD):\n\n```python\ndef topic0_entry(topic: bytes, block: int, tx_index: int, log_index: int) -\u003e bytes:\n    # type 3 = log.topics[0]; 2 + 32 + 8 + 4 + 4 = 50 bytes\n    return (3).to_bytes(2, \"big\") + topic + block.to_bytes(8, \"big\") \\\n        + tx_index.to_bytes(4, \"big\") + log_index.to_bytes(4, \"big\")\n\nentry_hash = sha256(topic0_entry(TRANSFER_TOPIC, 42, 0, 1))\n```\n\n```solidity\n// get(): 64 bytes of calldata -\u003e 32-byte table root, reverts if unknown/overwritten\nfunction tableRoot(address index, uint256 firstBlock, uint256 tableSize) view returns (bytes32) {\n    (bool ok, bytes memory ret) = index.staticcall(abi.encode(firstBlock, tableSize));\n    require(ok, \"no root\");\n    return abi.decode(ret, (bytes32));\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 컨트랙트 주소와 배포 세부 사항은 아직 TBD입니다.\n- 같은 저자가 같은 제목으로 낸 [EIP-7745](/eip-7745/)는 헤더 블룸 필터를 대체하는 이전의 다른 설계입니다. 이 제안은 블룸을 그대로 두고 블록당 낮은 처리 비용에 집중합니다.\n- 동기화 후 클라이언트가 다음에 커밋해야 하는 테이블을 재구성하는 데 필요한 것은 최대 최근 319개 블록뿐이며, 동기화 프로토콜 변경은 필요 없습니다.\n- [EIP-8141](/eip-8141/) 프레임 트랜잭션이 활성화되면 로그 위치에 2바이트 프레임 인덱스가 추가됩니다. [EIP-7708](/eip-7708/) 이후에는 대체 인덱스 컨트랙트에서 ETH 전송 로그를 포함해 기록을 다시 인덱싱할 수 있습니다.\n- 쿼리 증명은 상태 증명보다 크며, 명세는 일반적인 쿼리에 수십 개의 개별 테이블 증명이 필요할 것으로 예상합니다.\n"},"zh":{"lang":"zh","tldr":"提出让每个区块把其交易和日志的有序索引表提交到一个系统合约中，使任何人都能获得紧凑的证明，证明某次日志或交易查询的结果既正确又完整。","tags":["logs","indexing","light-clients","proofs","core"],"related":[7745,4788,7708,8141],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8304/","markdown":"## 它解决什么问题？\n\n日志（事件）发出的成本很低，但协议没有提供高效*搜索*它们的方法。区块头中每个区块的 bloom 过滤器已经过度饱和，如今几乎毫无用处。于是用户向 RPC 提供商请求\"给我所有发到我地址的 `Transfer` 事件\"，只能完全信任对方的回答：提供商无法证明结果是正确的，也无法证明没有遗漏任何内容。\n\nEIP-8304 增加了一个维护成本低、支持无需信任的查询证明的索引。规范还提到了跨链消息（根据已知的区块哈希，证明另一条链上发出的日志），以及之后把日志用作一种廉价、易于过期的状态形式。\n\n## 它如何运作\n\n- **索引条目。** 对每个区块，客户端为每个交易哈希、每条日志的地址及其每个主题（topic），以及（延后一个区块）父区块哈希推导出条目。每个条目是大端字节序的 `type ‖ value ‖ position`，例如 `log.address` 条目是 `0x0002 ‖ address ‖ block number ‖ tx index ‖ log index`（38 字节）。\n- **索引表。** 条目按字典序排序并哈希：每个条目做 SHA-256，表根是该 `List[Hash32]` 的 SSZ 根。排序使*排除*变得可证明：你可以证明不存在更多匹配的条目。\n- **层级。** 存在 1、4、16、64 和 256 个区块的表。较大的表由下一层的四个表合并而成，并延迟 `table_size / 4` 个区块提交，这样合并可以在后台进行。\n- **系统合约。** 每个区块之后，一次系统调用会存储 `(first_block, table_size, table_root)`。每一层保留一个 1024 项的环形缓冲区，因此协议内的表大约覆盖最近 2^18 个区块。任何人都可以调用 `get(first_block, table_size)` 来读取根。\n- **更早的历史**预计由在协议外构建的大得多的表来覆盖，并在共用同一 `get` 接口的独立\"历史索引合约\"中通过 ZK 证明来证明。\n\n区块头的 bloom 保持不变，`LOG` 的 gas 成本也不会增加。\n\n## 示例代码\n\n编码一个 `log.topics[0]` 条目并读取表根（合约地址在规范中仍为 TBD）：\n\n```python\ndef topic0_entry(topic: bytes, block: int, tx_index: int, log_index: int) -\u003e bytes:\n    # type 3 = log.topics[0]; 2 + 32 + 8 + 4 + 4 = 50 bytes\n    return (3).to_bytes(2, \"big\") + topic + block.to_bytes(8, \"big\") \\\n        + tx_index.to_bytes(4, \"big\") + log_index.to_bytes(4, \"big\")\n\nentry_hash = sha256(topic0_entry(TRANSFER_TOPIC, 42, 0, 1))\n```\n\n```solidity\n// get(): 64 bytes of calldata -\u003e 32-byte table root, reverts if unknown/overwritten\nfunction tableRoot(address index, uint256 firstBlock, uint256 tableSize) view returns (bytes32) {\n    (bool ok, bytes memory ret) = index.staticcall(abi.encode(firstBlock, tableSize));\n    require(ok, \"no root\");\n    return abi.decode(ret, (bytes32));\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**。合约地址和部署细节仍为 TBD。\n- [EIP-7745](/eip-7745/) 出自同一位作者，标题相同，是一个更早的、不同的设计，它取代区块头的 bloom 过滤器；本提案不动 bloom，而是着重于降低每个区块的处理成本。\n- 同步之后，客户端最多只需要最近 319 个区块，就能重建它接下来必须提交的表；不需要更改同步协议。\n- 如果 [EIP-8141](/eip-8141/) 的 frame 交易被激活，日志位置中会增加一个 2 字节的 frame 索引。在 [EIP-7708](/eip-7708/) 之后，可以在另一个索引合约中，连同 ETH 转账日志一起对历史重新建立索引。\n- 查询证明比状态证明更大；规范预计一次典型的查询需要几十个单独的表证明。\n"}}}
