diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 083fe786b..f92294455 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -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` diff --git a/specs/core/1_shard-data-chains.md b/specs/core/1_shard-data-chains.md index 45fe91337..33ef8632b 100644 --- a/specs/core/1_shard-data-chains.md +++ b/specs/core/1_shard-data-chains.md @@ -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`