EIPs Explained

EIP-6916 · Final · Core · 2023-04-10

EIP-6916: Automatically Reset Testnet

Specifies a testnet that automatically resets to a freshly derived genesis every fixed period, giving short-lived, always-clean test networks with refilled faucets and a small state.

What problem does it solve?

Long-running testnets age badly. State grows until nodes are slow to sync, test ETH becomes scarce, inactive validators pile up, and consensus problems linger. Eventually the network is deprecated and everyone migrates to a new one.

EIP-6916 describes an automatically reset testnet: an ephemeral network that throws itself away and restarts from genesis on a fixed schedule. Every iteration starts small and with full faucets, which is ideal for short-term testing of applications, validators and client changes. The best-known network built on this design is Ephemery.

How it works

Deterministic genesis. Clients hardcode genesis 0 and a constant period (the lifetime of one iteration). From the current time, any client can work out which iteration is live:

i                 = floor((now - genesis_0.genesis_time) / period)
genesis_time      = genesis_0.genesis_time + i * period
chainId           = genesis_0.chainId + i

Incrementing the chain ID every iteration prevents transactions from one iteration being replayed in the next.

Consensus layer. The beacon genesis state must also differ per iteration so that each has a unique fork digest. Instead of changing fork versions, the first genesis validator's withdrawal credentials are overridden with a value derived from i, which changes genesis_validators_root. Because generating the SSZ genesis state is not a standard client feature, clients may instead download it through checkpoint sync or from a published file, verifying it where they can.

Reset. When a slot's timestamp reaches genesis_time + period, a client:

  1. stops producing and accepting blocks and shuts down network services,
  2. deletes the old chain data (optionally exporting it first),
  3. generates or fetches the next genesis and restarts on it.

The spec defines two levels of support: basic (can compute and join the current iteration; users restart manually) and full (performs the reset automatically, needed for bootnodes and genesis validators).

Sample code

Computing the current iteration's parameters (TypeScript):

interface Genesis0 { genesisTime: number; chainId: bigint }

function currentIteration(g0: Genesis0, periodSec: number, nowSec = Math.floor(Date.now() / 1000)) {
  const i = Math.floor((nowSec - g0.genesisTime) / periodSec);
  const genesisTime = g0.genesisTime + i * periodSec;
  return {
    iteration: i,
    genesisTime,
    terminalTimestamp: genesisTime + periodSec, // reset when a slot reaches this
    chainId: g0.chainId + BigInt(i),
  };
}

Withdrawal-credential override for validator 0, per the spec:

base = int.from_bytes(bytes.fromhex("01" + "00" * 31), "big")   # 0x0100...00
genesis.validators[0].withdrawal_credentials = (base + i).to_bytes(32, "big")
genesis.genesis_validators_root = hash_tree_root(genesis.validators)

Things to know

  • Status is Final. It is a client feature for a dedicated test network; it does not change Ethereum mainnet.
  • Everything is wiped at each reset, contracts included. It suits throwaway testing, not applications that need long-lived state.
  • Because genesis_validators_root changes each time, light clients that hardcode it will not work.
  • Security relies on a large enough trusted genesis validator set relative to period, so an attacker cannot gain a majority by depositing new validators before the next reset. Low chain IDs are discouraged to avoid colliding with other networks as i grows.

#testnet #genesis #clients #infrastructure #core

Details

Authors
Mário Havel (@taxmeifyoucan), pk910 (@pk910), Rémy Roy (@remyroy), Holly Atkinson (@atkinsonholly), Tereza Burianova (@T-ess)
Status
Final
Type
Standards Track / Core
Created
2023-04-10

Machine-readable: Markdown · JSON