Skip to content

feat: implement EIP-7549 - #6689

Merged
g11tech merged 13 commits into
electra-forkfrom
nc/7549
May 8, 2024
Merged

feat: implement EIP-7549#6689
g11tech merged 13 commits into
electra-forkfrom
nc/7549

Conversation

@ensi321

@ensi321 ensi321 commented Apr 19, 2024

Copy link
Copy Markdown
Member

NOTE FOR REVIEWERS:

Description

General:

  • Add containers & presets
  • Retrieve field values from serialized electra.attestations

Beacon node:

  • Modify processAttestations
  • Update attesting indices parsing from electra.Attestation

p2p:

  • Handle and publish new format of beacon_aggregate_and_proof and beacon_attestation
  • New validation rule

Validator:

  • Use MAX_ATTESTER_SLASHINGS_ELECTRA limit when constructing block body
  • Sign electra.attestations and electra.aggregateAndProof
  • Come up with new algo to get electra.attestations for block body in AggregatedAttestationPool
  • Create valid attestation and aggregate when attesting/aggregating

Misc but important:

@ensi321 ensi321 added the status-do-not-merge Merging this issue will break the build. Do not merge! label Apr 19, 2024
Comment thread packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts Outdated
@ensi321
ensi321 marked this pull request as ready for review May 7, 2024 19:09
@ensi321
ensi321 requested a review from a team as a code owner May 7, 2024 19:09
ensi321 and others added 13 commits May 7, 2024 22:13
* 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)) {

Copy link
Copy Markdown
Member

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (attData.index === 0) {
if (attData.index !== 0) {

@twoeths twoeths May 8, 2024

Copy link
Copy Markdown
Member

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

Copy link
Copy Markdown
Member

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


/** 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

Copy link
Copy Markdown
Member

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),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {

Copy link
Copy Markdown
Member

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

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

@g11tech g11tech left a comment

Copy link
Copy Markdown
Contributor

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

@g11tech
g11tech merged commit 838add9 into electra-fork May 8, 2024
@g11tech
g11tech deleted the nc/7549 branch May 8, 2024 11:00
@ensi321 ensi321 removed the status-do-not-merge Merging this issue will break the build. Do not merge! label May 8, 2024
g11tech pushed a commit that referenced this pull request May 24, 2024
* 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>
g11tech pushed a commit to g11tech/lodestar that referenced this pull request Jun 19, 2024
* 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>
g11tech added a commit that referenced this pull request Jun 25, 2024
* 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>
g11tech added a commit that referenced this pull request Jun 25, 2024
* 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>
g11tech added a commit that referenced this pull request Jul 1, 2024
* 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>
g11tech added a commit that referenced this pull request Jul 30, 2024
* 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>
g11tech added a commit that referenced this pull request Jul 31, 2024
* 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>
g11tech added a commit that referenced this pull request Aug 2, 2024
* 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>
g11tech added a commit that referenced this pull request Aug 9, 2024
* 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>
g11tech added a commit that referenced this pull request Aug 9, 2024
* 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>
g11tech added a commit that referenced this pull request Aug 23, 2024
* 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>
g11tech added a commit that referenced this pull request Aug 27, 2024
* 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>
philknows pushed a commit that referenced this pull request Sep 3, 2024
* 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>
@wemeetagain

Copy link
Copy Markdown
Member

馃帀 This PR is included in v1.22.0 馃帀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants