fix activation queue to finality

This commit is contained in:
Danny Ryan 2019-12-11 16:00:46 -07:00
parent e4d710590a
commit 6610aeea2f
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 16 additions and 2 deletions

View File

@ -601,6 +601,21 @@ def is_slashable_validator(validator: Validator, epoch: Epoch) -> bool:
return (not validator.slashed) and (validator.activation_epoch <= epoch < validator.withdrawable_epoch)
```
#### `is_eligible_for_activation`
```python
def is_eligible_for_activation(state: BeaconState, validator: Validator) -> bool:
"""
Check if ``validator`` is eligible for activation.
"""
return (
# Was placed in activation queue prior to most recent finalized epoch
validator.activation_eligibility_epoch < state.finalized_checkpoint.epoch
# Has not yet been activated
and validator.activation_epoch == FAR_FUTURE_EPOCH
)
```
#### `is_slashable_attestation_data`
```python
@ -1314,8 +1329,7 @@ def process_registry_updates(state: BeaconState) -> None:
# Queue validators eligible for activation and not yet dequeued for activation
activation_queue = sorted([
index for index, validator in enumerate(state.validators)
if validator.activation_eligibility_epoch != FAR_FUTURE_EPOCH
and validator.activation_epoch == FAR_FUTURE_EPOCH
if is_eligible_for_activation(state, validator)
], key=lambda index: state.validators[index].activation_eligibility_epoch)
# Dequeued validators for activation up to churn limit
for index in activation_queue[:get_validator_churn_limit(state)]: