snapshot download enhancement (#17415)
1. Allow the validator bootstrap code to specify the minimal snapshot download speed. If the snapshot download speed is detected below that, a different RPC can be retried. The default is 10MB/sec. 2. To prevent spinning on a number of sub-optimal choices and not making progress, the abort/retry logic is implemented with the following safe guards: 2.1 at maximum we do this retry for 5 times -- this number is configurable with default 5. 2.2 if the download in one notification round (5 second) is more than 2%, do not do retry -- it is not as bad anyway. 2.3 if the remaining estimate time is less than 1 minutes, do not abort retry as it will be done quickly anyway. 2.4 We do this abort/retry logic only at the first notification to avoid wasting download efforts -- the reasoning is being opportunistic and too greedy may not achieve overall shorter download time. 3. The download_snapshot and download_file is modified with the option allowing caller to notified of download progress via a callback. This allows the business logic of retrying to the place it belongs.
This commit is contained in:
@ -4,7 +4,7 @@ use {
|
||||
crate_description, crate_name, crate_version, value_t, value_t_or_exit, values_t, App, Arg,
|
||||
},
|
||||
regex::Regex,
|
||||
solana_download_utils::download_file,
|
||||
solana_download_utils::{download_file, DownloadProgressRecord},
|
||||
solana_sdk::signature::{write_keypair_file, Keypair},
|
||||
std::{
|
||||
collections::HashMap,
|
||||
@ -112,7 +112,12 @@ fn install_if_missing(
|
||||
url.push_str(version);
|
||||
url.push('/');
|
||||
url.push_str(file.to_str().unwrap());
|
||||
download_file(&url.as_str(), &file, true)?;
|
||||
download_file(
|
||||
&url.as_str(),
|
||||
&file,
|
||||
true,
|
||||
&None::<fn(&DownloadProgressRecord) -> bool>,
|
||||
)?;
|
||||
fs::create_dir_all(&target_path).map_err(|err| err.to_string())?;
|
||||
let zip = File::open(&file).map_err(|err| err.to_string())?;
|
||||
let tar = BzDecoder::new(BufReader::new(zip));
|
||||
|
Reference in New Issue
Block a user