From a7f58ef08acb81a88b279b449335faebc6c717b2 Mon Sep 17 00:00:00 2001 From: protolambda Date: Wed, 14 Jul 2021 13:19:00 +0200 Subject: [PATCH] fix comment + handle missing pending headers --- specs/sharding/beacon-chain.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/specs/sharding/beacon-chain.md b/specs/sharding/beacon-chain.md index 63b9457c4..2ab0f68cd 100644 --- a/specs/sharding/beacon-chain.md +++ b/specs/sharding/beacon-chain.md @@ -367,7 +367,7 @@ class ShardProposerSlashing(Container): ```python class ShardWork(Container): - # Upon confirmation the data is reduced to just the header. + # Upon confirmation the data is reduced to just the commitment. status: Union[ # See Shard Work Status enum None, # SHARD_WORK_UNCONFIRMED DataCommitment, # SHARD_WORK_CONFIRMED @@ -597,7 +597,15 @@ def update_pending_shard_work(state: BeaconState, attestation: Attestation) -> N current_headers: Sequence[PendingShardHeader] = committee_work.status.value # Find the corresponding header, abort if it cannot be found - header_index = [header.root for header in current_headers].index(attestation.data.shard_blob_root) + header_index = len(current_headers) + for i, header in enumerate(current_headers): + if attestation.data.shard_blob_root == header.root: + header_index = i + break + # Attestations for an unknown header do not count towards shard confirmations, but can otherwise be valid. + if header_index == len(current_headers): + # TODO: Attestations may be re-included if headers are included late. + return pending_header: PendingShardHeader = current_headers[header_index] full_committee = get_beacon_committee(state, attestation.data.slot, attestation.data.index)