Skip to content

Commit

Permalink
Merge pull request #3900 from status-im/single-attestation
Browse files Browse the repository at this point in the history
Separate type for unaggregated network attestations
  • Loading branch information
jtraglia authored Oct 31, 2024
2 parents c060147 + d763a6e commit f169475
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
11 changes: 11 additions & 0 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [`DepositRequest`](#depositrequest)
- [`WithdrawalRequest`](#withdrawalrequest)
- [`ConsolidationRequest`](#consolidationrequest)
- [`SingleAttestation`](#singleattestation)
- [`ExecutionRequests`](#executionrequests)
- [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing)
Expand Down Expand Up @@ -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 [
Expand Down
17 changes: 13 additions & 4 deletions specs/electra/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))`.
11 changes: 6 additions & 5 deletions specs/electra/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,17 @@ 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

### Construct aggregate

- 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.

0 comments on commit f169475

Please sign in to comment.