-
Notifications
You must be signed in to change notification settings - Fork 1.3k
throw 503 error when submit attestation and sync committee are called on syncing node + align changes to gRPC #16152
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4bb1da4
init
james-prysm d06385f
putting saves in own goroutine like gRPC
james-prysm dbb0400
wrapping attestation cache add as well
james-prysm 0c640c0
fixing tests
james-prysm cde779c
change log
james-prysm 9f58a91
Merge branch 'develop' into align-atter-pool-apis
james-prysm 847ec22
updating changelog
james-prysm 8261fcc
radek's feedback
james-prysm 17a6779
removed unused variable
james-prysm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,6 +130,10 @@ func (s *Server) SubmitAttestationsV2(w http.ResponseWriter, r *http.Request) { | |
| ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitAttestationsV2") | ||
| defer span.End() | ||
|
|
||
| if shared.IsSyncing(ctx, w, s.SyncChecker, s.HeadFetcher, s.TimeFetcher, s.OptimisticModeFetcher) { | ||
| return | ||
| } | ||
|
|
||
| versionHeader := r.Header.Get(api.VersionHeader) | ||
| if versionHeader == "" { | ||
| httputil.HandleError(w, api.VersionHeader+" header is required", http.StatusBadRequest) | ||
|
|
@@ -238,22 +242,14 @@ func (s *Server) handleAttestationsElectra( | |
| }, | ||
| }) | ||
|
|
||
| targetState, err := s.AttestationStateFetcher.AttestationTargetState(ctx, singleAtt.Data.Target) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrap(err, "could not get target state for attestation") | ||
| } | ||
| committee, err := corehelpers.BeaconCommitteeFromState(ctx, targetState, singleAtt.Data.Slot, singleAtt.CommitteeId) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrap(err, "could not get committee for attestation") | ||
| } | ||
| att := singleAtt.ToAttestationElectra(committee) | ||
|
|
||
| wantedEpoch := slots.ToEpoch(att.Data.Slot) | ||
| // Broadcast first using CommitteeId directly (fast path) | ||
| // This matches gRPC behavior and avoids blocking on state fetching | ||
| wantedEpoch := slots.ToEpoch(singleAtt.Data.Slot) | ||
| vals, err := s.HeadFetcher.HeadValidatorsIndices(ctx, wantedEpoch) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrap(err, "could not get head validator indices") | ||
| } | ||
| subnet := corehelpers.ComputeSubnetFromCommitteeAndSlot(uint64(len(vals)), att.GetCommitteeIndex(), att.Data.Slot) | ||
| subnet := corehelpers.ComputeSubnetFromCommitteeAndSlot(uint64(len(vals)), singleAtt.CommitteeId, singleAtt.Data.Slot) | ||
| if err = s.Broadcaster.BroadcastAttestation(ctx, subnet, singleAtt); err != nil { | ||
| failedBroadcasts = append(failedBroadcasts, &server.IndexedError{ | ||
| Index: i, | ||
|
|
@@ -264,17 +260,35 @@ func (s *Server) handleAttestationsElectra( | |
| } | ||
| continue | ||
| } | ||
| } | ||
|
|
||
| if features.Get().EnableExperimentalAttestationPool { | ||
| if err = s.AttestationCache.Add(att); err != nil { | ||
| log.WithError(err).Error("Could not save attestation") | ||
| // Save to pool after broadcast (slow path - requires state fetching) | ||
| // Run in goroutine to avoid blocking the HTTP response | ||
| go func() { | ||
| for _, singleAtt := range validAttestations { | ||
| targetState, err := s.AttestationStateFetcher.AttestationTargetState(context.Background(), singleAtt.Data.Target) | ||
| if err != nil { | ||
| log.WithError(err).Error("Could not get target state for attestation") | ||
| continue | ||
| } | ||
| } else { | ||
| if err = s.AttestationsPool.SaveUnaggregatedAttestation(att); err != nil { | ||
| log.WithError(err).Error("Could not save attestation") | ||
| committee, err := corehelpers.BeaconCommitteeFromState(context.Background(), targetState, singleAtt.Data.Slot, singleAtt.CommitteeId) | ||
| if err != nil { | ||
| log.WithError(err).Error("Could not get committee for attestation") | ||
| continue | ||
| } | ||
| att := singleAtt.ToAttestationElectra(committee) | ||
|
|
||
| if features.Get().EnableExperimentalAttestationPool { | ||
| if err = s.AttestationCache.Add(att); err != nil { | ||
| log.WithError(err).Error("Could not save attestation") | ||
| } | ||
| } else { | ||
| if err = s.AttestationsPool.SaveUnaggregatedAttestation(att); err != nil { | ||
| log.WithError(err).Error("Could not save attestation") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }() | ||
|
|
||
| if len(failedBroadcasts) > 0 { | ||
| log.WithFields(logrus.Fields{ | ||
|
|
@@ -470,6 +484,10 @@ func (s *Server) SubmitSyncCommitteeSignatures(w http.ResponseWriter, r *http.Re | |
| ctx, span := trace.StartSpan(r.Context(), "beacon.SubmitPoolSyncCommitteeSignatures") | ||
| defer span.End() | ||
|
|
||
| if shared.IsSyncing(ctx, w, s.SyncChecker, s.HeadFetcher, s.TimeFetcher, s.OptimisticModeFetcher) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should i break this out? this is for /eth/v1/beacon/pool/sync_committees
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the sync commitee cache should also be checked here |
||
| return | ||
| } | ||
|
|
||
| var req structs.SubmitSyncCommitteeSignaturesRequest | ||
| err := json.NewDecoder(r.Body).Decode(&req.Data) | ||
| switch { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed context to background so that it doesn't get context deadlined