Fix `slash_validator`

Define `validator` before using it.
This commit is contained in:
Hsiao-Wei Wang 2019-02-15 18:25:30 +08:00 committed by GitHub
parent 2be42ebbbf
commit e0c28a3cd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1372,9 +1372,9 @@ def slash_validator(state: BeaconState, index: ValidatorIndex) -> None:
Slash the validator with index ``index``. Slash the validator with index ``index``.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
validator = state.validator_registry[index]
assert state.slot < validator.withdrawable_epoch # [TO BE REMOVED IN PHASE 2] assert state.slot < validator.withdrawable_epoch # [TO BE REMOVED IN PHASE 2]
exit_validator(state, index) exit_validator(state, index)
validator = state.validator_registry[index]
state.latest_slashed_balances[get_current_epoch(state) % LATEST_SLASHED_EXIT_LENGTH] += get_effective_balance(state, index) state.latest_slashed_balances[get_current_epoch(state) % LATEST_SLASHED_EXIT_LENGTH] += get_effective_balance(state, index)
whistleblower_index = get_beacon_proposer_index(state, state.slot) whistleblower_index = get_beacon_proposer_index(state, state.slot)