Update specs/core/1_shard-data-chains.md

This commit is contained in:
vbuterin 2019-02-10 15:44:58 -06:00 committed by GitHub
parent 181dc183b6
commit 046119fb2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -86,7 +86,27 @@ def get_persistent_commmitee(state: BeaconState,
[i for i in later_committee if epoch % PERSISTENT_COMMITTEE_PERIOD >= get_switchover_epoch(i)] [i for i in later_committee if epoch % PERSISTENT_COMMITTEE_PERIOD >= get_switchover_epoch(i)]
))) )))
``` ```
#### get_shard_proposer_index
```python
def get_shard_proposer_index(state: BeaconState,
shard: ShardNumber,
slot: SlotNumber) -> ValidatorIndex:
seed = hash(
state.current_epoch_seed +
int_to_bytes8(shard) +
int_to_bytes8(slot)
)
persistent_committee = get_persistent_committee(state, shard, slot_to_epoch(slot))
# Default proposer
index = bytes_to_int(seed[0:8]) % len(persistent_committee)
# If default proposer exits, try the other proposers in order; if all are exited
# return None (ie. no block can be proposed)
validators_to_try = persistent_committee[index:] + persistent_committee[:index]
for index in validators_to_try:
if is_active_validator(state.validators[index], get_current_epoch(state)):
return index
return None
## Data Structures ## Data Structures
### Shard chain blocks ### Shard chain blocks