Added handling for withdrawn validators
This commit is contained in:
parent
0d1b63bca3
commit
9a20ecb9e4
|
@ -760,10 +760,6 @@ def add_validator(state: State,
|
||||||
msg=hash(signed_message),
|
msg=hash(signed_message),
|
||||||
sig=proof_of_possession,
|
sig=proof_of_possession,
|
||||||
domain=get_domain(state, current_slot, DOMAIN_DEPOSIT))
|
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,
|
pubkey=pubkey,
|
||||||
withdrawal_credentials=withdrawal_credentials,
|
withdrawal_credentials=withdrawal_credentials,
|
||||||
|
@ -774,6 +770,11 @@ def add_validator(state: State,
|
||||||
last_status_change_slot=current_slot,
|
last_status_change_slot=current_slot,
|
||||||
exit_seq=0
|
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)
|
index = min_empty_validator(state.validators)
|
||||||
if index is None:
|
if index is None:
|
||||||
state.validators.append(rec)
|
state.validators.append(rec)
|
||||||
|
@ -787,6 +788,9 @@ def add_validator(state: State,
|
||||||
assert val.withdrawal_credentials == withdrawal_credentials
|
assert val.withdrawal_credentials == withdrawal_credentials
|
||||||
assert deposit_size >= MIN_TOPUP_SIZE
|
assert deposit_size >= MIN_TOPUP_SIZE
|
||||||
val.balance += deposit_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
|
return index
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue