{"eip":1930,"title":"CALLs with strict gas semantic. Revert if not enough gas available.","description":"Add the ability for smart contract to execute calls with a specific amount of gas. If this is not possible the execution should revert.","authors":["Ronan Sandford (@wighawag)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2019-04-10","discussionsTo":"https://github.com/ethereum/EIPs/issues/1930","repo":"EIPs","label":"EIP-1930","officialUrl":"https://eips.ethereum.org/EIPS/eip-1930","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1930.md","url":"https://eips.huatuo.xyz/eip-1930/","tldr":{"en":"Proposes CALL variants that give the callee exactly the gas requested or revert the caller, closing a 63/64-rule loophole that lets relayers make meta-transactions and ERC-165 checks fail on purpose.","ja":"呼び出された側に要求したとおりの gas を渡すか、呼び出し元を revert する CALL の亜種を提案する。リレイヤーがメタトランザクションや ERC-165 のチェックをわざと失敗させられる、63/64 ルールの抜け穴をふさぐ。","ko":"피호출자에게 요청한 만큼의 gas를 정확히 주거나 호출자를 revert시키는 CALL 변형을 제안한다. 릴레이어가 메타 트랜잭션과 ERC-165 검사를 일부러 실패시킬 수 있는 63/64 규칙의 허점을 막는다.","zh":"提议新增 CALL 变体，要么给被调用方恰好所请求的 gas，要么让调用方 revert，以堵住 63/64 规则的漏洞，该漏洞会让中继者故意使元交易和 ERC-165 检查失败。"},"tags":["evm","gas","opcode","meta-transactions","core"],"explainers":{"en":{"lang":"en","tldr":"Proposes CALL variants that give the callee exactly the gas requested or revert the caller, closing a 63/64-rule loophole that lets relayers make meta-transactions and ERC-165 checks fail on purpose.","tags":["evm","gas","opcode","meta-transactions","core"],"related":[150,165,1702,7],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1930/","markdown":"## What problem does it solve?\n\nThe gas argument of `CALL`, `DELEGATECALL` and `STATICCALL` is only a *maximum*. Since [EIP-150](/eip-150/), a call forwards at most `G - floor(G/64)` of the gas left `G`, keeping 1/64 back for the caller. If the caller asks for more than that, the callee silently gets less, and the caller keeps running.\n\nThat matters when the callee's failure must reflect real behaviour, not a lack of gas:\n\n- **Meta-transactions and smart-contract wallets.** A relayer submits a call signed by a user with a specified gas amount. By supplying just too little gas, a malicious relayer can make the inner call fail while the outer transaction still succeeds (and, for example, the nonce is used up or a fee is paid).\n- **[ERC-165](/eip-165/) checks.** `supportsInterface` is called with 30,000 gas. If less is actually forwarded, it can fail and the caller wrongly concludes the interface is unsupported.\n\nDevelopers can work around this with manual `gasleft()` checks, but these depend on exact gas pricing and are easy to get wrong.\n\n## How it works\n\nThe EIP offers two alternatives:\n\n- **Option a:** add strict variants of `CALL`, `DELEGATECALL` and `STATICCALL`. If the gas left (after the call's own cost) is not enough to forward the requested amount, the current frame reverts.\n- **Option b:** reuse the existing opcodes. If the most significant bit of the gas argument is set, the remaining bits are a strict gas amount; otherwise behaviour is unchanged. This relies on no existing contract passing such huge gas values.\n\nIn both cases the strict rule is: revert unless `G \u003e= I * 64/63`, where `G` is gas left at the call and `I` the requested amount. In Geth terms, the branch that silently caps gas would instead return an out-of-gas error.\n\n## Sample code\n\nThe workaround contracts use today, which this EIP would make unnecessary:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Forwarder {\n    /// Call `to` with exactly `txGas`, or revert.\n    function execute(address to, bytes calldata data, uint256 txGas)\n        external returns (bool success, bytes memory ret)\n    {\n        (success, ret) = to.call{gas: txGas}(data);\n\n        // Post-call check from the EIP: if the callee was starved,\n        // less than txGas/63 can remain, so revert the whole thing.\n        if (gasleft() \u003c= txGas / 63) {\n            assembly { invalid() } // consume all gas, like a real out-of-gas\n        }\n    }\n}\n```\n\nThe post-call check still has a gap: if the callee returned early after being given too little gas, enough gas may remain to pass it. That is why the author argues for an EVM-level fix.\n\n## Things to know\n\n- Status is **Stagnant**. No strict-gas call opcode exists on mainnet, so the workarounds above remain necessary.\n- Libraries such as OpenZeppelin's meta-transaction forwarder include this kind of gas check; prefer an audited implementation over hand-rolled code.\n- Option a mentions [EIP-1702](/eip-1702/) (account versioning) as a way to retire the old opcodes; that proposal is also stagnant.\n- A strict-gas opcode would also decouple such contracts from EIP-150's exact forwarding rule, so the rule could change later without breaking them.\n"},"ja":{"lang":"ja","tldr":"呼び出された側に要求したとおりの gas を渡すか、呼び出し元を revert する CALL の亜種を提案する。リレイヤーがメタトランザクションや ERC-165 のチェックをわざと失敗させられる、63/64 ルールの抜け穴をふさぐ。","tags":["evm","gas","opcode","meta-transactions","core"],"related":[150,165,1702,7],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1930/","markdown":"## 何を解決するのか\n\n`CALL`、`DELEGATECALL`、`STATICCALL` の gas 引数は、あくまで*上限*です。[EIP-150](/eip-150/) 以降、呼び出しが転送するのは、残りの gas `G` のうち最大でも `G - floor(G/64)` で、1/64 は呼び出し元のために残されます。呼び出し元がそれ以上を要求しても、呼び出された側は黙ってそれより少ない gas を受け取り、呼び出し元は実行を続けます。\n\nこれは、呼び出された側の失敗が、gas 不足ではなく実際の挙動を反映していなければならない場合に問題になります。\n\n- **メタトランザクションとスマートコントラクトウォレット。** リレイヤーは、ユーザーが指定した gas 量で署名した呼び出しを送信します。わずかに足りない gas を渡すことで、悪意のあるリレイヤーは、外側のトランザクションは成功したまま内側の呼び出しだけを失敗させられます（たとえば、nonce が消費されたり、手数料が支払われたりします）。\n- **[ERC-165](/eip-165/) のチェック。** `supportsInterface` は 30,000 gas で呼び出されます。実際にそれより少なく転送されると失敗する可能性があり、呼び出し元はそのインターフェースが未サポートだと誤って結論づけます。\n\n開発者は、`gasleft()` を手動でチェックすることで回避できますが、これは正確な gas 価格に依存し、間違えやすいものです。\n\n## 仕組み\n\nこの EIP は 2 つの代案を示しています。\n\n- **案 a:** `CALL`、`DELEGATECALL`、`STATICCALL` の厳格版を追加します。（呼び出し自体のコストを引いた後の）残りの gas が、要求された量を転送するのに足りなければ、現在のフレームを revert します。\n- **案 b:** 既存の opcode を再利用します。gas 引数の最上位ビットが立っている場合、残りのビットは厳格な gas 量とみなされ、そうでなければ挙動は変わりません。これは、既存のコントラクトがそのような巨大な gas 値を渡していないことに依存します。\n\nどちらの場合も、厳格なルールは、`G \u003e= I * 64/63` でなければ revert する、というものです。ここで `G` は呼び出し時点の残り gas、`I` は要求された量です。Geth で言えば、gas を黙って切り詰める分岐は、代わりに out-of-gas エラーを返すことになります。\n\n## サンプルコード\n\n現在コントラクトが使っている回避策で、この EIP が不要にするもの:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Forwarder {\n    /// Call `to` with exactly `txGas`, or revert.\n    function execute(address to, bytes calldata data, uint256 txGas)\n        external returns (bool success, bytes memory ret)\n    {\n        (success, ret) = to.call{gas: txGas}(data);\n\n        // Post-call check from the EIP: if the callee was starved,\n        // less than txGas/63 can remain, so revert the whole thing.\n        if (gasleft() \u003c= txGas / 63) {\n            assembly { invalid() } // consume all gas, like a real out-of-gas\n        }\n    }\n}\n```\n\n呼び出し後のチェックにはまだ抜け穴があります。呼び出された側が、少なすぎる gas を渡された後に早期に return した場合、チェックを通過するのに十分な gas が残っている可能性があります。そのため、作者は EVM レベルでの修正を主張しています。\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。メインネットには厳格な gas の呼び出し opcode は存在しないため、上記の回避策が引き続き必要です。\n- OpenZeppelin のメタトランザクション用フォワーダーのようなライブラリには、この種の gas チェックが含まれています。自前で書くより、監査済みの実装を使ってください。\n- 案 a は、古い opcode を廃止する方法として [EIP-1702](/eip-1702/)（アカウントのバージョニング）に言及していますが、その提案も停滞しています。\n- 厳格な gas の opcode があれば、そうしたコントラクトは EIP-150 の正確な転送ルールからも切り離されるため、後でルールが変わっても壊れずに済みます。\n"},"ko":{"lang":"ko","tldr":"피호출자에게 요청한 만큼의 gas를 정확히 주거나 호출자를 revert시키는 CALL 변형을 제안한다. 릴레이어가 메타 트랜잭션과 ERC-165 검사를 일부러 실패시킬 수 있는 63/64 규칙의 허점을 막는다.","tags":["evm","gas","opcode","meta-transactions","core"],"related":[150,165,1702,7],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1930/","markdown":"## 어떤 문제를 해결하나요?\n\n`CALL`, `DELEGATECALL`, `STATICCALL`의 gas 인자는 *최댓값*일 뿐입니다. [EIP-150](/eip-150/) 이후 호출은 남은 gas `G` 중 최대 `G - floor(G/64)`만 전달하고, 1/64는 호출자를 위해 남겨 둡니다. 호출자가 그보다 많이 요청하면 피호출자는 조용히 더 적은 gas를 받고 호출자는 계속 실행됩니다.\n\n피호출자의 실패가 gas 부족이 아니라 실제 동작을 반영해야 할 때 이것이 문제가 됩니다.\n\n- **메타 트랜잭션과 스마트 컨트랙트 지갑.** 릴레이어는 사용자가 지정한 gas 양으로 서명한 호출을 제출합니다. 악의적인 릴레이어는 gas를 아주 조금 모자라게 넘겨, 바깥 트랜잭션은 성공하면서 안쪽 호출만 실패하게 만들 수 있습니다(예를 들어 nonce가 소진되거나 수수료가 지불됩니다).\n- **[ERC-165](/eip-165/) 검사.** `supportsInterface`는 30,000 gas로 호출됩니다. 실제로 그보다 적게 전달되면 실패할 수 있고, 호출자는 그 인터페이스가 지원되지 않는다고 잘못 결론짓습니다.\n\n개발자는 `gasleft()`를 수동으로 검사해 우회할 수 있지만, 이는 정확한 gas 가격에 의존하며 틀리기 쉽습니다.\n\n## 어떻게 동작하나요?\n\n이 EIP는 두 가지 대안을 제시합니다.\n\n- **안 a:** `CALL`, `DELEGATECALL`, `STATICCALL`의 엄격한 변형을 추가합니다. (호출 자체의 비용을 뺀) 남은 gas가 요청한 양을 전달하기에 충분하지 않으면 현재 프레임이 revert됩니다.\n- **안 b:** 기존 옵코드를 재사용합니다. gas 인자의 최상위 비트가 설정되어 있으면 나머지 비트는 엄격한 gas 양이고, 그렇지 않으면 동작은 그대로입니다. 이는 기존 컨트랙트 중 그렇게 큰 gas 값을 넘기는 것이 없다는 점에 의존합니다.\n\n두 경우 모두 엄격한 규칙은 `G \u003e= I * 64/63`이 아니면 revert하는 것입니다. 여기서 `G`는 호출 시점의 남은 gas이고 `I`는 요청한 양입니다. Geth 용어로 말하면, gas를 조용히 제한하던 분기가 대신 out-of-gas 오류를 반환하게 됩니다.\n\n## 샘플 코드\n\n오늘날 컨트랙트가 쓰는 우회 방법으로, 이 EIP가 있으면 필요 없어지는 것:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Forwarder {\n    /// Call `to` with exactly `txGas`, or revert.\n    function execute(address to, bytes calldata data, uint256 txGas)\n        external returns (bool success, bytes memory ret)\n    {\n        (success, ret) = to.call{gas: txGas}(data);\n\n        // Post-call check from the EIP: if the callee was starved,\n        // less than txGas/63 can remain, so revert the whole thing.\n        if (gasleft() \u003c= txGas / 63) {\n            assembly { invalid() } // consume all gas, like a real out-of-gas\n        }\n    }\n}\n```\n\n호출 후 검사에는 여전히 허점이 있습니다. 피호출자가 너무 적은 gas를 받은 뒤 일찍 반환하면, 검사를 통과할 만큼의 gas가 남아 있을 수 있습니다. 작성자가 EVM 수준의 수정을 주장하는 이유입니다.\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. 메인넷에는 엄격한 gas 호출 옵코드가 없으므로 위의 우회 방법이 계속 필요합니다.\n- OpenZeppelin의 메타 트랜잭션 포워더 같은 라이브러리에는 이런 종류의 gas 검사가 포함되어 있습니다. 직접 짠 코드보다 감사를 거친 구현을 쓰세요.\n- 안 a는 옛 옵코드를 폐기하는 방법으로 [EIP-1702](/eip-1702/)(계정 버전 관리)를 언급하는데, 그 제안 역시 정체되어 있습니다.\n- 엄격한 gas 옵코드가 있으면 그런 컨트랙트는 EIP-150의 정확한 전달 규칙과도 분리되므로, 나중에 규칙이 바뀌어도 깨지지 않습니다.\n"},"zh":{"lang":"zh","tldr":"提议新增 CALL 变体，要么给被调用方恰好所请求的 gas，要么让调用方 revert，以堵住 63/64 规则的漏洞，该漏洞会让中继者故意使元交易和 ERC-165 检查失败。","tags":["evm","gas","opcode","meta-transactions","core"],"related":[150,165,1702,7],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1930/","markdown":"## 它解决什么问题？\n\n`CALL`、`DELEGATECALL` 和 `STATICCALL` 的 gas 参数只是一个*上限*。自 [EIP-150](/eip-150/) 起，一次调用最多转发剩余 gas `G` 中的 `G - floor(G/64)`，其中 1/64 留给调用方。如果调用方请求的超过这个数，被调用方会悄悄得到更少的 gas，而调用方继续运行。\n\n当被调用方的失败必须反映其真实行为，而不是缺少 gas 时，这就成了问题：\n\n- **元交易和智能合约钱包。** 中继者提交由用户签名、并指定了 gas 数量的调用。通过提供刚好不够的 gas，恶意中继者可以让内部调用失败，而外层交易仍然成功（例如 nonce 被用掉或手续费被支付）。\n- **[ERC-165](/eip-165/) 检查。** `supportsInterface` 以 30,000 gas 被调用。如果实际转发的更少，它可能失败，调用方就会错误地得出该接口不受支持的结论。\n\n开发者可以用手动的 `gasleft()` 检查来变通，但这依赖于精确的 gas 定价，而且很容易写错。\n\n## 它如何运作\n\n该 EIP 提供了两种备选方案：\n\n- **方案 a：** 添加 `CALL`、`DELEGATECALL` 和 `STATICCALL` 的严格变体。如果（扣除调用自身成本后）剩余的 gas 不足以转发所请求的数量，当前帧就会 revert。\n- **方案 b：** 复用现有操作码。如果 gas 参数的最高位被置位，其余位就表示严格的 gas 数量；否则行为不变。这依赖于没有任何现有合约传入如此巨大的 gas 值。\n\n在两种情况下，严格规则都是：除非 `G \u003e= I * 64/63`，否则 revert，其中 `G` 是调用时的剩余 gas，`I` 是所请求的数量。用 Geth 的话说，原本悄悄限制 gas 的那个分支，会改为返回 out-of-gas 错误。\n\n## 示例代码\n\n如今合约所使用的变通写法，而这个 EIP 会让它变得不再必要：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Forwarder {\n    /// Call `to` with exactly `txGas`, or revert.\n    function execute(address to, bytes calldata data, uint256 txGas)\n        external returns (bool success, bytes memory ret)\n    {\n        (success, ret) = to.call{gas: txGas}(data);\n\n        // Post-call check from the EIP: if the callee was starved,\n        // less than txGas/63 can remain, so revert the whole thing.\n        if (gasleft() \u003c= txGas / 63) {\n            assembly { invalid() } // consume all gas, like a real out-of-gas\n        }\n    }\n}\n```\n\n调用后的检查仍然存在漏洞：如果被调用方在得到过少的 gas 后提前返回，剩余的 gas 可能仍足以通过该检查。这就是作者主张在 EVM 层面修复的原因。\n\n## 需要注意\n\n- 状态为 **Stagnant**。主网上不存在严格 gas 的调用操作码，因此上述变通方法仍然是必要的。\n- 像 OpenZeppelin 的元交易转发器这样的库包含这类 gas 检查；请优先使用经过审计的实现，而不是手写代码。\n- 方案 a 提到 [EIP-1702](/eip-1702/)（账户版本控制）作为淘汰旧操作码的一种方式；该提案同样已停滞。\n- 严格 gas 操作码还能让这类合约与 EIP-150 的精确转发规则解耦，这样规则以后即使改变，也不会破坏它们。\n"}}}
