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

fix: select correct gossip type when publishing single attestation #7256

Merged
merged 2 commits into from
Nov 28, 2024

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Nov 28, 2024

Motivation

We are not selecting the correct type to serialize single attestation when publishing to gossip

Nov-28 09:00:03.241[api]             error: Error on submitPoolAttestations [0] slot=94, index=0 - Cannot read properties of undefined (reading 'bitLen')
TypeError: Cannot read properties of undefined (reading 'bitLen')
    at BitListType.value_serializedSize (/usr/app/node_modules/@chainsafe/ssz/src/type/bitList.ts:60:43)
    at ContainerType.value_serializedSize (/usr/app/node_modules/@chainsafe/ssz/src/type/container.ts:189:54)
    at ContainerType.serialize (/usr/app/node_modules/@chainsafe/ssz/src/type/abstract.ts:119:44)
    at Network.publishGossip (file:///usr/app/packages/beacon-node/src/network/network.ts:421:34)
    at Network.publishBeaconAttestation (file:///usr/app/packages/beacon-node/src/network/network.ts:333:17)
    at file:///usr/app/packages/beacon-node/src/api/impl/beacon/pool/index.ts:137:45
    at async Promise.all (index 0)
    at Object.submitPoolAttestationsV2 (file:///usr/app/packages/beacon-node/src/api/impl/beacon/pool/index.ts:99:7)
    at Object.<anonymous> (file:///usr/app/packages/api/src/utils/server/handler.ts:105:22)

Description

Select correct gossip type when publishing single attestation, instead of electra.Attestation, we need to use electra.SingleAttestation

@nflaig nflaig requested a review from a team as a code owner November 28, 2024 09:41
@@ -89,7 +89,7 @@ export function getGossipSSZType(topic: GossipTopic) {
case GossipType.beacon_aggregate_and_proof:
return sszTypesFor(topic.fork).SignedAggregateAndProof;
case GossipType.beacon_attestation:
return sszTypesFor(topic.fork).Attestation;
return isForkPostElectra(topic.fork) ? ssz.electra.SingleAttestation : ssz.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.

could also be return sszTypesFor(topic.fork).SingleAttestation;?

Copy link
Member Author

Choose a reason for hiding this comment

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

For this to work we would have to define SingleAttestation in phase0 types

[ForkName.phase0]: {...phase0},

Otherwise it does not exist in all forks

Copy link
Member Author

Choose a reason for hiding this comment

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

we can add it as an alias though

Copy link
Member Author

@nflaig nflaig Nov 28, 2024

Choose a reason for hiding this comment

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

I think the alias makes sense as it matches with what we did in types

SingleAttestation: phase0.Attestation;

Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 48.44%. Comparing base (1a74884) to head (72d3448).
Report is 1 commits behind head on devnet-5.

Additional details and impacted files
@@            Coverage Diff            @@
##           devnet-5    #7256   +/-   ##
=========================================
  Coverage     48.43%   48.44%           
=========================================
  Files           602      602           
  Lines         40320    40321    +1     
  Branches       2057     2057           
=========================================
+ Hits          19531    19532    +1     
  Misses        20751    20751           
  Partials         38       38           

Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

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

lgtm

@nflaig nflaig merged commit cfe6c89 into devnet-5 Nov 28, 2024
17 checks passed
@nflaig nflaig deleted the nflaig/fix-gossip-publish branch November 28, 2024 10:54
nflaig added a commit that referenced this pull request Nov 29, 2024
…7256)

* fix: select correct gossip type when publishing single attestation

* Add SingleAttestation as alias to phase0 ssz types
ensi321 pushed a commit that referenced this pull request Dec 14, 2024
…7256)

* fix: select correct gossip type when publishing single attestation

* Add SingleAttestation as alias to phase0 ssz types
ensi321 pushed a commit that referenced this pull request Dec 14, 2024
…7256)

* fix: select correct gossip type when publishing single attestation

* Add SingleAttestation as alias to phase0 ssz types
ensi321 pushed a commit that referenced this pull request Dec 17, 2024
…7256)

* fix: select correct gossip type when publishing single attestation

* Add SingleAttestation as alias to phase0 ssz types
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.

2 participants