-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add GetAggregateAttestation V2 endpoint version #6511
Conversation
https://github.com/status-im/nimbus-eth2/actions/runs/10667055348/job/29568268145
running |
var res: Opt[electra.Attestation] | ||
for _, entry in pool.electraCandidates[candidateIdx.get].mpairs(): | ||
if entry.data.index != committeeIndex.distinctBase: | ||
continue |
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.
The point of the Electra changes is that attestations across committees can be aggregated.
https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/phase0/validator.md#construct-aggregate (phase 0, i.e. pre-Electra) states that:
Construct aggregate
If the validator is selected to aggregate (
is_aggregator()
), they construct an aggregate attestation via the following.Collect
attestations
seen via gossip during theslot
that have an equivalentattestation_data
to that constructed by the validator. Iflen(attestations) > 0
, create anaggregate_attestation: Attestation
with the following fields.Data
Set
aggregate_attestation.data = attestation_data
whereattestation_data
is theAttestationData
object that is the same for each individual attestation being aggregated.Aggregation bits
Let
aggregate_attestation.aggregation_bits
be aBitlist[MAX_VALIDATORS_PER_COMMITTEE]
of lengthlen(committee)
, where each bit set from each individual attestation is set to0b1
.
But the index
field of https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/phase0/beacon-chain.md#attestationdata is the committee index, until Electra. So this condition means that aggregation cannot happen across committees pre-Electra.
https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/electra/validator.md#construct-attestation changes this:
Construct attestation
- Set
attestation_data.index = 0
.- Let
attestation.aggregation_bits
be aBitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]
of lengthlen(committee)
, where the bit of the index of the validator in thecommittee
is set to0b1
.- Let
attestation.committee_bits
be aBitvector[MAX_COMMITTEES_PER_SLOT]
, where the bit at the index associated with the validator's committee is set to0b1
.Note: Calling
get_attesting_indices(state, attestation)
should return a list of length equal to 1, containingvalidator_index
.
And the procedure for https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/electra/validator.md#attestation-aggregation similarly allows cross-committee index-aggregation.
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.
Yes, Electra changes will allow cross committee index-aggregationss, however, the new getAgregatedAttestationV2 endpoint version is only interested in attestations in its corresponding committee(*) (previous version, could aggregate attestations from multiple committees since committee_index is not in its params, and that 's not the objective wanted for the API according to the spec).
Also, and more important, we are still using the data.index field from phase0 (maybe as "transition/temp" structure while we still have 2 attestations pools):
- template addAttToPool on _proc addAttestation uses data.index field to save the index obtained from get_committee_index_one
- toElectraAttestation recovers this index and saves it on committee_bits while building the final electra aggregated attestation
This particular conditional statement in the code is to achieve the objective defined in (*) given the code particularites referred before.
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.
Oh, indeed.
Added new version (v2) of GetAggregateAttestation endpoint to support EIP-7549.
spec: ethereum/beacon-APIs#447