-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix epoch processing tests for proposer lookahead #4364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jtraglia
merged 5 commits into
ethereum:dev
from
jtraglia:fix-epoch-processing-proposer-lookahead-test
Jun 4, 2025
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 11 additions & 22 deletions
33
tests/core/pyspec/eth2spec/test/fulu/epoch_processing/test_process_proposer_lookahead.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,31 @@ | ||
| 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 ( | ||
| state.proposer_lookahead[: spec.SLOTS_PER_EPOCH] | ||
| == initial_lookahead[spec.SLOTS_PER_EPOCH :] | ||
| ) | ||
jtraglia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # run_epoch_processing_with does not increment the slot | ||
jtraglia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.