-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: add cli download
to download public node snapshots
#13598
base: main
Are you sure you want to change the base?
feat: add cli download
to download public node snapshots
#13598
Conversation
CodSpeed Performance ReportMerging #13598 will not alter performanceComparing Summary
|
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 also maybe add a list of pre-set snapshot URLs so that the user doesn't need to find the URL themselves? And we can default to one of them, while the --help
menu shows alternatives/fallbacks?
What would you advise me to be able to fetch the same block height they are using in their url ? @matias-gonz @joshieDo My aim is to build a default "dynamic" url with the corresponding block height with this pattern : |
println!("Starting snapshot download for chain: {:?}", self.chain.chain()); | ||
println!("Target directory: {:?}", data_dir.data_dir()); | ||
println!("Source URL: {}", self.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.
We should use info!
instead
pub async fn execute<N>(self) -> Result<()> { | ||
let data_dir = self.datadir.resolve_datadir(self.chain.chain()); | ||
let snapshot_path = data_dir.data_dir().join(SNAPSHOT_FILE); | ||
fs::create_dir_all(&data_dir).await?; |
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.
std::fs instead of tokio::fs
let mut response = client.get(url).send().await?.error_for_status()?; | ||
|
||
let total_size = response.content_length().unwrap_or(0); | ||
let mut file = fs::File::create(&target_path).await?; |
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 there a reason for using tokio::fs::File
here ?
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.
Snapshots can be quite big (>2TB with an archival node).
The current PR would mean that we'd need double that space, since we're downloading everything first and then decompressing. Ideally we'd pipe what we download straight into the decompressing stage.
Basically replicating the following behaviour:
wget -O - https://downloads.merkle.io/reth-2025-01-06.tar.lz4 | tar -I lz4 -xvf -
Regarding merkle url, it's possible to find the latest archive with the following link: https://downloads.merkle.io/latest.txt |
Thanks, I've added this option |
Closes #13469.
Example of use :