This commit is contained in:
Hsiao-Wei Wang 2019-03-29 00:43:28 +08:00
parent deb0e32590
commit aa4bbcc1c8
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 5 additions and 3 deletions

View File

@ -596,7 +596,7 @@ The types are defined topologically to aid in facilitating an executable version
# Exit queue # Exit queue
'exit_epoch': 'uint64', 'exit_epoch': 'uint64',
'exit_queue_filled': 'uint64' 'exit_queue_filled': 'uint64',
# Finality # Finality
'previous_epoch_attestations': [PendingAttestation], 'previous_epoch_attestations': [PendingAttestation],
@ -1974,9 +1974,10 @@ def process_ejections(state: BeaconState) -> None:
and deposit or eject active validators with sufficiently high or low balances and deposit or eject active validators with sufficiently high or low balances
""" """
for index, validator in enumerate(state.validator_registry): for index, validator in enumerate(state.validator_registry):
balance = get_balance(state, index)
if validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and balance >= MAX_DEPOSIT_AMOUNT: if validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and balance >= MAX_DEPOSIT_AMOUNT:
state.activation_eligibility_epoch = get_current_epoch(state) state.activation_eligibility_epoch = get_current_epoch(state)
if is_active(validator, get_current_epoch(state)) and get_balance(state, index) < EJECTION_BALANCE: if is_active_validator(validator, get_current_epoch(state)) and balance < EJECTION_BALANCE:
initiate_validator_exit(state, index) initiate_validator_exit(state, index)
``` ```
@ -1986,12 +1987,13 @@ Run the following function:
```python ```python
def update_registry(state: BeaconState) -> None: def update_registry(state: BeaconState) -> None:
current_epoch = get_current_epoch(state)
# Check if we should update, and if so, update # Check if we should update, and if so, update
if state.finalized_epoch > state.validator_registry_update_epoch: if state.finalized_epoch > state.validator_registry_update_epoch:
# Validator indices that could be activated # Validator indices that could be activated
indices_for_activation = sorted( indices_for_activation = sorted(
filter( filter(
lambda index: state.validator_registry[index].activation_epoch == FAR_FUTURE_EPOCH lambda index: state.validator_registry[index].activation_epoch == FAR_FUTURE_EPOCH,
get_active_validator_indices(state.validator_registry, current_epoch), get_active_validator_indices(state.validator_registry, current_epoch),
), ),
key=lambda index: state.validator_registry[index].activation_eligibility_epoch key=lambda index: state.validator_registry[index].activation_eligibility_epoch