Merge pull request #2358 from ericsson49/ericsson49/fix_process_shard_header

More typos fixes in `sharding`
This commit is contained in:
Diederik Loerakker 2021-04-26 20:27:07 +02:00 committed by GitHub
commit fd9c96d41d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -559,7 +559,7 @@ def process_shard_header(state: BeaconState,
assert header.shard < get_active_shard_count(state, header_epoch) assert header.shard < get_active_shard_count(state, header_epoch)
# Verify that the block root matches, # Verify that the block root matches,
# to ensure the header will only be included in this specific Beacon Chain sub-tree. # to ensure the header will only be included in this specific Beacon Chain sub-tree.
assert header.beacon_block_root == get_block_root_at_slot(state, header.slot - 1) assert header.body_summary.beacon_block_root == get_block_root_at_slot(state, header.slot - 1)
# Verify proposer # Verify proposer
assert header.proposer_index == get_shard_proposer_index(state, header.slot, header.shard) assert header.proposer_index == get_shard_proposer_index(state, header.slot, header.shard)
# Verify signature # Verify signature
@ -644,7 +644,7 @@ def process_epoch(state: BeaconState) -> None:
# Sharding # Sharding
process_pending_headers(state) process_pending_headers(state)
process_confirmed_header_fees(state) charge_confirmed_header_fees(state)
reset_pending_headers(state) reset_pending_headers(state)
# Final updates # Final updates
@ -706,7 +706,7 @@ def process_pending_headers(state: BeaconState) -> None:
state.grandparent_epoch_confirmed_commitments[shard][slot_index] = DataCommitment() state.grandparent_epoch_confirmed_commitments[shard][slot_index] = DataCommitment()
confirmed_headers = [candidate for candidate in state.previous_epoch_pending_shard_headers if candidate.confirmed] confirmed_headers = [candidate for candidate in state.previous_epoch_pending_shard_headers if candidate.confirmed]
for header in confirmed_headers: for header in confirmed_headers:
state.grandparent_epoch_confirmed_commitments[c.shard][c.slot % SLOTS_PER_EPOCH] = c.commitment state.grandparent_epoch_confirmed_commitments[header.shard][header.slot % SLOTS_PER_EPOCH] = header.commitment
``` ```
```python ```python
@ -728,7 +728,7 @@ def charge_confirmed_header_fees(state: BeaconState) -> None:
candidate = confirmed_candidates[0] candidate = confirmed_candidates[0]
# Charge EIP 1559 fee # Charge EIP 1559 fee
proposer = get_shard_proposer(state, slot, shard) proposer = get_shard_proposer_index(state, slot, shard)
fee = ( fee = (
(state.shard_gasprice * candidate.commitment.length) (state.shard_gasprice * candidate.commitment.length)
// TARGET_SAMPLES_PER_BLOCK // TARGET_SAMPLES_PER_BLOCK
@ -751,8 +751,8 @@ def reset_pending_headers(state: BeaconState) -> None:
# Add dummy "empty" PendingShardHeader (default vote for if no shard header available) # Add dummy "empty" PendingShardHeader (default vote for if no shard header available)
next_epoch = get_current_epoch(state) + 1 next_epoch = get_current_epoch(state) + 1
next_epoch_start_slot = compute_start_slot_at_epoch(next_epoch) next_epoch_start_slot = compute_start_slot_at_epoch(next_epoch)
for slot in range(next_epoch_start_slot, next_epoch_start_slot + SLOTS_IN_EPOCH): for slot in range(next_epoch_start_slot, next_epoch_start_slot + SLOTS_PER_EPOCH):
for index in range(get_committee_count_per_slot(next_epoch)): for index in range(get_committee_count_per_slot(state, next_epoch)):
shard = compute_shard_from_committee_index(state, slot, index) shard = compute_shard_from_committee_index(state, slot, index)
committee_length = len(get_beacon_committee(state, slot, shard)) committee_length = len(get_beacon_committee(state, slot, shard))
state.current_epoch_pending_shard_headers.append(PendingShardHeader( state.current_epoch_pending_shard_headers.append(PendingShardHeader(