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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

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?

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...

s.OperationNotifier.OperationFeed().Send(&feed.Event{
Type: operation.SingleAttReceived,
Data: &operation.SingleAttReceivedData{
Attestation: singleAtt,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sending in a loop might not be OK, need to look at this

})
}
}
s.cfg.attestationNotifier.OperationFeed().Send(&feed.Event{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about pending att queue?

s.cfg.attestationNotifier.OperationFeed().Send(&feed.Event{
Type: operation.SingleAttReceived,
Data: &operation.SingleAttReceivedData{
Attestation: attToBroadcast,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, this should be singleAtt

s.cfg.attestationNotifier.OperationFeed().Send(&feed.Event{
Type: operation.UnaggregatedAttReceived,
Data: &operation.UnAggregatedAttReceivedData{
Attestation: attToBroadcast,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, this should be att

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