Skip to content

Commit 50e2cc5

Browse files
authored
Test proposer lookahead initialization uses active validator set at fork (#4413)
1 parent 3d40477 commit 50e2cc5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/core/pyspec/eth2spec/test/fulu/fork/test_fork_lookahead_consistency.py renamed to tests/core/pyspec/eth2spec/test/fulu/fork/test_fulu_fork_proposer_lookahead.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,36 @@ def test_lookahead_consistency_at_fork(spec, phases, state):
4242
assert pre_fork_proposers == state.proposer_lookahead
4343

4444

45+
@with_phases(phases=[ELECTRA], other_phases=[FULU])
46+
@spec_test
47+
@with_state
48+
@with_meta_tags(FULU_FORK_TEST_META_TAGS)
49+
def test_proposer_lookahead_init_at_fork_only_contains_active_validators(spec, phases, state):
50+
"""
51+
Test proposer lookahead does not contain exited validators at Fulu fork activation.
52+
"""
53+
current_epoch = spec.get_current_epoch(state)
54+
55+
# Change the active validator set by exiting half of the validators in future epochs
56+
# within the MIN_SEED_LOOKAHEAD range
57+
for validator_index in range(len(state.validators) // 2):
58+
validator = state.validators[validator_index]
59+
# Set exit_epoch to a future epoch within MIN_SEED_LOOKAHEAD + 1 range
60+
# This makes the validator active at current_epoch but exited in future epochs
61+
validator.exit_epoch = current_epoch + 1
62+
63+
# Upgrade to Fulu
64+
spec = phases[FULU]
65+
state = yield from run_fork_test(spec, state)
66+
67+
# Check that the proposer lookahead does not contain inactive validators
68+
for slot_index, validator_index in enumerate(state.proposer_lookahead):
69+
epoch_for_slot = current_epoch + (slot_index // spec.SLOTS_PER_EPOCH)
70+
assert spec.is_active_validator(state.validators[validator_index], epoch_for_slot), (
71+
f"Validator {validator_index} in lookahead at slot {slot_index} (epoch {epoch_for_slot}) should be active"
72+
)
73+
74+
4575
@with_phases(phases=[ELECTRA], other_phases=[FULU])
4676
@spec_test
4777
@with_state

0 commit comments

Comments
 (0)