---
eip: 1013
label: EIP-1013
title: "Hardfork Meta: Constantinople"
status: Final
type: Meta
created: 2018-04-20
requires: 145, 609, 1014, 1052, 1234, 1283
official: https://eips.ethereum.org/EIPS/eip-1013
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1013.md
canonical: https://eips.huatuo.xyz/zh/eip-1013/
lang: zh
tldr: 元 EIP，列出 Constantinople 硬分叉包含的内容：按位移位、CREATE2、EXTCODEHASH、伴随区块奖励降低的难度炸弹推迟，以及 SSTORE 净 gas 计量。
tags: [meta, hardfork, constantinople, evm]
---

# EIP-1013: Hardfork Meta: Constantinople

> This meta-EIP specifies the changes included in the Ethereum hardfork named Constantinople.

**TL;DR:** 元 EIP，列出 Constantinople 硬分叉包含的内容：按位移位、CREATE2、EXTCODEHASH、伴随区块奖励降低的难度炸弹推迟，以及 SSTORE 净 gas 计量。

## 它解决什么问题？

一次硬分叉会把若干彼此独立的 EIP 打包在一起，它们必须在所有客户端的同一个区块激活。客户端团队、交易所和节点运营者需要一份权威的清单，说明包含哪些内容以及何时激活。

EIP-1013 就是 **Constantinople** 的这份清单。Constantinople 是"Metropolis"升级的第二部分，该系列升级始于 Byzantium（[EIP-609](/eip-609/)）。

## 它如何运作

**代号：** Constantinople（别名：Metropolis/Constantinople、Metropolis part 2）。

**包含的 EIP：**

| EIP | 变更 | 对开发者的影响 |
| --- | --- | --- |
| [EIP-145](/eip-145/) | `SHL`、`SHR`、`SAR` 操作码 | 原生按位移位，比用 `MUL`/`DIV` 取巧更便宜 |
| [EIP-1014](/eip-1014/) | `CREATE2` | 根据部署者 + salt + 初始化代码，部署到一个事先已知的地址 |
| [EIP-1052](/eip-1052/) | `EXTCODEHASH` | 无需复制代码即可获得另一个合约代码的哈希 |
| [EIP-1234](/eip-1234/) | 难度炸弹推迟 | 炸弹推迟约 12 个月；区块奖励从 3 ETH 降至 2 ETH |
| [EIP-1283](/eip-1283/) | `SSTORE` 的净 gas 计量 | 在同一笔交易中重复写入同一个存储槽更便宜 |

规范中的**激活区块**：

- 主网：`7,280,000`
- Ropsten：`4,230,000`，Kovan：`9,200,000`，Rinkeby：`3,660,663`

## 示例代码

开发者立刻用上的两个特性，使用 Solidity：

```solidity
// EIP-1014: predict a CREATE2 address before deploying
function predict(address deployer, bytes32 salt, bytes memory initCode)
    pure returns (address)
{
    return address(uint160(uint256(keccak256(
        abi.encodePacked(bytes1(0xff), deployer, salt, keccak256(initCode))
    ))));
}

// EIP-1052: check whether an address has code
function hasCode(address a) view returns (bool) {
    return a.codehash != bytes32(0) && a.codehash != keccak256("");
}
```

当时的客户端链配置用区块号来表示这次分叉：

```json
{ "config": { "chainId": 1, "constantinopleBlock": 7280000, "petersburgBlock": 7280000 } }
```

## 需要注意

- 在 2019 年 1 月计划的主网激活前不久，Constantinople 被推迟了，因为在 [EIP-1283](/eip-1283/) 中发现了重入风险：`SSTORE` 变便宜后，`transfer()` 的 2,300 gas 补贴现在可能足以修改状态。
- 在主网上，它与 **Petersburg**（[EIP-1716](/eip-1716/)）同时激活，后者移除了 EIP-1283。因此主网得到的是**没有**净 gas 计量的 Constantinople。净计量后来在 Istanbul（EIP-2200）中带着一项保护措施回归。
- 在 Ropsten 等测试网上，Constantinople 先连同 EIP-1283 一起激活，之后在更晚的区块由 Petersburg 将其移除。
- `CREATE2` 成为反事实钱包（counterfactual wallet）和确定性工厂部署的基础。
- 这里列出的测试网（Ropsten、Kovan、Rinkeby）此后已被关闭。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-1013
