From 30e2ff3a25f406b085925b49131bdb2494f7c7f2 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Wed, 4 Jun 2025 13:48:31 -0500 Subject: [PATCH 1/5] Fix epoch processing tests for proposer lookahead --- .../test_process_proposer_lookahead.py | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py index 2c548a2c62..53fcea095b 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py +++ b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py @@ -1,21 +1,21 @@ from eth2spec.test.context import spec_state_test, with_fulu_and_later +from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with from eth2spec.test.helpers.state import next_epoch @with_fulu_and_later @spec_state_test -def test_next_epoch_proposer_lookahead_shifted_to_front(spec, state): - """Test that the next epoch proposer lookahead is shifted to the front at epoch transition.""" - # Transition few epochs to pass the MIN_SEED_LOOKAHEAD - next_epoch(spec, state) - next_epoch(spec, state) +def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state): + """Test that the proposer lookahead in the state matches the computed lookahead.""" + # Transition few epochs to past the MIN_SEED_LOOKAHEAD + for _ in range(spec.MIN_SEED_LOOKAHEAD + 1): + next_epoch(spec, state) + # Get initial lookahead initial_lookahead = state.proposer_lookahead.copy() # Run epoch processing - yield "pre", state - next_epoch(spec, state) - yield "post", state + yield from run_epoch_processing_with(spec, state, "process_proposer_lookahead") # Verify lookahead was shifted correctly assert ( @@ -23,20 +23,9 @@ def test_next_epoch_proposer_lookahead_shifted_to_front(spec, state): == initial_lookahead[spec.SLOTS_PER_EPOCH :] ) + # run_epoch_processing_with does not increment the slot + state.slot += 1 -@with_fulu_and_later -@spec_state_test -def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state): - """Test that the proposer lookahead in the state matches the lookahead computed on the fly.""" - # Transition few epochs to pass the MIN_SEED_LOOKAHEAD - next_epoch(spec, state) - next_epoch(spec, state) - - # Run epoch processing - yield "pre", state - next_epoch(spec, state) - yield "post", state - - # Verify lookahead in state matches the lookahead computed on the fly + # Verify lookahead in state matches the computed lookahead computed_lookahead = spec.initialize_proposer_lookahead(state) assert state.proposer_lookahead == computed_lookahead From deb1887768d9cd05675561522fad6af73b05e580 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Wed, 4 Jun 2025 14:04:22 -0500 Subject: [PATCH 2/5] Update get_process_calls --- tests/core/pyspec/eth2spec/test/helpers/epoch_processing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/core/pyspec/eth2spec/test/helpers/epoch_processing.py b/tests/core/pyspec/eth2spec/test/helpers/epoch_processing.py index 3cc791e5fe..8c6ef54479 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/epoch_processing.py +++ b/tests/core/pyspec/eth2spec/test/helpers/epoch_processing.py @@ -34,6 +34,7 @@ def get_process_calls(spec): else ("process_participation_record_updates") ), "process_sync_committee_updates", # altair + "process_proposer_lookahead", # fulu ] From 6d5aa47f3214266fb939cb93d9cafeed673d59de Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:31:09 -0500 Subject: [PATCH 3/5] Make test more robust Co-authored-by: Lin Oshitani --- .../fulu/epoch_processing/test_process_proposer_lookahead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py index 53fcea095b..cea963fbf6 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py +++ b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py @@ -19,7 +19,7 @@ def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state): # Verify lookahead was shifted correctly assert ( - state.proposer_lookahead[: spec.SLOTS_PER_EPOCH] + state.proposer_lookahead[: spec.SLOTS_PER_EPOCH * spec.MIN_SEED_LOOKAHEAD] == initial_lookahead[spec.SLOTS_PER_EPOCH :] ) From 99aae873b8bc5796f75639de10b4323f969577fc Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:39:38 -0500 Subject: [PATCH 4/5] Use minus since instead Co-authored-by: Potuz --- .../fulu/epoch_processing/test_process_proposer_lookahead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py index cea963fbf6..167c4e9e66 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py +++ b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py @@ -19,7 +19,7 @@ def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state): # Verify lookahead was shifted correctly assert ( - state.proposer_lookahead[: spec.SLOTS_PER_EPOCH * spec.MIN_SEED_LOOKAHEAD] + state.proposer_lookahead[: -spec.SLOTS_PER_EPOCH] == initial_lookahead[spec.SLOTS_PER_EPOCH :] ) From 582608a1116ea47d200cda1fc43fe1bdbd56baae Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Wed, 4 Jun 2025 15:18:22 -0500 Subject: [PATCH 5/5] Revert "Use minus since instead" This reverts commit 99aae873b8bc5796f75639de10b4323f969577fc. --- .../fulu/epoch_processing/test_process_proposer_lookahead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py index 167c4e9e66..cea963fbf6 100644 --- a/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py +++ b/tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py @@ -19,7 +19,7 @@ def test_proposer_lookahead_in_state_matches_computed_lookahead(spec, state): # Verify lookahead was shifted correctly assert ( - state.proposer_lookahead[: -spec.SLOTS_PER_EPOCH] + state.proposer_lookahead[: spec.SLOTS_PER_EPOCH * spec.MIN_SEED_LOOKAHEAD] == initial_lookahead[spec.SLOTS_PER_EPOCH :] )