From 5f78d2b4361c5ceb3abb629f75a292d1eb046997 Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:10:41 +0800 Subject: [PATCH] apply suggestions --- specs/_features/eip7549/beacon-chain.md | 16 +++------------- specs/_features/eip7549/validator.md | 4 +++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/specs/_features/eip7549/beacon-chain.md b/specs/_features/eip7549/beacon-chain.md index 24a3386e8..2382551e2 100644 --- a/specs/_features/eip7549/beacon-chain.md +++ b/specs/_features/eip7549/beacon-chain.md @@ -16,7 +16,6 @@ - [Misc](#misc) - [`get_committee_indices`](#get_committee_indices) - [Beacon state accessors](#beacon-state-accessors) - - [New `get_committee_attesters`](#new-get_committee_attesters) - [Modified `get_attesting_indices`](#modified-get_attesting_indices) - [Block processing](#block-processing) - [Modified `process_attestation`](#modified-process_attestation) @@ -74,15 +73,6 @@ def get_committee_indices(commitee_bits: Bitvector) -> List[CommitteeIndex]: ### Beacon state accessors -#### New `get_committee_attesters` - -```python -def get_committee_attesters(state: BeaconState, slot: Slot, - attesting_bits: Bitlist, index: CommitteeIndex) -> Set[ValidatorIndex]: - committee = get_beacon_committee(state, slot, index) - return set(index for i, index in enumerate(committee) if attesting_bits[i]) -``` - #### Modified `get_attesting_indices` ```python @@ -94,8 +84,9 @@ def get_attesting_indices(state: BeaconState, attestation: Attestation) -> Set[V output = set() committee_indices = get_committee_indices(attestation.committee_bits) for index in committee_indices: - attesting_bits = attestation.attesting_bits[index] - committee_attesters = get_committee_attesters(state, attestation.data.slot, attesting_bits, index) + attesting_bits = attestation.aggregation_bits[index] + committee = get_beacon_committee(state, attestation.data.slot, index) + committee_attesters = set(index for i, index in enumerate(committee) if attesting_bits[i]) output = output.union(committee_attesters) return output @@ -115,7 +106,6 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None: # [Modified in EIP7549] assert data.index == 0 committee_indices = get_committee_indices(attestation.committee_bits) - assert len(committee_indices) > 0 assert len(committee_indices) == len(attestation.aggregation_bits) for index in committee_indices: assert index < get_committee_count_per_slot(state, data.target.epoch) diff --git a/specs/_features/eip7549/validator.md b/specs/_features/eip7549/validator.md index 1efe3bfbc..6ae84aca6 100644 --- a/specs/_features/eip7549/validator.md +++ b/specs/_features/eip7549/validator.md @@ -35,6 +35,8 @@ Attestations received from aggregators with disjoint `committee_bits` sets and e - Set `attestation_data.index = 0`. - Let `aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE]` of length `len(committee)`, where the bit of the index of the validator in the `committee` is set to `0b1`. - Set `attestation.aggregation_bits = [aggregation_bits]`, a list of length 1 +- Let `committee_bits` be a `Bitvector[MAX_COMMITTEES_PER_SLOT]`, where the bit at the index associated with the validator's committee is set to `0b1` +- Set `attestation.committee_bits = committee_bits` *Note*: Calling `get_attesting_indices(state, attestation)` should return a list of length equal to 1, containing `validator_index`. @@ -45,5 +47,5 @@ Attestations received from aggregators with disjoint `committee_bits` sets and e - Set `attestation_data.index = 0`. - Let `aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE]` of length `len(committee)`, where each bit set from each individual attestation is set to `0b1`. - Set `attestation.aggregation_bits = [aggregation_bits]`, a list of length 1 - +- Set `attestation.committee_bits = committee_bits`, where `committee_bits` has the same value as in each individual attestation