be explicit about input for balance sum

This commit is contained in:
protolambda 2019-06-25 00:24:13 +02:00
parent 81a2c84a68
commit 9fb5806764
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
3 changed files with 7 additions and 7 deletions

View File

@ -12,7 +12,7 @@ from typing import (
PHASE0_IMPORTS = '''from typing import (
Any, Callable, Iterable, Dict, Set, Sequence, Tuple,
Any, Callable, Dict, Set, Sequence, Tuple,
)
from dataclasses import (
@ -37,7 +37,7 @@ from eth2spec.utils.bls import (
from eth2spec.utils.hash_function import hash
'''
PHASE1_IMPORTS = '''from typing import (
Any, Callable, Dict, Iterable, Optional, Set, Sequence, Tuple,
Any, Callable, Dict, Optional, Set, Sequence, Tuple,
List as TypingList
)

View File

@ -908,7 +908,7 @@ def bytes_to_int(data: bytes) -> int:
### `get_total_balance`
```python
def get_total_balance(state: BeaconState, indices: Iterable[ValidatorIndex]) -> Gwei:
def get_total_balance(state: BeaconState, indices: Set[ValidatorIndex]) -> Gwei:
"""
Return the combined effective balance of the ``indices``. (1 Gwei minimum to avoid divisions by zero.)
"""
@ -1383,7 +1383,7 @@ def process_crosslinks(state: BeaconState) -> None:
for epoch in (get_previous_epoch(state), get_current_epoch(state)):
for offset in range(get_epoch_committee_count(state, epoch)):
shard = Shard((get_epoch_start_shard(state, epoch) + offset) % SHARD_COUNT)
crosslink_committee = get_crosslink_committee(state, epoch, shard)
crosslink_committee = set(get_crosslink_committee(state, epoch, shard))
winning_crosslink, attesting_indices = get_winning_crosslink_and_attesting_indices(state, epoch, shard)
if 3 * get_total_balance(state, attesting_indices) >= 2 * get_total_balance(state, crosslink_committee):
state.current_crosslinks[shard] = winning_crosslink
@ -1456,7 +1456,7 @@ def get_crosslink_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequence[G
epoch = get_previous_epoch(state)
for offset in range(get_epoch_committee_count(state, epoch)):
shard = Shard((get_epoch_start_shard(state, epoch) + offset) % SHARD_COUNT)
crosslink_committee = get_crosslink_committee(state, epoch, shard)
crosslink_committee = set(get_crosslink_committee(state, epoch, shard))
winning_crosslink, attesting_indices = get_winning_crosslink_and_attesting_indices(state, epoch, shard)
attesting_balance = get_total_balance(state, attesting_indices)
committee_balance = get_total_balance(state, crosslink_committee)

View File

@ -378,7 +378,7 @@ Let:
* `shard` be a valid `Shard`
* `shard_blocks` be the `ShardBlock` list such that `shard_blocks[slot]` is the canonical `ShardBlock` for shard `shard` at slot `slot`
* `beacon_state` be the canonical `BeaconState`
* `valid_attestations` be the list of valid `Attestation`, recursively defined
* `valid_attestations` be the set of valid `Attestation` objects, recursively defined
* `candidate` be a candidate `Attestation` which is valid under Phase 0 rules, and for which validity is to be determined under Phase 1 rules by running `is_valid_beacon_attestation`
```python
@ -388,7 +388,7 @@ def is_valid_beacon_attestation(shard: Shard,
valid_attestations: Set[Attestation],
candidate: Attestation) -> bool:
# Check if attestation is already determined valid
for _, attestation in enumerate(valid_attestations):
for attestation in valid_attestations:
if candidate == attestation:
return True