{"eip":7971,"title":"Hard Limits for Transient Storage","description":"Decrease costs for TLOAD and TSTORE with a transaction-global limit","authors":["Charles Cooper (@charles-cooper)","Ben Adams (@benaadams)","Maria Silva (@misilva73)","Jochem Brouwer (@jochem-brouwer)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2025-06-12","requires":[1153],"discussionsTo":"https://ethereum-magicians.org/t/add-eip-hard-limit-and-cost-reduction-for-transient-storage-allocation/24542","repo":"EIPs","label":"EIP-7971","officialUrl":"https://eips.ethereum.org/EIPS/eip-7971","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7971.md","url":"https://eips.huatuo.xyz/eip-7971/","tldr":{"en":"Makes TLOAD and TSTORE much cheaper by giving transient storage a hard per-transaction slot limit instead of pricing it like warm storage.","ja":"transient storage に「1 トランザクションあたりのスロット数の上限」を設けることで、warm storage 並みの価格付けをやめ、TLOAD と TSTORE を大幅に安くする。","ko":"transient storage에 트랜잭션당 슬롯 개수의 하드 상한을 두어, warm storage처럼 가격을 매기는 대신 TLOAD와 TSTORE를 훨씬 저렴하게 만든다.","zh":"通过给 transient storage 设置每笔交易的硬性槽位上限，而不是按 warm storage 定价，大幅降低 TLOAD 和 TSTORE 的成本。"},"tags":["evm","gas","transient-storage","repricing","core"],"explainers":{"en":{"lang":"en","tldr":"Makes TLOAD and TSTORE much cheaper by giving transient storage a hard per-transaction slot limit instead of pricing it like warm storage.","tags":["evm","gas","transient-storage","repricing","core"],"related":[1153,8007,8038],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7971/","markdown":"## What problem does it solve?\n\n[EIP-1153](/eip-1153/) added transient storage: `TSTORE`/`TLOAD` slots that live only for the duration of a transaction. It is ideal for reentrancy locks, temporary approvals and passing data between call frames. But both opcodes cost 100 gas, the same as a warm `SLOAD`, even though transient storage never touches disk or the state root.\n\nAt that price, languages are reluctant to add reentrancy guards by default, and developers avoid transient storage for other legitimate uses. The main reason the price is not lower is denial-of-service risk: cheap writes could let one transaction allocate huge amounts of memory.\n\n## How it works\n\nEIP-7971 replaces the price-based protection with a **hard cap**:\n\n| Parameter | Value | Meaning |\n| --- | --- | --- |\n| `GAS_TLOAD` | 5 | Cost of `TLOAD` (was 100) |\n| `GAS_TSTORE` | 12 | Base cost of `TSTORE` (was 100) |\n| `GAS_TSTORE_ALLOCATE` | 24 | Extra charge when a slot is written for the first time |\n| `MAX_TRANSIENT_SLOTS` | 131072 | Max unique transient slots per transaction |\n\nA counter tracks unique `(contract_address, key)` slots written across **all** contracts in the transaction. Writing the same slot again does not increase it. If the counter exceeds the limit, the transaction halts exceptionally.\n\nThe cap bounds transient memory to roughly 8 MB per transaction (131072 × 64 bytes), so clients can reserve it up front. The spec notes that under current 100-gas pricing a 60M gas transaction could allocate about 38.4 MB.\n\n## Sample code\n\nA reentrancy guard that becomes much cheaper under this EIP (Solidity 0.8.28+ supports `transient` state variables):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.28;\n\nabstract contract TransientGuard {\n    bool transient locked;\n\n    modifier nonReentrant() {\n        require(!locked, \"reentrant\");\n        locked = true;   // TSTORE: 100 gas today, 12 (+24 first write) proposed\n        _;\n        locked = false;\n    }\n}\n```\n\nThe client-side rule, from the reference implementation:\n\n```python\ndef tstore(ctx, address, key, value):\n    ctx.charge_gas(GAS_TSTORE)\n    slot = (address, key)\n    if slot not in ctx.unique_slots:\n        ctx.charge_gas(GAS_TSTORE_ALLOCATE)\n        ctx.unique_slots.add(slot)\n        if len(ctx.unique_slots) \u003e MAX_TRANSIENT_SLOTS:\n            raise ExceptionalHalt(\"transient storage limit exceeded\")\n    ctx.transient_storage[slot] = value\n```\n\n## Things to know\n\n- **Status: Draft.** The gas numbers are explicitly not final and await benchmarks; the authors say they should stay consistent with [EIP-8038](/eip-8038/).\n- The Glamsterdam repricing directory, [EIP-8007](/eip-8007/), lists this EIP as declined for inclusion in that fork.\n- A transaction that legitimately writes more than 131072 unique transient slots would fail under this rule; typical uses need only a handful.\n- No other behaviour of transient storage changes: values are still cleared at the end of the transaction and reverted with their call frame.\n"},"ja":{"lang":"ja","tldr":"transient storage に「1 トランザクションあたりのスロット数の上限」を設けることで、warm storage 並みの価格付けをやめ、TLOAD と TSTORE を大幅に安くする。","tags":["evm","gas","transient-storage","repricing","core"],"related":[1153,8007,8038],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7971/","markdown":"## 何を解決するのか\n\n[EIP-1153](/eip-1153/) は transient storage を追加しました。トランザクションの間だけ存在する `TSTORE`/`TLOAD` スロットで、リエントランシーロック、一時的な承認、コールフレーム間のデータ受け渡しに最適です。しかし、transient storage はディスクにもステートルートにも触れないにもかかわらず、どちらのオペコードもコストは 100 ガスで、warm な `SLOAD` と同じです。\n\nこの価格では、言語側はリエントランシーガードをデフォルトで追加することをためらい、開発者も他の正当な用途で transient storage を避けます。価格をもっと下げられない主な理由はサービス拒否（DoS）のリスクです。書き込みが安いと、1 つのトランザクションで大量のメモリを確保できてしまいます。\n\n## 仕組み\n\nEIP-7971 は、価格による防御を**ハードな上限**に置き換えます。\n\n| パラメータ | 値 | 意味 |\n| --- | --- | --- |\n| `GAS_TLOAD` | 5 | `TLOAD` のコスト（従来は 100） |\n| `GAS_TSTORE` | 12 | `TSTORE` の基本コスト（従来は 100） |\n| `GAS_TSTORE_ALLOCATE` | 24 | スロットへの初回書き込み時の追加料金 |\n| `MAX_TRANSIENT_SLOTS` | 131072 | 1 トランザクションあたりの一意な transient スロットの最大数 |\n\nカウンターが、トランザクション内の**すべての**コントラクトにわたって書き込まれた一意な `(contract_address, key)` スロットを追跡します。同じスロットへの再書き込みではカウンターは増えません。カウンターが上限を超えると、トランザクションは例外的に停止します。\n\nこの上限により、transient メモリは 1 トランザクションあたり約 8 MB（131072 × 64 バイト）に抑えられ、クライアントは事前に確保できます。仕様には、現行の 100 ガスの価格付けでは 6,000 万ガスのトランザクションが約 38.4 MB を確保できると記されています。\n\n## サンプルコード\n\nこの EIP のもとで大幅に安くなるリエントランシーガード（Solidity 0.8.28 以降は `transient` 状態変数をサポート）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.28;\n\nabstract contract TransientGuard {\n    bool transient locked;\n\n    modifier nonReentrant() {\n        require(!locked, \"reentrant\");\n        locked = true;   // TSTORE: 100 gas today, 12 (+24 first write) proposed\n        _;\n        locked = false;\n    }\n}\n```\n\nリファレンス実装にあるクライアント側のルール:\n\n```python\ndef tstore(ctx, address, key, value):\n    ctx.charge_gas(GAS_TSTORE)\n    slot = (address, key)\n    if slot not in ctx.unique_slots:\n        ctx.charge_gas(GAS_TSTORE_ALLOCATE)\n        ctx.unique_slots.add(slot)\n        if len(ctx.unique_slots) \u003e MAX_TRANSIENT_SLOTS:\n            raise ExceptionalHalt(\"transient storage limit exceeded\")\n    ctx.transient_storage[slot] = value\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** ガスの数値は明示的に確定しておらず、ベンチマークを待っています。作者は [EIP-8038](/eip-8038/) と整合させるべきだとしています。\n- Glamsterdam の価格改定ディレクトリである [EIP-8007](/eip-8007/) は、この EIP を当該フォークへの採用見送りとして挙げています。\n- 131072 を超える一意な transient スロットに正当に書き込むトランザクションは、このルールでは失敗します。一般的な用途で必要なのはごくわずかです。\n- transient storage のその他の挙動は変わりません。値はトランザクション終了時に消去され、コールフレームとともにリバートされます。\n"},"ko":{"lang":"ko","tldr":"transient storage에 트랜잭션당 슬롯 개수의 하드 상한을 두어, warm storage처럼 가격을 매기는 대신 TLOAD와 TSTORE를 훨씬 저렴하게 만든다.","tags":["evm","gas","transient-storage","repricing","core"],"related":[1153,8007,8038],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7971/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-1153](/eip-1153/)은 transient storage를 추가했습니다. 트랜잭션이 진행되는 동안에만 존재하는 `TSTORE`/`TLOAD` 슬롯으로, 재진입 락, 임시 승인, 콜 프레임 간 데이터 전달에 이상적입니다. 하지만 transient storage는 디스크나 상태 루트를 전혀 건드리지 않는데도, 두 옵코드 모두 비용이 100 가스로 warm `SLOAD`와 같습니다.\n\n이 가격에서는 언어들이 재진입 방지 장치를 기본으로 넣기를 꺼리고, 개발자들도 다른 정당한 용도에 transient storage를 쓰지 않으려 합니다. 가격을 더 낮추지 못하는 주된 이유는 서비스 거부(DoS) 위험입니다. 쓰기가 저렴하면 트랜잭션 하나가 막대한 메모리를 할당할 수 있습니다.\n\n## 어떻게 동작하나요?\n\nEIP-7971은 가격 기반 보호를 **하드 상한**으로 대체합니다.\n\n| 매개변수 | 값 | 의미 |\n| --- | --- | --- |\n| `GAS_TLOAD` | 5 | `TLOAD` 비용(기존 100) |\n| `GAS_TSTORE` | 12 | `TSTORE` 기본 비용(기존 100) |\n| `GAS_TSTORE_ALLOCATE` | 24 | 슬롯에 처음 쓸 때 추가되는 비용 |\n| `MAX_TRANSIENT_SLOTS` | 131072 | 트랜잭션당 고유 transient 슬롯 최대 개수 |\n\n카운터가 트랜잭션 내 **모든** 컨트랙트에 걸쳐 기록된 고유한 `(contract_address, key)` 슬롯을 추적합니다. 같은 슬롯에 다시 쓰면 카운터는 늘지 않습니다. 카운터가 상한을 넘으면 트랜잭션은 예외적으로 중단됩니다.\n\n이 상한은 transient 메모리를 트랜잭션당 약 8 MB(131072 × 64바이트)로 제한하므로, 클라이언트가 미리 확보해 둘 수 있습니다. 스펙에는 현재 100 가스 가격에서는 6천만 가스짜리 트랜잭션이 약 38.4 MB를 할당할 수 있다고 적혀 있습니다.\n\n## 샘플 코드\n\n이 EIP에서 훨씬 저렴해지는 재진입 방지 장치(Solidity 0.8.28 이상은 `transient` 상태 변수를 지원):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.28;\n\nabstract contract TransientGuard {\n    bool transient locked;\n\n    modifier nonReentrant() {\n        require(!locked, \"reentrant\");\n        locked = true;   // TSTORE: 100 gas today, 12 (+24 first write) proposed\n        _;\n        locked = false;\n    }\n}\n```\n\n레퍼런스 구현의 클라이언트 측 규칙:\n\n```python\ndef tstore(ctx, address, key, value):\n    ctx.charge_gas(GAS_TSTORE)\n    slot = (address, key)\n    if slot not in ctx.unique_slots:\n        ctx.charge_gas(GAS_TSTORE_ALLOCATE)\n        ctx.unique_slots.add(slot)\n        if len(ctx.unique_slots) \u003e MAX_TRANSIENT_SLOTS:\n            raise ExceptionalHalt(\"transient storage limit exceeded\")\n    ctx.transient_storage[slot] = value\n```\n\n## 알아둘 점\n\n- **상태: Draft.** 가스 수치는 명시적으로 확정되지 않았고 벤치마크를 기다리고 있습니다. 작성자들은 [EIP-8038](/eip-8038/)과 일관되게 유지해야 한다고 말합니다.\n- Glamsterdam 가격 재조정 디렉터리인 [EIP-8007](/eip-8007/)은 이 EIP를 해당 포크에 포함하지 않기로 한 제안으로 분류합니다.\n- 고유 transient 슬롯을 131072개보다 많이 정당하게 써야 하는 트랜잭션은 이 규칙에서 실패합니다. 일반적인 용도에는 몇 개면 충분합니다.\n- transient storage의 다른 동작은 바뀌지 않습니다. 값은 트랜잭션이 끝날 때 지워지고 해당 콜 프레임과 함께 되돌려집니다.\n"},"zh":{"lang":"zh","tldr":"通过给 transient storage 设置每笔交易的硬性槽位上限，而不是按 warm storage 定价，大幅降低 TLOAD 和 TSTORE 的成本。","tags":["evm","gas","transient-storage","repricing","core"],"related":[1153,8007,8038],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7971/","markdown":"## 它解决什么问题？\n\n[EIP-1153](/eip-1153/) 引入了 transient storage：`TSTORE`/`TLOAD` 槽位只在一笔交易期间存在。它非常适合重入锁、临时授权以及在调用帧之间传递数据。但这两个操作码的成本都是 100 gas，与 warm `SLOAD` 相同，尽管 transient storage 从不接触磁盘或状态根。\n\n在这个价格下，各语言不愿默认加入重入保护，开发者也会避免把 transient storage 用于其他正当用途。价格无法更低的主要原因是拒绝服务（DoS）风险：廉价的写入可能让一笔交易分配海量内存。\n\n## 它如何运作\n\nEIP-7971 用**硬性上限**取代基于价格的防护：\n\n| 参数 | 值 | 含义 |\n| --- | --- | --- |\n| `GAS_TLOAD` | 5 | `TLOAD` 的成本（原为 100） |\n| `GAS_TSTORE` | 12 | `TSTORE` 的基础成本（原为 100） |\n| `GAS_TSTORE_ALLOCATE` | 24 | 槽位首次写入时的额外费用 |\n| `MAX_TRANSIENT_SLOTS` | 131072 | 每笔交易的唯一 transient 槽位上限 |\n\n一个计数器记录交易中**所有**合约写入过的唯一 `(contract_address, key)` 槽位。重复写入同一个槽位不会使计数增加。如果计数器超过上限，交易将异常终止。\n\n这个上限把每笔交易的 transient 内存限制在大约 8 MB（131072 × 64 字节），因此客户端可以预先预留。规范指出，在目前 100 gas 的定价下，一笔 6000 万 gas 的交易可以分配约 38.4 MB。\n\n## 示例代码\n\n在本 EIP 下会便宜得多的重入保护（Solidity 0.8.28+ 支持 `transient` 状态变量）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.28;\n\nabstract contract TransientGuard {\n    bool transient locked;\n\n    modifier nonReentrant() {\n        require(!locked, \"reentrant\");\n        locked = true;   // TSTORE: 100 gas today, 12 (+24 first write) proposed\n        _;\n        locked = false;\n    }\n}\n```\n\n参考实现中的客户端规则：\n\n```python\ndef tstore(ctx, address, key, value):\n    ctx.charge_gas(GAS_TSTORE)\n    slot = (address, key)\n    if slot not in ctx.unique_slots:\n        ctx.charge_gas(GAS_TSTORE_ALLOCATE)\n        ctx.unique_slots.add(slot)\n        if len(ctx.unique_slots) \u003e MAX_TRANSIENT_SLOTS:\n            raise ExceptionalHalt(\"transient storage limit exceeded\")\n    ctx.transient_storage[slot] = value\n```\n\n## 需要注意\n\n- **状态：Draft。** gas 数值明确尚未最终确定，有待基准测试；作者表示应与 [EIP-8038](/eip-8038/) 保持一致。\n- Glamsterdam 重新定价目录 [EIP-8007](/eip-8007/) 把本 EIP 列为该分叉中被拒绝纳入的提案。\n- 如果一笔交易确实需要写入超过 131072 个唯一 transient 槽位，在此规则下会失败；典型用途只需要少数几个。\n- transient storage 的其他行为均不变：值仍会在交易结束时清除，并随其调用帧一起回滚。\n"}},"requiredBy":[8007]}
