{"eip":160,"title":"EXP cost increase","authors":["Vitalik Buterin (@vbuterin)"],"status":"Final","type":"Standards Track","category":"Core","created":"2016-10-20","repo":"EIPs","label":"EIP-160","officialUrl":"https://eips.ethereum.org/EIPS/eip-160","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-160.md","url":"https://eips.huatuo.xyz/eip-160/","tldr":{"en":"Raised the gas cost of the EXP opcode from 10 to 50 gas per exponent byte in the Spurious Dragon fork, because benchmarks showed it was underpriced.","ja":"Spurious Dragon フォークで EXP オペコードの gas コストを、指数 1 バイトあたり 10 から 50 に引き上げた。ベンチマークで価格が低すぎると判明したため。","ko":"Spurious Dragon 포크에서 EXP opcode의 gas 비용을 지수 바이트당 10에서 50으로 올렸다. 벤치마크 결과 가격이 너무 낮게 책정되어 있었기 때문이다.","zh":"在 Spurious Dragon 分叉中，将 EXP 操作码每个指数字节的 gas 成本从 10 提高到 50，因为基准测试显示它定价过低。"},"tags":["gas","evm","opcode","spurious-dragon","core"],"explainers":{"en":{"lang":"en","tldr":"Raised the gas cost of the EXP opcode from 10 to 50 gas per exponent byte in the Spurious Dragon fork, because benchmarks showed it was underpriced.","tags":["gas","evm","opcode","spurious-dragon","core"],"related":[607,150,161,155,170],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-160/","markdown":"## What problem does it solve?\n\nEvery EVM opcode has a fixed gas price that should roughly match how much work it costs a node to run. If an opcode is too cheap, an attacker can fill blocks with it and slow every node down while paying little. This kind of denial-of-service attack hit Ethereum in 2016.\n\n`EXP` (`0x0a`, `a ** b` modulo 2^256) was one of the underpriced opcodes. The spec reports that benchmarks showed it was underpriced by a factor of about **4 to 8**.\n\n## How it works\n\nThe cost of `EXP` depends on how many bytes the exponent needs. EIP-160 changes only the per-byte part:\n\n| | Static | Per byte of exponent |\n| --- | --- | --- |\n| Before | 10 | 10 |\n| After EIP-160 | 10 | **50** |\n\n\"Bytes in the exponent\" means the minimum number of bytes needed to represent `b`. An exponent of `0` costs only the static 10 gas. An exponent up to `255` costs 10 + 50 = 60. A full 256-bit exponent costs 10 + 50 × 32 = 1,610.\n\nThe change went live in the Spurious Dragon hard fork at block 2,675,000 on mainnet (chain ID 1).\n\n## Sample code\n\nGas calculation in pseudocode:\n\n```python\ndef exp_gas(exponent: int) -\u003e int:\n    G_EXP = 10\n    G_EXPBYTE = 50                      # was 10 before EIP-160\n    byte_len = (exponent.bit_length() + 7) // 8\n    return G_EXP + G_EXPBYTE * byte_len\n\nexp_gas(0)          # 10\nexp_gas(255)        # 60\nexp_gas(256)        # 110\nexp_gas(2**256 - 1) # 1610\n```\n\nSolidity's `**` operator compiles to `EXP`. For powers of two, a shift is cheaper:\n\n```solidity\nuint256 a = 2 ** n;   // EXP: 10 + 50 * bytes(n)\nuint256 b = 1 \u003c\u003c n;   // SHL: 3 gas (opcode from EIP-145)\n```\n\n## Things to know\n\n- This is a pure repricing. The result of `EXP` does not change. Only contracts that relied on an exact gas amount could notice it.\n- The fixed per-byte price makes `EXP` cheap for small exponents and five times more expensive than before for large ones. That is fine for typical uses such as `10 ** decimals`, which has a one-byte exponent.\n- When the exponent is a constant, the compiler often folds `**` away. The cost matters most when the exponent is a runtime value.\n- EIP-160 is one of several anti-DoS changes from 2016. See [EIP-150](/eip-150/) (IO-heavy opcodes repricing) and the Spurious Dragon meta EIP [EIP-607](/eip-607/), which also includes [EIP-155](/eip-155/), [EIP-161](/eip-161/) and [EIP-170](/eip-170/).\n"},"ja":{"lang":"ja","tldr":"Spurious Dragon フォークで EXP オペコードの gas コストを、指数 1 バイトあたり 10 から 50 に引き上げた。ベンチマークで価格が低すぎると判明したため。","tags":["gas","evm","opcode","spurious-dragon","core"],"related":[607,150,161,155,170],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-160/","markdown":"## 何を解決するのか\n\nEVM の各オペコードには固定の gas 価格があり、ノードがそれを実行する際の作業量におおよそ見合うべきです。オペコードが安すぎると、攻撃者はわずかな支払いでブロックをそれで埋め尽くし、すべてのノードを遅くできます。この種のサービス拒否攻撃は 2016 年に Ethereum を襲いました。\n\n`EXP`（`0x0a`、`a ** b` を 2^256 で割った余り）は、価格が低すぎたオペコードの 1 つでした。仕様には、ベンチマークで約 **4 〜 8 倍**安すぎることが示されたと記されています。\n\n## 仕組み\n\n`EXP` のコストは、指数の表現に必要なバイト数で決まります。EIP-160 が変更するのはバイトあたりの部分だけです。\n\n| | 固定 | 指数 1 バイトあたり |\n| --- | --- | --- |\n| 変更前 | 10 | 10 |\n| EIP-160 後 | 10 | **50** |\n\n「指数のバイト数」とは、`b` を表現するのに必要な最小のバイト数です。指数が `0` なら固定の 10 gas だけです。`255` までの指数なら 10 + 50 = 60 です。256 ビットすべてを使う指数なら 10 + 50 × 32 = 1,610 です。\n\nこの変更は、メインネット（チェーン ID 1）のブロック 2,675,000 で Spurious Dragon ハードフォークとともに有効になりました。\n\n## サンプルコード\n\n疑似コードによる gas 計算です。\n\n```python\ndef exp_gas(exponent: int) -\u003e int:\n    G_EXP = 10\n    G_EXPBYTE = 50                      # was 10 before EIP-160\n    byte_len = (exponent.bit_length() + 7) // 8\n    return G_EXP + G_EXPBYTE * byte_len\n\nexp_gas(0)          # 10\nexp_gas(255)        # 60\nexp_gas(256)        # 110\nexp_gas(2**256 - 1) # 1610\n```\n\nSolidity の `**` 演算子は `EXP` にコンパイルされます。2 のべき乗には、シフトのほうが安上がりです。\n\n```solidity\nuint256 a = 2 ** n;   // EXP: 10 + 50 * bytes(n)\nuint256 b = 1 \u003c\u003c n;   // SHL: 3 gas (opcode from EIP-145)\n```\n\n## 知っておくべきこと\n\n- これは純粋な価格改定です。`EXP` の結果は変わりません。正確な gas 量に依存していたコントラクトだけが影響に気づく可能性があります。\n- バイトあたりの価格が固定のため、`EXP` は小さな指数では安く、大きな指数では以前の 5 倍の高さになります。`10 ** decimals`（指数は 1 バイト）のような一般的な用途では問題ありません。\n- 指数が定数の場合、コンパイラが `**` を畳み込んで消すことがよくあります。コストが最も問題になるのは、指数が実行時の値のときです。\n- EIP-160 は 2016 年のサービス拒否対策の一環です。[EIP-150](/eip-150/)（IO 負荷の高いオペコードの価格改定）と、Spurious Dragon のメタ EIP である [EIP-607](/eip-607/) も参照してください。後者には [EIP-155](/eip-155/)、[EIP-161](/eip-161/)、[EIP-170](/eip-170/) も含まれます。\n"},"ko":{"lang":"ko","tldr":"Spurious Dragon 포크에서 EXP opcode의 gas 비용을 지수 바이트당 10에서 50으로 올렸다. 벤치마크 결과 가격이 너무 낮게 책정되어 있었기 때문이다.","tags":["gas","evm","opcode","spurious-dragon","core"],"related":[607,150,161,155,170],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-160/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM의 모든 opcode에는 고정된 gas 가격이 있으며, 이는 노드가 그것을 실행하는 데 드는 작업량과 대략 맞아야 합니다. opcode가 너무 싸면 공격자는 적은 비용으로 블록을 그 opcode로 가득 채워 모든 노드를 느리게 만들 수 있습니다. 이런 서비스 거부 공격이 2016년 이더리움을 덮쳤습니다.\n\n`EXP`(`0x0a`, `a ** b`를 2^256으로 나눈 나머지)는 가격이 너무 낮았던 opcode 중 하나였습니다. 명세는 벤치마크에서 약 **4~8배** 저평가된 것으로 나타났다고 밝힙니다.\n\n## 어떻게 동작하나요?\n\n`EXP`의 비용은 지수에 필요한 바이트 수에 따라 달라집니다. EIP-160은 바이트당 부분만 바꿉니다.\n\n| | 고정 | 지수 바이트당 |\n| --- | --- | --- |\n| 변경 전 | 10 | 10 |\n| EIP-160 이후 | 10 | **50** |\n\n\"지수의 바이트 수\"는 `b`를 표현하는 데 필요한 최소 바이트 수입니다. 지수가 `0`이면 고정 10 gas만 듭니다. `255` 이하의 지수는 10 + 50 = 60입니다. 256비트를 모두 쓰는 지수는 10 + 50 × 32 = 1,610입니다.\n\n이 변경은 Spurious Dragon 하드 포크와 함께 메인넷(체인 ID 1)의 블록 2,675,000에서 적용되었습니다.\n\n## 샘플 코드\n\n의사 코드로 나타낸 gas 계산입니다.\n\n```python\ndef exp_gas(exponent: int) -\u003e int:\n    G_EXP = 10\n    G_EXPBYTE = 50                      # was 10 before EIP-160\n    byte_len = (exponent.bit_length() + 7) // 8\n    return G_EXP + G_EXPBYTE * byte_len\n\nexp_gas(0)          # 10\nexp_gas(255)        # 60\nexp_gas(256)        # 110\nexp_gas(2**256 - 1) # 1610\n```\n\nSolidity의 `**` 연산자는 `EXP`로 컴파일됩니다. 2의 거듭제곱에는 시프트가 더 저렴합니다.\n\n```solidity\nuint256 a = 2 ** n;   // EXP: 10 + 50 * bytes(n)\nuint256 b = 1 \u003c\u003c n;   // SHL: 3 gas (opcode from EIP-145)\n```\n\n## 알아둘 점\n\n- 순수한 가격 재조정입니다. `EXP`의 결과는 바뀌지 않습니다. 정확한 gas 양에 의존하던 컨트랙트만 영향을 느낄 수 있습니다.\n- 바이트당 가격이 고정이라 `EXP`는 작은 지수에서는 저렴하고, 큰 지수에서는 이전보다 다섯 배 비쌉니다. 지수가 1바이트인 `10 ** decimals` 같은 일반적인 용도에서는 문제없습니다.\n- 지수가 상수이면 컴파일러가 `**`를 미리 계산해 없애는 경우가 많습니다. 비용은 지수가 런타임 값일 때 가장 중요합니다.\n- EIP-160은 2016년의 여러 DoS 방지 변경 중 하나입니다. [EIP-150](/eip-150/)(IO 부하가 큰 opcode 가격 재조정)과 Spurious Dragon 메타 EIP인 [EIP-607](/eip-607/)을 참고하세요. 후자에는 [EIP-155](/eip-155/), [EIP-161](/eip-161/), [EIP-170](/eip-170/)도 포함됩니다.\n"},"zh":{"lang":"zh","tldr":"在 Spurious Dragon 分叉中，将 EXP 操作码每个指数字节的 gas 成本从 10 提高到 50，因为基准测试显示它定价过低。","tags":["gas","evm","opcode","spurious-dragon","core"],"related":[607,150,161,155,170],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-160/","markdown":"## 它解决什么问题？\n\n每个 EVM 操作码都有固定的 gas 价格，应大致与节点执行它所需的工作量相匹配。如果某个操作码太便宜，攻击者就能用它塞满区块，只付很少的费用却拖慢所有节点。这类拒绝服务攻击在 2016 年袭击过以太坊。\n\n`EXP`（`0x0a`，`a ** b` 对 2^256 取模）就是定价过低的操作码之一。规范指出，基准测试显示它被低估了约 **4 到 8 倍**。\n\n## 它如何运作\n\n`EXP` 的成本取决于指数需要多少字节。EIP-160 只修改按字节计费的部分：\n\n| | 固定部分 | 每个指数字节 |\n| --- | --- | --- |\n| 之前 | 10 | 10 |\n| EIP-160 之后 | 10 | **50** |\n\n“指数的字节数”是指表示 `b` 所需的最少字节数。指数为 `0` 时只收固定的 10 gas。指数不超过 `255` 时为 10 + 50 = 60。完整的 256 位指数为 10 + 50 × 32 = 1,610。\n\n这一改动随 Spurious Dragon 硬分叉在主网（链 ID 1）的 2,675,000 区块生效。\n\n## 示例代码\n\n用伪代码计算 gas：\n\n```python\ndef exp_gas(exponent: int) -\u003e int:\n    G_EXP = 10\n    G_EXPBYTE = 50                      # was 10 before EIP-160\n    byte_len = (exponent.bit_length() + 7) // 8\n    return G_EXP + G_EXPBYTE * byte_len\n\nexp_gas(0)          # 10\nexp_gas(255)        # 60\nexp_gas(256)        # 110\nexp_gas(2**256 - 1) # 1610\n```\n\nSolidity 的 `**` 运算符会编译为 `EXP`。对于 2 的幂，位移更便宜：\n\n```solidity\nuint256 a = 2 ** n;   // EXP: 10 + 50 * bytes(n)\nuint256 b = 1 \u003c\u003c n;   // SHL: 3 gas (opcode from EIP-145)\n```\n\n## 需要注意\n\n- 这纯粹是重新定价。`EXP` 的结果不变。只有依赖精确 gas 数量的合约才可能察觉到影响。\n- 固定的按字节价格使 `EXP` 在指数较小时很便宜，在指数较大时则比以前贵五倍。对于 `10 ** decimals` 这类典型用法（指数只有一个字节）来说没有问题。\n- 当指数是常量时，编译器通常会把 `**` 折叠掉。成本在指数为运行时值时最为重要。\n- EIP-160 是 2016 年多项反 DoS 改动之一。参见 [EIP-150](/eip-150/)（重新定价 IO 密集型操作码）和 Spurious Dragon 的元 EIP [EIP-607](/eip-607/)，后者还包括 [EIP-155](/eip-155/)、[EIP-161](/eip-161/) 和 [EIP-170](/eip-170/)。\n"}},"requiredBy":[607]}
