EIPs Explained

EIP-6988 · Stagnant · Core · 2023-05-04

EIP-6988: Elected block proposer has not been slashed

A stagnant consensus-layer fix that stops slashed validators from being picked as block proposers, so their slots are not guaranteed to be missed.

What problem does it solve?

On the beacon chain, each slot's block proposer is chosen pseudo-randomly from the active validator set, weighted by effective balance. The phase0 consensus spec has an inconsistency:

  • compute_proposer_index can select a validator that has been slashed (slashed validators stay "active" until their exit epoch).
  • process_block_header rejects any block whose proposer is slashed.

So when a slashed validator is elected, the slot is certain to be empty. One slashing makes that a negligible loss, but correlated slashings change the picture: the EIP's example is that if a tenth of validators were slashed together, roughly a tenth of proposals could be missed for a number of epochs afterwards, exactly when the network is already under stress.

How it works

The change lives in the consensus specs (feature eip6988) rather than in the EIP text. It has two parts:

  1. Skip slashed candidates in proposer selection. The sampling loop in compute_proposer_index only accepts a candidate that is not slashed, so selection simply moves on to the next candidate.
  2. Adjust get_beacon_proposer_index. If the latest block header's slot equals state.slot, the function returns the proposer index stored in that header instead of recomputing it. Without this, a proposer slashed during processing of its own block (for example by an included slashing message) would no longer be computed as the proposer, breaking reward accounting for that block.

Because proposer election is part of consensus, this is backwards-incompatible and needs a hard fork.

Sample code

Illustrative pseudocode of the selection loop with the added check (simplified from the phase0 function; see the consensus-specs feature for the exact text):

def compute_proposer_index(state, indices, seed):
    MAX_RANDOM_BYTE = 2**8 - 1
    i = 0
    total = len(indices)
    while True:
        candidate = indices[compute_shuffled_index(i % total, total, seed)]
        random_byte = hash(seed + uint_to_bytes(uint64(i // 32)))[i % 32]
        validator = state.validators[candidate]
        if (not validator.slashed                       # new in EIP-6988
                and validator.effective_balance * MAX_RANDOM_BYTE
                    >= MAX_EFFECTIVE_BALANCE * random_byte):
            return candidate
        i += 1


def get_beacon_proposer_index(state):
    if state.latest_block_header.slot == state.slot:   # block already being processed
        return state.latest_block_header.proposer_index
    epoch = get_current_epoch(state)
    seed = hash(get_seed(state, epoch, DOMAIN_BEACON_PROPOSER) + uint_to_bytes(state.slot))
    indices = get_active_validator_indices(state, epoch)
    return compute_proposer_index(state, indices, seed)

Things to know

  • Status is Stagnant: it has not been scheduled for a network upgrade, and the authoritative specification is the linked consensus-specs feature, not the EIP document.
  • It affects only the consensus layer; nothing changes for transactions, contracts or the execution layer.
  • Test cases in consensus-specs cover both the old behaviour (a slashed validator can be elected) and the new one (it cannot), plus reward handling when a proposer is slashed within its own block.
  • Later consensus changes such as EIP-7251 also modify proposer selection, so any revival would need to be rebased on the current spec.

#consensus #proposer #slashing #beacon-chain #stagnant

Details

Authors
Mikhail Kalinin (@mkalinin)
Status
Stagnant
Type
Standards Track / Core
Created
2023-05-04

Machine-readable: Markdown · JSON