{"eip":1985,"title":"Sane limits for certain EVM parameters","description":"Introduce an explicit value range for certain EVM parameters (such as gas limit, block number, block timestamp, size field when returning/copying data within EVM). Some of these already have an implicit value range due to various (practical) reasons.","authors":["Alex Beregszaszi (@axic)","Paweł Bylica (@chfast)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2018-08-01","discussionsTo":"https://ethereum-magicians.org/t/eip-1985-sane-limits-for-certain-evm-parameters/3224","repo":"EIPs","label":"EIP-1985","officialUrl":"https://eips.ethereum.org/EIPS/eip-1985","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1985.md","url":"https://eips.huatuo.xyz/eip-1985/","tldr":{"en":"Proposes explicit value ranges for EVM values such as gas, block number, timestamp, addresses and buffer sizes, so clients can use 64-bit or 32-bit integers safely and tests can skip impossible edge cases.","ja":"ガス、ブロック番号、タイムスタンプ、アドレス、バッファサイズなどの EVM の値に明示的な範囲を定める提案。クライアントが 64 ビットや 32 ビット整数を安全に使え、テストでは起こり得ないエッジケースを省けるようになる。","ko":"gas, 블록 번호, 타임스탬프, 주소, 버퍼 크기 같은 EVM 값에 명시적인 범위를 정하자는 제안. 클라이언트가 64비트나 32비트 정수를 안전하게 쓸 수 있고, 테스트는 불가능한 엣지 케이스를 건너뛸 수 있다.","zh":"为 gas、区块号、时间戳、地址和缓冲区大小等 EVM 值提出明确的取值范围，使客户端可以安全地使用 64 位或 32 位整数，测试也可以跳过不可能出现的边界情况。"},"tags":["evm","limits","core","clients","specification"],"explainers":{"en":{"lang":"en","tldr":"Proposes explicit value ranges for EVM values such as gas, block number, timestamp, addresses and buffer sizes, so clients can use 64-bit or 32-bit integers safely and tests can skip impossible edge cases.","tags":["evm","limits","core","clients","specification"],"related":[170,1482],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1985/","markdown":"## What problem does it solve?\n\nThe EVM works on 256-bit words, so in theory instructions like `GAS` or `TIMESTAMP` could return any 256-bit value. In practice clients store these values in 64-bit integers, and some can never get that large because gas makes it impossible. These implicit limits were not written down.\n\nThat gap has costs: client authors must guess which limits are safe, implementations may disagree on absurd edge cases, and consensus test suites spend effort on values that can never occur. EIP-1985 proposes stating the ranges explicitly.\n\n## How it works\n\nFrom a fork block onwards, the values these instructions push onto the stack are guaranteed to fall within:\n\n| Value | Range | Instructions |\n| --- | --- | --- |\n| Gas, gas limit, block gas limit | `0` to `2**63 - 1` | `GASLIMIT`, `GAS` |\n| Block number, timestamp | `0` to `2**63 - 1` | `NUMBER`, `TIMESTAMP` |\n| Account address | `0` to `2**160 - 1` (top 96 bits zero) | `ADDRESS`, `ORIGIN`, `CALLER`, `COINBASE`, `CREATE`, `CREATE2` |\n| Buffer, code and memory size | `0` to `2**32 - 1` | `CALLDATASIZE`, `CODESIZE`, `EXTCODESIZE`, `RETURNDATASIZE`, `MSIZE`, `PC` |\n\nWhy `2**63 - 1` rather than `2**64 - 1`? It fits a **signed** 64-bit integer, which helps languages without unsigned types and makes out-of-gas checks as simple as `gas_counter \u003c 0`.\n\nThe memory-size cap is backed by gas cost: memory expansion cost grows quadratically, so reaching 4 GiB is already prohibitively expensive. Code size is already far below the cap thanks to [EIP-170](/eip-170/).\n\nThe authors argue there is no behaviour change, since these limits are already enforced in practice, mostly via the block gas limit.\n\n## Sample code\n\nHow a client might use the guarantee, in Go-like pseudocode:\n\n```go\nconst MaxInt63 = 1\u003c\u003c63 - 1\n\n// Safe to keep these as native integers instead of 256-bit words\ntype BlockContext struct {\n    Number    int64  // 0 .. 2**63-1\n    Timestamp int64  // 0 .. 2**63-1\n    GasLimit  int64  // 0 .. 2**63-1\n}\n\nfunc opMsize(mem *Memory, stack *Stack) {\n    stack.Push(uint256.NewInt(uint64(mem.Len()))) // fits in uint32 by this EIP\n}\n```\n\n## Things to know\n\n- Status is **Stagnant**; it has not been adopted as a consensus rule.\n- The spec leaves open whether the gas range also applies to the gas argument of call instructions.\n- Even without this EIP, most clients already represent these values with 64-bit integers, so the practical behaviour largely matches what it describes.\n- [EIP-1482](/eip-1482/) is a related proposal about bounding the *drift* of block timestamps rather than their numeric range.\n"},"ja":{"lang":"ja","tldr":"ガス、ブロック番号、タイムスタンプ、アドレス、バッファサイズなどの EVM の値に明示的な範囲を定める提案。クライアントが 64 ビットや 32 ビット整数を安全に使え、テストでは起こり得ないエッジケースを省けるようになる。","tags":["evm","limits","core","clients","specification"],"related":[170,1482],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1985/","markdown":"## 何を解決するのか\n\nEVM は 256 ビットのワードで動作するため、理論上は `GAS` や `TIMESTAMP` のような命令が任意の 256 ビット値を返し得ます。実際には、クライアントはこれらの値を 64 ビット整数で保持しており、ガスの制約上そこまで大きくなり得ない値もあります。こうした暗黙の上限は明文化されていませんでした。\n\nこの空白にはコストがあります。クライアント開発者はどの上限が安全かを推測しなければならず、実装ごとに極端なエッジケースの扱いが食い違う可能性があり、コンセンサスのテストスイートは決して発生しない値に労力を費やします。EIP-1985 はこれらの範囲を明示することを提案しています。\n\n## 仕組み\n\nフォークブロック以降、これらの命令がスタックに積む値は、次の範囲に収まることが保証されます。\n\n| 値 | 範囲 | 命令 |\n| --- | --- | --- |\n| ガス、ガスリミット、ブロックガスリミット | `0` ～ `2**63 - 1` | `GASLIMIT`, `GAS` |\n| ブロック番号、タイムスタンプ | `0` ～ `2**63 - 1` | `NUMBER`, `TIMESTAMP` |\n| アカウントアドレス | `0` ～ `2**160 - 1`（上位 96 ビットは 0） | `ADDRESS`, `ORIGIN`, `CALLER`, `COINBASE`, `CREATE`, `CREATE2` |\n| バッファ、コード、メモリのサイズ | `0` ～ `2**32 - 1` | `CALLDATASIZE`, `CODESIZE`, `EXTCODESIZE`, `RETURNDATASIZE`, `MSIZE`, `PC` |\n\nなぜ `2**64 - 1` ではなく `2**63 - 1` なのでしょうか。**符号付き** 64 ビット整数に収まるため、符号なし型を持たない言語で扱いやすく、ガス切れの判定を `gas_counter \u003c 0` のように単純にできるからです。\n\nメモリサイズの上限はガスコストによって裏付けられています。メモリ拡張のコストは二次関数的に増えるため、4 GiB に到達するだけでも非現実的なほど高額です。コードサイズは [EIP-170](/eip-170/) のおかげですでに上限をはるかに下回っています。\n\n作者は、これらの上限は主にブロックガスリミットによって実際にはすでに守られているため、挙動の変更はないと主張しています。\n\n## サンプルコード\n\nクライアントがこの保証をどう利用できるかを、Go 風の疑似コードで示します。\n\n```go\nconst MaxInt63 = 1\u003c\u003c63 - 1\n\n// Safe to keep these as native integers instead of 256-bit words\ntype BlockContext struct {\n    Number    int64  // 0 .. 2**63-1\n    Timestamp int64  // 0 .. 2**63-1\n    GasLimit  int64  // 0 .. 2**63-1\n}\n\nfunc opMsize(mem *Memory, stack *Stack) {\n    stack.Push(uint256.NewInt(uint64(mem.Len()))) // fits in uint32 by this EIP\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** で、コンセンサスルールとしては採用されていません。\n- ガスの範囲が call 系命令のガス引数にも適用されるかどうかは、仕様では未決定のままです。\n- この EIP がなくても、ほとんどのクライアントはすでにこれらの値を 64 ビット整数で表現しているため、実際の挙動はおおむねこの EIP の記述と一致します。\n- [EIP-1482](/eip-1482/) は関連する提案で、ブロックのタイムスタンプの数値範囲ではなく、そのずれ（*ドリフト*）に上限を設けるものです。\n"},"ko":{"lang":"ko","tldr":"gas, 블록 번호, 타임스탬프, 주소, 버퍼 크기 같은 EVM 값에 명시적인 범위를 정하자는 제안. 클라이언트가 64비트나 32비트 정수를 안전하게 쓸 수 있고, 테스트는 불가능한 엣지 케이스를 건너뛸 수 있다.","tags":["evm","limits","core","clients","specification"],"related":[170,1482],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1985/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM은 256비트 워드로 동작하므로, 이론적으로는 `GAS`나 `TIMESTAMP` 같은 명령어가 어떤 256비트 값이든 반환할 수 있습니다. 실제로 클라이언트는 이 값들을 64비트 정수로 저장하며, 일부는 gas 때문에 그만큼 커지는 것이 불가능합니다. 이런 암묵적인 한계는 어디에도 명시되어 있지 않았습니다.\n\n이 공백에는 비용이 따릅니다. 클라이언트 개발자는 어떤 한계가 안전한지 추측해야 하고, 구현마다 터무니없는 엣지 케이스에서 결과가 다를 수 있으며, 합의 테스트 스위트는 절대 발생하지 않을 값에 노력을 들입니다. EIP-1985는 이 범위를 명시하자고 제안합니다.\n\n## 어떻게 동작하나요?\n\n포크 블록부터 이 명령어들이 스택에 넣는 값은 다음 범위 안에 있음이 보장됩니다.\n\n| 값 | 범위 | 명령어 |\n| --- | --- | --- |\n| Gas, gas 한도, 블록 gas 한도 | `0` ~ `2**63 - 1` | `GASLIMIT`, `GAS` |\n| 블록 번호, 타임스탬프 | `0` ~ `2**63 - 1` | `NUMBER`, `TIMESTAMP` |\n| 계정 주소 | `0` ~ `2**160 - 1` (상위 96비트는 0) | `ADDRESS`, `ORIGIN`, `CALLER`, `COINBASE`, `CREATE`, `CREATE2` |\n| 버퍼, 코드, 메모리 크기 | `0` ~ `2**32 - 1` | `CALLDATASIZE`, `CODESIZE`, `EXTCODESIZE`, `RETURNDATASIZE`, `MSIZE`, `PC` |\n\n왜 `2**64 - 1`이 아니라 `2**63 - 1`일까요? **부호 있는** 64비트 정수에 들어가기 때문에, 부호 없는 타입이 없는 언어에서 다루기 쉽고 out-of-gas 검사를 `gas_counter \u003c 0`처럼 간단하게 만들 수 있습니다.\n\n메모리 크기 상한은 gas 비용이 뒷받침합니다. 메모리 확장 비용은 제곱으로 늘어나므로 4 GiB에 도달하는 것만으로도 이미 감당할 수 없을 만큼 비쌉니다. 코드 크기는 [EIP-170](/eip-170/) 덕분에 이미 상한보다 훨씬 작습니다.\n\n저자들은 이 한계가 주로 블록 gas 한도를 통해 실제로 이미 지켜지고 있으므로 동작 변화는 없다고 주장합니다.\n\n## 샘플 코드\n\n클라이언트가 이 보장을 어떻게 활용할 수 있는지 Go 스타일 의사 코드로 보여줍니다.\n\n```go\nconst MaxInt63 = 1\u003c\u003c63 - 1\n\n// Safe to keep these as native integers instead of 256-bit words\ntype BlockContext struct {\n    Number    int64  // 0 .. 2**63-1\n    Timestamp int64  // 0 .. 2**63-1\n    GasLimit  int64  // 0 .. 2**63-1\n}\n\nfunc opMsize(mem *Memory, stack *Stack) {\n    stack.Push(uint256.NewInt(uint64(mem.Len()))) // fits in uint32 by this EIP\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**이며 합의 규칙으로 채택되지 않았습니다.\n- gas 범위가 call 계열 명령어의 gas 인자에도 적용되는지는 명세에서 열어 두었습니다.\n- 이 EIP가 없어도 대부분의 클라이언트는 이미 이 값들을 64비트 정수로 표현하므로, 실제 동작은 대체로 여기에 설명된 내용과 일치합니다.\n- [EIP-1482](/eip-1482/)는 관련 제안으로, 블록 타임스탬프의 수치 범위가 아니라 *드리프트*를 제한하는 내용입니다.\n"},"zh":{"lang":"zh","tldr":"为 gas、区块号、时间戳、地址和缓冲区大小等 EVM 值提出明确的取值范围，使客户端可以安全地使用 64 位或 32 位整数，测试也可以跳过不可能出现的边界情况。","tags":["evm","limits","core","clients","specification"],"related":[170,1482],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1985/","markdown":"## 它解决什么问题？\n\nEVM 以 256 位字为单位运算，因此理论上 `GAS` 或 `TIMESTAMP` 这类指令可以返回任意 256 位的值。实际上，客户端用 64 位整数保存这些值，而且有些值由于 gas 的限制根本不可能那么大。这些隐含的上限从未被明文写下。\n\n这一空白是有代价的：客户端开发者必须猜测哪些上限是安全的，不同实现在极端边界情况上可能出现分歧，共识测试套件也要在永远不会出现的值上耗费精力。EIP-1985 提议把这些范围明确写出来。\n\n## 它如何运作\n\n从某个分叉区块开始，这些指令压入栈的值保证落在以下范围内：\n\n| 值 | 范围 | 指令 |\n| --- | --- | --- |\n| Gas、gas 上限、区块 gas 上限 | `0` 到 `2**63 - 1` | `GASLIMIT`, `GAS` |\n| 区块号、时间戳 | `0` 到 `2**63 - 1` | `NUMBER`, `TIMESTAMP` |\n| 账户地址 | `0` 到 `2**160 - 1`（高 96 位为零） | `ADDRESS`, `ORIGIN`, `CALLER`, `COINBASE`, `CREATE`, `CREATE2` |\n| 缓冲区、代码和内存大小 | `0` 到 `2**32 - 1` | `CALLDATASIZE`, `CODESIZE`, `EXTCODESIZE`, `RETURNDATASIZE`, `MSIZE`, `PC` |\n\n为什么是 `2**63 - 1` 而不是 `2**64 - 1`？因为它能放进**有符号** 64 位整数，这对没有无符号类型的语言很有帮助，也让 out-of-gas 检查简单到只需 `gas_counter \u003c 0`。\n\n内存大小的上限由 gas 成本支撑：内存扩展的成本呈二次方增长，所以光是达到 4 GiB 就已经贵得无法承受。得益于 [EIP-170](/eip-170/)，代码大小早已远低于上限。\n\n作者认为这不会带来行为上的改变，因为这些限制在实践中已经被执行了，主要是通过区块 gas 上限。\n\n## 示例代码\n\n客户端可能如何利用这一保证，使用类 Go 伪代码：\n\n```go\nconst MaxInt63 = 1\u003c\u003c63 - 1\n\n// Safe to keep these as native integers instead of 256-bit words\ntype BlockContext struct {\n    Number    int64  // 0 .. 2**63-1\n    Timestamp int64  // 0 .. 2**63-1\n    GasLimit  int64  // 0 .. 2**63-1\n}\n\nfunc opMsize(mem *Memory, stack *Stack) {\n    stack.Push(uint256.NewInt(uint64(mem.Len()))) // fits in uint32 by this EIP\n}\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**，尚未被采纳为共识规则。\n- 规范没有说明 gas 范围是否同样适用于 call 类指令的 gas 参数。\n- 即使没有这个 EIP，大多数客户端也已经用 64 位整数表示这些值，因此实际行为与它所描述的基本一致。\n- [EIP-1482](/eip-1482/) 是相关提案，它限制的是区块时间戳的*漂移*，而不是其数值范围。\n"}}}
