rebase fixes

This commit is contained in:
Danny Ryan 2019-12-05 12:36:48 -07:00
parent 4bf5eb86c4
commit a32b0100ff
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
5 changed files with 38 additions and 38 deletions

View File

@ -165,10 +165,10 @@ def combine_constants(old_constants: Dict[str, str], new_constants: Dict[str, st
ignored_dependencies = [ ignored_dependencies = [
'bit', 'boolean', 'Vector', 'List', 'Container', 'Hash', 'BLSPubkey', 'BLSSignature', 'bit', 'boolean', 'Vector', 'List', 'Container', 'BLSPubkey', 'BLSSignature',
'Bytes1', 'Bytes4', 'Bytes32', 'Bytes48', 'Bytes96', 'Bitlist', 'Bitvector', 'Bytes1', 'Bytes4', 'Bytes32', 'Bytes48', 'Bytes96', 'Bitlist', 'Bitvector',
'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256', 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256',
'bytes', 'byte', 'Bytes', 'BytesN' # to be removed after updating spec doc 'bytes', 'byte', 'ByteList', 'ByteVector'
] ]

View File

@ -43,7 +43,7 @@ Configuration is not namespaced. Instead it is strictly an extension;
| `TARGET_SHARD_BLOCK_SIZE` | `3 * 2**16` (= 196,608) | | | `TARGET_SHARD_BLOCK_SIZE` | `3 * 2**16` (= 196,608) | |
| `SHARD_BLOCK_OFFSETS` | `[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]` | | | `SHARD_BLOCK_OFFSETS` | `[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]` | |
| `MAX_SHARD_BLOCKS_PER_ATTESTATION` | `len(SHARD_BLOCK_OFFSETS)` | | | `MAX_SHARD_BLOCKS_PER_ATTESTATION` | `len(SHARD_BLOCK_OFFSETS)` | |
| `EMPTY_CHUNK_ROOT` | `hash_tree_root(BytesN[SHARD_BLOCK_CHUNK_SIZE]())` | | | `EMPTY_CHUNK_ROOT` | `hash_tree_root(ByteList[SHARD_BLOCK_CHUNK_SIZE]())` | |
| `MAX_GASPRICE` | `Gwei(2**14)` (= 16,384) | Gwei | | | `MAX_GASPRICE` | `Gwei(2**14)` (= 16,384) | Gwei | |
| `MIN_GASPRICE` | `Gwei(2**5)` (= 32) | Gwei | | | `MIN_GASPRICE` | `Gwei(2**5)` (= 32) | Gwei | |
| `GASPRICE_ADJUSTMENT_COEFFICIENT` | `2**3` (= 8) | | | `GASPRICE_ADJUSTMENT_COEFFICIENT` | `2**3` (= 8) | |
@ -62,14 +62,14 @@ class AttestationData(Container):
slot: Slot slot: Slot
index: CommitteeIndex index: CommitteeIndex
# LMD GHOST vote # LMD GHOST vote
beacon_block_root: Hash beacon_block_root: Root
# FFG vote # FFG vote
source: Checkpoint source: Checkpoint
target: Checkpoint target: Checkpoint
# Current-slot shard block root # Current-slot shard block root
head_shard_root: Hash head_shard_root: Root
# Shard transition root # Shard transition root
shard_transition_root: Hash shard_transition_root: Root
``` ```
### Extended `Attestation` ### Extended `Attestation`
@ -98,7 +98,7 @@ class PendingAttestation(Container):
```python ```python
class Validator(Container): class Validator(Container):
pubkey: BLSPubkey pubkey: BLSPubkey
withdrawal_credentials: Hash # Commitment to pubkey for withdrawals withdrawal_credentials: Bytes32 # Commitment to pubkey for withdrawals
effective_balance: Gwei # Balance at stake effective_balance: Gwei # Balance at stake
slashed: boolean slashed: boolean
# Status epochs # Status epochs
@ -147,8 +147,8 @@ Note that the `body` has a new `BeaconBlockBody` definition.
```python ```python
class BeaconBlock(Container): class BeaconBlock(Container):
slot: Slot slot: Slot
parent_root: Hash parent_root: Root
state_root: Hash state_root: Root
body: BeaconBlockBody body: BeaconBlockBody
signature: BLSSignature signature: BLSSignature
``` ```
@ -165,9 +165,9 @@ class BeaconState(Container):
fork: Fork fork: Fork
# History # History
latest_block_header: BeaconBlockHeader latest_block_header: BeaconBlockHeader
block_roots: Vector[Hash, SLOTS_PER_HISTORICAL_ROOT] block_roots: Vector[Root, SLOTS_PER_HISTORICAL_ROOT]
state_roots: Vector[Hash, SLOTS_PER_HISTORICAL_ROOT] state_roots: Vector[Root, SLOTS_PER_HISTORICAL_ROOT]
historical_roots: List[Hash, HISTORICAL_ROOTS_LIMIT] historical_roots: List[Root, HISTORICAL_ROOTS_LIMIT]
# Eth1 # Eth1
eth1_data: Eth1Data eth1_data: Eth1Data
eth1_data_votes: List[Eth1Data, SLOTS_PER_ETH1_VOTING_PERIOD] eth1_data_votes: List[Eth1Data, SLOTS_PER_ETH1_VOTING_PERIOD]
@ -176,7 +176,7 @@ class BeaconState(Container):
validators: List[Validator, VALIDATOR_REGISTRY_LIMIT] validators: List[Validator, VALIDATOR_REGISTRY_LIMIT]
balances: List[Gwei, VALIDATOR_REGISTRY_LIMIT] balances: List[Gwei, VALIDATOR_REGISTRY_LIMIT]
# Randomness # Randomness
randao_mixes: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR] randao_mixes: Vector[Root, EPOCHS_PER_HISTORICAL_VECTOR]
# Slashings # Slashings
slashings: Vector[Gwei, EPOCHS_PER_SLASHINGS_VECTOR] # Per-epoch sums of slashed effective balances slashings: Vector[Gwei, EPOCHS_PER_SLASHINGS_VECTOR] # Per-epoch sums of slashed effective balances
# Attestations # Attestations
@ -189,7 +189,7 @@ class BeaconState(Container):
finalized_checkpoint: Checkpoint finalized_checkpoint: Checkpoint
# Phase 1 # Phase 1
shard_states: List[ShardState, MAX_SHARDS] shard_states: List[ShardState, MAX_SHARDS]
online_countdown: Bytes[VALIDATOR_REGISTRY_LIMIT] online_countdown: ByteList[VALIDATOR_REGISTRY_LIMIT]
current_light_committee: CompactCommittee current_light_committee: CompactCommittee
next_light_committee: CompactCommittee next_light_committee: CompactCommittee
# Custody game # Custody game
@ -209,10 +209,10 @@ _Wrapper for being broadcasted over the network._
```python ```python
class ShardBlockWrapper(Container): class ShardBlockWrapper(Container):
shard_parent_root: Hash shard_parent_root: Root
beacon_parent_root: Hash beacon_parent_root: Root
slot: Slot slot: Slot
body: BytesN[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE] body: ByteList[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE]
signature: BLSSignature signature: BLSSignature
``` ```
@ -220,10 +220,10 @@ class ShardBlockWrapper(Container):
```python ```python
class ShardSignableHeader(Container): class ShardSignableHeader(Container):
shard_parent_root: Hash shard_parent_root: Root
beacon_parent_root: Hash beacon_parent_root: Root
slot: Slot slot: Slot
body_root: Hash body_root: Root
``` ```
### `ShardState` ### `ShardState`
@ -232,8 +232,8 @@ class ShardSignableHeader(Container):
class ShardState(Container): class ShardState(Container):
slot: Slot slot: Slot
gasprice: Gwei gasprice: Gwei
data: Hash data: Bytes32
latest_block_root: Hash latest_block_root: Root
``` ```
### `ShardTransition` ### `ShardTransition`
@ -245,7 +245,7 @@ class ShardTransition(Container):
# Shard block lengths # Shard block lengths
shard_block_lengths: List[uint64, MAX_SHARD_BLOCKS_PER_ATTESTATION] shard_block_lengths: List[uint64, MAX_SHARD_BLOCKS_PER_ATTESTATION]
# Shard data roots # Shard data roots
shard_data_roots: List[List[Hash, MAX_SHARD_BLOCK_CHUNKS], MAX_SHARD_BLOCKS_PER_ATTESTATION] shard_data_roots: List[List[Bytes32, MAX_SHARD_BLOCK_CHUNKS], MAX_SHARD_BLOCKS_PER_ATTESTATION]
# Intermediate shard states # Intermediate shard states
shard_states: List[ShardState, MAX_SHARD_BLOCKS_PER_ATTESTATION] shard_states: List[ShardState, MAX_SHARD_BLOCKS_PER_ATTESTATION]
# Proposer signature aggregate # Proposer signature aggregate
@ -272,7 +272,7 @@ class CompactCommittee(Container):
```python ```python
class AttestationCustodyBitWrapper(Container): class AttestationCustodyBitWrapper(Container):
attestation_data_root: Hash attestation_data_root: Root
block_index: uint64 block_index: uint64
bit: boolean bit: boolean
``` ```
@ -319,8 +319,8 @@ def committee_to_compact_committee(state: BeaconState, committee: Sequence[Valid
#### `chunks_to_body_root` #### `chunks_to_body_root`
```python ```python
def chunks_to_body_root(chunks: List[Hash, MAX_SHARD_BLOCK_CHUNKS]) -> Hash: def chunks_to_body_root(chunks: List[Bytes32, MAX_SHARD_BLOCK_CHUNKS]) -> Root:
return hash_tree_root(Vector[Hash, MAX_SHARD_BLOCK_CHUNKS]( return hash_tree_root(Vector[Bytes32, MAX_SHARD_BLOCK_CHUNKS](
chunks + [EMPTY_CHUNK_ROOT] * (MAX_SHARD_BLOCK_CHUNKS - len(chunks)) chunks + [EMPTY_CHUNK_ROOT] * (MAX_SHARD_BLOCK_CHUNKS - len(chunks))
)) ))
``` ```
@ -543,7 +543,7 @@ def validate_attestation(state: BeaconState, attestation: Attestation) -> None:
# Type 2: delayed attestations # Type 2: delayed attestations
else: else:
assert state.slot - compute_start_slot_at_epoch(compute_epoch_at_slot(data.slot)) < SLOTS_PER_EPOCH assert state.slot - compute_start_slot_at_epoch(compute_epoch_at_slot(data.slot)) < SLOTS_PER_EPOCH
assert data.shard_transition_root == Hash() assert data.shard_transition_root == Root()
``` ```
###### `apply_shard_transition` ###### `apply_shard_transition`
@ -608,7 +608,7 @@ def apply_shard_transition(state: BeaconState, shard: Shard, transition: ShardTr
def process_crosslink_for_shard(state: BeaconState, def process_crosslink_for_shard(state: BeaconState,
shard: Shard, shard: Shard,
shard_transition: ShardTransition, shard_transition: ShardTransition,
attestations: Sequence[Attestation]) -> Hash: attestations: Sequence[Attestation]) -> Root:
committee = get_beacon_committee(state, get_current_epoch(state), shard) committee = get_beacon_committee(state, get_current_epoch(state), shard)
online_indices = get_online_validator_indices(state) online_indices = get_online_validator_indices(state)
@ -657,7 +657,7 @@ def process_crosslink_for_shard(state: BeaconState,
# No winning transition root, ensure empty and return empty root # No winning transition root, ensure empty and return empty root
assert shard_transition == ShardTransition() assert shard_transition == ShardTransition()
return Hash() return Root()
``` ```
###### `process_crosslinks` ###### `process_crosslinks`
@ -665,8 +665,8 @@ def process_crosslink_for_shard(state: BeaconState,
```python ```python
def process_crosslinks(state: BeaconState, def process_crosslinks(state: BeaconState,
block_body: BeaconBlockBody, block_body: BeaconBlockBody,
attestations: Sequence[Attestation]) -> Set[Tuple[Shard, Hash]]: attestations: Sequence[Attestation]) -> Set[Tuple[Shard, Root]]:
winners: Set[Tuple[Shard, Hash]] = set() winners: Set[Tuple[Shard, Root]] = set()
for shard in map(Shard, range(ACTIVE_SHARDS)): for shard in map(Shard, range(ACTIVE_SHARDS)):
# All attestations in the block for this shard # All attestations in the block for this shard
shard_attestations = [ shard_attestations = [
@ -675,7 +675,7 @@ def process_crosslinks(state: BeaconState,
] ]
shard_transition = block_body.shard_transitions[shard] shard_transition = block_body.shard_transitions[shard]
winning_root = process_crosslink_for_shard(state, shard, shard_transition, shard_attestations) winning_root = process_crosslink_for_shard(state, shard, shard_transition, shard_attestations)
if winning_root != Hash(): if winning_root != Root():
winners.add((shard, winning_root)) winners.add((shard, winning_root))
return winners return winners
``` ```

View File

@ -100,7 +100,7 @@ class CustodySlashing(Container):
whistleblower_index: ValidatorIndex whistleblower_index: ValidatorIndex
shard_transition: ShardTransition shard_transition: ShardTransition
attestation: Attestation attestation: Attestation
data: Bytes[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE] data: ByteList[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE]
signature: BLSSignature signature: BLSSignature
``` ```

View File

@ -34,10 +34,10 @@ The proof verifies that one of the two conditions is false:
```python ```python
def shard_state_transition(shard: Shard, def shard_state_transition(shard: Shard,
slot: Slot, slot: Slot,
pre_state: Hash, pre_state: Root,
previous_beacon_root: Hash, previous_beacon_root: Root,
proposer_pubkey: BLSPubkey, proposer_pubkey: BLSPubkey,
block_data: BytesN[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE]) -> Hash: block_data: ByteVector[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE]) -> Root:
# We will add something more substantive in phase 2 # We will add something more substantive in phase 2
return hash(pre_state + hash_tree_root(previous_beacon_root) + hash_tree_root(block_data)) return hash(pre_state + hash_tree_root(previous_beacon_root) + hash_tree_root(block_data))
``` ```

View File

@ -89,10 +89,10 @@ def upgrade_to_phase1(pre: phase0.BeaconState) -> BeaconState:
slot=pre.slot, slot=pre.slot,
gasprice=INITIAL_GASPRICE, gasprice=INITIAL_GASPRICE,
data=Root(), data=Root(),
latest_block_root=Hash(), latest_block_root=Root(),
) for i in range(ACTIVE_SHARDS) ) for i in range(ACTIVE_SHARDS)
), ),
online_countdown=Bytes[VALIDATOR_REGISTRY_LIMIT]( online_countdown=ByteList[VALIDATOR_REGISTRY_LIMIT](
ONLINE_PERIOD for i in range(len(pre.validators)) ONLINE_PERIOD for i in range(len(pre.validators))
), ),
current_light_committee=CompactCommittee(), # computed after state creation current_light_committee=CompactCommittee(), # computed after state creation