-
Notifications
You must be signed in to change notification settings - Fork 996
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
Add max epoch activation churn limit (EIP-7514) to Deneb #3499
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e6f7c99
Add limit inbound churn
dapplion fd37ffc
Add _features/eip7668 and make linter happy
hwwhww cc3ced5
Enable eip7668 pytest
hwwhww 298a630
review PR
dapplion 417b95c
Add basic activation churn limit tests
hwwhww 8878a31
Fix test_process_voluntary_exit.py
hwwhww 28286e7
Fix tests
hwwhww 19bf51d
Rename eip7668 to eip7514
dapplion a56c4d0
add extension
dapplion f165d39
Update mainnet.yaml
dapplion 0efd778
Update beacon_chain.md
dapplion e5e50e3
Add EIP-7514 into Deneb
hwwhww 26d3fa3
Apply suggestions from code review
hwwhww e804174
Apply PR feedback. Rename `inbound_limit` to `activation_limit`
hwwhww 264dfad
Merge branch 'dev' into pr3499
hwwhww 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Empty file.
90 changes: 90 additions & 0 deletions
90
tests/core/pyspec/eth2spec/test/deneb/epoch_processing/test_process_registry_updates.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from eth2spec.test.helpers.keys import pubkeys | ||
from eth2spec.test.helpers.constants import MINIMAL | ||
from eth2spec.test.context import ( | ||
with_deneb_and_later, | ||
spec_test, | ||
spec_state_test, | ||
single_phase, | ||
with_custom_state, | ||
with_presets, | ||
scaled_churn_balances_exceed_activation_churn_limit, | ||
scaled_churn_balances_equal_activation_churn_limit, | ||
) | ||
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with | ||
|
||
|
||
def run_process_registry_updates(spec, state): | ||
yield from run_epoch_processing_with(spec, state, 'process_registry_updates') | ||
|
||
|
||
def run_test_activation_churn_limit(spec, state): | ||
mock_activations = spec.get_validator_activation_churn_limit(state) * 2 | ||
|
||
validator_count_0 = len(state.validators) | ||
|
||
for i in range(mock_activations): | ||
index = validator_count_0 + i | ||
validator = spec.Validator( | ||
pubkey=pubkeys[index], | ||
withdrawal_credentials=spec.ETH1_ADDRESS_WITHDRAWAL_PREFIX + b'\x00' * 11 + b'\x56' * 20, | ||
activation_eligibility_epoch=0, | ||
activation_epoch=spec.FAR_FUTURE_EPOCH, | ||
exit_epoch=spec.FAR_FUTURE_EPOCH, | ||
withdrawable_epoch=spec.FAR_FUTURE_EPOCH, | ||
effective_balance=spec.MAX_EFFECTIVE_BALANCE, | ||
) | ||
state.validators.append(validator) | ||
state.balances.append(spec.MAX_EFFECTIVE_BALANCE) | ||
state.previous_epoch_participation.append(spec.ParticipationFlags(0b0000_0000)) | ||
state.current_epoch_participation.append(spec.ParticipationFlags(0b0000_0000)) | ||
state.inactivity_scores.append(0) | ||
state.validators[index].activation_epoch = spec.FAR_FUTURE_EPOCH | ||
|
||
churn_limit_0 = spec.get_validator_activation_churn_limit(state) | ||
|
||
yield from run_process_registry_updates(spec, state) | ||
|
||
# Half should churn in first run of registry update | ||
for i in range(mock_activations): | ||
index = validator_count_0 + i | ||
if index < validator_count_0 + churn_limit_0: | ||
# The eligible validators within the activation churn limit should have been activated | ||
assert state.validators[index].activation_epoch < spec.FAR_FUTURE_EPOCH | ||
else: | ||
assert state.validators[index].activation_epoch == spec.FAR_FUTURE_EPOCH | ||
|
||
|
||
@with_deneb_and_later | ||
@with_presets([MINIMAL], | ||
reason="mainnet config leads to larger validator set than limit of public/private keys pre-generated") | ||
@spec_test | ||
@with_custom_state(balances_fn=scaled_churn_balances_exceed_activation_churn_limit, | ||
threshold_fn=lambda spec: spec.config.EJECTION_BALANCE) | ||
@single_phase | ||
def test_activation_churn_limit__greater_than_activation_limit(spec, state): | ||
assert spec.get_validator_activation_churn_limit(state) == spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT | ||
assert spec.get_validator_churn_limit(state) > spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT | ||
yield from run_test_activation_churn_limit(spec, state) | ||
|
||
|
||
@with_deneb_and_later | ||
@with_presets([MINIMAL], | ||
reason="mainnet config leads to larger validator set than limit of public/private keys pre-generated") | ||
@spec_test | ||
@with_custom_state(balances_fn=scaled_churn_balances_equal_activation_churn_limit, | ||
threshold_fn=lambda spec: spec.config.EJECTION_BALANCE) | ||
@single_phase | ||
def test_activation_churn_limit__equal_to_activation_limit(spec, state): | ||
assert spec.get_validator_activation_churn_limit(state) == spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT | ||
assert spec.get_validator_churn_limit(state) == spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT | ||
yield from run_test_activation_churn_limit(spec, state) | ||
|
||
|
||
@with_deneb_and_later | ||
@with_presets([MINIMAL], | ||
reason="mainnet config leads to larger validator set than limit of public/private keys pre-generated") | ||
@spec_state_test | ||
def test_activation_churn_limit__less_than_activation_limit(spec, state): | ||
assert spec.get_validator_activation_churn_limit(state) < spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT | ||
assert spec.get_validator_churn_limit(state) < spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT | ||
yield from run_test_activation_churn_limit(spec, state) |
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit: since this new param is only applied from
Deneb
, should it be calledDENEB_MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
?There might be confusion in testnets with a
Bellatrix
genesis and aMAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
set to1
and you may think that it is immediately applied but you actually have to wait untilDeneb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but it would break the current code conventions for the new constants/presets/configurations. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 ... It actually should be
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_DENEB
, similar toMAX_REQUEST_BLOCKS_DENEB
, even if the phase0 counterpartMAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
won't exist.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, but we do have
MAX_REQUEST_BLOCKS
in phase0! Adding a suffix to a new preset breaks the current code conventions.