EIPs Explained

EIP-1716 · Final · Meta · 2019-01-21

EIP-1716: Hardfork Meta: Petersburg

The Petersburg hard fork, which removed EIP-1283's SSTORE gas change from Constantinople after a reentrancy risk was found just before launch.

What problem does it solve?

Constantinople (EIP-1013) bundled several changes, including EIP-1283, which made repeated writes to the same storage slot within a transaction much cheaper. Shortly before mainnet activation, security researchers showed this could enable a new reentrancy attack: some existing contracts relied on the 2,300-gas stipend of transfer/send being too little to modify storage, and cheaper SSTORE broke that assumption.

Constantinople was postponed. EIP-1716 defines Petersburg, a fork whose only job is to take EIP-1283 back out, so the rest of Constantinople could ship safely.

How it works

Petersburg is a meta-EIP: it does not add features, it removes one.

  • Removed: EIP-1283 (net gas metering for SSTORE).
  • Everything else in Constantinople stays, including the bomb delay of EIP-1234.

Activation blocks listed in the spec:

Network Block
Ethereum mainnet 7,280,000
Ropsten 4,939,394
Kovan 10,255,201
Rinkeby 4,321,234
Görli 0

Two rules cover how it interacts with Constantinople in client configs:

  • If both forks are set to the same block, Petersburg wins: EIP-1283 is never active. This is what happened on mainnet.
  • If Petersburg is set earlier than Constantinople, it has no immediate effect, but once Constantinople activates, EIP-1283 stays disabled.

Testnets that had already run Constantinople with EIP-1283 enabled (such as Ropsten) had a window where it was live, then Petersburg turned it off.

Sample code

In geth-style chain config, both fork blocks are set. With the same value, the chain behaves as "Constantinople minus EIP-1283":

{
  "config": {
    "chainId": 1337,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0
  }
}

Things to know

  • Status: Final. Removal was agreed on All Core Devs call #53 in January 2019.
  • Aliases you may see: St. Petersfork, Peter's Fork, Constantinople Fix.
  • Net gas metering returned later in Istanbul as EIP-2200, which adds a rule that SSTORE fails if the remaining gas is at or below the 2,300 stipend, closing the reentrancy hole.
  • Lesson for contract authors: never rely on gas stipends for security. Use reentrancy guards or checks-effects-interactions instead.

#hardfork #meta #petersburg #constantinople #sstore

Details

Authors
Afri Schoedon (@5chdn), Marius van der Wijden (@MariusVanDerWijden)
Status
Final
Type
Meta
Created
2019-01-21
Requires
Required by

Machine-readable: Markdown · JSON