EIPs Explained

EIP-607 · Final · Meta · 2017-04-23

EIP-607: Hardfork Meta: Spurious Dragon

The meta EIP that lists what went into the Spurious Dragon hard fork of November 2016: replay protection, a pricier EXP opcode, state clearing and a contract size limit.

What problem does it solve?

A hard fork bundles several protocol changes that every client must switch on at the same block. A "hardfork meta" EIP is the single place that names the fork, gives its activation block, and lists the EIPs it includes, so client teams and node operators work from the same list.

Spurious Dragon was the second of two forks responding to the denial-of-service attacks of autumn 2016. The first was Tangerine Whistle (EIP-608), which repriced I/O-heavy opcodes. Spurious Dragon finished the job by letting the network delete the many empty accounts the attacks had created, and it added protection against transaction replay across chains.

How it works

  • Codename: Spurious Dragon (alias: "State-clearing")
  • Activation: block 2,675,000 on mainnet, block 1,885,000 on the Morden testnet

Included changes:

EIP Change
EIP-155 Simple replay protection: the chain ID is mixed into the transaction signature, so a transaction signed for one chain is invalid on another
EIP-160 Raises the gas cost of the EXP opcode based on exponent size
EIP-161 State trie clearing: empty accounts (no code, zero nonce, zero balance) that are touched get removed, which shrinks the state left by the attacks
EIP-170 Caps deployed contract code at 24,576 bytes

The spec also lists EIP-608 as a requirement, because forks build on the previous fork's rules.

Sample code

How a client typically switches on the fork's rules, as pseudocode:

SPURIOUS_DRAGON_BLOCK = 2_675_000  # mainnet

def rules_for(block_number):
    r = rules_for_tangerine_whistle(block_number)
    if block_number >= SPURIOUS_DRAGON_BLOCK:
        r.eip155_replay_protection = True
        r.exp_byte_gas = 50              # EIP-160
        r.clear_empty_touched_accounts = True  # EIP-161
        r.max_code_size = 24_576         # EIP-170
    return r

In a geth-style genesis config, the same fork appears as block numbers:

{
  "config": {
    "chainId": 1,
    "eip155Block": 2675000,
    "eip158Block": 2675000
  }
}

Things to know

  • This is a historical, Final record. It does not define behaviour itself; the individual EIPs do.
  • Geth names the state-clearing switch eip158Block, after an earlier draft of what became EIP-161.
  • EIP-155 replay protection was optional for senders at first. Legacy unprotected transactions remained valid, which is why many nodes later added options to reject them.
  • The EIP-170 code size limit from this fork is still in force and is a common reason large contracts are split up.

#hardfork #meta #spurious-dragon #history

Details

Authors
Alex Beregszaszi (@axic)
Status
Final
Type
Meta
Created
2017-04-23
Requires
Required by

Machine-readable: Markdown · JSON