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") andgenesis_validators_root, which identifies the chain so a mainnet file is not imported into a testnet client.data: one entry per validatorpubkey, withsigned_blocks(each withslotand optionalsigning_root) andsigned_attestations(each withsource_epoch,target_epochand optionalsigning_root).
Numbers are encoded as strings so JavaScript and other languages with limited integer ranges handle them safely.
After import, the signer must:
- refuse any block slashable against the imported blocks (no
signing_rootmeans any new block in the same slot is treated as conflicting); - refuse any block at or below the lowest imported slot, unless it is an identical re-sign;
- refuse any attestation slashable against the imported attestations;
- refuse any attestation with a source epoch below the lowest imported source epoch;
- 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.