EIP-1013 · Final · Meta · 2018-04-20
EIP-1013: Hardfork Meta: Constantinople
The meta-EIP listing what went into the Constantinople hard fork: bitwise shifts, CREATE2, EXTCODEHASH, a difficulty bomb delay with lower block reward, and SSTORE net gas metering.
What problem does it solve?
A hard fork bundles several independent EIPs that must activate at the same block on every client. Client teams, exchanges and node operators need one authoritative list of what is included and when it activates.
EIP-1013 is that list for Constantinople, the second part of the "Metropolis" upgrades that began with Byzantium (EIP-609).
How it works
Codename: Constantinople (aliases: Metropolis/Constantinople, Metropolis part 2).
Included EIPs:
| EIP | Change | Effect for developers |
|---|---|---|
| EIP-145 | SHL, SHR, SAR opcodes |
Native bitwise shifts, cheaper than MUL/DIV tricks |
| EIP-1014 | CREATE2 |
Deploy to an address known in advance, from deployer + salt + init code |
| EIP-1052 | EXTCODEHASH |
Get the hash of another contract's code without copying it |
| EIP-1234 | Difficulty bomb delay | Bomb pushed back about 12 months; block reward cut from 3 to 2 ETH |
| EIP-1283 | Net gas metering for SSTORE |
Cheaper repeated writes to the same slot in one transaction |
Activation blocks in the spec:
- Mainnet:
7,280,000 - Ropsten:
4,230,000, Kovan:9,200,000, Rinkeby:3,660,663
Sample code
Two features developers used immediately, in 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("");
}
A client chain config of that era expressed the fork as a block number:
{ "config": { "chainId": 1, "constantinopleBlock": 7280000, "petersburgBlock": 7280000 } }
Things to know
- Constantinople was delayed shortly before its planned mainnet activation in January 2019 after a reentrancy risk was found in EIP-1283: cheaper
SSTOREmeant the 2,300 gas stipend oftransfer()could now be enough to change state. - On mainnet it activated together with Petersburg (EIP-1716), which removed EIP-1283. So mainnet got Constantinople without net gas metering. Net metering returned later, with a safeguard, in Istanbul (EIP-2200).
- On testnets such as Ropsten, Constantinople activated with EIP-1283 first, and Petersburg removed it at a later block.
CREATE2became the basis for counterfactual wallets and deterministic factory deployments.- Testnets listed here (Ropsten, Kovan, Rinkeby) have since been shut down.