simplify get_winning_root logic
This commit is contained in:
parent
529cf4223e
commit
d8df789a70
|
@ -1761,13 +1761,12 @@ def get_previous_epoch_matching_head_attestations(state: BeaconState) -> List[Pe
|
|||
|
||||
```python
|
||||
def get_winning_root_and_participants(state: BeaconState, slot: Slot, shard: Shard) -> Tuple[Bytes32, List[ValidatorIndex]]:
|
||||
all_attestations = state.current_epoch_attestations + state.previous_epoch_attestations
|
||||
attestations = state.current_epoch_attestations if slot_to_epoch(slot) == get_current_epoch(state) else state.previous_epoch_attestations
|
||||
crosslinks = state.current_crosslinks if slot_to_epoch(slot) == get_current_epoch(state) else state.previous_crosslinks
|
||||
|
||||
valid_attestations = [
|
||||
a for a in all_attestations
|
||||
if a.data.previous_crosslink == crosslinks[shard] and
|
||||
a.data.shard == shard and a.data.slot == slot
|
||||
a for a in attestations
|
||||
if a.data.previous_crosslink == crosslinks[shard] and a.data.shard == shard
|
||||
]
|
||||
all_roots = [a.data.crosslink_data_root for a in valid_attestations]
|
||||
|
||||
|
|
Loading…
Reference in New Issue