@@ -42,6 +42,36 @@ def test_lookahead_consistency_at_fork(spec, phases, state):
42
42
assert pre_fork_proposers == state .proposer_lookahead
43
43
44
44
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
+
45
75
@with_phases (phases = [ELECTRA ], other_phases = [FULU ])
46
76
@spec_test
47
77
@with_state
0 commit comments