mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-19 23:19:28 +00:00
temporary fix for phase-1 spec typing
This commit is contained in:
parent
6b82e3faa5
commit
5048b9e87a
@ -35,7 +35,8 @@ from eth2spec.utils.hash_function import hash
|
||||
Deltas = list
|
||||
'''
|
||||
PHASE1_IMPORTS = '''from typing import (
|
||||
Any, Callable, Dict, Optional, Set, Tuple, Iterable
|
||||
Any, Callable, Dict, Optional, Set, Tuple, Iterable,
|
||||
List as TypingList
|
||||
)
|
||||
|
||||
from eth2spec.utils.ssz.ssz_impl import (
|
||||
|
@ -113,6 +113,13 @@ This document details the beacon chain additions and changes in Phase 1 of Ether
|
||||
| - | - |
|
||||
| `DOMAIN_CUSTODY_BIT_CHALLENGE` | `6` |
|
||||
|
||||
|
||||
### TODO PLACEHOLDER
|
||||
|
||||
| Name | Value |
|
||||
| - | - |
|
||||
| `PLACEHOLDER` | `2**32` |
|
||||
|
||||
## Data structures
|
||||
|
||||
### Custody objects
|
||||
@ -134,7 +141,7 @@ class CustodyBitChallenge(Container):
|
||||
attestation: Attestation
|
||||
challenger_index: ValidatorIndex
|
||||
responder_key: BLSSignature
|
||||
chunk_bits: bytes
|
||||
chunk_bits: Bytes[PLACEHOLDER]
|
||||
signature: BLSSignature
|
||||
```
|
||||
|
||||
@ -171,9 +178,9 @@ class CustodyBitChallengeRecord(Container):
|
||||
class CustodyResponse(Container):
|
||||
challenge_index: uint64
|
||||
chunk_index: uint64
|
||||
chunk: Vector[bytes, BYTES_PER_CUSTODY_CHUNK]
|
||||
data_branch: List[Bytes32]
|
||||
chunk_bits_branch: List[Bytes32]
|
||||
chunk: Vector[Bytes[PLACEHOLDER], BYTES_PER_CUSTODY_CHUNK]
|
||||
data_branch: List[Bytes32, PLACEHOLDER]
|
||||
chunk_bits_branch: List[Bytes32, PLACEHOLDER]
|
||||
chunk_bits_leaf: Bytes32
|
||||
```
|
||||
|
||||
@ -226,24 +233,25 @@ class Validator(Container):
|
||||
|
||||
```python
|
||||
class BeaconState(Container):
|
||||
custody_chunk_challenge_records: List[CustodyChunkChallengeRecord]
|
||||
custody_bit_challenge_records: List[CustodyBitChallengeRecord]
|
||||
custody_chunk_challenge_records: List[CustodyChunkChallengeRecord, PLACEHOLDER]
|
||||
custody_bit_challenge_records: List[CustodyBitChallengeRecord, PLACEHOLDER]
|
||||
custody_challenge_index: uint64
|
||||
|
||||
# Future derived secrets already exposed; contains the indices of the exposed validator
|
||||
# at RANDAO reveal period % EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS
|
||||
exposed_derived_secrets: Vector[List[ValidatorIndex], EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS]
|
||||
exposed_derived_secrets: Vector[List[ValidatorIndex, PLACEHOLDER],
|
||||
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS]
|
||||
```
|
||||
|
||||
#### `BeaconBlockBody`
|
||||
|
||||
```python
|
||||
class BeaconBlockBody(Container):
|
||||
custody_chunk_challenges: List[CustodyChunkChallenge]
|
||||
custody_bit_challenges: List[CustodyBitChallenge]
|
||||
custody_responses: List[CustodyResponse]
|
||||
custody_key_reveals: List[CustodyKeyReveal]
|
||||
early_derived_secret_reveals: List[EarlyDerivedSecretReveal]
|
||||
custody_chunk_challenges: List[CustodyChunkChallenge, PLACEHOLDER]
|
||||
custody_bit_challenges: List[CustodyBitChallenge, PLACEHOLDER]
|
||||
custody_responses: List[CustodyResponse, PLACEHOLDER]
|
||||
custody_key_reveals: List[CustodyKeyReveal, PLACEHOLDER]
|
||||
early_derived_secret_reveals: List[EarlyDerivedSecretReveal, PLACEHOLDER]
|
||||
```
|
||||
|
||||
## Helpers
|
||||
@ -310,7 +318,7 @@ def get_validators_custody_reveal_period(state: BeaconState,
|
||||
### `replace_empty_or_append`
|
||||
|
||||
```python
|
||||
def replace_empty_or_append(list: List[Any], new_element: Any) -> int:
|
||||
def replace_empty_or_append(list: TypingList[Any], new_element: Any) -> int:
|
||||
for i in range(len(list)):
|
||||
if is_empty(list[i]):
|
||||
list[i] = new_element
|
||||
|
@ -70,13 +70,19 @@ This document describes the shard data layer and the shard fork choice rule in P
|
||||
| `DOMAIN_SHARD_PROPOSER` | `128` |
|
||||
| `DOMAIN_SHARD_ATTESTER` | `129` |
|
||||
|
||||
### TODO PLACEHOLDER
|
||||
|
||||
| Name | Value |
|
||||
| - | - |
|
||||
| `PLACEHOLDER` | `2**32` |
|
||||
|
||||
## Data structures
|
||||
|
||||
### `ShardBlockBody`
|
||||
|
||||
```python
|
||||
class ShardBlockBody(Container):
|
||||
data: Vector[bytes, BYTES_PER_SHARD_BLOCK_BODY]
|
||||
data: Vector[Bytes[PLACEHOLDER], BYTES_PER_SHARD_BLOCK_BODY]
|
||||
```
|
||||
|
||||
### `ShardAttestation`
|
||||
@ -87,7 +93,7 @@ class ShardAttestation(Container):
|
||||
slot: Slot
|
||||
shard: Shard
|
||||
shard_block_root: Bytes32
|
||||
aggregation_bitfield: bytes
|
||||
aggregation_bitfield: Bytes[PLACEHOLDER]
|
||||
aggregate_signature: BLSSignature
|
||||
```
|
||||
|
||||
@ -101,7 +107,7 @@ class ShardBlock(Container):
|
||||
parent_root: Bytes32
|
||||
data: ShardBlockBody
|
||||
state_root: Bytes32
|
||||
attestations: List[ShardAttestation]
|
||||
attestations: List[ShardAttestation, PLACEHOLDER]
|
||||
signature: BLSSignature
|
||||
```
|
||||
|
||||
@ -115,7 +121,7 @@ class ShardBlockHeader(Container):
|
||||
parent_root: Bytes32
|
||||
body_root: Bytes32
|
||||
state_root: Bytes32
|
||||
attestations: List[ShardAttestation]
|
||||
attestations: List[ShardAttestation, PLACEHOLDER]
|
||||
signature: BLSSignature
|
||||
```
|
||||
|
||||
@ -128,7 +134,7 @@ def get_period_committee(state: BeaconState,
|
||||
epoch: Epoch,
|
||||
shard: Shard,
|
||||
index: int,
|
||||
count: int) -> List[ValidatorIndex]:
|
||||
count: int) -> Tuple[ValidatorIndex, ...]:
|
||||
"""
|
||||
Return committee for a period. Used to construct persistent committees.
|
||||
"""
|
||||
@ -243,11 +249,11 @@ def verify_shard_attestation_signature(state: BeaconState,
|
||||
### `compute_crosslink_data_root`
|
||||
|
||||
```python
|
||||
def compute_crosslink_data_root(blocks: List[ShardBlock]) -> Bytes32:
|
||||
def compute_crosslink_data_root(blocks: Iterable[ShardBlock]) -> Bytes32:
|
||||
def is_power_of_two(value: int) -> bool:
|
||||
return (value > 0) and (value & (value - 1) == 0)
|
||||
|
||||
def pad_to_power_of_2(values: List[bytes]) -> List[bytes]:
|
||||
def pad_to_power_of_2(values: TypingList[bytes]) -> TypingList[bytes]:
|
||||
while not is_power_of_two(len(values)):
|
||||
values += [b'\x00' * BYTES_PER_SHARD_BLOCK_BODY]
|
||||
return values
|
||||
@ -282,7 +288,7 @@ Let:
|
||||
* `candidate` be a candidate `ShardBlock` for which validity is to be determined by running `is_valid_shard_block`
|
||||
|
||||
```python
|
||||
def is_valid_shard_block(beacon_blocks: List[BeaconBlock],
|
||||
def is_valid_shard_block(beacon_blocks: TypingList[BeaconBlock],
|
||||
beacon_state: BeaconState,
|
||||
valid_shard_blocks: Iterable[ShardBlock],
|
||||
candidate: ShardBlock) -> bool:
|
||||
@ -378,7 +384,7 @@ Let:
|
||||
|
||||
```python
|
||||
def is_valid_beacon_attestation(shard: Shard,
|
||||
shard_blocks: List[ShardBlock],
|
||||
shard_blocks: TypingList[ShardBlock],
|
||||
beacon_state: BeaconState,
|
||||
valid_attestations: Set[Attestation],
|
||||
candidate: Attestation) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user