Skip to content
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: get attestations for electra block #6732

Merged
merged 6 commits into from
May 7, 2024

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented May 4, 2024

Motivation

  • Implement getAttestationsForBlock() for electra

Description

  • Group attestations by AttData hex first because different committees could have the same AttestationData
  • Implement on-chain aggregation for electra when producing blocks

part of #6689

cc @ensi321

@twoeths twoeths marked this pull request as ready for review May 4, 2024 08:49
@twoeths twoeths requested a review from a team as a code owner May 4, 2024 08:49
@ensi321 ensi321 mentioned this pull request May 4, 2024
31 tasks
@ensi321 ensi321 force-pushed the tuyen/eip_7549_getAttestationsForBlock branch from 9ceeac9 to 0df33bf Compare May 6, 2024 14:59
Copy link
Contributor

@ensi321 ensi321 left a comment

Choose a reason for hiding this comment

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

Minor comment. Good to go when they are addressed 🙂
Learned a lot when reviewing thanks

*/
getAttestationsForBlock(
getAttestationsForBlockPreElectra(
Copy link
Contributor

Choose a reason for hiding this comment

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

Return type of getAttestationsForBlockPreElectra() should be phase0.Attestation[]

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

fork: ForkName,
forkChoice: IForkChoice,
state: CachedBeaconStateAllForks
): allForks.Attestation[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can safely define the return type as electra.Attestation[]

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

// These properties should not change after being validate in gossip
// IF they have to be validated, do it only with one attestation per group since same data
// The committeeCountPerSlot can be precomputed once per slot
// for (const [i, {attestation, notSeenAttesterCount}] of attestationGroup
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line of comment necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

let the comment be there for now, later cleanups can alwayss happen

if (attestationNonParticipation !== undefined) {
const {attestation} = attestationNonParticipation;
committeeBits.set(committeeIndex, true);
aggregationBits = [...aggregationBits, ...attestation.aggregationBits.toBoolArray()];
Copy link
Contributor

Choose a reason for hiding this comment

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

Chain up aggregationBits by using toBoolArray() and later do fromBoolArray() seems like a hack. Looks good for now but this chain up operation should ideally be provided by ssz library

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm like a concat op

);
const aggAttestation = {
...attestationSeed,
// aggregationBits: BitArray.fromBoolArray(aggregationBitsArr[i]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Obsolete comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@ensi321 ensi321 merged commit 0a58616 into nc/7549 May 7, 2024
13 of 17 checks passed
@ensi321 ensi321 deleted the tuyen/eip_7549_getAttestationsForBlock branch May 7, 2024 18:42
@ensi321 ensi321 mentioned this pull request May 7, 2024
ensi321 added a commit that referenced this pull request May 7, 2024
* 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>
g11tech pushed a commit that referenced this pull request May 8, 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>
ensi321 added a commit that referenced this pull request May 8, 2024
* 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>
ensi321 added a commit that referenced this pull request May 8, 2024
* initial commit

* Update gossip validation

* Update attestation gossip validation

* aggregateAndProof validation

* Extend spec runner to be more flexible

* Add missing state attributes for electra

* Fix ss data types for electra spec

* Make the spec runner more flexible

* Fix the bug in process attestation

* Update the sepc test version

* clean up

* 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

* Fix the build erros

* Extend spec runner to be more flexible

* Add missing state attributes for electra

* Fix ss data types for electra spec

* Make the spec runner more flexible

* Fix the bug in process attestation

* Update the sepc test version

* Fix rebase issue

* Update committee index count check

---------

Co-authored-by: NC <adrninistrator1@protonmail.com>
Co-authored-by: Navie Chan <naviechan@gmail.com>
Co-authored-by: tuyennhv <tuyen@chainsafe.io>
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 that referenced this pull request May 24, 2024
* initial commit

* Update gossip validation

* Update attestation gossip validation

* aggregateAndProof validation

* Extend spec runner to be more flexible

* Add missing state attributes for electra

* Fix ss data types for electra spec

* Make the spec runner more flexible

* Fix the bug in process attestation

* Update the sepc test version

* clean up

* 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

* Fix the build erros

* Extend spec runner to be more flexible

* Add missing state attributes for electra

* Fix ss data types for electra spec

* Make the spec runner more flexible

* Fix the bug in process attestation

* Update the sepc test version

* Fix rebase issue

* Update committee index count check

---------

Co-authored-by: NC <adrninistrator1@protonmail.com>
Co-authored-by: Navie Chan <naviechan@gmail.com>
Co-authored-by: tuyennhv <tuyen@chainsafe.io>
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.

None yet

3 participants