{"eip":150,"title":"Gas cost changes for IO-heavy operations","authors":["Vitalik Buterin (@vbuterin)"],"status":"Final","type":"Standards Track","category":"Core","created":"2016-09-24","repo":"EIPs","label":"EIP-150","officialUrl":"https://eips.ethereum.org/EIPS/eip-150","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md","url":"https://eips.huatuo.xyz/eip-150/","tldr":{"en":"Raised gas costs for state-reading opcodes after the 2016 DoS attacks and added the \"all but one 64th\" rule that caps gas forwarded to sub-calls.","ja":"2016 年の DoS 攻撃を受けて、ステートを読み取る opcode のガスコストを引き上げ、サブコールに渡すガスを制限する「64 分の 1 を除く全部」ルールを追加した。","ko":"2016년 DoS 공격 이후 상태를 읽는 opcode의 가스 비용을 올리고, 서브콜에 전달되는 가스를 제한하는 \"64분의 1을 제외한 전부\" 규칙을 추가했다.","zh":"在 2016 年的 DoS 攻击之后，提高了读取状态的操作码的 gas 成本，并加入了限制转发给子调用的 gas 的“除 64 分之一外的全部”规则。"},"tags":["gas","dos","evm","core","tangerine-whistle"],"explainers":{"en":{"lang":"en","tldr":"Raised gas costs for state-reading opcodes after the 2016 DoS attacks and added the \"all but one 64th\" rule that caps gas forwarded to sub-calls.","tags":["gas","dos","evm","core","tangerine-whistle"],"related":[608,2929,607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-150/","markdown":"## What problem does it solve?\n\nIn autumn 2016, attackers spammed Ethereum with transactions that ran opcodes like `EXTCODESIZE` and `BALANCE` over and over. These opcodes read state from disk, which is slow, but they cost only 20 gas each. Blocks became extremely slow to process and the network degraded.\n\nThe spec says the underlying problem would not go away with client optimizations alone: state-reading opcodes were **underpriced** compared with how expensive they are to execute. EIP-150 reprices them. It also fixes a related weakness, the call-stack depth limit.\n\n## How it works\n\nFrom block 2,463,000 on mainnet (the Tangerine Whistle fork):\n\n| Opcode | Old gas | New gas |\n| --- | --- | --- |\n| `EXTCODESIZE` | 20 | 700 |\n| `EXTCODECOPY` (base) | 20 | 700 |\n| `BALANCE` | 20 | 400 |\n| `SLOAD` | 50 | 200 |\n| `CALL`, `CALLCODE`, `DELEGATECALL` | 40 | 700 |\n| `SELFDESTRUCT` | 0 | 5000 (+25000 if it creates a new account) |\n\nThe spec derives these numbers from a target of at most about 8 MB of disk reads per block, plus a flat 300 gas to cover loading contract code.\n\n**The 63/64 rule.** Before this change, a call that requested more gas than was available failed with out-of-gas. Now the call is not rejected. It receives at most \"all but one 64th\" of the remaining gas, `N - floor(N / 64)`. `CREATE` follows the same rule.\n\nThis has two effects:\n\n- Old contracts that forwarded `msg.gas - 40` (assuming a call costs 40) kept working after the call price changed.\n- Every nested call keeps 1/64 of its gas back, so gas shrinks with each level. The spec says this limits practical call depth to about 340. The **call-stack depth attack**, where an attacker made a victim's sub-call fail at depth 1024, stopped being a practical threat.\n\nThe recommended block gas limit target was raised to 5.5 million to keep throughput roughly the same.\n\n## Sample code\n\nThe new gas-forwarding logic, from the spec:\n\n```python\ndef max_call_gas(gas):\n    return gas - (gas // 64)\n\nextra_gas = (not account_exists(to)) * GCALLNEWACCOUNT + (value \u003e 0) * GCALLVALUETRANSFER\nif available_gas \u003c extra_gas:\n    raise OutOfGas\nif available_gas \u003c requested_gas + extra_gas:\n    requested_gas = min(requested_gas, max_call_gas(available_gas - extra_gas))\nsub_call_gas = requested_gas + GSTIPEND * (value \u003e 0)\n```\n\nIn Solidity, the parent always keeps some gas back, even when you forward \"everything\":\n\n```solidity\n(bool ok, ) = target.call{gas: gasleft()}(data); // callee gets at most 63/64 of what remains\n```\n\n## Things to know\n\n- The hard fork that shipped this change is described in [EIP-608](/eip-608/) (Tangerine Whistle).\n- Because of the 63/64 rule, a contract cannot assume a sub-call got exactly the gas it asked for. Code that checks `gasleft()` after a failed call should take this into account.\n- Most of these prices were raised again in Berlin by [EIP-2929](/eip-2929/), which split state access into \"cold\" (first touch) and \"warm\" costs.\n"},"ja":{"lang":"ja","tldr":"2016 年の DoS 攻撃を受けて、ステートを読み取る opcode のガスコストを引き上げ、サブコールに渡すガスを制限する「64 分の 1 を除く全部」ルールを追加した。","tags":["gas","dos","evm","core","tangerine-whistle"],"related":[608,2929,607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-150/","markdown":"## 何を解決するのか\n\n2016 年の秋、攻撃者は `EXTCODESIZE` や `BALANCE` などの opcode を何度も実行するトランザクションで Ethereum を埋め尽くしました。これらの opcode はディスクからステートを読み取るため遅いにもかかわらず、コストは 1 回あたりわずか 20 ガスでした。ブロックの処理は極端に遅くなり、ネットワークは劣化しました。\n\n仕様は、クライアントの最適化だけでは根本的な問題は解決しないと述べています。ステートを読み取る opcode は、実行にかかるコストに比べて**価格が低すぎた**のです。EIP-150 はこれらを再価格設定します。あわせて、関連する弱点であるコールスタック深度の制限も修正します。\n\n## 仕組み\n\nメインネットのブロック 2,463,000 以降（Tangerine Whistle フォーク）:\n\n| Opcode | 旧ガス | 新ガス |\n| --- | --- | --- |\n| `EXTCODESIZE` | 20 | 700 |\n| `EXTCODECOPY`（基本） | 20 | 700 |\n| `BALANCE` | 20 | 400 |\n| `SLOAD` | 50 | 200 |\n| `CALL`, `CALLCODE`, `DELEGATECALL` | 40 | 700 |\n| `SELFDESTRUCT` | 0 | 5000（新しいアカウントを作成する場合は +25000） |\n\n仕様は、ブロックあたりのディスク読み取りを最大でおよそ 8 MB に抑えるという目標に、コントラクトコードの読み込みをまかなう一律 300 ガスを加えて、これらの数値を導いています。\n\n**63/64 ルール。** この変更の前は、利用可能なガスより多くを要求したコールは out-of-gas で失敗しました。変更後はコールが拒否されなくなり、残りのガスのうち「64 分の 1 を除く全部」、つまり `N - floor(N / 64)` までを受け取ります。`CREATE` も同じルールに従います。\n\nこれには 2 つの効果があります。\n\n- `msg.gas - 40`（コールのコストが 40 だと仮定）を渡していた古いコントラクトは、コールの価格が変わった後も動き続けました。\n- ネストしたコールはどれも自分のガスの 1/64 を手元に残すため、階層が深くなるたびにガスが減っていきます。仕様によれば、これにより実用上のコール深度は約 340 に制限されます。攻撃者が深度 1024 で被害者のサブコールを失敗させる**コールスタック深度攻撃**は、現実的な脅威ではなくなりました。\n\nスループットをほぼ同じに保つため、推奨されるブロックガスリミットの目標は 550 万に引き上げられました。\n\n## サンプルコード\n\n仕様に記載された、新しいガス転送ロジック:\n\n```python\ndef max_call_gas(gas):\n    return gas - (gas // 64)\n\nextra_gas = (not account_exists(to)) * GCALLNEWACCOUNT + (value \u003e 0) * GCALLVALUETRANSFER\nif available_gas \u003c extra_gas:\n    raise OutOfGas\nif available_gas \u003c requested_gas + extra_gas:\n    requested_gas = min(requested_gas, max_call_gas(available_gas - extra_gas))\nsub_call_gas = requested_gas + GSTIPEND * (value \u003e 0)\n```\n\nSolidity では、「すべて」を渡そうとしても、親コントラクトは常にいくらかのガスを手元に残します。\n\n```solidity\n(bool ok, ) = target.call{gas: gasleft()}(data); // callee gets at most 63/64 of what remains\n```\n\n## 知っておくべきこと\n\n- この変更を含めたハードフォークは [EIP-608](/eip-608/)（Tangerine Whistle）に記載されています。\n- 63/64 ルールのため、コントラクトはサブコールが要求どおりのガスを正確に受け取ったと仮定できません。失敗したコールの後で `gasleft()` を確認するコードは、この点を考慮する必要があります。\n- これらの価格の多くは、Berlin で [EIP-2929](/eip-2929/) によって再び引き上げられました。この提案はステートアクセスを「コールド」（初回アクセス）と「ウォーム」のコストに分けています。\n"},"ko":{"lang":"ko","tldr":"2016년 DoS 공격 이후 상태를 읽는 opcode의 가스 비용을 올리고, 서브콜에 전달되는 가스를 제한하는 \"64분의 1을 제외한 전부\" 규칙을 추가했다.","tags":["gas","dos","evm","core","tangerine-whistle"],"related":[608,2929,607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-150/","markdown":"## 어떤 문제를 해결하나요?\n\n2016년 가을, 공격자들은 `EXTCODESIZE`, `BALANCE` 같은 opcode를 반복 실행하는 트랜잭션으로 이더리움을 도배했습니다. 이 opcode들은 디스크에서 상태를 읽어 느린데도 비용은 호출당 20 가스에 불과했습니다. 블록 처리가 극도로 느려졌고 네트워크 성능이 떨어졌습니다.\n\n명세는 클라이언트 최적화만으로는 근본 문제가 사라지지 않는다고 말합니다. 상태를 읽는 opcode는 실행 비용에 비해 **가격이 너무 낮게** 책정되어 있었습니다. EIP-150은 이를 재조정합니다. 또한 관련된 약점인 콜 스택 깊이 제한도 함께 고칩니다.\n\n## 어떻게 동작하나요?\n\n메인넷 블록 2,463,000부터(Tangerine Whistle 포크):\n\n| Opcode | 이전 가스 | 새 가스 |\n| --- | --- | --- |\n| `EXTCODESIZE` | 20 | 700 |\n| `EXTCODECOPY`(기본) | 20 | 700 |\n| `BALANCE` | 20 | 400 |\n| `SLOAD` | 50 | 200 |\n| `CALL`, `CALLCODE`, `DELEGATECALL` | 40 | 700 |\n| `SELFDESTRUCT` | 0 | 5000(새 계정을 만들면 +25000) |\n\n명세는 블록당 디스크 읽기를 최대 약 8 MB로 제한한다는 목표에, 컨트랙트 코드 로딩 비용을 감당하는 고정 300 가스를 더해 이 숫자들을 도출합니다.\n\n**63/64 규칙.** 이 변경 이전에는 사용 가능한 가스보다 많이 요청한 호출이 out-of-gas로 실패했습니다. 이제 호출은 거부되지 않고, 남은 가스의 \"64분의 1을 제외한 전부\", 즉 `N - floor(N / 64)`까지만 받습니다. `CREATE`도 같은 규칙을 따릅니다.\n\n여기에는 두 가지 효과가 있습니다.\n\n- `msg.gas - 40`(호출 비용이 40이라고 가정)을 전달하던 기존 컨트랙트는 호출 가격이 바뀐 뒤에도 계속 동작했습니다.\n- 중첩된 모든 호출은 자기 가스의 1/64를 남겨 두므로 단계가 깊어질수록 가스가 줄어듭니다. 명세에 따르면 이로 인해 실질적인 호출 깊이는 약 340으로 제한됩니다. 공격자가 깊이 1024에서 피해자의 서브콜을 실패하게 만들던 **콜 스택 깊이 공격**은 더 이상 현실적인 위협이 아니게 되었습니다.\n\n처리량을 대체로 유지하기 위해 권장 블록 가스 한도 목표는 550만으로 올랐습니다.\n\n## 샘플 코드\n\n명세에 나온 새로운 가스 전달 로직:\n\n```python\ndef max_call_gas(gas):\n    return gas - (gas // 64)\n\nextra_gas = (not account_exists(to)) * GCALLNEWACCOUNT + (value \u003e 0) * GCALLVALUETRANSFER\nif available_gas \u003c extra_gas:\n    raise OutOfGas\nif available_gas \u003c requested_gas + extra_gas:\n    requested_gas = min(requested_gas, max_call_gas(available_gas - extra_gas))\nsub_call_gas = requested_gas + GSTIPEND * (value \u003e 0)\n```\n\nSolidity에서는 \"전부\"를 전달하려 해도 부모가 항상 일부 가스를 남겨 둡니다.\n\n```solidity\n(bool ok, ) = target.call{gas: gasleft()}(data); // callee gets at most 63/64 of what remains\n```\n\n## 알아둘 점\n\n- 이 변경을 포함한 하드 포크는 [EIP-608](/eip-608/)(Tangerine Whistle)에 설명되어 있습니다.\n- 63/64 규칙 때문에 컨트랙트는 서브콜이 요청한 가스를 정확히 받았다고 가정할 수 없습니다. 실패한 호출 뒤에 `gasleft()`를 확인하는 코드는 이 점을 고려해야 합니다.\n- 이 가격의 대부분은 Berlin에서 [EIP-2929](/eip-2929/)에 의해 다시 올랐습니다. 이 제안은 상태 접근을 \"콜드\"(첫 접근)와 \"웜\" 비용으로 나눴습니다.\n"},"zh":{"lang":"zh","tldr":"在 2016 年的 DoS 攻击之后，提高了读取状态的操作码的 gas 成本，并加入了限制转发给子调用的 gas 的“除 64 分之一外的全部”规则。","tags":["gas","dos","evm","core","tangerine-whistle"],"related":[608,2929,607],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-150/","markdown":"## 它解决什么问题？\n\n2016 年秋天，攻击者向以太坊发送大量交易，反复执行 `EXTCODESIZE` 和 `BALANCE` 等操作码。这些操作码要从磁盘读取状态，速度很慢，但每次只收 20 gas。区块的处理变得极其缓慢，网络性能下降。\n\n规范指出，仅靠客户端优化无法消除根本问题：读取状态的操作码相对其执行成本而言**定价过低**。EIP-150 对它们重新定价，同时修复了一个相关的弱点，即调用栈深度限制。\n\n## 它如何运作\n\n从主网区块 2,463,000 起（Tangerine Whistle 分叉）：\n\n| 操作码 | 旧 gas | 新 gas |\n| --- | --- | --- |\n| `EXTCODESIZE` | 20 | 700 |\n| `EXTCODECOPY`（基础） | 20 | 700 |\n| `BALANCE` | 20 | 400 |\n| `SLOAD` | 50 | 200 |\n| `CALL`、`CALLCODE`、`DELEGATECALL` | 40 | 700 |\n| `SELFDESTRUCT` | 0 | 5000（如果创建新账户则 +25000） |\n\n规范以每个区块最多约 8 MB 磁盘读取为目标，再加上用于覆盖合约代码加载的固定 300 gas，推导出这些数字。\n\n**63/64 规则。** 在此变更之前，请求的 gas 超过可用量的调用会因 out-of-gas 而失败。现在调用不会被拒绝，它最多获得剩余 gas 的“除 64 分之一外的全部”，即 `N - floor(N / 64)`。`CREATE` 遵循同样的规则。\n\n这有两个效果：\n\n- 过去转发 `msg.gas - 40`（假设一次调用成本为 40）的旧合约，在调用价格变化后仍能继续工作。\n- 每层嵌套调用都会留下自己 1/64 的 gas，所以 gas 随层级逐渐减少。规范指出，这将实际调用深度限制在约 340。攻击者在深度 1024 处让受害者的子调用失败的**调用栈深度攻击**，不再是现实的威胁。\n\n推荐的区块 gas 上限目标提高到了 550 万，以使吞吐量大致保持不变。\n\n## 示例代码\n\n规范中给出的新的 gas 转发逻辑：\n\n```python\ndef max_call_gas(gas):\n    return gas - (gas // 64)\n\nextra_gas = (not account_exists(to)) * GCALLNEWACCOUNT + (value \u003e 0) * GCALLVALUETRANSFER\nif available_gas \u003c extra_gas:\n    raise OutOfGas\nif available_gas \u003c requested_gas + extra_gas:\n    requested_gas = min(requested_gas, max_call_gas(available_gas - extra_gas))\nsub_call_gas = requested_gas + GSTIPEND * (value \u003e 0)\n```\n\n在 Solidity 中，即使你想转发“全部”，父合约也总会留下一部分 gas：\n\n```solidity\n(bool ok, ) = target.call{gas: gasleft()}(data); // callee gets at most 63/64 of what remains\n```\n\n## 需要注意\n\n- 发布此变更的硬分叉在 [EIP-608](/eip-608/)（Tangerine Whistle）中描述。\n- 由于 63/64 规则，合约不能假定子调用恰好得到了它所请求的 gas。在调用失败后检查 `gasleft()` 的代码应当考虑这一点。\n- 其中大部分价格在 Berlin 中又被 [EIP-2929](/eip-2929/) 再次提高，该提案把状态访问分为“冷”（首次访问）和“热”两种成本。\n"}},"requiredBy":[608,1380,1884,7069,8133,8257]}
