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

Update Beacon API events to Electra #14855

Merged
merged 7 commits into from
Feb 3, 2025
Merged

Update Beacon API events to Electra #14855

merged 7 commits into from
Feb 3, 2025

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Jan 31, 2025

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Beacon API event support for SingleAttestation and SignedAggregateAttestationAndProofElectra

Acknowledgements

@rkapka rkapka requested a review from a team as a code owner January 31, 2025 18:47
@rkapka rkapka added API Api related tasks Electra electra hardfork labels Jan 31, 2025
@@ -170,24 +167,23 @@ func (vs *Server) proposeAtt(
return nil, status.Errorf(codes.Internal, "Could not get attestation root: %v", err)
}

var singleAtt *ethpb.SingleAttestation
Copy link
Contributor Author

@rkapka rkapka Jan 31, 2025

Choose a reason for hiding this comment

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

There is no need for this variable anymore. It was used so that we can broadcast a single attestation but send an Electra attestation through the feed. But we can safely send a single attestation because the only consumers are the monitor tool and API which know how to handle single attestations.

@@ -320,6 +320,13 @@ func (s *Server) handleAttestationsElectra(
}

for i, singleAtt := range validAttestations {
s.OperationNotifier.OperationFeed().Send(&feed.Event{
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we need to move this?

Copy link
Contributor Author

@rkapka rkapka Jan 31, 2025

Choose a reason for hiding this comment

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

So that we send a single attestation and not an Electra one. Previously we were sending att where att := singleAtt.ToAttestationElectra(committee)

@@ -139,8 +139,9 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(ctx context.Context, p
return validationRes, err
}

var singleAtt *eth.SingleAttestation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In contrast to the code in beacon-chain/rpc/prysm/v1alpha1/validator/attester.go, here we need the variable because att becomes the Electra attestation (see line 148). It is necessary to convert before calling validateUnaggregatedAttWithState

case operation.SingleAttReceived:
data, ok := e.Data.(*operation.SingleAttReceivedData)
if !ok {
log.Error("Event feed data is not of type *operation.SingleAttReceivedData")
Copy link
Contributor

Choose a reason for hiding this comment

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

i wonder why we don't print the Type of the data here for old ones, maybe that would be useful

Copy link
Contributor

Choose a reason for hiding this comment

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

is it because we already do that once in the marshal reader?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure you are looking at the correct file? I don't see any marshal reader in the monitor

Copy link
Contributor

Choose a reason for hiding this comment

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

oops then maybe we should print the type somewhere.

att := structs.AttFromConsensus(att)
return jsonMarshalReader(eventName, att)
}, nil
case *eth.AttestationElectra:
Copy link
Contributor

Choose a reason for hiding this comment

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

shoot this must have been missed...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change in beacon-chain/sync/validate_aggregate_proof.go had to be introduced for this to have any effect anyway

@@ -433,6 +433,15 @@ func (a *AttestationElectra) ToConsensus() (*eth.AttestationElectra, error) {
}, nil
}

func SingleAttFromConsensus(a *eth.SingleAttestation) *SingleAttestation {
Copy link
Contributor

Choose a reason for hiding this comment

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

not a comment here but something i forgot why we did it, why do we not check if a.Data is not nil? do we do that somewhere else? i forgot.

att := structs.AttFromConsensus(v.Attestation.Aggregate)
return jsonMarshalReader(eventName, att)
}, nil
switch att := v.Attestation.AggregateVal().(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would this ever panic? v.Attestation being nil?

@rkapka rkapka force-pushed the electra-events-api branch from 8d9c78b to 1006d25 Compare February 3, 2025 15:54
@rkapka rkapka enabled auto-merge February 3, 2025 16:05
@rkapka rkapka added this pull request to the merge queue Feb 3, 2025
Merged via the queue into develop with commit 177769a Feb 3, 2025
17 checks passed
@rkapka rkapka deleted the electra-events-api branch February 3, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants