-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Keep data in fails cases in sync service #2361
base: master
Are you sure you want to change the base?
Conversation
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.
I don't understand the import task well enough to approve right now. I need clarification on the following points:
- How do we ensure this cache doesn't grow forever? Is the
Import
task short-lived? While the import task launches short-lived streams, it seems like a long-living task to me. - How can we be sure we'll query exactly the same ranges as we have cached? Where is that invariant maintained.
Let me know if you want to jump on a call to chat about this, or just write if I'm missing something obvious here.
@netrome Thanks for taking the time to review this Regarding your interrogations : |
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.
So far looks good, I need to have a deeper look at the tests though.
Convert to draft because of big refacto. |
…rs and blocks mixed)
…r and added a bunch of tests
Co-authored-by: Rafał Chabowski <88321181+rafal-ch@users.noreply.github.com>
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.
Copilot reviewed 6 out of 10 changed files in this pull request and generated no suggestions.
Files not reviewed (4)
- crates/services/sync/src/import/test_helpers/pressure_peer_to_peer.rs: Evaluated as low risk
- crates/services/sync/src/import/tests.rs: Evaluated as low risk
- crates/services/sync/src/ports.rs: Evaluated as low risk
- CHANGELOG.md: Evaluated as low risk
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.
The change looks really good=)
crates/services/sync/src/import.rs
Outdated
} | ||
} | ||
BlockHeaderData::Cached(CachedDataBatch::None(_)) => { | ||
unreachable!() |
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.
While it is true, let's return an error and print a log that this place shouldn't be reachable
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.
I have added a log and I returned a malformed batch which is used as error in this whole process. I don't want to change the whole architecture of the module for this error. (the other solution is to panic like it's done here :
fuel-core/crates/services/sync/src/import.rs
Line 475 in 99135e3
.expect("We checked headers are not empty above"), |
@xgreenx Thanks for the kind comment and I have addressed all of your concerns some may still need some answers :) |
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.
Nice stuff! Some minor questions and comments from me, but overall looks good.
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.
Missed this previously, but saw the clippy error in CI regarding the arithmetic operation and want to ensure we avoid the array slicing as well since that can also panic.
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 the update 🙏
@xgreenx Why you prefer to make the check inside the loop instead of the split at the end to simplify the logic in the loop ? |
It is much easier to read. It is more performant, because the old implementation was doing |
Linked Issues/PRs
Closes #2357
Description
This pull request introduces a caching mechanism to the sync service to avoid redundant data fetching from the network. The most important changes include adding a cache module, modifying the
Import
struct to include a cache, and updating related methods to utilize this cache.Caching Mechanism:
crates/services/sync/src/import.rs
: Added a newcache
module and integrated it into theImport
struct. Updated methods to use the cache for fetching and storing headers and blocks.Test Updates:
This PR contains 50% of changes in the tests and addition of tests in the cache.
Checklist
Before requesting review