EIP-3436 · Stagnant · Core · 2021-03-25
EIP-3436: Expanded Clique Block Choice Rule
A deterministic four-step fork-choice tie-breaker for Clique proof-of-authority networks, meant to stop the chain halts seen on Goerli when validators split into equally weighted forks.
What problem does it solve?
Clique is the proof-of-authority engine used by several Ethereum testnets and private networks. Signers take turns; an in-turn block has difficulty 2 and an out-of-turn block difficulty 1, and nodes follow the chain with the highest total difficulty.
When two competing chain heads have the same total difficulty, the original spec says nothing more, so clients fell back to "keep whichever I saw first". On the multi-client Goerli testnet this caused real deadlocks: honest validators sat on two equally heavy forks, each refusing to switch, and the chain halted even though more than half of validators were online. One incident was resolved only when an offline validator came back.
Geth already added a "prefer the shorter chain" rule, but the EIP shows a configuration where even that does not break the tie.
How it works
When choosing between two chain heads, a Clique validator applies these rules in order:
-
Most total difficulty.
-
Lowest block number (the shorter chain, which implicitly has more in-turn blocks).
-
Validator whose in-turn slot is least recent. Compute, and prefer the largest value of:
(header_number - validator_index) % validator_countwhere
validator_indexis the signer's position in the sorted validator list. An in-turn block counts as the most recent. The idea is to decline the fork of the validator who will be in-turn soonest, freeing them to produce an in-turn block. -
Lowest block hash, interpreted as an unsigned 256-bit integer, as a final catch-all.
Because every step is deterministic, validators who see the same two heads always pick the same one. The rule degrades gracefully: if only some clients implement it, or implement only the higher-priority rules, behaviour is no worse than before.
Sample code
The choice rule as a comparison key (Python):
def clique_choice_key(head, validators):
"""Higher key wins. validators = signer addresses sorted as in epoch checkpoints."""
n = len(validators)
idx = validators.index(head.signer)
recency = (head.number - idx) % n # rule 3: larger = less recent in-turn
return (
head.total_difficulty, # rule 1: more is better
-head.number, # rule 2: lower number is better
recency, # rule 3
-int.from_bytes(head.hash, "big"), # rule 4: lower hash is better
)
def choose(a, b, validators):
return a if clique_choice_key(a, validators) >= clique_choice_key(b, validators) else b
Things to know
- Status: Stagnant. It was not finalized as a change to the Clique spec.
- A deterministic lowest-hash tiebreak makes it somewhat easier for a malicious validator to produce a replacement block; the author judged this impact low.
- Clique only matters for proof-of-authority networks. Ethereum mainnet moved to proof-of-stake with EIP-3675, and Goerli, the network that motivated this EIP, has since been deprecated.