Fixed get_persistent_committee

This commit is contained in:
vbuterin 2019-02-08 22:10:54 -06:00 committed by GitHub
parent e0d8cf4268
commit 65c5a1a1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -45,13 +45,15 @@ def get_split_offset(list_size: int, chunks: int, index: int) -> int:
#### get_persistent_committee #### get_persistent_committee
```python ```python
def get_persistent_commmitee(seed: Bytes32, def get_persistent_commmitee(state: BeaconState,
validators: List[Validator], shard: ShardNumber,
shard: ShardNumber, epoch: EpochNumber) -> List[ValidatorIndex]:
epoch: EpochNumber) -> List[ValidatorIndex]: """
Returns the persistent committee for the given shard at the given epoch
"""
earlier_committee_start = epoch - (epoch % PERSISTENT_COMMITTEE_PERIOD) - PERSISTENT_COMMITTEE_PERIOD * 2 earlier_committee_start = epoch - (epoch % PERSISTENT_COMMITTEE_PERIOD) - PERSISTENT_COMMITTEE_PERIOD * 2
earlier_validator_set = get_active_validator_indices(validators, earlier_committee_start) earlier_validator_set = get_active_validator_indices(state.validators, earlier_committee_start)
earlier_seed = generate_seed(state, earlier_committee_start) earlier_seed = generate_seed(state, earlier_committee_start)
earlier_start_offset = get_split_offset(len(earlier_validator_set), SHARD_COUNT, shard) earlier_start_offset = get_split_offset(len(earlier_validator_set), SHARD_COUNT, shard)
earlier_end_offset = get_split_offset(len(earlier_validator_set), SHARD_COUNT, shard+1) earlier_end_offset = get_split_offset(len(earlier_validator_set), SHARD_COUNT, shard+1)
@ -61,7 +63,7 @@ def get_persistent_commmitee(seed: Bytes32,
] ]
later_committee_start = epoch - (epoch % PERSISTENT_COMMITTEE_PERIOD) - PERSISTENT_COMMITTEE_PERIOD later_committee_start = epoch - (epoch % PERSISTENT_COMMITTEE_PERIOD) - PERSISTENT_COMMITTEE_PERIOD
later_validator_set = get_active_validator_indices(validators, later_committee_start) later_validator_set = get_active_validator_indices(state.validators, later_committee_start)
later_seed = generate_seed(state, later_committee_start) later_seed = generate_seed(state, later_committee_start)
later_start_offset = get_split_offset(len(later_validator_set), SHARD_COUNT, shard) later_start_offset = get_split_offset(len(later_validator_set), SHARD_COUNT, shard)
later_end_offset = get_split_offset(len(later_validator_set), SHARD_COUNT, shard+1) later_end_offset = get_split_offset(len(later_validator_set), SHARD_COUNT, shard+1)