-
Notifications
You must be signed in to change notification settings - Fork 2k
[PRIV-412] Add duplicate check for items in the pending queue #21437
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1034,16 +1034,24 @@ func (r *ReportingPlugin) ValidateObservation(ctx context.Context, seqNr uint64, | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| seen := map[string]bool{} | ||||||||||||||
| for _, i := range obs.PendingQueueItems { | ||||||||||||||
| bh, err := r.unmarshalBlob(i) | ||||||||||||||
| if err != nil { | ||||||||||||||
| return fmt.Errorf("could not unmarshal blob handle from observation pending queue item: %w", err) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| _, err = blobFetcher.FetchBlob(ctx, bh) | ||||||||||||||
| blob, err := blobFetcher.FetchBlob(ctx, bh) | ||||||||||||||
| if err != nil { | ||||||||||||||
|
Comment on lines
+1037
to
1045
|
||||||||||||||
| return fmt.Errorf("could not fetch blob for observation pending queue item: %w", err) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| sha := fmt.Sprintf("%x", sha256.Sum256(blob)) | ||||||||||||||
| if seen[sha] { | ||||||||||||||
| return errors.New("duplicate item found in pending queue item observation") | ||||||||||||||
| } | ||||||||||||||
| seen[sha] = true | ||||||||||||||
|
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return nil | ||||||||||||||
|
|
@@ -1312,6 +1320,7 @@ func (r *ReportingPlugin) stateTransitionPendingQueue(ctx context.Context, store | |||||||||||||
| oidsToIDs := map[uint8][]string{} // for debugging only | ||||||||||||||
| shaToItem := map[string]*vaultcommon.StoredPendingQueueItem{} | ||||||||||||||
| for oid, o := range obs { | ||||||||||||||
| shaSeenForOracle := map[string]bool{} | ||||||||||||||
| for _, pqi := range o.PendingQueueItems { | ||||||||||||||
| bh, err := r.unmarshalBlob(pqi) | ||||||||||||||
| if err != nil { | ||||||||||||||
|
|
@@ -1340,6 +1349,13 @@ func (r *ReportingPlugin) stateTransitionPendingQueue(ctx context.Context, store | |||||||||||||
| continue | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if shaSeenForOracle[sha] { | ||||||||||||||
| r.lggr.Warnw("duplicate sha found for oracle, skipping...") | ||||||||||||||
|
||||||||||||||
| r.lggr.Warnw("duplicate sha found for oracle, skipping...") | |
| r.lggr.Warnw("duplicate sha found for oracle, skipping...", | |
| "oracleID", oid, | |
| "sha", sha, | |
| "itemID", i.Id, | |
| ) |
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.
Seems like a good find.
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.
Perhaps also log the blob for which we saw this. So we can troubleshoot and see the raw request which was being duplicated.
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.
Can we also add a check on the total size of this obs.PendingQueueItems?
Don't want a bad oracle to send a too large number of items here.