Skip to content

Commit

Permalink
Separate type for unaggregated network attestations
Browse files Browse the repository at this point in the history
As a complement to
ethereum#3787, this PR
introduces a `SingleAttestation` type used for network propagation only.

In Electra, the on-chain attestation format introduced in
[EIP-7549](ethereum#3559)
presents several difficulties - not only are the new fields to be
interpreted differently during network processing and onchain which adds
complexity in clients, they also introduce inefficiency both in hash
computation and bandwidth.

The new type puts the validator and committee indices directly in the
attestation type, this simplifying processing and increasing security.

* placing the validator index directly in the attestation allows
verifying the signature without computing a shuffling - this closes a
loophole where clients either must drop attestations or risk being
overwhelmed by shuffling computations during attestation verification
* the simpler "structure" of the attestation saves several hash calls
during processing (a single-item List has significant hashing overhead
compared to a field)
* we save a few bytes here and there - we can also put stricter bounds
on message size on the attestation topic because `SingleAttestation` is
now fixed-size
* the ambiguity of interpreting the `attestation_bits` list indices
which became contextual under EIP-7549 is removed

Because this change only affects the network encoding (and not block
contents), the implementation impact on clients should be minimal.
  • Loading branch information
arnetheduck committed Aug 26, 2024
1 parent ca04b1e commit 0b95012
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [`WithdrawalRequest`](#withdrawalrequest)
- [`ConsolidationRequest`](#consolidationrequest)
- [`PendingConsolidation`](#pendingconsolidation)
- [`SingleAttestation`](#singleattestation)
- [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing)
- [Extended Containers](#extended-containers)
Expand Down Expand Up @@ -258,6 +259,17 @@ class PendingConsolidation(Container):
target_index: ValidatorIndex
```


#### `SingleAttestation`

```python
class SingleAttestation(Container):
committee_index: CommitteeIndex
attester_index: ValidatorIndex
data: AttestationData
signature: BLSSignature
```

### Modified Containers

#### `AttesterSlashing`
Expand Down Expand Up @@ -875,7 +887,7 @@ def process_pending_balance_deposits(state: BeaconState) -> None:
if processed_amount + deposit.amount > available_for_processing:
break
# Deposit fits in the churn, process it. Increase balance and consume churn.
else:
else:
increase_balance(state, deposit.index, deposit.amount)
processed_amount += deposit.amount
# Regardless of how the deposit was handled, we move on in the queue.
Expand Down
5 changes: 3 additions & 2 deletions specs/electra/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ The following validations are added:

##### `beacon_attestation_{subnet_id}`

The topic is updated to propagate `SingleAttestation` objects.

The following convenience variables are re-defined
- `index = get_committee_indices(attestation.committee_bits)[0]`
- `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`

0 comments on commit 0b95012

Please sign in to comment.