mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-12 19:54:34 +00:00
add CommitteeIndex type
This commit is contained in:
parent
bd1c71b82e
commit
219084a08a
@ -137,6 +137,7 @@ We define the following Python custom types for type hinting and readability:
|
|||||||
| - | - | - |
|
| - | - | - |
|
||||||
| `Slot` | `uint64` | a slot number |
|
| `Slot` | `uint64` | a slot number |
|
||||||
| `Epoch` | `uint64` | an epoch number |
|
| `Epoch` | `uint64` | an epoch number |
|
||||||
|
| `CommitteeIndex` | `uint64` | an index for a committee within a slot |
|
||||||
| `Shard` | `uint64` | a shard number |
|
| `Shard` | `uint64` | a shard number |
|
||||||
| `ValidatorIndex` | `uint64` | a validator registry index |
|
| `ValidatorIndex` | `uint64` | a validator registry index |
|
||||||
| `Gwei` | `uint64` | an amount in Gwei |
|
| `Gwei` | `uint64` | an amount in Gwei |
|
||||||
@ -310,7 +311,7 @@ class AttestationData(Container):
|
|||||||
source: Checkpoint
|
source: Checkpoint
|
||||||
target: Checkpoint
|
target: Checkpoint
|
||||||
# Committee Index
|
# Committee Index
|
||||||
index: uint64
|
index: CommitteeIndex
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `AttestationDataAndCustodyBit`
|
#### `AttestationDataAndCustodyBit`
|
||||||
@ -874,7 +875,7 @@ def get_committees_per_slot(state: BeaconState, slot: Slot) -> uint64:
|
|||||||
#### `get_crosslink_committee`
|
#### `get_crosslink_committee`
|
||||||
|
|
||||||
```python
|
```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``.
|
Return the crosslink committee at ``slot`` for ``index``.
|
||||||
"""
|
"""
|
||||||
|
@ -135,7 +135,7 @@ A validator can get committee assignments for a given epoch using the following
|
|||||||
def get_committee_assignment(state: BeaconState,
|
def get_committee_assignment(state: BeaconState,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
validator_index: ValidatorIndex
|
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``.
|
Return the committee assignment in the ``epoch`` for ``validator_index``.
|
||||||
``assignment`` returned is a tuple of the following form:
|
``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)
|
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), index)
|
committee = get_crosslink_committee(state, Slot(slot), CommitteeIndex(index))
|
||||||
if validator_index in committee:
|
if validator_index in committee:
|
||||||
return committee, index, Slot(slot)
|
return committee, CommitteeIndex(index), Slot(slot)
|
||||||
return None
|
return None
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user