-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
feat: implement EIP-7549 #6689
feat: implement EIP-7549 #6689
Conversation
packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts
Outdated
Show resolved
Hide resolved
* 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 <[email protected]>
const bitIndex = attestation.aggregationBits.getSingleTrueBit(); | ||
|
||
// Should never happen, attestations are verified against this exact condition before | ||
if (bitIndex === null) { | ||
throw Error("Invalid attestation not exactly one bit set"); | ||
} | ||
|
||
if ("committeeBits" in attestation && !("committeeBits" in aggregate)) { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (attData.index === 0) { | |
if (attData.index !== 0) { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
subnet: number; | ||
attDataRootHex: RootHex; | ||
}; | ||
|
||
export type AttestationOrBytes = ApiAttestation | GossipAttestation; | ||
|
||
/** 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 |
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.
remove TODO
?
return { | ||
aggregationBits: BitArray.fromSingleBit(duty.committeeLength, duty.validatorCommitteeIndex), | ||
data: attestationData, | ||
committeeBits: BitArray.fromSingleBit(duty.committeesAtSlot, duty.committeeIndex), |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ("committeeBits" in aggFast) { | |
return {...aggFast, signature: aggFast.signature.toBytes(PointFormat.compressed)}; |
@@ -48,4 +48,4 @@ export type SignedConsolidation = ValueOf<typeof ssz.SignedConsolidation>; | |||
|
|||
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>; |
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.
could we remove this diff? i think newlines got removed
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.
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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
* 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 <[email protected]> * Fix check-types * Address comments --------- Co-authored-by: Nazar Hussain <[email protected]> Co-authored-by: tuyennhv <[email protected]> Co-authored-by: gajinder <[email protected]>
🎉 This PR is included in v1.22.0 🎉 |
NOTE FOR REVIEWERS:
aggregatedAttestationPool.ts
andaggregatedAttestationPool.test.ts
have already been reviewed in feat: get attestations for electra block #6732. Feel free to skip themprocessAttestation()
andimportBlock
has 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_proof
andbeacon_attestation
Validator:
AggregatedAttestationPool
Misc but important:
AggregatedAttestationPool
to store new attestation formatAttestationPool
to aggregate electra.attestations