diff --git a/Cargo.lock b/Cargo.lock index 7cf4d87df2..b8b734e8c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3507,7 +3507,6 @@ dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-clap-utils 0.21.0", "solana-client 0.21.0", "solana-config-program 0.21.0", diff --git a/install/Cargo.toml b/install/Cargo.toml index 19b1359183..53bc51f52c 100644 --- a/install/Cargo.toml +++ b/install/Cargo.toml @@ -26,7 +26,6 @@ reqwest = { version = "0.9.22", default-features = false, features = ["rustls-tl serde = "1.0.102" serde_derive = "1.0.102" serde_yaml = "0.8.11" -sha2 = "0.8.0" solana-clap-utils = { path = "../clap-utils", version = "0.21.0" } solana-client = { path = "../client", version = "0.21.0" } solana-config-program = { path = "../programs/config", version = "0.21.0" } diff --git a/install/src/command.rs b/install/src/command.rs index 255e6b5038..0b36f88756 100644 --- a/install/src/command.rs +++ b/install/src/command.rs @@ -1,22 +1,27 @@ -use crate::config::{Config, ExplicitRelease}; -use crate::stop_process::stop_process; -use crate::update_manifest::{SignedUpdateManifest, UpdateManifest}; +use crate::{ + config::{Config, ExplicitRelease}, + stop_process::stop_process, + update_manifest::{SignedUpdateManifest, UpdateManifest}, +}; use chrono::{Local, TimeZone}; use console::{style, Emoji}; use indicatif::{ProgressBar, ProgressStyle}; -use sha2::{Digest, Sha256}; use solana_client::rpc_client::RpcClient; use solana_config_program::{config_instruction, get_config_data}; -use solana_sdk::message::Message; -use solana_sdk::pubkey::Pubkey; -use solana_sdk::signature::{read_keypair_file, Keypair, KeypairUtil, Signable}; -use solana_sdk::transaction::Transaction; -use std::fs::{self, File}; -use std::io::{self, BufReader, Read}; -use std::path::{Path, PathBuf}; -use std::sync::mpsc; -use std::time::SystemTime; -use std::time::{Duration, Instant}; +use solana_sdk::{ + hash::{Hash, Hasher}, + message::Message, + pubkey::Pubkey, + signature::{read_keypair_file, Keypair, KeypairUtil, Signable}, + transaction::Transaction, +}; +use std::{ + fs::{self, File}, + io::{self, BufReader, Read}, + path::{Path, PathBuf}, + sync::mpsc, + time::{Duration, Instant, SystemTime}, +}; use tempdir::TempDir; use url::Url; @@ -51,12 +56,12 @@ fn println_name_value(name: &str, value: &str) { /// fn download_to_temp_archive( url: &str, - expected_sha256: Option<&str>, -) -> Result<(TempDir, PathBuf, String), Box> { - fn sha256_file_digest>(path: P) -> Result> { + expected_sha256: Option<&Hash>, +) -> Result<(TempDir, PathBuf, Hash), Box> { + fn sha256_file_digest>(path: P) -> Result> { let input = File::open(path)?; let mut reader = BufReader::new(input); - let mut hasher = Sha256::new(); + let mut hasher = Hasher::default(); let mut buffer = [0; 1024]; loop { @@ -64,9 +69,9 @@ fn download_to_temp_archive( if count == 0 { break; } - hasher.input(&buffer[..count]); + hasher.hash(&buffer[..count]); } - Ok(bs58::encode(hasher.result()).into_string()) + Ok(hasher.result()) } let url = Url::parse(url).map_err(|err| format!("Unable to parse {}: {}", url, err))?; @@ -788,7 +793,7 @@ pub fn update(config_file: &str) -> Result { return Err("Unable to update to an older version".to_string()); } } - let release_dir = config.release_dir(&update_manifest.download_sha256); + let release_dir = config.release_dir(&update_manifest.download_sha256.to_string()); let (_temp_dir, temp_archive, _temp_archive_sha256) = download_to_temp_archive( &update_manifest.download_url, Some(&update_manifest.download_sha256), diff --git a/install/src/config.rs b/install/src/config.rs index b7ff171964..77130b8247 100644 --- a/install/src/config.rs +++ b/install/src/config.rs @@ -33,7 +33,7 @@ impl Config { json_rpc_url: json_rpc_url.to_string(), update_manifest_pubkey: *update_manifest_pubkey, current_update_manifest: None, - update_poll_secs: 60, // check for updates once a minute + update_poll_secs: 60 * 60, // check for updates once an hour explicit_release, releases_dir: PathBuf::from(data_dir).join("releases"), active_release_dir: PathBuf::from(data_dir).join("active_release"), diff --git a/install/src/update_manifest.rs b/install/src/update_manifest.rs index ec834e16f0..b3571019b2 100644 --- a/install/src/update_manifest.rs +++ b/install/src/update_manifest.rs @@ -1,17 +1,18 @@ use serde_derive::{Deserialize, Serialize}; use solana_config_program::ConfigState; -use solana_sdk::pubkey::Pubkey; -use solana_sdk::signature::{Signable, Signature}; -use std::borrow::Cow; -use std::error; -use std::io; +use solana_sdk::{ + hash::Hash, + pubkey::Pubkey, + signature::{Signable, Signature}, +}; +use std::{borrow::Cow, error, io}; /// Information required to download and apply a given update #[derive(Serialize, Deserialize, Default, Debug, PartialEq)] pub struct UpdateManifest { pub timestamp_secs: u64, // When the release was deployed in seconds since UNIX EPOCH pub download_url: String, // Download URL to the release tar.bz2 - pub download_sha256: String, // SHA256 digest of the release tar.bz2 file + pub download_sha256: Hash, // SHA256 digest of the release tar.bz2 file } /// Userdata of an Update Manifest program Account.