Fix #361: pass `poc_commitment` to `validate_proof_of_possession` (#364)

* Fix #361
This commit is contained in:
Hsiao-Wei Wang 2018-12-28 02:11:38 +08:00 committed by Justin
parent 44c389bfe3
commit 6b84dae09e
1 changed files with 8 additions and 4 deletions

View File

@ -1214,6 +1214,7 @@ def get_initial_beacon_state(initial_validator_deposits: List[Deposit],
proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession, proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession,
withdrawal_credentials=deposit.deposit_data.deposit_input.withdrawal_credentials, withdrawal_credentials=deposit.deposit_data.deposit_input.withdrawal_credentials,
randao_commitment=deposit.deposit_data.deposit_input.randao_commitment, randao_commitment=deposit.deposit_data.deposit_input.randao_commitment,
poc_commitment=deposit.deposit_data.deposit_input.poc_commitment,
) )
if get_effective_balance(state, validator_index) == MAX_DEPOSIT * GWEI_PER_ETH: if get_effective_balance(state, validator_index) == MAX_DEPOSIT * GWEI_PER_ETH:
update_validator_status(state, validator_index, ACTIVE) update_validator_status(state, validator_index, ACTIVE)
@ -1248,11 +1249,13 @@ def validate_proof_of_possession(state: BeaconState,
pubkey: int, pubkey: int,
proof_of_possession: bytes, proof_of_possession: bytes,
withdrawal_credentials: Hash32, withdrawal_credentials: Hash32,
randao_commitment: Hash32) -> bool: randao_commitment: Hash32,
poc_commitment: Hash32) -> bool:
proof_of_possession_data = DepositInput( proof_of_possession_data = DepositInput(
pubkey=pubkey, pubkey=pubkey,
withdrawal_credentials=withdrawal_credentials, withdrawal_credentials=withdrawal_credentials,
randao_commitment=randao_commitment, randao_commitment=randao_commitment,
poc_commitment=poc_commitment,
proof_of_possession=EMPTY_SIGNATURE, proof_of_possession=EMPTY_SIGNATURE,
) )
@ -1276,8 +1279,8 @@ def process_deposit(state: BeaconState,
deposit: int, deposit: int,
proof_of_possession: bytes, proof_of_possession: bytes,
withdrawal_credentials: Hash32, withdrawal_credentials: Hash32,
poc_commitment: Hash32, randao_commitment: Hash32,
randao_commitment: Hash32) -> int: poc_commitment: Hash32) -> int:
""" """
Process a deposit from Ethereum 1.0. Process a deposit from Ethereum 1.0.
Note that this function mutates ``state``. Note that this function mutates ``state``.
@ -1289,6 +1292,7 @@ def process_deposit(state: BeaconState,
proof_of_possession, proof_of_possession,
withdrawal_credentials, withdrawal_credentials,
randao_commitment, randao_commitment,
poc_commitment,
) )
validator_pubkeys = [v.pubkey for v in state.validator_registry] validator_pubkeys = [v.pubkey for v in state.validator_registry]
@ -1557,8 +1561,8 @@ process_deposit(
deposit=deposit.deposit_data.value, deposit=deposit.deposit_data.value,
proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession, proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession,
withdrawal_credentials=deposit.deposit_data.deposit_input.withdrawal_credentials, withdrawal_credentials=deposit.deposit_data.deposit_input.withdrawal_credentials,
poc_commitment=deposit.deposit_data.deposit_input.poc_commitment,
randao_commitment=deposit.deposit_data.deposit_input.randao_commitment, randao_commitment=deposit.deposit_data.deposit_input.randao_commitment,
poc_commitment=deposit.deposit_data.deposit_input.poc_commitment,
) )
``` ```