-
Notifications
You must be signed in to change notification settings - Fork 988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate type for onchain attestation aggregates #3787
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,6 @@ The specification of these changes continues in the same format as the network s | |
- [Modifications in Electra](#modifications-in-electra) | ||
- [The gossip domain: gossipsub](#the-gossip-domain-gossipsub) | ||
- [Topics and messages](#topics-and-messages) | ||
- [Global topics](#global-topics) | ||
- [`beacon_aggregate_and_proof`](#beacon_aggregate_and_proof) | ||
- [`beacon_attestation_{subnet_id}`](#beacon_attestation_subnet_id) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
@@ -32,28 +29,6 @@ Topics follow the same specification as in prior upgrades. | |
|
||
The `beacon_block` topic is modified to also support Electra blocks. | ||
|
||
The `beacon_aggregate_and_proof` and `beacon_attestation_{subnet_id}` topics are modified to support the gossip of the new attestation type. | ||
|
||
The specification around the creation, validation, and dissemination of messages has not changed from the Capella document unless explicitly noted here. | ||
|
||
The derivation of the `message-id` remains stable. | ||
|
||
#### Global topics | ||
|
||
##### `beacon_aggregate_and_proof` | ||
|
||
The following convenience variables are re-defined | ||
- `index = get_committee_indices(aggregate.committee_bits)[0]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
The following validations are added: | ||
* [REJECT] `len(committee_indices) == 1`, where `committee_indices = get_committee_indices(aggregate)`. | ||
* [REJECT] `aggregate.data.index == 0` | ||
|
||
##### `beacon_attestation_{subnet_id}` | ||
|
||
The following convenience variables are re-defined | ||
- `index = get_committee_indices(attestation.committee_bits)[0]` | ||
|
||
The following validations are added: | ||
* [REJECT] `len(committee_indices) == 1`, where `committee_indices = get_committee_indices(attestation)`. | ||
* [REJECT] `attestation.data.index == 0` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the key thing of EIP-7549 is to have |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,7 @@ | |
- [Deposits](#deposits) | ||
- [Execution payload](#execution-payload) | ||
- [Attesting](#attesting) | ||
- [Construct attestation](#construct-attestation) | ||
- [Attestation aggregation](#attestation-aggregation) | ||
- [Construct aggregate](#construct-aggregate) | ||
- [Modified aggregate signature](#modified-aggregate-signature) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
@@ -72,14 +70,14 @@ Changed the max attester slashings size to `MAX_ATTESTER_SLASHINGS_ELECTRA`. | |
Changed the max attestations size to `MAX_ATTESTATIONS_ELECTRA`. | ||
|
||
The network attestation aggregates contain only the assigned committee attestations. | ||
Attestation aggregates received by the block proposer from the committee aggregators with disjoint `committee_bits` sets and equal `AttestationData` SHOULD be consolidated into a single `Attestation` object. | ||
The proposer should run the following function to construct an on chain final aggregate form a list of network aggregates with equal `AttestationData`: | ||
Attestation aggregates received by the block proposer from the committee aggregators with disjoint `committee_bits` sets and equal signing `AttestationData` SHOULD be consolidated into a single `Attestation` object. | ||
mkalinin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The proposer should run the following function to construct an on chain final aggregate form a list of network aggregates with equal signing `AttestationData`: | ||
|
||
```python | ||
def compute_on_chain_aggregate(network_aggregates: Sequence[Attestation]) -> Attestation: | ||
def compute_on_chain_aggregate(network_aggregates: Sequence[Attestation]) -> OnchainAttestation: | ||
aggregates = sorted(network_aggregates, key=lambda a: get_committee_indices(a.committee_bits)[0]) | ||
|
||
data = aggregates[0].data | ||
data = compute_signing_attestation_data(aggregates[0].data) | ||
aggregation_bits = Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]() | ||
for a in aggregates: | ||
for b in a.aggregation_bits: | ||
|
@@ -91,7 +89,7 @@ def compute_on_chain_aggregate(network_aggregates: Sequence[Attestation]) -> Att | |
committee_flags = [(index in committee_indices) for index in range(0, MAX_COMMITTEES_PER_SLOT)] | ||
committee_bits = Bitvector[MAX_COMMITTEES_PER_SLOT](committee_flags) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
return Attestation( | ||
return OnchainAttestation( | ||
aggregation_bits=aggregation_bits, | ||
data=data, | ||
committee_bits=committee_bits, | ||
|
@@ -150,18 +148,16 @@ def prepare_execution_payload(state: BeaconState, | |
|
||
## Attesting | ||
|
||
### Construct attestation | ||
##### Modified aggregate signature | ||
|
||
- 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`. | ||
*Note:* The `get_attestation_sinagure` is modified to use signing attestation data. | ||
mkalinin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
*Note*: Calling `get_attesting_indices(state, attestation)` should return a list of length equal to 1, containing `validator_index`. | ||
Set `attestation.signature = attestation_signature` where `attestation_signature` is obtained from: | ||
|
||
## 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. | ||
```python | ||
def get_attestation_signature(state: BeaconState, attestation_data: AttestationData, privkey: int) -> BLSSignature: | ||
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, attestation_data.target.epoch) | ||
signing_data = compute_signing_attestation_data(attestation_data) | ||
signing_root = compute_signing_root(signing_data, domain) | ||
return bls.Sign(privkey, signing_root) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to be consistent with the current
Attestation
by havingcommittee_bits
to be after thesignature
field