Skip to content

test(st): genesis with maximum validators (VALIDATOR_REGISTRY_LIMIT) #580

@tcoratger

Description

@tcoratger

Context

The maximum configuration: a chain with `VALIDATOR_REGISTRY_LIMIT = 4096` validators. This stress-tests:

  • Genesis state generation with a large validator set
  • Proposer rotation through all 4096 slots before wrapping
  • Supermajority threshold: `ceil(2/3 * 4096) = 2731` validators needed to justify
  • SSZ serialization of a large validator list
  • Memory and performance characteristics

What to test

Write a state transition filler that:

  1. Generates genesis with 4096 validators
  2. Produces a block at slot 1 (proposer = validator 1)
  3. Verifies the genesis state and first block are valid
  4. Optionally: includes attestations from 2731 validators to test justification threshold

Key assertions

  • `StateExpectation(validator_count=4096)`
  • Proposer at slot N is validator `N % 4096`
  • Genesis state is well-formed with 4096 entries
  • Block processing does not error

Warning: This test may be slow due to the large validator count. Consider whether the test framework handles large key generation efficiently (XMSS key generation for 4096 validators).

Where to add the test

Add to: `tests/consensus/devnet/state_transition/test_genesis.py`

Code skeleton

def test_genesis_maximum_validators(
    state_transition_test: StateTransitionTestFiller,
) -> None:
    """Genesis with VALIDATOR_REGISTRY_LIMIT (4096) validators."""
    state_transition_test(
        pre=generate_pre_state(num_validators=4096, genesis_time=Uint64(0)),
        blocks=[BlockSpec(slot=Slot(1))],
        post=StateExpectation(
            slot=Slot(1),
            validator_count=4096,
        ),
    )

How to run

uv run fill --fork=devnet --clean -n auto -k test_genesis_maximum_validators

References

  • `VALIDATOR_REGISTRY_LIMIT = 2**12 = 4096`: `src/lean_spec/subspecs/chain/config.py`
  • `generate_pre_state`: `packages/testing/src/consensus_testing/init.py`
  • Threshold: `3 * count >= 2 * 4096` → need count >= 2731

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomerstestsScope: Changes to the spec tests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions