Merge pull request #750 from ethereum/JustinDrake-patch-7

Do not check withdrawal credentials for existing validators
This commit is contained in:
Danny Ryan 2019-03-12 11:22:28 -06:00 committed by GitHub
commit 54fae53ce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1305,6 +1305,12 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
# object, and we need to be able to skip over it
state.deposit_index += 1
validator_pubkeys = [v.pubkey for v in state.validator_registry]
pubkey = deposit_input.pubkey
amount = deposit.deposit_data.amount
withdrawal_credentials = deposit_input.withdrawal_credentials
if pubkey not in validator_pubkeys:
# Verify the proof of possession
proof_is_valid = bls_verify(
pubkey=deposit_input.pubkey,
@ -1316,16 +1322,9 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
DOMAIN_DEPOSIT,
)
)
if not proof_is_valid:
return
validator_pubkeys = [v.pubkey for v in state.validator_registry]
pubkey = deposit_input.pubkey
amount = deposit.deposit_data.amount
withdrawal_credentials = deposit_input.withdrawal_credentials
if pubkey not in validator_pubkeys:
# Add new validator
validator = Validator(
pubkey=pubkey,
@ -1342,10 +1341,7 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
state.validator_balances.append(amount)
else:
# Increase balance by deposit amount
index = validator_pubkeys.index(pubkey)
assert state.validator_registry[index].withdrawal_credentials == withdrawal_credentials
state.validator_balances[index] += amount
state.validator_balances[validator_pubkeys.index(pubkey)] += amount
```
### Routines for updating validator status