Skip to content
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 invalid large withdrawable epoch test #2887

Merged
merged 7 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,31 @@ def test_activation_queue_activation_and_ejection__exceed_scaled_churn_limit(spe
churn_limit = spec.get_validator_churn_limit(state)
assert churn_limit > spec.config.MIN_PER_EPOCH_CHURN_LIMIT
yield from run_test_activation_queue_activation_and_ejection(spec, state, churn_limit * 2)


@with_all_phases
@spec_state_test
def test_invalid_large_withdrawable_epoch(spec, state):
"""
This test forces a validator into a withdrawable epoch that overflows the
epoch (uint64) type. To do this we need two validators, one validator that
already has an exit epoch and another with a low effective balance. When
calculating the withdrawable epoch for the second validator, it will
use the greatest exit epoch of all of the validators. If the first
validator is given an exit epoch between
(FAR_FUTURE_EPOCH-MIN_VALIDATOR_WITHDRAWABILITY_DELAY+1) and
(FAR_FUTURE_EPOCH-1), it will cause an overflow.
"""
assert spec.is_active_validator(state.validators[0], spec.get_current_epoch(state))
assert spec.is_active_validator(state.validators[1], spec.get_current_epoch(state))

state.validators[0].exit_epoch = spec.FAR_FUTURE_EPOCH - 1
state.validators[1].effective_balance = spec.config.EJECTION_BALANCE

try:
yield from run_process_registry_updates(spec, state)
except ValueError:
yield 'post', None
return

raise AssertionError('expected ValueError')
2 changes: 1 addition & 1 deletion tests/formats/epoch_processing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ An SSZ-snappy encoded `BeaconState`, the state before running the epoch sub-tran

### `post.ssz_snappy`

An SSZ-snappy encoded `BeaconState`, the state after applying the epoch sub-transition.
An SSZ-snappy encoded `BeaconState`, the state after applying the epoch sub-transition. No value if the sub-transition processing is aborted.

## Condition

Expand Down