Update 0_beacon-chain.md

This commit is contained in:
Justin 2019-04-14 19:01:53 +10:00 committed by GitHub
parent 704ea7c301
commit 0908ffa653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 14 deletions

View File

@ -1313,22 +1313,15 @@ def initiate_validator_exit(state: BeaconState, index: ValidatorIndex) -> None:
Initiate the validator of the given ``index``. Initiate the validator of the given ``index``.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
# Return if validator already initiated exit
validator = state.validator_registry[index] validator = state.validator_registry[index]
# Operation is a no-op if validator is already in the queue
if validator.exit_epoch != FAR_FUTURE_EPOCH: if validator.exit_epoch != FAR_FUTURE_EPOCH:
return return
# Compute exit queue parameters (pad with GENESIS_EPOCH in case empty) # Compute exit queue epoch
exit_queue_epoch = sorted([ exit_epochs = [v.exit_epoch for v in state.validator_registry if v.exit_epoch != FAR_FUTURE_EPOCH]
validator.exit_epoch for validator in state.validator_registry latest_exit_epoch = GENESIS_EPOCH if len(exit_epochs) == 0 else sorted(exit_epochs)[-1]
if validator.exit_epoch != FAR_FUTURE_EPOCH exit_queue_epoch = max(latest_exit_epoch, get_delayed_activation_exit_epoch(get_current_epoch(state)))
] + [GENESIS_EPOCH])[-1]
delayed_activation_exit_epoch = get_delayed_activation_exit_epoch(get_current_epoch(state))
if exit_queue_epoch < delayed_activation_exit_epoch:
exit_queue_epoch = delayed_activation_exit_epoch
exit_queue_churn = len([v for v in state.validator_registry if v.exit_epoch == exit_queue_epoch]) exit_queue_churn = len([v for v in state.validator_registry if v.exit_epoch == exit_queue_epoch])
if exit_queue_churn >= get_churn_limit(state): if exit_queue_churn >= get_churn_limit(state):
exit_queue_epoch += 1 exit_queue_epoch += 1
@ -1336,8 +1329,6 @@ def initiate_validator_exit(state: BeaconState, index: ValidatorIndex) -> None:
# Set validator exit epoch and withdrawable epoch # Set validator exit epoch and withdrawable epoch
validator.exit_epoch = exit_queue_epoch validator.exit_epoch = exit_queue_epoch
validator.withdrawable_epoch = validator.exit_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY validator.withdrawable_epoch = validator.exit_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY
# Extend queue
``` ```
#### `slash_validator` #### `slash_validator`