crosslink committee -> beacon committee

This commit is contained in:
Danny Ryan 2019-10-17 10:45:07 +09:00
parent 219084a08a
commit c239ce0b5e
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
7 changed files with 17 additions and 16 deletions

View File

@ -81,7 +81,7 @@
- [`get_active_validator_indices`](#get_active_validator_indices) - [`get_active_validator_indices`](#get_active_validator_indices)
- [`get_validator_churn_limit`](#get_validator_churn_limit) - [`get_validator_churn_limit`](#get_validator_churn_limit)
- [`get_seed`](#get_seed) - [`get_seed`](#get_seed)
- [`get_crosslink_committee`](#get_crosslink_committee) - [`get_beacon_committee`](#get_beacon_committee)
- [`get_beacon_proposer_index`](#get_beacon_proposer_index) - [`get_beacon_proposer_index`](#get_beacon_proposer_index)
- [`get_total_balance`](#get_total_balance) - [`get_total_balance`](#get_total_balance)
- [`get_total_active_balance`](#get_total_active_balance) - [`get_total_active_balance`](#get_total_active_balance)
@ -872,10 +872,10 @@ def get_committees_per_slot(state: BeaconState, slot: Slot) -> uint64:
)) ))
``` ```
#### `get_crosslink_committee` #### `get_beacon_committee`
```python ```python
def get_crosslink_committee(state: BeaconState, slot: Slot, index: CommitteeIndex) -> Sequence[ValidatorIndex]: def get_beacon_committee(state: BeaconState, slot: Slot, index: CommitteeIndex) -> Sequence[ValidatorIndex]:
""" """
Return the crosslink committee at ``slot`` for ``index``. Return the crosslink committee at ``slot`` for ``index``.
""" """
@ -965,7 +965,7 @@ def get_attesting_indices(state: BeaconState,
""" """
Return the set of attesting indices corresponding to ``data`` and ``bits``. Return the set of attesting indices corresponding to ``data`` and ``bits``.
""" """
committee = get_crosslink_committee(state, data.slot, data.index) committee = get_beacon_committee(state, data.slot, data.index)
return set(index for i, index in enumerate(committee) if bits[i]) return set(index for i, index in enumerate(committee) if bits[i])
``` ```
@ -1504,7 +1504,7 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state)) assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state))
assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot <= data.slot + SLOTS_PER_EPOCH assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot <= data.slot + SLOTS_PER_EPOCH
committee = get_crosslink_committee(state, data.slot, data.index) committee = get_beacon_committee(state, data.slot, data.index)
assert len(attestation.aggregation_bits) == len(attestation.custody_bits) == len(committee) assert len(attestation.aggregation_bits) == len(attestation.custody_bits) == len(committee)
pending_attestation = PendingAttestation( pending_attestation = PendingAttestation(

View File

@ -624,7 +624,7 @@ def process_bit_challenge(state: BeaconState, challenge: CustodyBitChallenge) ->
chunk_count = get_custody_chunk_count(attestation.data.crosslink) chunk_count = get_custody_chunk_count(attestation.data.crosslink)
assert chunk_count == len(challenge.chunk_bits) assert chunk_count == len(challenge.chunk_bits)
# Verify custody bit is incorrect # Verify custody bit is incorrect
committee = get_crosslink_committee(state, epoch, shard) committee = get_beacon_committee(state, epoch, shard)
custody_bit = attestation.custody_bits[committee.index(challenge.responder_index)] custody_bit = attestation.custody_bits[committee.index(challenge.responder_index)]
assert custody_bit != get_chunk_bits_root(challenge.chunk_bits) assert custody_bit != get_chunk_bits_root(challenge.chunk_bits)
# Add new bit challenge record # Add new bit challenge record

View File

@ -62,6 +62,7 @@ This document describes the shard transition function (data layer only) and the
| Name | Value | | Name | Value |
| - | - | | - | - |
| `SHARD_COUNT` | `2**10` (= 1,024) |
| `MIN_BLOCK_BODY_PRICE` | `2**0` (= 1) | | `MIN_BLOCK_BODY_PRICE` | `2**0` (= 1) |
| `MAX_PERIOD_COMMITTEE_SIZE` | `2**7` (= 128) | | `MAX_PERIOD_COMMITTEE_SIZE` | `2**7` (= 128) |
| `SHARD_HEADER_SIZE` | `2**10` (= 1024) | | `SHARD_HEADER_SIZE` | `2**10` (= 1024) |

View File

@ -150,7 +150,7 @@ def get_committee_assignment(state: BeaconState,
start_slot = compute_start_slot_of_epoch(epoch) start_slot = compute_start_slot_of_epoch(epoch)
for slot in range(start_slot, start_slot + SLOTS_PER_EPOCH): for slot in range(start_slot, start_slot + SLOTS_PER_EPOCH):
for index in range(get_committees_per_slot(state, Slot(slot))): for index in range(get_committees_per_slot(state, Slot(slot))):
committee = get_crosslink_committee(state, Slot(slot), CommitteeIndex(index)) committee = get_beacon_committee(state, Slot(slot), CommitteeIndex(index))
if validator_index in committee: if validator_index in committee:
return committee, CommitteeIndex(index), Slot(slot) return committee, CommitteeIndex(index), Slot(slot)
return None return None
@ -166,7 +166,7 @@ def is_proposer(state: BeaconState,
*Note*: To see if a validator is assigned to propose during the slot, the beacon state must be in the epoch in question. At the epoch boundaries, the validator must run an epoch transition into the epoch to successfully check the proposal assignment of the first slot. *Note*: To see if a validator is assigned to propose during the slot, the beacon state must be in the epoch in question. At the epoch boundaries, the validator must run an epoch transition into the epoch to successfully check the proposal assignment of the first slot.
*Note*: `BeaconBlock` proposal is distinct from crosslink committee assignment, and in a given epoch each responsibility might occur at different a different slot. *Note*: `BeaconBlock` proposal is distinct from beacon committee assignment, and in a given epoch each responsibility might occur at different a different slot.
### Lookahead ### Lookahead

View File

@ -46,13 +46,13 @@ def get_valid_attestation(spec, state, slot=None, index=None, signed=False):
attestation_data = build_attestation_data(spec, state, slot, index) attestation_data = build_attestation_data(spec, state, slot, index)
crosslink_committee = spec.get_crosslink_committee( beacon_committee = spec.get_beacon_committee(
state, state,
attestation_data.slot, attestation_data.slot,
attestation_data.index, attestation_data.index,
) )
committee_size = len(crosslink_committee) committee_size = len(beacon_committee)
aggregation_bits = Bitlist[spec.MAX_VALIDATORS_PER_COMMITTEE](*([0] * committee_size)) aggregation_bits = Bitlist[spec.MAX_VALIDATORS_PER_COMMITTEE](*([0] * committee_size))
custody_bits = Bitlist[spec.MAX_VALIDATORS_PER_COMMITTEE](*([0] * committee_size)) custody_bits = Bitlist[spec.MAX_VALIDATORS_PER_COMMITTEE](*([0] * committee_size))
attestation = spec.Attestation( attestation = spec.Attestation(
@ -115,12 +115,12 @@ def get_attestation_signature(spec, state, attestation_data, privkey, custody_bi
def fill_aggregate_attestation(spec, state, attestation): def fill_aggregate_attestation(spec, state, attestation):
crosslink_committee = spec.get_crosslink_committee( beacon_committee = spec.get_beacon_committee(
state, state,
attestation.data.slot, attestation.data.slot,
attestation.data.index, attestation.data.index,
) )
for i in range(len(crosslink_committee)): for i in range(len(beacon_committee)):
attestation.aggregation_bits[i] = True attestation.aggregation_bits[i] = True

View File

@ -80,13 +80,13 @@ def bitlist_from_int(max_len, num_bits, n):
def get_valid_bit_challenge(spec, state, attestation, invalid_custody_bit=False): def get_valid_bit_challenge(spec, state, attestation, invalid_custody_bit=False):
crosslink_committee = spec.get_crosslink_committee( beacon_committee = spec.get_beacon_committee(
state, state,
attestation.data.slot, attestation.data.slot,
attestation.data.crosslink.shard, attestation.data.crosslink.shard,
) )
responder_index = crosslink_committee[0] responder_index = beacon_committee[0]
challenger_index = crosslink_committee[-1] challenger_index = beacon_committee[-1]
epoch = spec.get_randao_epoch_for_custody_period(attestation.data.target.epoch, epoch = spec.get_randao_epoch_for_custody_period(attestation.data.target.epoch,
responder_index) responder_index)

View File

@ -34,7 +34,7 @@ def add_mock_attestations(spec, state, epoch, source, target, sufficient_support
if remaining_balance < 0: if remaining_balance < 0:
return return
committee = spec.get_crosslink_committee(state, slot, index) committee = spec.get_beacon_committee(state, slot, index)
# Create a bitfield filled with the given count per attestation, # Create a bitfield filled with the given count per attestation,
# exactly on the right-most part of the committee field. # exactly on the right-most part of the committee field.