Renamings triggered by HW comment
This commit is contained in:
parent
8b1a2edb7c
commit
f4db9ebae0
|
@ -287,9 +287,9 @@ The types are defined topologically to aid in facilitating an executable version
|
|||
# Epoch number
|
||||
'epoch': 'uint64',
|
||||
# Root of the previous crosslink
|
||||
'previous_crosslink_root': 'bytes32',
|
||||
'parent_crosslink_root': 'bytes32',
|
||||
# Root of the crosslinked shard data since the previous crosslink
|
||||
'crosslink_data_root': 'bytes32',
|
||||
'data_root': 'bytes32',
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -369,7 +369,7 @@ The types are defined topologically to aid in facilitating an executable version
|
|||
```python
|
||||
{
|
||||
'slot': 'uint64',
|
||||
'previous_block_root': 'bytes32',
|
||||
'parent_block_root': 'bytes32',
|
||||
'state_root': 'bytes32',
|
||||
'block_body_root': 'bytes32',
|
||||
'signature': 'bytes96',
|
||||
|
@ -536,7 +536,7 @@ The types are defined topologically to aid in facilitating an executable version
|
|||
{
|
||||
# Header
|
||||
'slot': 'uint64',
|
||||
'previous_block_root': 'bytes32',
|
||||
'parent_block_root': 'bytes32',
|
||||
'state_root': 'bytes32',
|
||||
'body': BeaconBlockBody,
|
||||
'signature': 'bytes96',
|
||||
|
@ -1306,12 +1306,12 @@ def get_attesting_balance(state: BeaconState, attestations: List[PendingAttestat
|
|||
def get_winning_crosslink_and_attesting_indices(state: BeaconState, epoch: Epoch, shard: Shard) -> Tuple[Crosslink, List[ValidatorIndex]]:
|
||||
attestations = [a for a in get_matching_source_attestations(state, epoch) if a.data.crosslink.shard == shard]
|
||||
crosslinks = list(filter(
|
||||
lambda c: hash_tree_root(state.current_crosslinks[shard]) in (c.previous_crosslink_root, hash_tree_root(c)),
|
||||
lambda c: hash_tree_root(state.current_crosslinks[shard]) in (c.parent_crosslink_root, hash_tree_root(c)),
|
||||
[a.data.crosslink for a in attestations]
|
||||
))
|
||||
# Winning crosslink has the crosslink data root with the most balance voting for it (ties broken lexicographically)
|
||||
winning_crosslink = max(crosslinks, key=lambda c: (
|
||||
get_attesting_balance(state, [a for a in attestations if a.data.crosslink == c]), c.crosslink_data_root
|
||||
get_attesting_balance(state, [a for a in attestations if a.data.crosslink == c]), c.data_root
|
||||
), default=Crosslink())
|
||||
winning_attestations = [a for a in attestations if a.data.crosslink == winning_crosslink]
|
||||
return winning_crosslink, get_unslashed_attesting_indices(state, winning_attestations)
|
||||
|
@ -1586,11 +1586,11 @@ def process_block_header(state: BeaconState, block: BeaconBlock) -> None:
|
|||
# Verify that the slots match
|
||||
assert block.slot == state.slot
|
||||
# Verify that the parent matches
|
||||
assert block.previous_block_root == signing_root(state.latest_block_header)
|
||||
assert block.parent_block_root == signing_root(state.latest_block_header)
|
||||
# Save current block as the new latest block
|
||||
state.latest_block_header = BeaconBlockHeader(
|
||||
slot=block.slot,
|
||||
previous_block_root=block.previous_block_root,
|
||||
parent_block_root=block.parent_block_root,
|
||||
block_body_root=hash_tree_root(block.body),
|
||||
)
|
||||
# Verify proposer is not slashed
|
||||
|
@ -1707,18 +1707,18 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
|
|||
assert data.target_epoch in (get_previous_epoch(state), get_current_epoch(state))
|
||||
if data.target_epoch == get_current_epoch(state):
|
||||
ffg_data = (state.current_justified_epoch, state.current_justified_root, get_current_epoch(state))
|
||||
previous_crosslink = state.current_crosslinks[data.crosslink.shard]
|
||||
parent_crosslink = state.current_crosslinks[data.crosslink.shard]
|
||||
state.current_epoch_attestations.append(pending_attestation)
|
||||
else:
|
||||
ffg_data = (state.previous_justified_epoch, state.previous_justified_root, get_previous_epoch(state))
|
||||
previous_crosslink = state.previous_crosslinks[data.crosslink.shard]
|
||||
parent_crosslink = state.previous_crosslinks[data.crosslink.shard]
|
||||
state.previous_epoch_attestations.append(pending_attestation)
|
||||
|
||||
# Check FFG data, crosslink data, and signature
|
||||
assert ffg_data == (data.source_epoch, data.source_root, data.target_epoch)
|
||||
assert data.crosslink.epoch == min(data.target_epoch, previous_crosslink.epoch + MAX_EPOCHS_PER_CROSSLINK)
|
||||
assert data.crosslink.previous_crosslink_root == hash_tree_root(previous_crosslink)
|
||||
assert data.crosslink.crosslink_data_root == ZERO_HASH # [to be removed in phase 1]
|
||||
assert data.crosslink.epoch == min(data.target_epoch, parent_crosslink.epoch + MAX_EPOCHS_PER_CROSSLINK)
|
||||
assert data.crosslink.parent_crosslink_root == hash_tree_root(parent_crosslink)
|
||||
assert data.crosslink.data_root == ZERO_HASH # [to be removed in phase 1]
|
||||
assert verify_indexed_attestation(state, convert_to_indexed(state, attestation))
|
||||
```
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ All terminology, constants, functions, and protocol mechanics defined in the [Ph
|
|||
|
||||
Processing the beacon chain is similar to processing the Ethereum 1.0 chain. Clients download and process blocks and maintain a view of what is the current "canonical chain", terminating at the current "head". For a beacon block, `block`, to be processed by a node, the following conditions must be met:
|
||||
|
||||
* The parent block with root `block.previous_block_root` has been processed and accepted.
|
||||
* The parent block with root `block.parent_block_root` has been processed and accepted.
|
||||
* An Ethereum 1.0 block pointed to by the `state.latest_eth1_data.block_hash` has been processed and accepted.
|
||||
* The node's Unix time is greater than or equal to `state.genesis_time + block.slot * SECONDS_PER_SLOT`.
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ This document details the beacon chain additions and changes in Phase 1 of Ether
|
|||
'challenger_index': ValidatorIndex,
|
||||
'responder_index': ValidatorIndex,
|
||||
'deadline': Epoch,
|
||||
'crosslink_data_root': Hash,
|
||||
'data_root': Hash,
|
||||
'depth': 'uint64',
|
||||
'chunk_index': 'uint64',
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ This document details the beacon chain additions and changes in Phase 1 of Ether
|
|||
'challenger_index': ValidatorIndex,
|
||||
'responder_index': ValidatorIndex,
|
||||
'deadline': Epoch,
|
||||
'crosslink_data_root': Hash,
|
||||
'data_root': Hash,
|
||||
'chunk_count': 'uint64',
|
||||
'chunk_bits_merkle_root': Hash,
|
||||
'responder_key': BLSSignature,
|
||||
|
@ -474,7 +474,7 @@ def process_chunk_challenge(state: BeaconState,
|
|||
# Verify the challenge is not a duplicate
|
||||
for record in state.custody_chunk_challenge_records:
|
||||
assert (
|
||||
record.crosslink_data_root != challenge.attestation.data.crosslink.crosslink_data_root or
|
||||
record.data_root != challenge.attestation.data.crosslink.data_root or
|
||||
record.chunk_index != challenge.chunk_index
|
||||
)
|
||||
# Verify depth
|
||||
|
@ -486,7 +486,7 @@ def process_chunk_challenge(state: BeaconState,
|
|||
challenger_index=get_beacon_proposer_index(state),
|
||||
responder_index=challenge.responder_index
|
||||
deadline=get_current_epoch(state) + CUSTODY_RESPONSE_DEADLINE,
|
||||
crosslink_data_root=challenge.attestation.data.crosslink.crosslink_data_root,
|
||||
data_root=challenge.attestation.data.crosslink.data_root,
|
||||
depth=depth,
|
||||
chunk_index=challenge.chunk_index,
|
||||
)
|
||||
|
@ -564,7 +564,7 @@ def process_bit_challenge(state: BeaconState,
|
|||
challenger_index=challenge.challenger_index,
|
||||
responder_index=challenge.responder_index,
|
||||
deadline=get_current_epoch(state) + CUSTODY_RESPONSE_DEADLINE,
|
||||
crosslink_data_root=challenge.attestation.data.crosslink.crosslink_data_root,
|
||||
data_root=challenge.attestation.data.crosslink.data_root,
|
||||
chunk_count=chunk_count,
|
||||
chunk_bits_merkle_root=merkle_root(pad_to_power_of_2((challenge.chunk_bits))),
|
||||
responder_key=challenge.responder_key,
|
||||
|
@ -610,7 +610,7 @@ def process_chunk_challenge_response(state: BeaconState,
|
|||
branch=response.data_branch,
|
||||
depth=challenge.depth,
|
||||
index=response.chunk_index,
|
||||
root=challenge.crosslink_data_root,
|
||||
root=challenge.data_root,
|
||||
)
|
||||
# Clear the challenge
|
||||
records = state.custody_chunk_challenge_records
|
||||
|
@ -632,7 +632,7 @@ def process_bit_challenge_response(state: BeaconState,
|
|||
branch=response.data_branch,
|
||||
depth=math.log2(next_power_of_two(challenge.chunk_count)),
|
||||
index=response.chunk_index,
|
||||
root=challenge.crosslink_data_root,
|
||||
root=challenge.data_root,
|
||||
)
|
||||
# Verify the chunk bit leaf matches the challenge data
|
||||
assert verify_merkle_branch(
|
||||
|
|
|
@ -78,7 +78,7 @@ This document describes the shard data layer and the shard fork choice rule in P
|
|||
'slot': Slot,
|
||||
'shard': Shard,
|
||||
'beacon_chain_root': Hash,
|
||||
'previous_block_root': Hash,
|
||||
'parent_block_root': Hash,
|
||||
'data': ShardBlockBody,
|
||||
'state_root': Hash,
|
||||
'attestations': [ShardAttestation],
|
||||
|
@ -93,7 +93,7 @@ This document describes the shard data layer and the shard fork choice rule in P
|
|||
'slot': Slot,
|
||||
'shard': Shard,
|
||||
'beacon_chain_root': Hash,
|
||||
'previous_block_root': Hash,
|
||||
'parent_block_root': Hash,
|
||||
'body_root': Hash,
|
||||
'state_root': Hash,
|
||||
'attestations': [ShardAttestation],
|
||||
|
@ -201,7 +201,7 @@ def get_shard_header(block: ShardBlock) -> ShardBlockHeader:
|
|||
slot: block.slot,
|
||||
shard: block.shard,
|
||||
beacon_chain_root: block.beacon_chain_root,
|
||||
previous_block_root: block.previous_block_root,
|
||||
parent_block_root: block.parent_block_root,
|
||||
body_root: hash_tree_root(block.body),
|
||||
state_root: block.state_root,
|
||||
attestations: block.attestations,
|
||||
|
@ -296,11 +296,11 @@ def is_valid_shard_block(beacon_blocks: List[BeaconBlock],
|
|||
|
||||
# Check parent block
|
||||
if block.slot == PHASE_1_GENESIS_SLOT:
|
||||
assert candidate.previous_block_root == ZERO_HASH
|
||||
assert candidate.parent_block_root == ZERO_HASH
|
||||
else:
|
||||
parent_block = next(
|
||||
block for block in valid_shard_blocks if
|
||||
signing_root(block) == candidate.previous_block_root
|
||||
signing_root(block) == candidate.parent_block_root
|
||||
, None)
|
||||
assert parent_block != None
|
||||
assert parent_block.shard == block.shard
|
||||
|
@ -378,11 +378,11 @@ def is_valid_beacon_attestation(shard: Shard,
|
|||
|
||||
# Check previous attestation
|
||||
if candidate.data.previous_crosslink.epoch <= PHASE_1_GENESIS_EPOCH:
|
||||
assert candidate.data.previous_crosslink.crosslink_data_root == ZERO_HASH
|
||||
assert candidate.data.previous_crosslink.data_root == ZERO_HASH
|
||||
else:
|
||||
previous_attestation = next(
|
||||
attestation for attestation in valid_attestations if
|
||||
attestation.data.crosslink.crosslink_data_root == candidate.data.previous_crosslink.crosslink_data_root
|
||||
attestation.data.crosslink.data_root == candidate.data.previous_crosslink.data_root
|
||||
, None)
|
||||
assert previous_attestation != None
|
||||
assert candidate.data.previous_attestation.epoch < slot_to_epoch(candidate.data.slot)
|
||||
|
@ -393,7 +393,7 @@ def is_valid_beacon_attestation(shard: Shard,
|
|||
blocks = []
|
||||
for slot in range(start_epoch * SLOTS_PER_EPOCH, end_epoch * SLOTS_PER_EPOCH):
|
||||
blocks.append(shard_blocks[slot])
|
||||
assert candidate.data.crosslink.crosslink_data_root == compute_crosslink_data_root(blocks)
|
||||
assert candidate.data.crosslink.data_root == compute_crosslink_data_root(blocks)
|
||||
|
||||
return True
|
||||
```
|
||||
|
|
|
@ -152,7 +152,7 @@ Set `block.slot = slot` where `slot` is the current slot at which the validator
|
|||
|
||||
##### Parent root
|
||||
|
||||
Set `block.previous_block_root = signing_root(parent)`.
|
||||
Set `block.parent_block_root = signing_root(parent)`.
|
||||
|
||||
##### State root
|
||||
|
||||
|
@ -275,11 +275,11 @@ Set `attestation_data.crosslink.shard = shard` where `shard` is the shard associ
|
|||
|
||||
##### Previous crosslink root
|
||||
|
||||
Set `attestation_data.previous_crosslink_root = hash_tree_root(head_state.current_crosslinks[shard])`.
|
||||
Set `attestation_data.parent_crosslink_root = hash_tree_root(head_state.current_crosslinks[shard])`.
|
||||
|
||||
##### Crosslink data root
|
||||
|
||||
Set `attestation_data.crosslink.crosslink_data_root = ZERO_HASH`.
|
||||
Set `attestation_data.crosslink.data_root = ZERO_HASH`.
|
||||
|
||||
*Note*: This is a stub for Phase 0.
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ def test_non_zero_crosslink_data_root(state):
|
|||
attestation = get_valid_attestation(state)
|
||||
state.slot += spec.MIN_ATTESTATION_INCLUSION_DELAY
|
||||
|
||||
attestation.data.crosslink.crosslink_data_root = b'\x42' * 32
|
||||
attestation.data.crosslink.data_root = b'\x42' * 32
|
||||
|
||||
pre_state, post_state = run_attestation_processing(state, attestation, False)
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ def test_invalid_slot(state):
|
|||
return pre_state, block, None
|
||||
|
||||
|
||||
def test_invalid_previous_block_root(state):
|
||||
def test_invalid_parent_block_root(state):
|
||||
block = build_empty_block_for_next_slot(state)
|
||||
block.previous_block_root = b'\12' * 32 # invalid prev root
|
||||
block.parent_block_root = b'\12' * 32 # invalid prev root
|
||||
|
||||
pre_state, post_state = run_block_header_processing(state, block, valid=False)
|
||||
return pre_state, block, None
|
||||
|
|
|
@ -128,7 +128,7 @@ def build_empty_block_for_next_slot(state):
|
|||
previous_block_header = deepcopy(state.latest_block_header)
|
||||
if previous_block_header.state_root == spec.ZERO_HASH:
|
||||
previous_block_header.state_root = state.hash_tree_root()
|
||||
empty_block.previous_block_root = signing_root(previous_block_header)
|
||||
empty_block.parent_block_root = signing_root(previous_block_header)
|
||||
return empty_block
|
||||
|
||||
|
||||
|
@ -155,7 +155,7 @@ def build_attestation_data(state, slot, shard):
|
|||
assert state.slot >= slot
|
||||
|
||||
if slot == state.slot:
|
||||
block_root = build_empty_block_for_next_slot(state).previous_block_root
|
||||
block_root = build_empty_block_for_next_slot(state).parent_block_root
|
||||
else:
|
||||
block_root = get_block_root_at_slot(state, slot)
|
||||
|
||||
|
@ -184,8 +184,8 @@ def build_attestation_data(state, slot, shard):
|
|||
crosslink=Crosslink(
|
||||
shard=shard,
|
||||
epoch=min(slot_to_epoch(slot), crosslinks[shard].epoch + MAX_EPOCHS_PER_CROSSLINK),
|
||||
crosslink_data_root=spec.ZERO_HASH,
|
||||
previous_crosslink_root=hash_tree_root(crosslinks[shard]),
|
||||
data_root=spec.ZERO_HASH,
|
||||
parent_crosslink_root=hash_tree_root(crosslinks[shard]),
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -240,12 +240,12 @@ def get_valid_proposer_slashing(state):
|
|||
|
||||
header_1 = BeaconBlockHeader(
|
||||
slot=slot,
|
||||
previous_block_root=ZERO_HASH,
|
||||
parent_block_root=ZERO_HASH,
|
||||
state_root=ZERO_HASH,
|
||||
block_body_root=ZERO_HASH,
|
||||
)
|
||||
header_2 = deepcopy(header_1)
|
||||
header_2.previous_block_root = b'\x02' * 32
|
||||
header_2.parent_block_root = b'\x02' * 32
|
||||
header_2.slot = slot + 1
|
||||
|
||||
domain = get_domain(
|
||||
|
|
|
@ -68,7 +68,7 @@ def test_empty_block_transition(state):
|
|||
state_transition(test_state, block)
|
||||
|
||||
assert len(test_state.eth1_data_votes) == len(state.eth1_data_votes) + 1
|
||||
assert get_block_root_at_slot(test_state, state.slot) == block.previous_block_root
|
||||
assert get_block_root_at_slot(test_state, state.slot) == block.parent_block_root
|
||||
|
||||
return state, [block], test_state
|
||||
|
||||
|
@ -82,7 +82,7 @@ def test_skipped_slots(state):
|
|||
|
||||
assert test_state.slot == block.slot
|
||||
for slot in range(state.slot, test_state.slot):
|
||||
assert get_block_root_at_slot(test_state, slot) == block.previous_block_root
|
||||
assert get_block_root_at_slot(test_state, slot) == block.parent_block_root
|
||||
|
||||
return state, [block], test_state
|
||||
|
||||
|
@ -96,7 +96,7 @@ def test_empty_epoch_transition(state):
|
|||
|
||||
assert test_state.slot == block.slot
|
||||
for slot in range(state.slot, test_state.slot):
|
||||
assert get_block_root_at_slot(test_state, slot) == block.previous_block_root
|
||||
assert get_block_root_at_slot(test_state, slot) == block.parent_block_root
|
||||
|
||||
return state, [block], test_state
|
||||
|
||||
|
|
Loading…
Reference in New Issue