This commit is contained in:
Danny Ryan 2020-04-02 16:58:39 -06:00
parent 6067c511c5
commit d61b2991a0
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
2 changed files with 19 additions and 13 deletions

View File

@ -108,7 +108,7 @@ SSZObject = TypeVar('SSZObject', bound=View)
PHASE1_IMPORTS = '''from eth2spec.phase0 import spec as phase0
from eth2spec.config.config_util import apply_constants_config
from typing import (
Any, Dict, Set, Sequence, NewType, Tuple, TypeVar, Callable
Any, Dict, Set, Sequence, NewType, Tuple, Optional, TypeVar, Callable
)
from dataclasses import (
@ -373,11 +373,13 @@ class PySpecCommand(Command):
self.md_doc_paths = """
specs/phase0/beacon-chain.md
specs/phase0/fork-choice.md
specs/phase0/validator.md
specs/phase1/custody-game.md
specs/phase1/beacon-chain.md
specs/phase1/fraud-proofs.md
specs/phase1/fork-choice.md
specs/phase1/phase1-fork.md
specs/phase1/validator.md
"""
else:
raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork)

View File

@ -132,6 +132,7 @@ def get_successful_shard_transitions(state: BeaconState,
attestations: Attestation) -> Tuple[Sequence[Shard], Sequence[Root]]:
shards = []
winning_roots = []
online_indices = get_online_validator_indices(state)
committee_count = get_committee_count_at_slot(state, slot)
for committee_index in map(CommitteeIndex, range(committee_count)):
shard = compute_shard_from_committee_index(state, committee_index, slot)
@ -160,7 +161,7 @@ def get_successful_shard_transitions(state: BeaconState,
)
if enough_online_stake:
shards.append(shard)
transitions.append(shard_transition_root)
winning_roots.append(shard_transition_root)
break
return shards, winning_roots
@ -184,7 +185,7 @@ def get_best_light_client_aggregate(block: BeaconBlock,
return max(
viable_aggregates,
key=lambda a: len([_ for i in a.aggregation_bits if i == 1]),
key=lambda a: len([i for i in a.aggregation_bits if i == 1]),
default=LightClientVote(),
)
```
@ -251,9 +252,13 @@ Set `attestation_data.head_shard_root = hash_tree_root(head_shard_block)`.
Set `shard_transition` to the value returned by `get_shard_transition()`.
```python
def get_shard_transition(state: BeaconState, shard: Shard, shard_blocks: Sequence[ShardBlock]) -> ShardTransition:
def get_shard_transition(state: BeaconState,
shard: Shard,
shard_blocks: Sequence[ShardBlockWrapper]) -> ShardTransition:
"""
latest_shard_slot = get_latest_slot_for_shard(state, shard)
offset_slots = [Slot(latest_shard_slot + x) for x in SHARD_BLOCK_OFFSETS if latest_shard_slot + x <= state.slot]
"""
return ShardTransition()
```
@ -279,9 +284,8 @@ Set `attestation.signature = attestation_signature` where `attestation_signature
```python
def get_attestation_signature(state: BeaconState,
attestation_data: AttestationData,
custody_bits_blocks,
privkey: int
) -> List[Bitlist[MAX_VALIDATORS_PER_COMMITTEE], MAX_SHARD_BLOCKS_PER_ATTESTATION]:
cb_blocks: List[Bitlist[MAX_VALIDATORS_PER_COMMITTEE], MAX_SHARD_BLOCKS_PER_ATTESTATION],
privkey: int) -> BLSSignature:
pass
```
@ -425,7 +429,7 @@ def get_light_aggregate_and_proof_signature(state: BeaconState,
aggregate_and_proof: LightAggregateAndProof,
privkey: int) -> BLSSignature:
aggregate = aggregate_and_proof.aggregate
domain = get_domain(state, DOMAIN_CLIENT_AGGREGATE_AND_PROOF, compute_epoch_at_slot(aggregate.data.slot))
domain = get_domain(state, DOMAIN_LIGHT_AGGREGATE_AND_PROOF, compute_epoch_at_slot(aggregate.data.slot))
signing_root = compute_signing_root(aggregate_and_proof, domain)
return bls.Sign(privkey, signing_root)
```