Merge pull request #3900 from status-im/single-attestation

Separate type for unaggregated network attestations
This commit is contained in:
Justin Traglia 2024-10-31 09:37:58 -05:00 committed by GitHub
commit f169475d19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 9 deletions

View File

@ -30,6 +30,7 @@
- [`DepositRequest`](#depositrequest)
- [`WithdrawalRequest`](#withdrawalrequest)
- [`ConsolidationRequest`](#consolidationrequest)
- [`SingleAttestation`](#singleattestation)
- [`ExecutionRequests`](#executionrequests)
- [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing)
@ -270,6 +271,16 @@ class ConsolidationRequest(Container):
target_pubkey: BLSPubkey
```
#### `SingleAttestation`
```python
class SingleAttestation(Container):
committee_index: CommitteeIndex
attester_index: ValidatorIndex
data: AttestationData
signature: BLSSignature
```
#### `ExecutionRequests`
*Note*: This container holds requests from the execution layer that are received in [

View File

@ -56,9 +56,18 @@ The following validations are added:
##### `beacon_attestation_{subnet_id}`
The following convenience variables are re-defined
- `index = get_committee_indices(attestation.committee_bits)[0]`
The topic is updated to propagate `SingleAttestation` objects.
The following convenience variables are re-defined:
- `index = attestation.committee_index`
The following validations are added:
* [REJECT] `len(committee_indices) == 1`, where `committee_indices = get_committee_indices(attestation)`.
* [REJECT] `attestation.data.index == 0`
- _[REJECT]_ `attestation.data.index == 0`
- _[REJECT]_ The attester is a member of the committee -- i.e.
`attestation.attester_index in get_beacon_committee(state, attestation.data.slot, index)`.
The following validations are removed:
- _[REJECT]_ The attestation is unaggregated --
that is, it has exactly one participating validator (`len([bit for bit in aggregation_bits if bit]) == 1`, i.e. exactly 1 bit is set).
- _[REJECT]_ The number of aggregation bits matches the committee size -- i.e.
`len(aggregation_bits) == len(get_beacon_committee(state, attestation.data.slot, index))`.

View File

@ -207,11 +207,12 @@ def get_execution_requests(execution_requests: Sequence[bytes]) -> ExecutionRequ
### Construct attestation
- Set `attestation_data.index = 0`.
- Let `attestation.aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]` of length `len(committee)`, where the bit of the index of the validator in the `committee` is set to `0b1`.
- Let `attestation.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`.
The validator creates `attestation` as a `SingleAttestation` container
with updated field assignments:
*Note*: Calling `get_attesting_indices(state, attestation)` should return a list of length equal to 1, containing `validator_index`.
- Set `attestation_data.index = 0`.
- Set `attestation.committee_index` to the index associated with the validator's committee.
- Set `attestation.attester_index` to the index of the validator.
## Attestation aggregation
@ -219,4 +220,4 @@ def get_execution_requests(execution_requests: Sequence[bytes]) -> ExecutionRequ
- Set `attestation_data.index = 0`.
- Let `aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]` of length `len(committee)`, where each bit set from each individual attestation is set to `0b1`.
- Set `attestation.committee_bits = committee_bits`, where `committee_bits` has the same value as in each individual attestation.
- Set `attestation.committee_bits = committee_bits`, where `committee_bits` has the bit set corresponding to `committee_index` in each individual attestation.