Context
When a block arrives at a slot far in the future (e.g., slot 500), the state transition must call `process_slots` to advance through all intermediate empty slots. For each skipped slot:
- `historical_block_hashes` is extended with `ZERO_HASH` entries
- `justified_slots` is extended with `False` entries
- The state root may be cached in the block header
This is a stress test for client implementations. A naive implementation might be slow or run out of memory with hundreds of empty slot transitions.
The existing filler `test_block_at_large_slot_number` jumps to slot 100. This test should push further (e.g., slot 500 or 1000) to stress-test the slot processing loop.
What to test
Write a state transition filler that:
- Starts from genesis (slot 0)
- Processes a block at a very large slot (e.g., slot 500)
- Verifies the post-state has correct slot, historical block hashes count, and justified slots length
Key assertions
- `StateExpectation(slot=Slot(500))`
- `historical_block_hashes_count` should be 1 (only genesis parent) plus ZERO_HASH entries for all skipped slots
- `justified_slots` should be extended to cover all slots up to 499
- No errors or timeouts during processing
Where to add the test
Add to: `tests/consensus/devnet/state_transition/test_block_processing.py`
Code skeleton
def test_block_at_very_large_slot_with_many_skipped(
state_transition_test: StateTransitionTestFiller,
) -> None:
"""State transition handles hundreds of empty slots without error."""
state_transition_test(
pre=generate_pre_state(num_validators=4, genesis_time=Uint64(0)),
blocks=[BlockSpec(slot=Slot(500))],
post=StateExpectation(
slot=Slot(500),
# historical_block_hashes should have entries for each slot:
# genesis parent_root + ZERO_HASH * (500 - 1) skipped slots
# The first block adds parent_root; skipped slots add ZERO_HASH
),
)
How to run
uv run fill --fork=devnet --clean -n auto -k test_block_at_very_large_slot_with_many
References
- `State.process_slots`: `src/lean_spec/subspecs/containers/state/state.py`
- `State.process_block_header`: same file — extends `historical_block_hashes` and `justified_slots`
- Existing large slot test: `tests/consensus/devnet/state_transition/test_block_processing.py::test_block_at_large_slot_number`
Context
When a block arrives at a slot far in the future (e.g., slot 500), the state transition must call `process_slots` to advance through all intermediate empty slots. For each skipped slot:
This is a stress test for client implementations. A naive implementation might be slow or run out of memory with hundreds of empty slot transitions.
The existing filler `test_block_at_large_slot_number` jumps to slot 100. This test should push further (e.g., slot 500 or 1000) to stress-test the slot processing loop.
What to test
Write a state transition filler that:
Key assertions
Where to add the test
Add to: `tests/consensus/devnet/state_transition/test_block_processing.py`
Code skeleton
How to run
References