Move updater metadata to Cargo.toml of parity-version. (#7832)

This commit is contained in:
Tomasz Drwięga 2018-02-08 12:38:56 +01:00 committed by Afri Schoedon
parent a487182e92
commit a59f6d9bd2
15 changed files with 61 additions and 107 deletions

6
Cargo.lock generated
View File

@ -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"

View File

@ -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 <admin@parity.io>"]

View File

@ -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"

View File

@ -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<EthereumMachine> 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]

View File

@ -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<EthereumMachine> 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]

View File

@ -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<M: Machine> {
pub trait Engine<M: Machine>: 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.

View File

@ -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<EthereumMachine> 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]

View File

@ -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<EthereumMachine> for Arc<Ethash> {
impl Engine<EthereumMachine> for Arc<Ethash> {
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]

View File

@ -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<Option<SpecParams<'a>>>>(params: T, b: &[u8]) -> Spec {
match params.into() {
Some(params) => Spec::load(params, b),

View File

@ -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;

View File

@ -1,6 +0,0 @@
[package]
name = "semantic_version"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]

View File

@ -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 <http://www.gnu.org/licenses/>.
//! 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.

View File

@ -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 <admin@parity.io>"]
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 = []

View File

@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
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!("
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}\"
}}
", rustc_version::version().expect(ERROR_MSG)).as_bytes()).expect(ERROR_MSG);
",
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);
}

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! 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;
mod vergen {
#![allow(unused)]
include!(concat!(env!("OUT_DIR"), "/version.rs"));
include!(concat!(env!("OUT_DIR"), "/rustc_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::<u32>().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())
}