mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-23 15:58:12 +00:00
restore compute_committee
This commit is contained in:
parent
a0158c606e
commit
e85678ac15
@ -73,7 +73,7 @@
|
||||
- [`get_beacon_proposer_index`](#get_beacon_proposer_index)
|
||||
- [`verify_merkle_branch`](#verify_merkle_branch)
|
||||
- [`get_shuffled_index`](#get_shuffled_index)
|
||||
- [`get_committee`](#get_committee)
|
||||
- [`compute_committee`](#compute_committee)
|
||||
- [`get_crosslink_committee`](#get_crosslink_committee)
|
||||
- [`get_attesting_indices`](#get_attesting_indices)
|
||||
- [`int_to_bytes1`, `int_to_bytes2`, ...](#int_to_bytes1-int_to_bytes2-)
|
||||
@ -908,23 +908,25 @@ def get_shuffled_index(index: ValidatorIndex, index_count: int, seed: Bytes32) -
|
||||
return index
|
||||
```
|
||||
|
||||
### `get_committee`
|
||||
### `compute_committee`
|
||||
|
||||
```python
|
||||
def get_committee(state: BeaconState, epoch: Epoch, index: int, count: int) -> List[ValidatorIndex]:
|
||||
active_indices = get_active_validator_indices(state, epoch)
|
||||
return [
|
||||
active_indices[get_shuffled_index(i, len(active_indices), generate_seed(state, epoch))]
|
||||
for i in range((len(active_indices) * index) // count, (len(active_indices) * (index + 1)) // count)
|
||||
]
|
||||
def compute_committee(indices: List[ValidatorIndex], seed: Bytes32, index: int, count: int) -> List[ValidatorIndex]:
|
||||
start = (len(indices) * index) // count
|
||||
end = (len(indices) * (index + 1)) // count
|
||||
return [indices[get_shuffled_index(i, len(indices), seed)] for i in range(start, end)]
|
||||
```
|
||||
|
||||
### `get_crosslink_committee`
|
||||
|
||||
```python
|
||||
def get_crosslink_committee(state: BeaconState, epoch: Epoch, shard: Shard) -> List[ValidatorIndex]:
|
||||
committee_index = (shard + SHARD_COUNT - get_epoch_start_shard(state, epoch)) % SHARD_COUNT
|
||||
return get_committee(state, epoch, committee_index, get_epoch_committee_count(state, epoch))
|
||||
return compute_committee(
|
||||
indices=get_active_validator_indices(state, epoch),
|
||||
seed=generate_seed(state, epoch),
|
||||
index=(shard + SHARD_COUNT - get_epoch_start_shard(state, epoch)) % SHARD_COUNT,
|
||||
count=get_epoch_committee_count(state, epoch),
|
||||
)
|
||||
```
|
||||
|
||||
### `get_attesting_indices`
|
||||
|
@ -124,7 +124,12 @@ def get_period_committee(state: BeaconState, epoch: Epoch, shard: Shard, index:
|
||||
"""
|
||||
Return committee for a period. Used to construct persistent committees.
|
||||
"""
|
||||
return get_committee(state, epoch, shard * count + index, SHARD_COUNT * count)
|
||||
return compute_committee(
|
||||
indices=get_active_validator_indices(state, epoch),
|
||||
seed=generate_seed(state, epoch),
|
||||
index=shard * count + index,
|
||||
count=SHARD_COUNT * count,
|
||||
)
|
||||
```
|
||||
|
||||
### `get_switchover_epoch`
|
||||
|
Loading…
x
Reference in New Issue
Block a user