EIP-3436 Extended Clique block selection rule (Expanded Clique Block Choice Rule)

No call decision · Consensus & staking · EIP status Stagnant · created 2021-03-25

A proposal that extends the rule for choosing the canonical chain among competing blocks on a Clique (PoA) network from looking only at 'total difficulty' to a four-step rule that also considers block number, whether it was produced in turn, and hash, in order to prevent chain stalls (deadlocks).

Why it is needed

Clique (EIP-225) consensus is a proof of authority (PoA) scheme in which a pre-approved set of validators take turns producing blocks. When choosing the canonical chain among competing blocks, previously only the 'block with the highest total difficulty' rule was used. Because of this, the Goerli multi-client testnet experienced several incidents where the chain stalled even though a majority of active validators were online. When different forks ended up with the same total difficulty, each client resolved the remaining tie differently (for example by choosing whichever block it observed first), so validators sometimes believed different forks were canonical and never converged. Geth added a 'prefer the shorter chain' rule that resolved one such case, but chains could still stall in other cases where both length and difficulty were equal across forks.

What changes

Today

After EIP-3436

Who is affected

In depth

Background: a deadlock incident on a multi-client network

In EIP-225 Clique PoA, validators produce blocks in round-robin order, and a validator whose turn has not arrived can still produce a block after a delay (out-of-turn). On the Goerli multi-client network, an incident occurred where the chain stalled even though more than half of the active validators were online. According to the original text, two cases were identified in which the chain could stall with a set of 8 validators. At the time, three clients applied the rule 'the first observed block with the lowest total difficulty,' while Geth added one more rule on top of that: 'shortest chain first.' The Geth rule resolved the first scenario, but the second scenario remained unresolved.

The full 4-step selection rule

When deciding the canonical block between two competing chain head blocks, compare them in the following order. First, pick the block with the greatest total difficulty. If tied, pick the block with the lowest block number. If still tied, pick the block whose signing validator's 'most recent in-turn block production' is the oldest, meaning the block with the largest value from the formula below. If still tied at the end, pick the block with the lowest block hash.

Explanation of the step 3 formula

To evaluate step 3, compute (header_number - validator_index) % validator_count. validator_index is the integer index of the block's signer within the validator list sorted as of the epoch checkpoint, header_number is the block number, and validator_count is the current number of validators. The block with the largest value is chosen. A smaller value indicates a validator more likely to produce an in-turn block soon, so that validator's chain side yields, giving it a chance to produce an in-turn block in the near future.

Step 4 hash comparison

If still tied after step 3, convert the block hash to an unsigned 256-bit integer and select the block with the lower value. The original text notes that at least one client was observed producing multiple blocks at the same height and same difficulty, and explains that a final tiebreaker is needed to handle such cases.

Backward compatibility

Existing Clique implementations used only the total difficulty rule (some also added the shortest-chain rule). If more than half of the active validators implement this 4-step rule, clients that use only the existing difficulty rule will eventually converge on the chain this rule favors. If less than half implement it, deadlock can still occur, but this is no worse than the current situation. Even if a client implements only part of the rule, as long as it implements all higher-priority rules, it will likewise be no worse off than now.

Security considerations

A malicious validator participating in the network could craft blocks deliberately to induce a chain halt. Using a deterministic selection rule reduces this risk of a halt. An attacker can still flood the network with multiple blocks at the same height to cause congestion, but a deterministic rule based on the lowest hash reduces the effectiveness of such flooding attacks. However, there remains a possibility that a malicious validator could exploit this deterministic rule to replace a block; this issue already existed in prior implementations, and while the deterministic hash rule could make replacement slightly easier, the original text assesses that the impact is currently low or negligible.

Current status

This EIP's status is Stagnant. Clique (EIP-225) is a proof-of-authority (PoA) consensus mechanism used on testnets and elsewhere in place of proof of work, and this proposal is limited to the block selection rule for Clique-based networks, not Ethereum mainnet's proof-of-stake consensus. Since activity on it has stopped, the original text does not state whether it was actually adopted or implemented.

Original EIP · ← EIPs