Merge branch 'master' into HEAD

This commit is contained in:
Hsiao-Wei Wang 2019-01-04 15:55:03 +08:00
commit fa08e240c8
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 8 additions and 10 deletions

View File

@ -1044,8 +1044,8 @@ def verify_slashable_vote_data(state: BeaconState, vote_data: SlashableVoteData)
aggregate_pubkey([state.validators[i].pubkey for i in vote_data.custody_bit_1_indices]),
],
messages=[
hash_tree_root(AttestationDataAndCustodyBit(vote_data, False)),
hash_tree_root(AttestationDataAndCustodyBit(vote_data, True)),
hash_tree_root(AttestationDataAndCustodyBit(vote_data.data, False)),
hash_tree_root(AttestationDataAndCustodyBit(vote_data.data, True)),
],
signature=vote_data.aggregate_signature,
domain=get_domain(
@ -1585,7 +1585,7 @@ All [validators](#dfn-validator):
* Validators that made an attestation during the previous epoch:
* Let `previous_epoch_attestations = [a for a in state.latest_attestations if state.slot - 2 * EPOCH_LENGTH <= a.slot < state.slot - EPOCH_LENGTH]`.
* Let `previous_epoch_attester_indices` be the union of the validator index sets given by `[get_attestation_participants(state, a.data, a.participation_bitfield) for a in previous_epoch_attestations]`.
* Validators targeting the previous justified hash:
* Validators targeting the previous justified slot:
* Let `previous_epoch_justified_attestations = [a for a in current_epoch_attestations + previous_epoch_attestations if a.justified_slot == state.previous_justified_slot]`.
* Let `previous_epoch_justified_attester_indices` be the union of the validator index sets given by `[get_attestation_participants(state, a.data, a.participation_bitfield) for a in previous_epoch_justified_attestations]`.
* Let `previous_epoch_justified_attesting_balance = sum([get_effective_balance(state, i) for i in previous_epoch_justified_attester_indices])`.
@ -1695,7 +1695,7 @@ def process_ejections(state: BeaconState) -> None:
and eject active validators with balance below ``EJECTION_BALANCE``.
"""
for index in active_validator_indices(state.validator_registry):
if state.validator_balances[index] < EJECTION_BALANCE:
if state.validator_balances[index] < EJECTION_BALANCE * GWEI_PER_ETH:
update_validator_status(state, index, new_status=EXITED_WITHOUT_PENALTY)
```
@ -1764,8 +1764,6 @@ def update_validator_registry(state: BeaconState) -> None:
validators_to_penalize = filter(to_penalize, range(len(validator_registry)))
for index in validators_to_penalize:
state.validator_balances[index] -= get_effective_balance(state, index) * min(total_penalties * 3, total_balance) // total_balance
return validator_registry, latest_penalized_exit_balances, validator_registry_delta_chain_tip
```
Also perform the following updates:

View File

@ -53,8 +53,8 @@ A `ShardBlock` object has the following fields:
# Block signature
'signature': ['uint384'],
# Attestation
'attester_bitfield': 'bytes',
'aggregate_sig': ['uint384'],
'participation_bitfield': 'bytes',
'aggregate_signature': ['uint384'],
}
```
@ -69,9 +69,9 @@ To validate a block header on shard `shard_id`, compute as follows:
* Verify that `beacon_chain_ref` is the hash of a block in the beacon chain with slot less than or equal to `slot`. Verify that `beacon_chain_ref` is equal to or a descendant of the `beacon_chain_ref` specified in the `ShardBlock` pointed to by `parent_root`.
* Let `state` be the state of the beacon chain block referred to by `beacon_chain_ref`. Let `validators` be `[validators[i] for i in state.current_persistent_committees[shard_id]]`.
* Assert `len(attester_bitfield) == ceil_div8(len(validators))`
* Assert `len(participation_bitfield) == ceil_div8(len(validators))`
* Let `proposer_index = hash(state.randao_mix + bytes8(shard_id) + bytes8(slot)) % len(validators)`. Let `msg` be the block but with the `block.signature` set to `[0, 0]`. Verify that `BLSVerify(pub=validators[proposer_index].pubkey, msg=hash(msg), sig=block.signature, domain=get_domain(state, slot, SHARD_PROPOSER_DOMAIN))` passes.
* Generate the `group_public_key` by adding the public keys of all the validators for whom the corresponding position in the bitfield is set to 1. Verify that `BLSVerify(pub=group_public_key, msg=parent_root, sig=block.aggregate_sig, domain=get_domain(state, slot, SHARD_ATTESTER_DOMAIN))` passes.
* Generate the `group_public_key` by adding the public keys of all the validators for whom the corresponding position in the bitfield is set to 1. Verify that `BLSVerify(pub=group_public_key, msg=parent_root, sig=block.aggregate_signature, domain=get_domain(state, slot, SHARD_ATTESTER_DOMAIN))` passes.
### Block Merklization helper