diff --git a/Cargo.lock b/Cargo.lock index 0013ad4c0..f7d5e49ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -482,7 +482,6 @@ dependencies = [ "rlp_derive 0.1.0", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "semantic_version 0.1.0", "snappy 0.1.0 (git+https://github.com/paritytech/rust-snappy)", "stats 0.1.0", "stop-guard 0.1.0", @@ -2275,6 +2274,7 @@ dependencies = [ "rlp 0.2.1", "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2809,10 +2809,6 @@ dependencies = [ "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "semantic_version" -version = "0.1.0" - [[package]] name = "semver" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 78b9db18a..c7f7cc4cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] description = "Parity Ethereum client" name = "parity" +# NOTE Make sure to update util/version/Cargo.toml as well version = "1.10.0" license = "GPL-3.0" authors = ["Parity Technologies "] diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 3042ee1a1..f1f519d42 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -65,7 +65,6 @@ vm = { path = "vm" } wasm = { path = "wasm" } keccak-hash = { path = "../util/hash" } triehash = { path = "../util/triehash" } -semantic_version = { path = "../util/semantic_version" } unexpected = { path = "../util/unexpected" } journaldb = { path = "../util/journaldb" } tempdir = "0.3" diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index 47e0b9b40..913a5123d 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -40,7 +40,6 @@ use io::{IoContext, IoHandler, TimerToken, IoService}; use itertools::{self, Itertools}; use rlp::{UntrustedRlp, encode}; use ethereum_types::{H256, H520, Address, U128, U256}; -use semantic_version::SemanticVersion; use parking_lot::{Mutex, RwLock}; use unexpected::{Mismatch, OutOfBounds}; @@ -481,8 +480,6 @@ impl IoHandler<()> for TransitionHandler { impl Engine for AuthorityRound { fn name(&self) -> &str { "AuthorityRound" } - fn version(&self) -> SemanticVersion { SemanticVersion::new(1, 0, 0) } - fn machine(&self) -> &EthereumMachine { &self.machine } /// Two fields - consensus step and the corresponding proposer signature. @@ -916,7 +913,6 @@ mod tests { fn has_valid_metadata() { let engine = Spec::new_test_round().engine; assert!(!engine.name().is_empty()); - assert!(engine.version().major >= 1); } #[test] diff --git a/ethcore/src/engines/basic_authority.rs b/ethcore/src/engines/basic_authority.rs index a76c1308e..82c1ac845 100644 --- a/ethcore/src/engines/basic_authority.rs +++ b/ethcore/src/engines/basic_authority.rs @@ -28,7 +28,6 @@ use ethjson; use header::Header; use client::EngineClient; use machine::{AuxiliaryData, Call, EthereumMachine}; -use semantic_version::SemanticVersion; use super::signer::EngineSigner; use super::validator_set::{ValidatorSet, SimpleList, new_validator_set}; @@ -94,7 +93,6 @@ impl BasicAuthority { impl Engine for BasicAuthority { fn name(&self) -> &str { "BasicAuthority" } - fn version(&self) -> SemanticVersion { SemanticVersion::new(1, 0, 0) } fn machine(&self) -> &EthereumMachine { &self.machine } @@ -217,7 +215,6 @@ mod tests { fn has_valid_metadata() { let engine = new_test_authority().engine; assert!(!engine.name().is_empty()); - assert!(engine.version().major >= 1); } #[test] diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 95c9c9ae3..9185a9300 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -53,7 +53,6 @@ use transaction::{UnverifiedTransaction, SignedTransaction}; use ethkey::Signature; use parity_machine::{Machine, LocalizedMachine as Localized}; use ethereum_types::{H256, U256, Address}; -use semantic_version::SemanticVersion; use unexpected::{Mismatch, OutOfBounds}; use bytes::Bytes; @@ -176,8 +175,6 @@ pub enum EpochChange { pub trait Engine: Sync + Send { /// The name of this engine. fn name(&self) -> &str; - /// The version of this engine. Should be of the form - fn version(&self) -> SemanticVersion { SemanticVersion::new(0, 0, 0) } /// Get access to the underlying state machine. // TODO: decouple. diff --git a/ethcore/src/engines/tendermint/mod.rs b/ethcore/src/engines/tendermint/mod.rs index 4eb9c5009..fd32294f4 100644 --- a/ethcore/src/engines/tendermint/mod.rs +++ b/ethcore/src/engines/tendermint/mod.rs @@ -48,7 +48,6 @@ use super::transition::TransitionHandler; use super::vote_collector::VoteCollector; use self::message::*; use self::params::TendermintParams; -use semantic_version::SemanticVersion; use machine::{AuxiliaryData, EthereumMachine}; #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] @@ -441,8 +440,6 @@ impl Tendermint { impl Engine for Tendermint { fn name(&self) -> &str { "Tendermint" } - fn version(&self) -> SemanticVersion { SemanticVersion::new(1, 0, 0) } - /// (consensus view, proposal signature, authority signatures) fn seal_fields(&self) -> usize { 3 } @@ -855,7 +852,6 @@ mod tests { fn has_valid_metadata() { let engine = Spec::new_test_tendermint().engine; assert!(!engine.name().is_empty()); - assert!(engine.version().major >= 1); } #[test] diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 39b8e5fbc..824330d2a 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -29,7 +29,6 @@ use engines::{self, Engine}; use ethjson; use rlp::{self, UntrustedRlp}; use machine::EthereumMachine; -use semantic_version::SemanticVersion; /// Number of blocks in an ethash snapshot. // make dependent on difficulty incrment divisor? @@ -167,7 +166,6 @@ impl engines::EpochVerifier for Arc { impl Engine for Arc { fn name(&self) -> &str { "Ethash" } - fn version(&self) -> SemanticVersion { SemanticVersion::new(1, 0, 0) } fn machine(&self) -> &EthereumMachine { &self.machine } // Two fields - nonce and mix. @@ -572,7 +570,6 @@ mod tests { fn has_valid_metadata() { let engine = test_spec().engine; assert!(!engine.name().is_empty()); - assert!(engine.version().major >= 1); } #[test] diff --git a/ethcore/src/ethereum/mod.rs b/ethcore/src/ethereum/mod.rs index 01e812017..169c45751 100644 --- a/ethcore/src/ethereum/mod.rs +++ b/ethcore/src/ethereum/mod.rs @@ -30,15 +30,6 @@ pub use self::denominations::*; use machine::EthereumMachine; use super::spec::*; -/// Most recent fork block that we support on Mainnet. -pub const FORK_SUPPORTED_FOUNDATION: u64 = 4370000; - -/// Most recent fork block that we support on Ropsten. -pub const FORK_SUPPORTED_ROPSTEN: u64 = 10; - -/// Most recent fork block that we support on Kovan. -pub const FORK_SUPPORTED_KOVAN: u64 = 0; - fn load<'a, T: Into>>>(params: T, b: &[u8]) -> Spec { match params.into() { Some(params) => Spec::load(params, b), diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index c5f7050cd..565477eec 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -91,7 +91,6 @@ extern crate memorydb; extern crate patricia_trie as trie; extern crate triehash; extern crate ansi_term; -extern crate semantic_version; extern crate unexpected; extern crate kvdb; extern crate kvdb_rocksdb; diff --git a/util/semantic_version/Cargo.toml b/util/semantic_version/Cargo.toml deleted file mode 100644 index 5cd888d0a..000000000 --- a/util/semantic_version/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "semantic_version" -version = "0.1.0" -authors = ["Parity Technologies "] - -[dependencies] diff --git a/util/semantic_version/src/lib.rs b/util/semantic_version/src/lib.rs deleted file mode 100644 index 0a8eeb499..000000000 --- a/util/semantic_version/src/lib.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Semantic version formatting and comparing. - -/// A version value with strict meaning. Use `as_u32` to convert to a simple integer. -/// -/// # Example -/// ``` -/// extern crate semantic_version; -/// use semantic_version::*; -/// -/// fn main() { -/// assert_eq!(SemanticVersion::new(1, 2, 3).as_u32(), 0x010203); -/// } -/// ``` -pub struct SemanticVersion { - /// Major version - API/feature removals & breaking changes. - pub major: u8, - /// Minor version - API/feature additions. - pub minor: u8, - /// Tiny version - bug fixes. - pub tiny: u8, -} - -impl SemanticVersion { - /// Create a new object. - pub fn new(major: u8, minor: u8, tiny: u8) -> SemanticVersion { SemanticVersion{major: major, minor: minor, tiny: tiny} } - - /// Convert to a `u32` representation. - pub fn as_u32(&self) -> u32 { ((self.major as u32) << 16) + ((self.minor as u32) << 8) + self.tiny as u32 } -} - -// TODO: implement Eq, Comparison and Debug/Display for SemanticVersion. diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml index 900318f18..14d9ffb76 100644 --- a/util/version/Cargo.toml +++ b/util/version/Cargo.toml @@ -1,3 +1,5 @@ +# NOTE This file is used by the auto-updater service. +# Make sure to update the service if it's moved or the structure is changed. [package] name = "parity-version" # NOTE: this value is used for Parity version string (via env CARGO_PKG_VERSION) @@ -5,6 +7,17 @@ version = "1.10.0" authors = ["Parity Technologies "] build = "build.rs" +[package.metadata] +# This versions track. Should be changed to `stable` or `beta` when on respective branches. +# Used by auto-updater and for Parity version string. +track = "nightly" + +# Latest supported fork blocks for various networks. Used ONLY by auto-updater. +[package.metadata.forks] +foundation = 4370000 +ropsten = 10 +kovan = 5067000 + [dependencies] ethcore-bytes = { path = "../bytes" } rlp = { path = "../rlp" } @@ -13,6 +26,7 @@ target_info = "0.1" [build-dependencies] vergen = "0.1" rustc_version = "0.2.0" +toml = "0.4" [features] final = [] diff --git a/util/version/build.rs b/util/version/build.rs index 602a1e583..47c0e128f 100644 --- a/util/version/build.rs +++ b/util/version/build.rs @@ -14,8 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -extern crate vergen; extern crate rustc_version; +extern crate toml; +extern crate vergen; use std::env; use std::fs::File; @@ -23,17 +24,34 @@ use std::io::Write; use std::path::Path; use vergen::{vergen, OutputFns}; -const ERROR_MSG: &'static str = "Failed to generate rustc_version file"; +const ERROR_MSG: &'static str = "Failed to generate metadata files"; fn main() { vergen(OutputFns::all()).expect(ERROR_MSG); - let out_dir = env::var("OUT_DIR").expect(ERROR_MSG); - let dest_path = Path::new(&out_dir).join("rustc_version.rs"); - let mut f = File::create(&dest_path).expect(ERROR_MSG); - f.write_all(format!(" - /// Returns compiler version. - pub fn rustc_version() -> &'static str {{ - \"{}\" - }} - ", rustc_version::version().expect(ERROR_MSG)).as_bytes()).expect(ERROR_MSG); + + let version = rustc_version::version().expect(ERROR_MSG); + + let cargo: toml::Value = toml::from_str(include_str!("./Cargo.toml")).expect(ERROR_MSG); + let track = cargo["package"]["metadata"]["track"].as_str().expect("'track' has to be a string!"); + + create_file("meta.rs", format!(" + /// This versions track. + #[allow(unused)] + pub const TRACK: &str = {track:?}; + + /// Returns compiler version. + pub fn rustc_version() -> &'static str {{ + \"{version}\" + }} + ", + track = track, + version = version, + )); +} + +fn create_file(filename: &str, data: String) { + let out_dir = env::var("OUT_DIR").expect(ERROR_MSG); + let dest_path = Path::new(&out_dir).join(filename); + let mut f = File::create(&dest_path).expect(ERROR_MSG); + f.write_all(data.as_bytes()).expect(ERROR_MSG); } diff --git a/util/version/src/lib.rs b/util/version/src/lib.rs index 236f11914..6c56bfb7e 100644 --- a/util/version/src/lib.rs +++ b/util/version/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -//! Diff misc. +//! Parity version specific information. extern crate target_info; extern crate ethcore_bytes as bytes; @@ -24,12 +24,18 @@ use target_info::Target; use bytes::Bytes; use rlp::RlpStream; -include!(concat!(env!("OUT_DIR"), "/version.rs")); -include!(concat!(env!("OUT_DIR"), "/rustc_version.rs")); +mod vergen { + #![allow(unused)] + include!(concat!(env!("OUT_DIR"), "/version.rs")); +} + +mod generated { + include!(concat!(env!("OUT_DIR"), "/meta.rs")); +} #[cfg(feature = "final")] -const THIS_TRACK: &'static str = "nightly"; -// ^^^ should be reset to "stable" or "beta" according to the release branch. +const THIS_TRACK: &'static str = generated::TRACK; +// ^^^ should be reset in Cargo.toml to "stable" or "beta" according to the release branch. #[cfg(not(feature = "final"))] const THIS_TRACK: &'static str = "unstable"; @@ -44,11 +50,11 @@ pub fn platform() -> String { /// Get the standard version string for this software. pub fn version() -> String { - let sha3 = short_sha(); + let sha3 = vergen::short_sha(); let sha3_dash = if sha3.is_empty() { "" } else { "-" }; - let commit_date = commit_date().replace("-", ""); + let commit_date = vergen::commit_date().replace("-", ""); let date_dash = if commit_date.is_empty() { "" } else { "-" }; - format!("Parity/v{}-{}{}{}{}{}/{}/rustc{}", env!("CARGO_PKG_VERSION"), THIS_TRACK, sha3_dash, sha3, date_dash, commit_date, platform(), rustc_version()) + format!("Parity/v{}-{}{}{}{}{}/{}/rustc{}", env!("CARGO_PKG_VERSION"), THIS_TRACK, sha3_dash, sha3, date_dash, commit_date, platform(), generated::rustc_version()) } /// Get the standard version data for this software. @@ -60,12 +66,12 @@ pub fn version_data() -> Bytes { env!("CARGO_PKG_VERSION_PATCH").parse::().expect("Environment variables are known to be valid; qed"); s.append(&v); s.append(&"Parity"); - s.append(&rustc_version()); + s.append(&generated::rustc_version()); s.append(&&Target::os()[0..2]); s.out() } /// Provide raw information on the package. pub fn raw_package_info() -> (&'static str, &'static str, &'static str) { - (THIS_TRACK, env!["CARGO_PKG_VERSION"], sha()) + (THIS_TRACK, env!["CARGO_PKG_VERSION"], vergen::sha()) }