From a8fad7a39791b155a570fab281f22851ded2f57c Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 4 Mar 2019 17:51:25 -0700 Subject: [PATCH] handle when no attestations availble for crosslinking --- specs/core/0_beacon-chain.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 4525c609b4..4c608c0b39 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -2056,12 +2056,16 @@ def get_winning_root_and_participants(state: BeaconState, shard: Shard) -> Tuple a for a in all_attestations if a.data.latest_crosslink == state.latest_crosslinks[shard] ] all_roots = [a.data.crosslink_data_root for a in valid_attestations] - + + # handle when no attestations for shard available + if len(all_roots) == 0: + return ZERO_HASH, [] + def get_attestations_for(root) -> List[PendingAttestation]: return [a for a in valid_attestations if a.data.crosslink_data_root == root] - + winning_root = max(all_roots, key=lambda r: get_attesting_balance(state, get_attestations_for(r))) - + return winning_root, get_attesting_indices(state, get_attestations_for(winning_root)) ```