-
Notifications
You must be signed in to change notification settings - Fork 983
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
Fix EIP-7251 tests #3656
Merged
Merged
Fix EIP-7251 tests #3656
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2ed284d
format comment in EIP-7251 spec
ralexstokes 4f6a623
enable EIP-7251 in CI
ralexstokes 112924c
fix EIP-7251 tests
ralexstokes 163f287
Fix prior tests with new EIP-7251 logic
ralexstokes 6a668da
New consolidation tests, comments
fradamt 2a334d1
add test_invalid_validator_has_pending_withdrawal
fradamt dd0bea0
improve pending consolidation tests, fix bug in beacon-chain
fradamt 397f9eb
Merge branch 'dev' into pr3656
hwwhww 97507b6
fix mutable list bug in tests
fradamt 7a0bf5c
fix/add tests for process_execution_layer_withdraw_request
fradamt b03b2c8
fix/add tests for process_execution_layer_withdraw_request pt2
fradamt 91dc428
fix conflict
hwwhww eedb5c1
add effective_balance_hysteresis test with compounding credentials
fradamt b87f1fc
Remove duplicate tests
hwwhww 7602a52
rearrange hysteresis tests
fradamt 1d81af3
refactor the way run_deposit_processing deals with 7251
fradamt bb597fc
fix new process_voluntary_exit tests for eip7251
fradamt 4c60dad
Merge branch 'fix-7251-tests' into pr/ralexstokes/3656-1
ralexstokes 55c5b10
Merge pull request #3 from fradamt/pr/ralexstokes/3656-1
ralexstokes 05a891f
fix lint
ralexstokes 0027762
fix deposit test
ralexstokes 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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -106,13 +106,12 @@ def test_basic_consolidation_with_compounding_credential(spec, state): | |||||
def test_consolidation_churn_limit_balance(spec, state): | ||||||
# This state has 256 validators each with 32 ETH in MINIMAL preset, 128 ETH consolidation churn | ||||||
consolidation_churn_limit = spec.get_consolidation_churn_limit(state) | ||||||
# Set the consolidation balance to consume equal to churn limit | ||||||
state.consolidation_balance_to_consume = consolidation_churn_limit | ||||||
current_epoch = spec.get_current_epoch(state) | ||||||
|
||||||
source_index = spec.get_active_validator_indices(state, current_epoch)[0] | ||||||
# Set source balance to consolidation churn limit | ||||||
state.balances[source_index] = consolidation_churn_limit | ||||||
source_validator = state.validators[source_index] | ||||||
source_validator.effective_balance = consolidation_churn_limit | ||||||
updated_consolidation_churn_limit = spec.get_consolidation_churn_limit(state) | ||||||
target_index = spec.get_active_validator_indices(state, current_epoch)[1] | ||||||
source_privkey = pubkey_to_privkey[state.validators[source_index].pubkey] | ||||||
target_privkey = pubkey_to_privkey[state.validators[target_index].pubkey] | ||||||
|
@@ -131,7 +130,7 @@ def test_consolidation_churn_limit_balance(spec, state): | |||||
|
||||||
expected_exit_epoch = spec.compute_activation_exit_epoch(current_epoch) | ||||||
# Check consolidation churn is decremented correctly | ||||||
assert state.consolidation_balance_to_consume == 0 | ||||||
assert state.consolidation_balance_to_consume == updated_consolidation_churn_limit - consolidation_churn_limit | ||||||
# Check exit epoch | ||||||
assert state.validators[0].exit_epoch == expected_exit_epoch | ||||||
|
||||||
|
@@ -145,13 +144,11 @@ def test_consolidation_churn_limit_balance(spec, state): | |||||
def test_consolidation_balance_larger_than_churn_limit(spec, state): | ||||||
# This state has 256 validators each with 32 ETH in MINIMAL preset, 128 ETH consolidation churn | ||||||
consolidation_churn_limit = spec.get_consolidation_churn_limit(state) | ||||||
# Set the consolidation balance to consume equal to churn limit | ||||||
state.consolidation_balance_to_consume = consolidation_churn_limit | ||||||
current_epoch = spec.get_current_epoch(state) | ||||||
|
||||||
source_index = spec.get_active_validator_indices(state, current_epoch)[0] | ||||||
# Set source balance higher than consolidation churn limit | ||||||
state.balances[source_index] = consolidation_churn_limit + 1 | ||||||
state.validators[source_index].effective_balance = 2 * consolidation_churn_limit | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'd maybe do this instead, just to make it easier to interpret what happens. Here one sees the effective balance being 2x the churn limit, and it can be confusing why then |
||||||
target_index = spec.get_active_validator_indices(state, current_epoch)[1] | ||||||
source_privkey = pubkey_to_privkey[state.validators[source_index].pubkey] | ||||||
target_privkey = pubkey_to_privkey[state.validators[target_index].pubkey] | ||||||
|
@@ -160,6 +157,10 @@ def test_consolidation_balance_larger_than_churn_limit(spec, state): | |||||
set_compounding_withdrawal_credential(spec, state, source_index) | ||||||
set_compounding_withdrawal_credential(spec, state, target_index) | ||||||
|
||||||
new_churn_limit = spec.get_consolidation_churn_limit(state) | ||||||
remainder = state.validators[source_index].effective_balance % new_churn_limit | ||||||
expected_balance = new_churn_limit - remainder | ||||||
|
||||||
signed_consolidation = sign_consolidation(spec, state, | ||||||
spec.Consolidation( | ||||||
epoch=current_epoch, | ||||||
|
@@ -170,7 +171,7 @@ def test_consolidation_balance_larger_than_churn_limit(spec, state): | |||||
|
||||||
expected_exit_epoch = spec.compute_activation_exit_epoch(current_epoch) + 1 | ||||||
# Check consolidation churn is decremented correctly | ||||||
assert state.consolidation_balance_to_consume == consolidation_churn_limit - 1 | ||||||
assert state.consolidation_balance_to_consume == expected_balance | ||||||
# Check exit epoch | ||||||
assert state.validators[0].exit_epoch == expected_exit_epoch | ||||||
|
||||||
|
@@ -181,11 +182,9 @@ def test_consolidation_balance_larger_than_churn_limit(spec, state): | |||||
balances_fn=scaled_churn_balances_exceed_activation_exit_churn_limit, threshold_fn=default_activation_threshold) | ||||||
@spec_test | ||||||
@single_phase | ||||||
def test_consolidation_balance_twice_the_churn_limit(spec, state): | ||||||
def test_consolidation_balance_through_two_churn_epochs(spec, state): | ||||||
# This state has 256 validators each with 32 ETH in MINIMAL preset, 128 ETH consolidation churn | ||||||
consolidation_churn_limit = spec.get_consolidation_churn_limit(state) | ||||||
# Set the consolidation balance to consume equal to churn limit | ||||||
state.consolidation_balance_to_consume = consolidation_churn_limit | ||||||
current_epoch = spec.get_current_epoch(state) | ||||||
|
||||||
source_index = spec.get_active_validator_indices(state, current_epoch)[0] | ||||||
|
@@ -198,7 +197,11 @@ def test_consolidation_balance_twice_the_churn_limit(spec, state): | |||||
set_compounding_withdrawal_credential(spec, state, target_index) | ||||||
|
||||||
# Set source balance higher than consolidation churn limit | ||||||
state.balances[source_index] = 2 * consolidation_churn_limit | ||||||
state.validators[source_index].effective_balance = 3 * consolidation_churn_limit | ||||||
|
||||||
new_churn_limit = spec.get_consolidation_churn_limit(state) | ||||||
remainder = state.validators[source_index].effective_balance % new_churn_limit | ||||||
expected_balance = new_churn_limit - remainder | ||||||
|
||||||
signed_consolidation = sign_consolidation(spec, state, | ||||||
spec.Consolidation( | ||||||
|
@@ -212,7 +215,7 @@ def test_consolidation_balance_twice_the_churn_limit(spec, state): | |||||
expected_exit_epoch = spec.compute_activation_exit_epoch(current_epoch) + 2 | ||||||
assert state.validators[0].exit_epoch == expected_exit_epoch | ||||||
# since the earliest exit epoch moves to a new one, consolidation balance is back to full | ||||||
assert state.consolidation_balance_to_consume == consolidation_churn_limit | ||||||
assert state.consolidation_balance_to_consume == expected_balance | ||||||
|
||||||
|
||||||
@with_eip7251_and_later | ||||||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
should it be only with
if is_post_eip7251: ...
condition to distinguish the post-EIP-7251 behavior?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 think its fine as extending the blocks is backwards-compatible with the
capella
anddeneb
behavior