feat: implement EIP-7549 - #6689
Conversation
* feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com>
| throw Error("Invalid attestation not exactly one bit set"); | ||
| } | ||
|
|
||
| if ("committeeBits" in attestation && !("committeeBits" in aggregate)) { |
There was a problem hiding this comment.
use isElectraAttestation() util, same for below
| throw new AttestationError(GossipAction.REJECT, {code: AttestationErrorCode.NOT_EXACTLY_ONE_COMMITTEE_BIT_SET}); | ||
| } | ||
| // [REJECT] aggregate.data.index == 0 | ||
| if (attData.index === 0) { |
There was a problem hiding this comment.
| if (attData.index === 0) { | |
| if (attData.index !== 0) { |
There was a problem hiding this comment.
assert.equal should be more convenient
Edit: if (attData.index !== 0) { should be better since it throws gossip error to handle at upper level
| } | ||
|
|
||
| // [REJECT] aggregate.data.index == 0 | ||
| if (attData.index === 0) { |
There was a problem hiding this comment.
| if (attData.index === 0) { | |
| if (attData.index !== 0) { |
| throw Error("Attempt to aggregate electra attestation into phase0 attestation"); | ||
| } | ||
|
|
||
| if (!("committeeBits" in attestation) && "committeeBits" in aggregate) { |
There was a problem hiding this comment.
we don't need these validation unless we have to for the type assertion
in order to reach this code, attestation data should be the same hence the same type of attestation
|
|
||
| /** attestation from api */ | ||
| export type ApiAttestation = {attestation: phase0.Attestation; serializedData: null}; | ||
| export type ApiAttestation = {attestation: phase0.Attestation; serializedData: null}; // TODO Electra: add new attestation type |
| return { | ||
| aggregationBits: BitArray.fromSingleBit(duty.committeeLength, duty.validatorCommitteeIndex), | ||
| data: attestationData, | ||
| committeeBits: BitArray.fromSingleBit(duty.committeesAtSlot, duty.committeeIndex), |
There was a problem hiding this comment.
| committeeBits: BitArray.fromSingleBit(duty.committeesAtSlot, duty.committeeIndex), | |
| committeeBits: BitArray.fromSingleBit(MAX_COMMITTEES_PER_SLOT, duty.committeeIndex), |
| const attestationCommitteeIndex = attestation.committeeBits.getSingleTrueBit(); | ||
| const aggregateCommitteeIndex = (aggregate as AggregateFastElectra).committeeBits.getSingleTrueBit(); | ||
|
|
||
| if (attestationCommitteeIndex !== aggregateCommitteeIndex) { |
There was a problem hiding this comment.
now same attestation data could belong to different committee indices so we need to add 1 more level to our cache
implemented in #6744
| signature: aggFast.signature.toBytes(PointFormat.compressed), | ||
| }; | ||
| function fastToAttestation(aggFast: AggregateFast): allForks.Attestation { | ||
| if ("committeeBits" in aggFast) { |
There was a problem hiding this comment.
| if ("committeeBits" in aggFast) { | |
| return {...aggFast, signature: aggFast.signature.toBytes(PointFormat.compressed)}; |
| export type PendingBalanceDeposit = ValueOf<typeof ssz.PendingBalanceDeposit>; | ||
| export type PartialWithdrawal = ValueOf<typeof ssz.PartialWithdrawal>; | ||
| export type PendingConsolidation = ValueOf<typeof ssz.PendingConsolidation>; | ||
| export type PendingConsolidation = ValueOf<typeof ssz.PendingConsolidation>; No newline at end of file |
There was a problem hiding this comment.
could we remove this diff? i think newlines got removed
g11tech
left a comment
There was a problem hiding this comment.
merging the current work with electra
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (ChainSafe#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
* initial commit * lint * Add getAttestingIndices and update getIndexedAttestation * Update gossip validation * Update attestation gossip validation * aggregateAndProof validation * clean up * Validator * Misc * Fix the build erros * feat: get attestations for electra block (#6732) * feat: getAttestationsForBlock() for electra * chore: fix lint * fix: MAX_ATTESTATIONS_PER_GROUP_ELECTRA and address PR comments * chore: unit test aggregateConsolidation * Fix rebase mistake * Address my own comment :) --------- Co-authored-by: Navie Chan <naviechan@gmail.com> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: gajinder <develop@g11tech.io>
|
馃帀 This PR is included in v1.22.0 馃帀 |
NOTE FOR REVIEWERS:
aggregatedAttestationPool.tsandaggregatedAttestationPool.test.tshave already been reviewed in feat: get attestations for electra block聽#6732. Feel free to skip themprocessAttestation()andimportBlockhas been reviewed. Take the feedbacks in feat: beacon node process electra attestations EIP-7549 聽#6738 into account when reviewing.Description
General:
Beacon node:
p2p:
beacon_aggregate_and_proofandbeacon_attestationValidator:
AggregatedAttestationPoolMisc but important:
AggregatedAttestationPoolto store new attestation formatAttestationPoolto aggregate electra.attestations