-
Notifications
You must be signed in to change notification settings - Fork 180
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
[EN] Fix uploader missing events in block data uploaded to GCP #4562
[EN] Fix uploader missing events in block data uploaded to GCP #4562
Conversation
Previously, only last event is included in block data (repeated n times). This commit fixes the bug and includes all events.
eventsList := computationResult.AllEvents() | ||
events := make([]*flow.Event, len(eventsList)) | ||
for i := 0; i < len(eventsList); i++ { | ||
events[i] = &eventsList[i] | ||
} | ||
|
||
trieUpdates := make( |
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.
would this be affected as well?
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.
No, that code block avoids the problem and is unaffected by the bug. Also the unit test improved by this PR checks for the problem so tests won't pass anymore if that code is affected by the bug.
The bug in the old code is caused by reusing variable returned by range
which is a per-loop variable (it is not a per-iteration variable). So &variable would point to same variable each iteration. Each iteration was just appending the same variable's address to events
.
events := make([]*flow.Event, 0)
for _, e := range computationResult.AllEvents() {
events = append(events, &e) // BUG: same address appended each iteration.
}
All elements of events
is the same address of the same e
when loop finishes.
FVM Benchstat comparisonThis branch with compared with the base branch onflow:master commit 72b4db9 The command Collapsed results for better readability
|
Codecov Report
@@ Coverage Diff @@
## master #4562 +/- ##
==========================================
- Coverage 56.25% 54.45% -1.81%
==========================================
Files 653 914 +261
Lines 64699 85200 +20501
==========================================
+ Hits 36396 46392 +9996
- Misses 25362 35219 +9857
- Partials 2941 3589 +648
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Thanks for fixing this
Closes #4558
Problem
The uploader in
engine/execution/ingestion/uploader/
is only uploading the last event instead of all events.The problem is caused by reusing variable returned by
range
which is a per-loop variable (it is not a per-iteration variable). Each iteration was just appending the same variable's address toevents
.When loop finishes, all elements of
events
is the same address of the samee
.Solution
This PR:
range
loop with an index-based loop.2023-07-17 EDIT: Added more details about the problem and fix because there was a question about it.