From fb75c6dd55d21d864e79994659bab149078282f0 Mon Sep 17 00:00:00 2001 From: Ben Edgington Date: Wed, 30 Jan 2019 16:45:46 +0000 Subject: [PATCH 1/3] Fix to verify bitfields and aggregate signature. In blockprocessing, `crosslink_committee` is not defined. This is a fix. In Phase 0 this check is redundant since we've already asserted that the custody bitfield is all zero, but it will matter in later phases. --- specs/core/0_beacon-chain.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 5ba1b242c..71ad5c708 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1632,7 +1632,8 @@ For each `attestation` in `block.body.attestations`: assert attestation.custody_bitfield == b'\x00' * len(attestation.custody_bitfield) # [TO BE REMOVED IN PHASE 1] assert attestation.aggregation_bitfield != b'\x00' * len(attestation.aggregation_bitfield) - for i in range(len(crosslink_committee)): + assert len(attestation.aggregation_bitfield) <= len(attestation.custody_bitfield) + for i in range(len(attestation.aggregation_bitfield)): if get_bitfield_bit(attestation.aggregation_bitfield, i) == 0b0: assert get_bitfield_bit(attestation.custody_bitfield, i) == 0b0 From 0e7953fe8ab91f4640c86b450dbf6e7e80eefbba Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 30 Jan 2019 10:39:08 -0800 Subject: [PATCH 2/3] verify_bitiefld in aggregate signature section --- specs/core/0_beacon-chain.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 71ad5c708..1c5af9660 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1631,9 +1631,12 @@ For each `attestation` in `block.body.attestations`: ```python assert attestation.custody_bitfield == b'\x00' * len(attestation.custody_bitfield) # [TO BE REMOVED IN PHASE 1] assert attestation.aggregation_bitfield != b'\x00' * len(attestation.aggregation_bitfield) - - assert len(attestation.aggregation_bitfield) <= len(attestation.custody_bitfield) - for i in range(len(attestation.aggregation_bitfield)): + + crosslink_committee = get_crosslink_committee_at_slot(state, attestation.data.slot)[0] + verify_bitfield(attestation.aggregation_bitfield, len(crosslink_committee)) + verify_bitfield(attestation.custody_bitfield, len(crosslink_committee)) + + for i in range(len(crosslink_committee): if get_bitfield_bit(attestation.aggregation_bitfield, i) == 0b0: assert get_bitfield_bit(attestation.custody_bitfield, i) == 0b0 From 3c4615df0177959715191b2fe9f774008a618f06 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 30 Jan 2019 10:43:06 -0800 Subject: [PATCH 3/3] fix call --- specs/core/0_beacon-chain.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 1c5af9660..5622f0897 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1632,7 +1632,10 @@ For each `attestation` in `block.body.attestations`: assert attestation.custody_bitfield == b'\x00' * len(attestation.custody_bitfield) # [TO BE REMOVED IN PHASE 1] assert attestation.aggregation_bitfield != b'\x00' * len(attestation.aggregation_bitfield) - crosslink_committee = get_crosslink_committee_at_slot(state, attestation.data.slot)[0] + crosslink_committee = [ + committee for committee, shard in get_crosslink_committees_at_slot(state, attestation.data.slot) + if shard == attestation.data.shard + ][0] verify_bitfield(attestation.aggregation_bitfield, len(crosslink_committee)) verify_bitfield(attestation.custody_bitfield, len(crosslink_committee))