Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Store updater metadata in a single place #7832

Merged
merged 2 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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>"]
Expand Down
1 change: 0 additions & 1 deletion ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions ethcore/src/engines/authority_round/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/engines/basic_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions ethcore/src/engines/tendermint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
9 changes: 0 additions & 9 deletions ethcore/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions util/semantic_version/Cargo.toml

This file was deleted.

47 changes: 0 additions & 47 deletions util/semantic_version/src/lib.rs

This file was deleted.

14 changes: 14 additions & 0 deletions util/version/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# 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)
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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these values used?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess nowhere in parity... Used ONLY by auto-updater so https://github.com/paritytech/push-release . am I right @tomusdrw ?

foundation = 4370000
ropsten = 10
kovan = 5067000

[dependencies]
ethcore-bytes = { path = "../bytes" }
rlp = { path = "../rlp" }
Expand All @@ -13,6 +26,7 @@ target_info = "0.1"
[build-dependencies]
vergen = "0.1"
rustc_version = "0.2.0"
toml = "0.4"

[features]
final = []
36 changes: 27 additions & 9 deletions util/version/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,44 @@
// 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;
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 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("rustc_version.rs");
let dest_path = Path::new(&out_dir).join(filename);
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);
f.write_all(data.as_bytes()).expect(ERROR_MSG);
}
26 changes: 16 additions & 10 deletions util/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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.
Expand All @@ -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())
}