From 9a20ecb9e46817bea17637193ca866d976ff952b Mon Sep 17 00:00:00 2001 From: vbuterin Date: Tue, 27 Nov 2018 12:07:30 -0500 Subject: [PATCH] Added handling for withdrawn validators --- specs/core/0_beacon-chain.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 9376b95b3..01b3687c6 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -760,11 +760,7 @@ def add_validator(state: State, msg=hash(signed_message), sig=proof_of_possession, domain=get_domain(state, current_slot, DOMAIN_DEPOSIT)) - # Pubkey uniqueness - validator_pubkeys = [v.pubkey for v in state.validators] - if pubkey not in validator_pubkeys: - assert deposit_size == DEPOSIT_SIZE - rec = ValidatorRecord( + rec = ValidatorRecord( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, randao_commitment=randao_commitment, @@ -773,7 +769,12 @@ def add_validator(state: State, status=status, last_status_change_slot=current_slot, exit_seq=0 - ) + ) + # Pubkey uniqueness + validator_pubkeys = [v.pubkey for v in state.validators] + if pubkey not in validator_pubkeys: + assert deposit_size == DEPOSIT_SIZE + index = min_empty_validator(state.validators) if index is None: state.validators.append(rec) @@ -787,6 +788,9 @@ def add_validator(state: State, assert val.withdrawal_credentials == withdrawal_credentials assert deposit_size >= MIN_TOPUP_SIZE val.balance += deposit_size + # If the validator is withdrawn, overwrite it with the new validator data + if val.status == WITHDRAWN: + state.validators[index] = rec return index ```