{"eip":4803,"title":"Limit transaction gas to a maximum of 2^63-1","description":"Valid transactions must have a reasonable gas limit","authors":["Alex Beregszaszi (@axic)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2022-02-02","discussionsTo":"https://ethereum-magicians.org/t/eip-4803-limit-transaction-gas-to-a-maximum-of-2-63-1/8296","repo":"EIPs","label":"EIP-4803","officialUrl":"https://eips.ethereum.org/EIPS/eip-4803","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4803.md","url":"https://eips.huatuo.xyz/eip-4803/","tldr":{"en":"Proposed making any transaction with a gas limit above 2^63-1 invalid, retroactively from genesis, so the consensus rules match the 64-bit gas handling clients already use.","ja":"ガスリミットが 2^63-1 を超えるトランザクションを、ジェネシスにさかのぼって無効にする提案。クライアントがすでに使っている 64 ビットのガス処理とコンセンサスルールを一致させる。","ko":"가스 한도가 2^63-1을 넘는 트랜잭션을 제네시스부터 소급하여 무효로 하자는 제안. 클라이언트가 이미 사용하는 64비트 가스 처리와 합의 규칙을 일치시킨다.","zh":"提议将 gas 上限超过 2^63-1 的交易视为无效，并从创世区块起追溯生效，使共识规则与客户端已经在使用的 64 位 gas 处理保持一致。"},"tags":["gas","transactions","consensus","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed making any transaction with a gas limit above 2^63-1 invalid, retroactively from genesis, so the consensus rules match the 64-bit gas handling clients already use.","tags":["gas","transactions","consensus","core"],"related":[7825,1559,1985],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4803/","markdown":"## What problem does it solve?\n\nA transaction's `gasLimit` field is RLP-encoded, so in principle it can be an arbitrarily large integer. Real clients do not work that way: most cap it at 256 bits, and clients such as geth handle gas internally as a 64-bit number. That mismatch between \"what the spec allows\" and \"what clients can represent\" is a latent source of consensus edge cases.\n\nEIP-4803 proposed writing a reasonable upper bound into consensus.\n\n## How it works\n\nOne rule, applied retroactively from genesis:\n\n\u003e A transaction whose gas limit exceeds `2^63 - 1` is invalid and cannot be included in a block.\n\nWhy `2^63 - 1` and not `2^64 - 1`? It fits in a **signed** 64-bit integer, so an implementation can subtract gas and detect \"out of gas\" with a simple `remaining \u003c 0` check.\n\nThe spec also considered `2^31 - 1`, which is easy to handle in JavaScript, but chose the 64-bit-friendly bound.\n\nApplying it from genesis is safe because no historical transaction could have exceeded it: every transaction must fit in its block's gas limit, and the block gas limit can only change slowly, so it has never come anywhere near `2^63`.\n\n## Sample code\n\nThe validity check a client would add:\n\n```python\nMAX_TX_GAS = 2**63 - 1  # 9_223_372_036_854_775_807\n\ndef validate_gas_limit(tx) -\u003e None:\n    if tx.gas_limit \u003e MAX_TX_GAS:\n        raise InvalidTransaction(\"gas limit exceeds 2^63-1\")\n```\n\nThe same bound in Go, where it is simply `math.MaxInt64`:\n\n```go\nimport \"math\"\n\nfunc validGasLimit(gas uint64) bool {\n    return gas \u003c= math.MaxInt64\n}\n```\n\n## Things to know\n\n- Status is **Stagnant**: the rule was not adopted through this EIP.\n- The spec expects no visible effect on the chain: it only formalizes a limit that real blocks already respect.\n- A much lower per-transaction gas cap was later introduced by [EIP-7825](/eip-7825/), for different reasons (bounding the cost of a single transaction).\n- JavaScript numbers are only exact up to `2^53 - 1`, so tooling that handles gas values near this bound should use `bigint`, not `number`.\n- Before [EIP-1559](/eip-1559/) a zero gas price let `gasLimit * gasPrice` stay within any balance, but the block gas limit still kept historical values small.\n"},"ja":{"lang":"ja","tldr":"ガスリミットが 2^63-1 を超えるトランザクションを、ジェネシスにさかのぼって無効にする提案。クライアントがすでに使っている 64 ビットのガス処理とコンセンサスルールを一致させる。","tags":["gas","transactions","consensus","core"],"related":[7825,1559,1985],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4803/","markdown":"## 何を解決するのか\n\nトランザクションの `gasLimit` フィールドは RLP エンコードされるため、原理上は任意の大きさの整数になりえます。実際のクライアントはそうなっていません。多くは 256 ビットで上限を設け、geth のようなクライアントは内部でガスを 64 ビットの数値として扱います。「仕様が許すもの」と「クライアントが表現できるもの」のこのずれは、コンセンサス上のエッジケースの潜在的な原因です。\n\nEIP-4803 は、妥当な上限をコンセンサスに明記することを提案しました。\n\n## 仕組み\n\nルールは 1 つで、ジェネシスにさかのぼって適用されます。\n\n\u003e ガスリミットが `2^63 - 1` を超えるトランザクションは無効であり、ブロックに含めることはできない。\n\nなぜ `2^64 - 1` ではなく `2^63 - 1` なのでしょうか。これは**符号付き** 64 ビット整数に収まるため、実装はガスを減算して、単純な `remaining \u003c 0` の判定で「ガス切れ」を検出できます。\n\n仕様は JavaScript で扱いやすい `2^31 - 1` も検討しましたが、64 ビットに適した上限を選びました。\n\nジェネシスから適用しても安全です。過去のトランザクションがこれを超えていた可能性はないからです。すべてのトランザクションはそのブロックのガスリミットに収まる必要があり、ブロックのガスリミットはゆっくりとしか変化しないため、`2^63` に近づいたことは一度もありません。\n\n## サンプルコード\n\nクライアントが追加する検証チェック:\n\n```python\nMAX_TX_GAS = 2**63 - 1  # 9_223_372_036_854_775_807\n\ndef validate_gas_limit(tx) -\u003e None:\n    if tx.gas_limit \u003e MAX_TX_GAS:\n        raise InvalidTransaction(\"gas limit exceeds 2^63-1\")\n```\n\nGo での同じ上限。単に `math.MaxInt64` です。\n\n```go\nimport \"math\"\n\nfunc validGasLimit(gas uint64) bool {\n    return gas \u003c= math.MaxInt64\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。このルールは、この EIP を通じては採用されませんでした。\n- 仕様は、チェーン上に目に見える影響はないと見込んでいます。実際のブロックがすでに守っている上限を形式化するだけだからです。\n- トランザクションごとのはるかに低いガス上限は、のちに別の理由（単一トランザクションのコストの制限）で [EIP-7825](/eip-7825/) によって導入されました。\n- JavaScript の数値は `2^53 - 1` までしか正確ではないため、この上限付近のガス値を扱うツールでは `number` ではなく `bigint` を使うべきです。\n- [EIP-1559](/eip-1559/) 以前は、ガス価格がゼロなら `gasLimit * gasPrice` はどんな残高にも収まりましたが、それでもブロックのガスリミットによって過去の値は小さく保たれていました。\n"},"ko":{"lang":"ko","tldr":"가스 한도가 2^63-1을 넘는 트랜잭션을 제네시스부터 소급하여 무효로 하자는 제안. 클라이언트가 이미 사용하는 64비트 가스 처리와 합의 규칙을 일치시킨다.","tags":["gas","transactions","consensus","core"],"related":[7825,1559,1985],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4803/","markdown":"## 어떤 문제를 해결하나요?\n\n트랜잭션의 `gasLimit` 필드는 RLP로 인코딩되므로 원칙적으로는 임의로 큰 정수가 될 수 있습니다. 실제 클라이언트는 그렇게 동작하지 않습니다. 대부분 256비트로 제한하고, geth 같은 클라이언트는 내부적으로 가스를 64비트 숫자로 다룹니다. \"명세가 허용하는 것\"과 \"클라이언트가 표현할 수 있는 것\" 사이의 이런 불일치는 합의 엣지 케이스의 잠재적 원인입니다.\n\nEIP-4803은 합리적인 상한을 합의 규칙에 명시하자고 제안했습니다.\n\n## 어떻게 동작하나요?\n\n규칙은 하나이며 제네시스부터 소급 적용됩니다.\n\n\u003e 가스 한도가 `2^63 - 1`을 초과하는 트랜잭션은 무효이며 블록에 포함될 수 없다.\n\n왜 `2^64 - 1`이 아니라 `2^63 - 1`일까요? **부호 있는** 64비트 정수에 들어가기 때문에, 구현에서 가스를 빼고 단순한 `remaining \u003c 0` 검사로 \"가스 부족\"을 감지할 수 있습니다.\n\n명세는 JavaScript에서 다루기 쉬운 `2^31 - 1`도 검토했지만, 64비트에 친화적인 상한을 선택했습니다.\n\n제네시스부터 적용해도 안전합니다. 과거의 어떤 트랜잭션도 이를 넘을 수 없었기 때문입니다. 모든 트랜잭션은 해당 블록의 가스 한도 안에 들어가야 하고, 블록 가스 한도는 천천히만 바뀔 수 있으므로 `2^63`에 근접한 적이 한 번도 없습니다.\n\n## 샘플 코드\n\n클라이언트가 추가할 유효성 검사:\n\n```python\nMAX_TX_GAS = 2**63 - 1  # 9_223_372_036_854_775_807\n\ndef validate_gas_limit(tx) -\u003e None:\n    if tx.gas_limit \u003e MAX_TX_GAS:\n        raise InvalidTransaction(\"gas limit exceeds 2^63-1\")\n```\n\nGo에서의 같은 상한. 단순히 `math.MaxInt64`입니다.\n\n```go\nimport \"math\"\n\nfunc validGasLimit(gas uint64) bool {\n    return gas \u003c= math.MaxInt64\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. 이 규칙은 이 EIP를 통해 채택되지 않았습니다.\n- 명세는 체인에 눈에 보이는 영향이 없을 것으로 예상합니다. 실제 블록이 이미 지키고 있는 한도를 공식화할 뿐이기 때문입니다.\n- 트랜잭션당 훨씬 낮은 가스 상한은 이후 다른 이유(단일 트랜잭션의 비용 제한)로 [EIP-7825](/eip-7825/)에서 도입되었습니다.\n- JavaScript 숫자는 `2^53 - 1`까지만 정확하므로, 이 상한 근처의 가스 값을 다루는 도구는 `number` 대신 `bigint`를 사용해야 합니다.\n- [EIP-1559](/eip-1559/) 이전에는 가스 가격이 0이면 `gasLimit * gasPrice`가 어떤 잔액에도 들어맞았지만, 그래도 블록 가스 한도 때문에 과거의 값은 작게 유지되었습니다.\n"},"zh":{"lang":"zh","tldr":"提议将 gas 上限超过 2^63-1 的交易视为无效，并从创世区块起追溯生效，使共识规则与客户端已经在使用的 64 位 gas 处理保持一致。","tags":["gas","transactions","consensus","core"],"related":[7825,1559,1985],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4803/","markdown":"## 它解决什么问题？\n\n交易的 `gasLimit` 字段采用 RLP 编码，因此理论上可以是任意大的整数。但真实的客户端并不是这样工作的：大多数将其限制在 256 位，而 geth 等客户端在内部把 gas 当作 64 位数字处理。“规范允许的范围”与“客户端能表示的范围”之间的这种不一致，是共识边缘情况的潜在来源。\n\nEIP-4803 提议把一个合理的上限写入共识规则。\n\n## 它如何运作\n\n只有一条规则，并从创世区块起追溯适用：\n\n\u003e gas 上限超过 `2^63 - 1` 的交易无效，不能被打包进区块。\n\n为什么是 `2^63 - 1` 而不是 `2^64 - 1`？因为它可以放进**有符号** 64 位整数，实现者可以直接扣减 gas，并用简单的 `remaining \u003c 0` 判断来检测“gas 耗尽”。\n\n规范也考虑过在 JavaScript 中容易处理的 `2^31 - 1`，但最终选择了对 64 位友好的上限。\n\n从创世区块起适用是安全的，因为历史上没有任何交易可能超过这个值：每笔交易都必须容纳在其区块的 gas 上限之内，而区块 gas 上限只能缓慢变化，从未接近过 `2^63`。\n\n## 示例代码\n\n客户端会添加的有效性检查：\n\n```python\nMAX_TX_GAS = 2**63 - 1  # 9_223_372_036_854_775_807\n\ndef validate_gas_limit(tx) -\u003e None:\n    if tx.gas_limit \u003e MAX_TX_GAS:\n        raise InvalidTransaction(\"gas limit exceeds 2^63-1\")\n```\n\nGo 中的同一上限，其实就是 `math.MaxInt64`：\n\n```go\nimport \"math\"\n\nfunc validGasLimit(gas uint64) bool {\n    return gas \u003c= math.MaxInt64\n}\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**：该规则并未通过这个 EIP 被采纳。\n- 规范预期这不会对链产生可见影响：它只是把真实区块已经遵守的限制正式化。\n- 后来 [EIP-7825](/eip-7825/) 出于不同的原因（限制单笔交易的成本）引入了低得多的单笔交易 gas 上限。\n- JavaScript 的数字只在 `2^53 - 1` 以内是精确的，因此处理接近该上限的 gas 值的工具应使用 `bigint` 而不是 `number`。\n- 在 [EIP-1559](/eip-1559/) 之前，gas 价格为零时 `gasLimit * gasPrice` 可以落在任何余额之内，但区块 gas 上限仍然使历史取值保持在较小范围。\n"}},"requiredBy":[7675]}
