EIP-7688 · Review · Core · 2024-04-15
EIP-7688: Forward compatible consensus data structures
Moves beacon-chain SSZ types to ProgressiveContainer and ProgressiveList so Merkle proofs keep working across forks, without changing how data is serialized.
What problem does it solve?
Beacon-chain objects such as BeaconState, BeaconBlockBody and ExecutionPayload are SSZ Containers. SSZ defines both how they are serialized and how they are Merkleized, and the Merkle root lets anyone prove a single field, for example that a validator is not slashed, against a block root. Staking pools, bridges and light clients verify such proofs inside smart contracts or devices.
The catch: with a plain Container, the shape of the Merkle tree depends on the number of fields. When a fork adds or removes a field, the generalized index (gindex, the path in the tree) of other fields can move, and every verifier has to be updated in lockstep with the fork schedule. Fixed List[T, N] capacities cause similar churn when limits change.
EIP-7688 gives these structures stable Merkleization, so a verifier that checks validator.slashed keeps working as long as that field still exists.
How it works
It applies two new SSZ types:
ProgressiveContainer(EIP-7495) carries anactive_fieldsbitmap. Each field gets a permanent position. A fork that appends a field extends the bitmap with a trailing1; a fork that removes a field sets its bit to0rather than shifting the others.ProgressiveList/ProgressiveBitlist(EIP-7916) replace capacity-bound lists. Each element gets a gindex that does not depend on how many elements there are. Limits move from the type into runtime checks.
Containers that are expected to evolve are converted, including Attestation, IndexedAttestation, ExecutionPayload(Header), ExecutionRequests, BeaconBlockBody and BeaconState. Many list fields inside them (validators, balances, attestations, withdrawals, deposits and others) become progressive lists. Smaller building blocks such as Validator, Checkpoint and AttestationData are declared immutable: if they ever need an incompatible change, a new type and new field name must be introduced instead.
Only Merkleization changes. Serialization of the affected types stays the same, and per-topic network message size bounds are defined so gossip limits do not depend on the old list capacities.
Sample code
The conversion pattern from the spec, in the consensus-specs Python style:
# Before: tree shape depends on the field count
class Foo(Container):
a: uint8
b: uint16
# After: each field has a stable gindex
class Foo(ProgressiveContainer(active_fields=[1, 1])):
a: uint8
b: uint16
# A later fork appends c and drops a: positions of b and c stay stable
class Foo(ProgressiveContainer(active_fields=[0, 1, 1])):
b: uint16
c: uint32
A list with a fixed capacity becomes a progressive list plus a runtime limit:
# Before
attestations: List[Attestation, MAX_ATTESTATIONS_ELECTRA]
# After
attestations: ProgressiveList[Attestation]
assert len(body.attestations) <= MAX_ATTESTATIONS_ELECTRA # enforced in logic
Things to know
- Status: Review. The spec text and the list of converted types may still change. It depends on EIP-7495 and EIP-7916, which are also in Review.
- Existing proofs and verifiers need one final update when this is adopted, since gindices change once. The benefit is that later forks should not break them again.
- Some old limits, such as
MAX_TRANSACTIONS_PER_PAYLOAD, are no longer enforced by the type; other constraints (gas, network message size) still bound real sizes. - If you write on-chain verifiers for beacon state, follow this EIP closely: it determines how stable your proof paths will be.