diff --git a/Cargo.lock b/Cargo.lock index 7ad67559f..847e36134 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,8 +33,8 @@ dependencies = [ "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.5.0", - "parity-updater 1.5.0", "parity-rpc-client 1.4.0", + "parity-updater 1.5.0", "regex 0.1.68 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.1.0", "rpassword 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -890,7 +890,7 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1398,6 +1398,17 @@ dependencies = [ "parity-hash-fetch 1.5.0", ] +[[package]] +name = "parking_lot" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot" version = "0.3.6" @@ -1650,6 +1661,7 @@ dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2265,6 +2277,7 @@ dependencies = [ "checksum owning_ref 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d91377085359426407a287ab16884a0111ba473aa6844ff01d4ec20ce3d75e7" "checksum parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98378dec0a185da2b7180308752f0bad73aaa949c3e0a3b0528d0e067945f7ab" "checksum parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git)" = "" +"checksum parking_lot 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "968f685642555d2f7e202c48b8b11de80569e9bfea817f7f12d7c61aac62d4e6" "checksum parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e1435e7a2a00dfebededd6c6bdbd54008001e94b4a2aadd6aef0dc4c56317621" "checksum parking_lot_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1b97670a2ffadce7c397fb80a3d687c4f3060140b885621ef1653d0e5d5068" "checksum phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "447d9d45f2e0b4a9b532e808365abf18fc211be6ca217202fcd45236ef12f026" diff --git a/ipc-common-types/src/types/release_track.rs b/ipc-common-types/src/types/release_track.rs index 9b9e7d1e6..3fcc0bb64 100644 --- a/ipc-common-types/src/types/release_track.rs +++ b/ipc-common-types/src/types/release_track.rs @@ -27,7 +27,9 @@ pub enum ReleaseTrack { Beta, /// Nightly track. Nightly, - /// No known track. + /// Testing track. + Testing, + /// No known track, also "current executable's track" when it's not yet known. Unknown, } @@ -37,7 +39,8 @@ impl fmt::Display for ReleaseTrack { ReleaseTrack::Stable => "stable", ReleaseTrack::Beta => "beta", ReleaseTrack::Nightly => "nightly", - ReleaseTrack::Unknown => "unknown", + ReleaseTrack::Testing => "testing", + ReleaseTrack::Unknown => "unknown", }) } } @@ -48,6 +51,7 @@ impl<'a> From<&'a str> for ReleaseTrack { "stable" => ReleaseTrack::Stable, "beta" => ReleaseTrack::Beta, "nightly" => ReleaseTrack::Nightly, + "testing" => ReleaseTrack::Testing, _ => ReleaseTrack::Unknown, } } @@ -59,6 +63,7 @@ impl From for ReleaseTrack { 1 => ReleaseTrack::Stable, 2 => ReleaseTrack::Beta, 3 => ReleaseTrack::Nightly, + 4 => ReleaseTrack::Testing, _ => ReleaseTrack::Unknown, } } @@ -70,6 +75,7 @@ impl Into for ReleaseTrack { ReleaseTrack::Stable => 1, ReleaseTrack::Beta => 2, ReleaseTrack::Nightly => 3, + ReleaseTrack::Testing => 4, ReleaseTrack::Unknown => 0, } } diff --git a/parity/cli/config.full.toml b/parity/cli/config.full.toml index 2f420e0a7..ed204e0f3 100644 --- a/parity/cli/config.full.toml +++ b/parity/cli/config.full.toml @@ -3,6 +3,7 @@ mode = "last" mode_timeout = 300 mode_alarm = 3600 auto_update = "critical" +releases_track = "current" no_download = false no_consensus = false diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 91f407e1e..3ae20be03 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -86,6 +86,7 @@ usage! { flag_mode_timeout: u64 = 300u64, or |c: &Config| otry!(c.parity).mode_timeout.clone(), flag_mode_alarm: u64 = 3600u64, or |c: &Config| otry!(c.parity).mode_alarm.clone(), flag_auto_update: String = "critical", or |c: &Config| otry!(c.parity).auto_update.clone(), + flag_releases_track: String = "current", or |c: &Config| otry!(c.parity).releases_track.clone(), flag_no_download: bool = false, or |c: &Config| otry!(c.parity).no_download.clone(), flag_no_consensus: bool = false, or |c: &Config| otry!(c.parity).no_consensus.clone(), flag_chain: String = "homestead", or |c: &Config| otry!(c.parity).chain.clone(), @@ -313,6 +314,7 @@ struct Operating { mode_timeout: Option, mode_alarm: Option, auto_update: Option, + releases_track: Option, no_download: Option, no_consensus: Option, chain: Option, @@ -540,6 +542,7 @@ mod tests { flag_mode_timeout: 300u64, flag_mode_alarm: 3600u64, flag_auto_update: "critical".into(), + flag_releases_track: "current".into(), flag_no_download: false, flag_no_consensus: false, flag_chain: "xyz".into(), @@ -717,6 +720,7 @@ mod tests { mode_timeout: Some(15u64), mode_alarm: Some(10u64), auto_update: None, + releases_track: None, no_download: None, no_consensus: None, chain: Some("./chain.json".into()), diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index e05d94751..b2f033bfc 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -34,12 +34,19 @@ Operating Options: --mode-alarm SECS Specify the number of seconds before auto sleep reawake timeout occurs when mode is passive (default: {flag_mode_alarm}). - --auto-update TRACK Set a release track to automatically update and + --auto-update SET Set a releases set to automatically update and install. - all - All updates in the current release track. + all - All updates in the our release track. critical - Only consensus/security updates. none - No updates will be auto-installed. (default: {flag_auto_update}). + --releases-track TRACK Set which release track we should use for updates. + stable - Stable releases. + beta - Beta releases. + nightly - Nightly releases (unstable). + testing - Testing releases (do not use). + current - Whatever track this executable was + released on (default: {flag_releases_track}). --no-download Normally new releases will be downloaded ready for updating. This disables it. Not recommended. (default: {flag_no_download}). @@ -47,7 +54,7 @@ Operating Options: issues regarding consensus. Not recommended. (default: {flag_no_consensus}). --force-direct Run the originally installed version of Parity, - ignoring any updates that have since been installed. + ignoring any updates that have since been installed. --chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file or olympic, frontier, homestead, mainnet, morden, ropsten, classic, expanse, diff --git a/parity/configuration.rs b/parity/configuration.rs index 4019c4ec3..577f8a6c9 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -37,7 +37,7 @@ use ethcore_logger::Config as LogConfig; use dir::Directories; use dapps::Configuration as DappsConfiguration; use signer::{Configuration as SignerConfiguration}; -use updater::{UpdatePolicy, UpdateFilter}; +use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack}; use run::RunCmd; use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, KillBlockchain, ExportState, DataFormat}; use presale::ImportWallet; @@ -693,6 +693,14 @@ impl Configuration { "all" => UpdateFilter::All, _ => return Err("Invalid value for `--auto-update`. See `--help` for more information.".into()), }, + track: match self.args.flag_releases_track.as_ref() { + "stable" => ReleaseTrack::Stable, + "beta" => ReleaseTrack::Beta, + "nightly" => ReleaseTrack::Nightly, + "testing" => ReleaseTrack::Testing, + "current" => ReleaseTrack::Unknown, + _ => return Err("Invalid value for `--releases-track`. See `--help` for more information.".into()), + }, }) } diff --git a/rpc/src/v1/types/consensus_status.rs b/rpc/src/v1/types/consensus_status.rs index fabc3a1d8..f420d426e 100644 --- a/rpc/src/v1/types/consensus_status.rs +++ b/rpc/src/v1/types/consensus_status.rs @@ -58,6 +58,9 @@ pub enum ReleaseTrack { /// Nightly track. #[serde(rename="nightly")] Nightly, + /// Testing track. + #[serde(rename="testing")] + Testing, /// No known track. #[serde(rename="null")] Unknown, @@ -69,6 +72,7 @@ impl Into for updater::ReleaseTrack { updater::ReleaseTrack::Stable => ReleaseTrack::Stable, updater::ReleaseTrack::Beta => ReleaseTrack::Beta, updater::ReleaseTrack::Nightly => ReleaseTrack::Nightly, + updater::ReleaseTrack::Testing => ReleaseTrack::Testing, updater::ReleaseTrack::Unknown => ReleaseTrack::Unknown, } } diff --git a/updater/src/updater.rs b/updater/src/updater.rs index aed62873d..736d7e8a8 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -18,7 +18,7 @@ use std::sync::{Arc, Weak}; use std::{fs, env}; use std::io::Write; use std::path::{PathBuf}; -//use util::misc::platform; +use util::misc::platform; use ipc_common_types::{VersionInfo, ReleaseTrack}; use util::{Address, H160, H256, FixedHash, Mutex, Bytes}; use ethcore::client::{BlockId, BlockChainClient, ChainNotify}; @@ -47,6 +47,8 @@ pub struct UpdatePolicy { pub require_consensus: bool, /// Which of those downloaded should be automatically installed. pub filter: UpdateFilter, + /// Which track we should be following. + pub track: ReleaseTrack, } impl Default for UpdatePolicy { @@ -55,6 +57,7 @@ impl Default for UpdatePolicy { enable_downloading: false, require_consensus: true, filter: UpdateFilter::None, + track: ReleaseTrack::Unknown, } } } @@ -89,14 +92,9 @@ pub struct Updater { const CLIENT_ID: &'static str = "parity"; -// TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! REMOVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -fn platform() -> String { - "test".to_owned() -} - impl Updater { pub fn new(client: Weak, update_policy: UpdatePolicy) -> Arc { - let mut u = Updater { + let r = Arc::new(Updater { update_policy: update_policy, weak_self: Mutex::new(Default::default()), client: client.clone(), @@ -105,14 +103,7 @@ impl Updater { exit_handler: Mutex::new(None), this: VersionInfo::this(), state: Mutex::new(Default::default()), - }; - - // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! REMOVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - if u.this.track == ReleaseTrack::Unknown { - u.this.track = ReleaseTrack::Nightly; - } - - let r = Arc::new(u); + }); *r.fetcher.lock() = Some(fetch::Client::new(r.clone())); *r.weak_self.lock() = Arc::downgrade(&r); r.poll(); @@ -135,6 +126,13 @@ impl Updater { }) } + fn track(&self) -> ReleaseTrack { + match self.update_policy.track { + ReleaseTrack::Unknown => self.this.track, + x => x, + } + } + fn collect_latest(&self) -> Result { if let Some(ref operations) = *self.operations.lock() { let hh: H256 = self.this.hash.into(); @@ -145,15 +143,15 @@ impl Updater { if track > 0 {Some(fork as u64)} else {None} }); - if self.this.track == ReleaseTrack::Unknown { + if self.track() == ReleaseTrack::Unknown { return Err(format!("Current executable ({}) is unreleased.", H160::from(self.this.hash))); } - let latest_in_track = operations.latest_in_track(CLIENT_ID, self.this.track.into())?; + let latest_in_track = operations.latest_in_track(CLIENT_ID, self.track().into())?; let in_track = Self::collect_release_info(operations, &latest_in_track)?; let mut in_minor = Some(in_track.clone()); const PROOF: &'static str = "in_minor initialised and assigned with Some; loop breaks if None assigned; qed"; - while in_minor.as_ref().expect(PROOF).version.track != self.this.track { + while in_minor.as_ref().expect(PROOF).version.track != self.track() { let track = match in_minor.as_ref().expect(PROOF).version.track { ReleaseTrack::Beta => ReleaseTrack::Stable, ReleaseTrack::Nightly => ReleaseTrack::Beta,