Simplify/optimize process_registry_updates#4081
Merged
jtraglia merged 1 commit intoethereum:devfrom Jan 15, 2025
Merged
Conversation
Contributor
|
Looks good! |
prestonvanloon
approved these changes
Jan 14, 2025
| # [Modified in Electra:EIP7251] | ||
| activation_epoch = compute_activation_exit_epoch(get_current_epoch(state)) | ||
| for validator in state.validators: | ||
| if is_eligible_for_activation(state, validator): |
Contributor
There was a problem hiding this comment.
these three ifs could also be elifs couldn't they, as they are mutually exclusive?
Member
Author
There was a problem hiding this comment.
Hmm yes they are mutually exclusive. Making those elif conditions is a good idea.
Member
Author
There was a problem hiding this comment.
I've made a PR for this:
mergify bot
pushed a commit
to sigp/lighthouse
that referenced
this pull request
Jan 28, 2025
No substantial changes in v1.5.0-beta.1, this PR just updates the tests. The optimisation described in this PR is already implemented in our single-pass epoch processing: - ethereum/consensus-specs#4081
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When reviewing Prysm's implementation of
process_registry_updatesI noticed that they were processing registry changes in a single loop, rather than two like the spec does. After evaluating it, I came to the conclusion that it is safe. Since this is a simplification and an optimization that clients should implement, it would be best to include it in the specifications.These operations can be done in the same loop because they do not impact each other. For example, if a validator is added to the activation queue (
validator.activation_eligibility_epoch = current_epoch + 1) it will not be eligible for activation untilvalidator.activation_eligibility_epochis finalized, which is not this epoch.consensus-specs/specs/phase0/beacon-chain.md
Lines 699 to 708 in da17461
This PR makes the following changes:
get_current_epoch(state)withcurrent_epoch.