EIPs Explained

EIP-3076 · Last Call · Interface · 2020-10-27

EIP-3076: Slashing Protection Interchange Format

A standard JSON file for a validator's signing history, so stakers can move keys between consensus clients without accidentally signing a conflicting block or attestation and getting slashed.

What problem does it solve?

In proof-of-stake Ethereum, a validator is slashed (penalised and ejected) if it signs two conflicting messages: two different blocks for the same slot, or attestations that double-vote or surround each other. Each validator client keeps a local slashing protection database recording what it has signed and refuses to sign anything conflicting.

The keystore format (EIP-2335) lets you move your keys to a different client, but not that history. If client B does not know what client A already signed, it may sign again for the same slots or epochs. The spec points to real-world cases: a client whose clock jumped a day ahead had already voted on ~225 future epochs; switching to another client without the history would risk slashing for all of them. Re-orgs can also re-assign duties for an epoch the validator has already attested to.

EIP-3076 defines a common JSON format for exporting and importing that history.

How it works

The file has two parts:

  • metadata: interchange_format_version (currently "5") and genesis_validators_root, which identifies the chain so a mainnet file is not imported into a testnet client.
  • data: one entry per validator pubkey, with signed_blocks (each with slot and optional signing_root) and signed_attestations (each with source_epoch, target_epoch and optional signing_root).

Numbers are encoded as strings so JavaScript and other languages with limited integer ranges handle them safely.

After import, the signer must:

  1. refuse any block slashable against the imported blocks (no signing_root means any new block in the same slot is treated as conflicting);
  2. refuse any block at or below the lowest imported slot, unless it is an identical re-sign;
  3. refuse any attestation slashable against the imported attestations;
  4. refuse any attestation with a source epoch below the lowest imported source epoch;
  5. refuse any attestation with a target epoch at or below the lowest imported target epoch, unless it is an identical re-sign.

Rules 2, 4 and 5 let the same file serve both clients that store every signed message (complete) and clients that only store the latest (minimal).

Sample code

A minimal interchange file (from the spec's example):

{
  "metadata": {
    "interchange_format_version": "5",
    "genesis_validators_root": "0x04700007fabc8282644aed6d1c7c9e21d38a03a0c4ba193f3afe428824b3a673"
  },
  "data": [
    {
      "pubkey": "0xb845089a1457f811bfc000588fbb4e713669be8ce060ea6be3c6ece09afc3794106c91ca73acda5e5457122d58723bed",
      "signed_blocks": [{ "slot": "81952" }],
      "signed_attestations": [{ "source_epoch": "2290", "target_epoch": "3008" }]
    }
  ]
}

Checking rules 4 and 5 for a minimal database, in Python:

def may_attest(history, source: int, target: int, signing_root=None) -> bool:
    atts = history["signed_attestations"]
    if not atts:
        return True
    if source < min(int(a["source_epoch"]) for a in atts):
        return False
    min_target = min(int(a["target_epoch"]) for a in atts)
    if target <= min_target:
        # only an exact repeat (same signing_root) is allowed
        return any(int(a["target_epoch"]) == target and a.get("signing_root") == signing_root
                   and signing_root is not None for a in atts)
    return True  # still also check double/surround votes (rule 3)

Things to know

  • Status is Last Call in the EIP repository, though the format is widely implemented by validator clients for import and export.
  • Only export or import while the validator client is stopped. Exporting from a running client can produce an out-of-date file.
  • Never run the same keys in two clients at once, even with slashing protection; the format only helps when moving keys sequentially.
  • When merging into a minimal database, take the maximum slot and epochs from the file and keep any newer values already in the database. Beware of gaps between imports; do not sign inside a period with unknown history.
  • Drafts with version numbers below 5 are not compatible.

#staking #validators #slashing #consensus #json #interface

Details

Authors
Michael Sproul (@michaelsproul), Sacha Saint-Leger (@sachayves), Danny Ryan (@djrtwo)
Status
Last Call
Type
Standards Track / Interface
Created
2020-10-27
Required by

Machine-readable: Markdown · JSON