From 219084a08a679997425522336b84476c2724e73f Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 16 Oct 2019 18:53:36 +0900 Subject: [PATCH] add CommitteeIndex type --- specs/core/0_beacon-chain.md | 5 +++-- specs/validator/0_beacon-chain-validator.md | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index e0d6c108b..19712a7d9 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -137,6 +137,7 @@ We define the following Python custom types for type hinting and readability: | - | - | - | | `Slot` | `uint64` | a slot number | | `Epoch` | `uint64` | an epoch number | +| `CommitteeIndex` | `uint64` | an index for a committee within a slot | | `Shard` | `uint64` | a shard number | | `ValidatorIndex` | `uint64` | a validator registry index | | `Gwei` | `uint64` | an amount in Gwei | @@ -310,7 +311,7 @@ class AttestationData(Container): source: Checkpoint target: Checkpoint # Committee Index - index: uint64 + index: CommitteeIndex ``` #### `AttestationDataAndCustodyBit` @@ -874,7 +875,7 @@ def get_committees_per_slot(state: BeaconState, slot: Slot) -> uint64: #### `get_crosslink_committee` ```python -def get_crosslink_committee(state: BeaconState, slot: Slot, index: uint64) -> Sequence[ValidatorIndex]: +def get_crosslink_committee(state: BeaconState, slot: Slot, index: CommitteeIndex) -> Sequence[ValidatorIndex]: """ Return the crosslink committee at ``slot`` for ``index``. """ diff --git a/specs/validator/0_beacon-chain-validator.md b/specs/validator/0_beacon-chain-validator.md index 51f560243..15edc1e28 100644 --- a/specs/validator/0_beacon-chain-validator.md +++ b/specs/validator/0_beacon-chain-validator.md @@ -135,7 +135,7 @@ A validator can get committee assignments for a given epoch using the following def get_committee_assignment(state: BeaconState, epoch: Epoch, validator_index: ValidatorIndex - ) -> Optional[Tuple[Sequence[ValidatorIndex], uint64, Slot]]: + ) -> Optional[Tuple[Sequence[ValidatorIndex], CommitteeIndex, Slot]]: """ Return the committee assignment in the ``epoch`` for ``validator_index``. ``assignment`` returned is a tuple of the following form: @@ -150,9 +150,9 @@ def get_committee_assignment(state: BeaconState, start_slot = compute_start_slot_of_epoch(epoch) for slot in range(start_slot, start_slot + SLOTS_PER_EPOCH): for index in range(get_committees_per_slot(state, Slot(slot))): - committee = get_crosslink_committee(state, Slot(slot), index) + committee = get_crosslink_committee(state, Slot(slot), CommitteeIndex(index)) if validator_index in committee: - return committee, index, Slot(slot) + return committee, CommitteeIndex(index), Slot(slot) return None ```