-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat: serve forest CAR file as Blockstore #3365
Conversation
990732f
to
f434632
Compare
src/daemon/mod.rs
Outdated
@@ -709,14 +708,168 @@ fn create_password(prompt: &str) -> std::io::Result<String> { | |||
.interact_on(&term) | |||
} | |||
|
|||
pub async fn open_forest_car_union_db( |
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'd try to not bloat this file any further, it's already quite big. Maybe let's have a dedicated one?
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.
Moved to db_util.rs
src/daemon/mod.rs
Outdated
@@ -709,14 +708,168 @@ fn create_password(prompt: &str) -> std::io::Result<String> { | |||
.interact_on(&term) | |||
} | |||
|
|||
pub async fn open_forest_car_union_db( |
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.
Is this method unit-tested?
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.
test_prepare_and_open_forest_car_union_db
added
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.
And then removed, as this function no longer exists
src/daemon/mod.rs
Outdated
@@ -695,14 +694,170 @@ fn create_password(prompt: &str) -> std::io::Result<String> { | |||
.interact_on(&term) | |||
} | |||
|
|||
pub async fn open_forest_car_union_db( |
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 what this function is supposed to do. It appears that it does several unrelated things (like opening the current database AND handling snapshot importing). Could you write some documentation for it?
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.
In the current implementation, to avoid creating a wrapper type of Mutex<ManyCar>
that does not require &mut self
for APIs like fn read_only
, snapshot import is moved to before DB initialization, thus any functions that require a mutable ManyCar
is moved into this function(snapshot import, auto download snapshot).
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.
Doc added
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.
This PR contains a lot of changes that I need help to understand. Let's hold off merging this until the code is well-documented and intuitive.
Co-authored-by: David Himmelstrup <david.himmelstrup@chainsafe.io>
8657b05
to
8e5b137
Compare
src/daemon/mod.rs
Outdated
.context("Failed miserably while importing chain from snapshot")?; | ||
info!("Imported snapshot in: {}s", stopwatch.elapsed().as_secs()); | ||
.await?; | ||
consume_snapshot_file = true; |
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 need to set this flag as true. All downloaded files are always consumed.
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.
Removed
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.
db_util.rs
can be refactored away, but let's leave that for another PR.
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.
Do we have good coverage for this feature? E.g., scenarios with multiple CAR files?
src/cli_shared/snapshot.rs
Outdated
RetryArgs { | ||
timeout: None, | ||
max_retries: Some(3), | ||
delay: Some(Duration::from_secs(60)), |
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.
Do we want to have it somehow parametrized?
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 feel it's better to not ask the function caller to decide these parameters, for simplicity. How about changing it to
RetryArgs {
timeout: None,
..Default::default()
}
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.
Sounds good
src/cli_shared/snapshot.rs
Outdated
} | ||
|
||
pub async fn download_file_with_retry( | ||
url: Url, |
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.
Does it need to be owned?
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.
Not here, fixed
src/daemon/mod.rs
Outdated
// Import chain if needed | ||
if !opts.skip_load.unwrap_or_default() { | ||
if let Some(path) = &config.client.snapshot_path { | ||
// TODO: respect `--consume-snapshot` CLI option once it's implemented |
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.
do we have a tracking issue for this?
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.
Yes it's part of #3334
Add flag --consume-snapshot. It should do the same as --import-snapshot, but it'll move or delete the snapshot.
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.
let's have the link in the comment
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.
Done
@LesnyRumcajs I think CI tests should have covered most of the important scenarios. As for multiple CAR, it should have been covered by |
It wouldn't hurt to have such integration test. Another thing that may be interesting to test (if I understand the properties of this feature correctly) is to add an artificially crafted CAR with a single entry (that would normally not exist in the current blockchain) and see if we can retrieve it via e.g., |
@LesnyRumcajs How about loading |
d1c5c0a
to
8d6e339
Compare
@LesnyRumcajs |
Summary of changes
As part of #3334
Changes introduced in this pull request:
Running on mainnet on a DO droplet for ~1 week, everything including GC seems to work fine.
(With the Mmap change in #3414 GC time reduces by ~50%)
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist