-
Notifications
You must be signed in to change notification settings - Fork 13
Check data integrity for EVM events #529
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
Changes from 9 commits
1f60169
67855f0
75361ce
9666919
2be3802
8d6f49f
f0d4880
6ff9cb5
2b1ee91
76d544c
3c9ead3
deac76b
8f23141
89d918e
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 |
|---|---|---|
|
|
@@ -146,7 +146,16 @@ func (r *RPCSubscriber) subscribe(ctx context.Context, height uint64, opts ...ac | |
| return | ||
| } | ||
|
|
||
| events <- models.NewBlockEvents(blockEvents) | ||
| evts := models.NewBlockEvents(blockEvents) | ||
| if evts.Err != nil { | ||
|
Contributor
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. we should test this in the subscriber_test I think ti shouldn't be hard |
||
| r.logger.Warn().Err(err).Msgf( | ||
| "failed to parse EVM block events for Flow height: %d, retrying with gRPC API...", | ||
| blockEvents.Height, | ||
| ) | ||
| events <- r.fetchBlockEvents(ctx, blockEvents) | ||
|
Contributor
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. add a commnet something like:
Collaborator
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. Added in 76d544c |
||
| } else { | ||
| events <- models.NewBlockEvents(blockEvents) | ||
| } | ||
|
Comment on lines
+149
to
+161
This comment was marked as outdated.
Sorry, something went wrong. |
||
|
|
||
| case err, ok := <-errChan: | ||
| if !ok { | ||
|
|
@@ -252,3 +261,39 @@ func (r *RPCSubscriber) blocksFilter() flow.EventFilter { | |
| }, | ||
| } | ||
| } | ||
|
|
||
| func (r *RPCSubscriber) fetchBlockEvents( | ||
|
Contributor
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. add a comment explaining what this function does and how it is used for backup
Collaborator
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. Good point 👍 |
||
| ctx context.Context, | ||
| blockEvents flow.BlockEvents, | ||
| ) models.BlockEvents { | ||
| blkEvents := flow.BlockEvents{ | ||
| BlockID: blockEvents.BlockID, | ||
| Height: blockEvents.Height, | ||
| BlockTimestamp: blockEvents.BlockTimestamp, | ||
| } | ||
| for _, eventType := range r.blocksFilter().EventTypes { | ||
| recoveredEvents, err := r.client.GetEventsForHeightRange( | ||
| ctx, | ||
| eventType, | ||
| blockEvents.Height, | ||
| blockEvents.Height, | ||
| ) | ||
| if err != nil { | ||
| return models.NewBlockEventsError(err) | ||
| } | ||
|
|
||
| if len(recoveredEvents) != 1 { | ||
| return models.NewBlockEventsError( | ||
| fmt.Errorf( | ||
| "received %d but expected 1 event for height %d", | ||
| len(recoveredEvents), | ||
| blockEvents.Height, | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| blkEvents.Events = append(blkEvents.Events, recoveredEvents[0].Events...) | ||
| } | ||
|
|
||
| return models.NewBlockEvents(blkEvents) | ||
| } | ||
|
Comment on lines
+266
to
+309
Contributor
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. Review of The
Overall, the method is well-structured and addresses the primary concerns of error handling and data integrity. However, efficiency improvements could be considered if applicable.
Comment on lines
+265
to
+309
Contributor
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. Well-implemented error handling in The Suggestions:
Would you like a code snippet to implement these logging enhancements?
Comment on lines
+265
to
+309
This comment was marked as outdated.
Sorry, something went wrong. |
||
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.