Parity Ethereum 2.0.0 (#9052)

* parity-version: major bump to 2.0.0 🎉

* parity-ethereum: rename crate 🌵

* ethcore: only accept service transactions from parity-ethereum nodes

* parity: fix --identity tests

* rpc: fix sync provider in tests

* rpc: fix parity_net_peers test

* ethcore-sync: accept service transactions from parity and parity-ethereum

* ethcore-sync: fix indentation

* ethcore-sync: split the ifs to reduce code redundancy

* ethcore-sync: fix syntax

* Fix building ethcore

* update cargo.lock

* parity-version: major bump to 2.0.0 tada

* fix merge
This commit is contained in:
Afri Schoedon 2018-07-11 13:35:10 +02:00 committed by GitHub
parent c082af6f74
commit 484ecfaf47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 96 additions and 90 deletions

62
Cargo.lock generated
View File

@ -1855,7 +1855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1949,8 +1949,32 @@ dependencies = [
] ]
[[package]] [[package]]
name = "parity" name = "parity-bytes"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity-common#a72c34f82ff7ccc0f49827bb7f8c5d1fbff794bb"
[[package]]
name = "parity-clib"
version = "1.12.0" version = "1.12.0"
dependencies = [
"parity-ethereum 2.0.0",
]
[[package]]
name = "parity-crypto"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity-common#a72c34f82ff7ccc0f49827bb7f8c5d1fbff794bb"
dependencies = [
"ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.12.1 (git+https://github.com/paritytech/ring)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-ethereum"
version = "2.0.0"
dependencies = [ dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2000,7 +2024,7 @@ dependencies = [
"parity-rpc 1.12.0", "parity-rpc 1.12.0",
"parity-rpc-client 1.4.0", "parity-rpc-client 1.4.0",
"parity-updater 1.12.0", "parity-updater 1.12.0",
"parity-version 1.12.0", "parity-version 2.0.0",
"parity-whisper 0.1.0", "parity-whisper 0.1.0",
"parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"path 0.1.1 (git+https://github.com/paritytech/parity-common)", "path 0.1.1 (git+https://github.com/paritytech/parity-common)",
@ -2023,30 +2047,6 @@ dependencies = [
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "parity-bytes"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity-common#a72c34f82ff7ccc0f49827bb7f8c5d1fbff794bb"
[[package]]
name = "parity-clib"
version = "1.12.0"
dependencies = [
"parity 1.12.0",
]
[[package]]
name = "parity-crypto"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity-common#a72c34f82ff7ccc0f49827bb7f8c5d1fbff794bb"
dependencies = [
"ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.12.1 (git+https://github.com/paritytech/ring)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "parity-hash-fetch" name = "parity-hash-fetch"
version = "1.12.0" version = "1.12.0"
@ -2164,7 +2164,7 @@ dependencies = [
"parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)",
"parity-reactor 0.1.0", "parity-reactor 0.1.0",
"parity-updater 1.12.0", "parity-updater 1.12.0",
"parity-version 1.12.0", "parity-version 2.0.0",
"parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)",
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2234,7 +2234,7 @@ dependencies = [
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)",
"parity-hash-fetch 1.12.0", "parity-hash-fetch 1.12.0",
"parity-version 1.12.0", "parity-version 2.0.0",
"parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"path 0.1.1 (git+https://github.com/paritytech/parity-common)", "path 0.1.1 (git+https://github.com/paritytech/parity-common)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2245,7 +2245,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-version" name = "parity-version"
version = "1.12.0" version = "2.0.0"
dependencies = [ dependencies = [
"parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)",
"rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)",
@ -2579,7 +2579,7 @@ dependencies = [
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]

View File

@ -1,8 +1,8 @@
[package] [package]
description = "Parity Ethereum client" description = "Parity Ethereum client"
name = "parity" name = "parity-ethereum"
# NOTE Make sure to update util/version/Cargo.toml as well # NOTE Make sure to update util/version/Cargo.toml as well
version = "1.12.0" version = "2.0.0"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]

View File

@ -48,15 +48,21 @@ fn accepts_service_transaction(client_id: &str) -> bool {
// Parity versions starting from this will accept service-transactions // Parity versions starting from this will accept service-transactions
const SERVICE_TRANSACTIONS_VERSION: (u32, u32) = (1u32, 6u32); const SERVICE_TRANSACTIONS_VERSION: (u32, u32) = (1u32, 6u32);
// Parity client string prefix // Parity client string prefix
const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity/v"; const LEGACY_CLIENT_ID_PREFIX: &'static str = "Parity/v";
const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity-Ethereum/v";
if !client_id.starts_with(PARITY_CLIENT_ID_PREFIX) { let splitted = if client_id.starts_with(LEGACY_CLIENT_ID_PREFIX) {
client_id[LEGACY_CLIENT_ID_PREFIX.len()..].split('.')
} else if client_id.starts_with(PARITY_CLIENT_ID_PREFIX) {
client_id[PARITY_CLIENT_ID_PREFIX.len()..].split('.')
} else {
return false; return false;
} };
let ver: Vec<u32> = client_id[PARITY_CLIENT_ID_PREFIX.len()..].split('.')
.take(2) let ver: Vec<u32> = splitted
.filter_map(|s| s.parse().ok()) .take(2)
.collect(); .filter_map(|s| s.parse().ok())
.collect();
ver.len() == 2 && (ver[0] > SERVICE_TRANSACTIONS_VERSION.0 || (ver[0] == SERVICE_TRANSACTIONS_VERSION.0 && ver[1] >= SERVICE_TRANSACTIONS_VERSION.1)) ver.len() == 2 && (ver[0] > SERVICE_TRANSACTIONS_VERSION.0 || (ver[0] == SERVICE_TRANSACTIONS_VERSION.0 && ver[1] >= SERVICE_TRANSACTIONS_VERSION.1))
} }
@ -577,13 +583,13 @@ mod tests {
io.peers_info.insert(1, "Geth".to_owned()); io.peers_info.insert(1, "Geth".to_owned());
// and peer#2 is Parity, accepting service transactions // and peer#2 is Parity, accepting service transactions
insert_dummy_peer(&mut sync, 2, block_hash); insert_dummy_peer(&mut sync, 2, block_hash);
io.peers_info.insert(2, "Parity/v1.6".to_owned()); io.peers_info.insert(2, "Parity-Ethereum/v2.6".to_owned());
// and peer#3 is Parity, discarding service transactions // and peer#3 is Parity, discarding service transactions
insert_dummy_peer(&mut sync, 3, block_hash); insert_dummy_peer(&mut sync, 3, block_hash);
io.peers_info.insert(3, "Parity/v1.5".to_owned()); io.peers_info.insert(3, "Parity/v1.5".to_owned());
// and peer#4 is Parity, accepting service transactions // and peer#4 is Parity, accepting service transactions
insert_dummy_peer(&mut sync, 4, block_hash); insert_dummy_peer(&mut sync, 4, block_hash);
io.peers_info.insert(4, "Parity/v1.7.3-ABCDEFGH".to_owned()); io.peers_info.insert(4, "Parity-Ethereum/v2.7.3-ABCDEFGH".to_owned());
// and new service transaction is propagated to peers // and new service transaction is propagated to peers
SyncPropagator::propagate_new_transactions(&mut sync, &mut io); SyncPropagator::propagate_new_transactions(&mut sync, &mut io);
@ -607,7 +613,7 @@ mod tests {
// when peer#1 is Parity, accepting service transactions // when peer#1 is Parity, accepting service transactions
insert_dummy_peer(&mut sync, 1, block_hash); insert_dummy_peer(&mut sync, 1, block_hash);
io.peers_info.insert(1, "Parity/v1.6".to_owned()); io.peers_info.insert(1, "Parity-Ethereum/v2.6".to_owned());
// and service + non-service transactions are propagated to peers // and service + non-service transactions are propagated to peers
SyncPropagator::propagate_new_transactions(&mut sync, &mut io); SyncPropagator::propagate_new_transactions(&mut sync, &mut io);

View File

@ -10,8 +10,8 @@ name = "parity"
crate-type = ["cdylib", "staticlib"] crate-type = ["cdylib", "staticlib"]
[dependencies] [dependencies]
parity = { path = "../", default-features = false } parity-ethereum = { path = "../", default-features = false }
[features] [features]
default = [] default = []
final = ["parity/final"] final = ["parity-ethereum/final"]

View File

@ -17,7 +17,7 @@
//! Note that all the structs and functions here are documented in `parity.h`, to avoid //! Note that all the structs and functions here are documented in `parity.h`, to avoid
//! duplicating documentation. //! duplicating documentation.
extern crate parity; extern crate parity_ethereum;
use std::os::raw::{c_char, c_void, c_int}; use std::os::raw::{c_char, c_void, c_int};
use std::panic; use std::panic;
@ -56,7 +56,7 @@ pub extern fn parity_config_from_cli(args: *const *const c_char, args_lens: *con
args args
}; };
match parity::Configuration::parse_cli(&args) { match parity_ethereum::Configuration::parse_cli(&args) {
Ok(mut cfg) => { Ok(mut cfg) => {
// Always disable the auto-updater when used as a library. // Always disable the auto-updater when used as a library.
cfg.args.arg_auto_update = "none".to_owned(); cfg.args.arg_auto_update = "none".to_owned();
@ -77,7 +77,7 @@ pub extern fn parity_config_from_cli(args: *const *const c_char, args_lens: *con
pub extern fn parity_config_destroy(cfg: *mut c_void) { pub extern fn parity_config_destroy(cfg: *mut c_void) {
unsafe { unsafe {
let _ = panic::catch_unwind(|| { let _ = panic::catch_unwind(|| {
let _cfg = Box::from_raw(cfg as *mut parity::Configuration); let _cfg = Box::from_raw(cfg as *mut parity_ethereum::Configuration);
}); });
} }
} }
@ -89,7 +89,7 @@ pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -
*output = ptr::null_mut(); *output = ptr::null_mut();
let cfg: &ParityParams = &*cfg; let cfg: &ParityParams = &*cfg;
let config = Box::from_raw(cfg.configuration as *mut parity::Configuration); let config = Box::from_raw(cfg.configuration as *mut parity_ethereum::Configuration);
let on_client_restart_cb = { let on_client_restart_cb = {
struct Cb(Option<extern "C" fn(*mut c_void, *const c_char, usize)>, *mut c_void); struct Cb(Option<extern "C" fn(*mut c_void, *const c_char, usize)>, *mut c_void);
@ -106,16 +106,16 @@ pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -
move |new_chain: String| { cb.call(new_chain); } move |new_chain: String| { cb.call(new_chain); }
}; };
let action = match parity::start(*config, on_client_restart_cb, || {}) { let action = match parity_ethereum::start(*config, on_client_restart_cb, || {}) {
Ok(action) => action, Ok(action) => action,
Err(_) => return 1, Err(_) => return 1,
}; };
match action { match action {
parity::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 }, parity_ethereum::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 },
parity::ExecutionAction::Instant(None) => 0, parity_ethereum::ExecutionAction::Instant(None) => 0,
parity::ExecutionAction::Running(client) => { parity_ethereum::ExecutionAction::Running(client) => {
*output = Box::into_raw(Box::<parity::RunningClient>::new(client)) as *mut c_void; *output = Box::into_raw(Box::<parity_ethereum::RunningClient>::new(client)) as *mut c_void;
0 0
} }
} }
@ -127,7 +127,7 @@ pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -
pub extern fn parity_destroy(client: *mut c_void) { pub extern fn parity_destroy(client: *mut c_void) {
unsafe { unsafe {
let _ = panic::catch_unwind(|| { let _ = panic::catch_unwind(|| {
let client = Box::from_raw(client as *mut parity::RunningClient); let client = Box::from_raw(client as *mut parity_ethereum::RunningClient);
client.shutdown(); client.shutdown();
}); });
} }
@ -137,7 +137,7 @@ pub extern fn parity_destroy(client: *mut c_void) {
pub extern fn parity_rpc(client: *mut c_void, query: *const char, len: usize, out_str: *mut c_char, out_len: *mut usize) -> c_int { pub extern fn parity_rpc(client: *mut c_void, query: *const char, len: usize, out_str: *mut c_char, out_len: *mut usize) -> c_int {
unsafe { unsafe {
panic::catch_unwind(|| { panic::catch_unwind(|| {
let client: &mut parity::RunningClient = &mut *(client as *mut parity::RunningClient); let client: &mut parity_ethereum::RunningClient = &mut *(client as *mut parity_ethereum::RunningClient);
let query_str = { let query_str = {
let string = slice::from_raw_parts(query as *const u8, len); let string = slice::from_raw_parts(query as *const u8, len);

View File

@ -102,7 +102,7 @@ impl Configuration {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// let _cfg = parity::Configuration::parse_cli(&["--light", "--chain", "kovan"]).unwrap(); /// let _cfg = parity_ethereum::Configuration::parse_cli(&["--light", "--chain", "kovan"]).unwrap();
/// ``` /// ```
pub fn parse_cli<S: AsRef<str>>(command: &[S]) -> Result<Self, ArgsError> { pub fn parse_cli<S: AsRef<str>>(command: &[S]) -> Result<Self, ArgsError> {
let config = Configuration { let config = Configuration {
@ -722,7 +722,7 @@ impl Configuration {
ret.client_version = { ret.client_version = {
let mut client_version = version(); let mut client_version = version();
if !self.args.arg_identity.is_empty() { if !self.args.arg_identity.is_empty() {
// Insert name after the "Parity/" at the beginning of version string. // Insert name after the "Parity-Ethereum/" at the beginning of version string.
let idx = client_version.find('/').unwrap_or(client_version.len()); let idx = client_version.find('/').unwrap_or(client_version.len());
client_version.insert_str(idx, &format!("/{}", self.args.arg_identity)); client_version.insert_str(idx, &format!("/{}", self.args.arg_identity));
} }
@ -1740,7 +1740,7 @@ mod tests {
match conf.into_command().unwrap().cmd { match conf.into_command().unwrap().cmd {
Cmd::Run(c) => { Cmd::Run(c) => {
assert_eq!(c.name, "Somebody"); assert_eq!(c.name, "Somebody");
assert!(c.net_conf.client_version.starts_with("Parity/Somebody/")); assert!(c.net_conf.client_version.starts_with("Parity-Ethereum/Somebody/"));
} }
_ => panic!("Should be Cmd::Run"), _ => panic!("Should be Cmd::Run"),
} }

View File

@ -24,7 +24,7 @@ extern crate fdlimit;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate panic_hook; extern crate panic_hook;
extern crate parity; extern crate parity_ethereum;
extern crate parking_lot; extern crate parking_lot;
#[cfg(windows)] extern crate winapi; #[cfg(windows)] extern crate winapi;
@ -40,7 +40,7 @@ use std::{process, env};
use ctrlc::CtrlC; use ctrlc::CtrlC;
use dir::default_hypervisor_path; use dir::default_hypervisor_path;
use fdlimit::raise_fd_limit; use fdlimit::raise_fd_limit;
use parity::{start, ExecutionAction}; use parity_ethereum::{start, ExecutionAction};
use parking_lot::{Condvar, Mutex}; use parking_lot::{Condvar, Mutex};
const PLEASE_RESTART_EXIT_CODE: i32 = 69; const PLEASE_RESTART_EXIT_CODE: i32 = 69;
@ -61,9 +61,9 @@ fn update_path(name: &str) -> PathBuf {
} }
fn latest_exe_path() -> Result<PathBuf, Error> { fn latest_exe_path() -> Result<PathBuf, Error> {
File::open(update_path("latest")).and_then(|mut f| { File::open(update_path("latest")).and_then(|mut f| {
let mut exe_path = String::new(); let mut exe_path = String::new();
trace!(target: "updater", "latest binary path: {:?}", f); trace!(target: "updater", "latest binary path: {:?}", f);
f.read_to_string(&mut exe_path).map(|_| update_path(&exe_path)) f.read_to_string(&mut exe_path).map(|_| update_path(&exe_path))
}) })
.or(Err(Error::BinaryNotFound)) .or(Err(Error::BinaryNotFound))
@ -98,9 +98,9 @@ fn take_spec_name_override() -> Option<String> {
let p = update_path("spec_name_override"); let p = update_path("spec_name_override");
let r = File::open(p.clone()) let r = File::open(p.clone())
.ok() .ok()
.and_then(|mut f| { .and_then(|mut f| {
let mut spec_name = String::new(); let mut spec_name = String::new();
f.read_to_string(&mut spec_name).ok().map(|_| spec_name) f.read_to_string(&mut spec_name).ok().map(|_| spec_name)
}); });
let _ = remove_file(p); let _ = remove_file(p);
r r
@ -137,7 +137,7 @@ fn run_parity() -> Result<(), Error> {
global_init(); global_init();
let prefix = vec![OsString::from("--can-restart"), OsString::from("--force-direct")]; let prefix = vec![OsString::from("--can-restart"), OsString::from("--force-direct")];
let res: Result<(), Error> = latest_exe_path() let res: Result<(), Error> = latest_exe_path()
.and_then(|exe| process::Command::new(exe) .and_then(|exe| process::Command::new(exe)
.args(&(env::args_os().skip(1).chain(prefix.into_iter()).collect::<Vec<_>>())) .args(&(env::args_os().skip(1).chain(prefix.into_iter()).collect::<Vec<_>>()))
@ -155,7 +155,7 @@ fn run_parity() -> Result<(), Error> {
_ => Err(Error::Unknown), _ => Err(Error::Unknown),
} }
}) })
); );
global_cleanup(); global_cleanup();
res res
@ -181,7 +181,7 @@ fn main_direct(force_can_restart: bool) -> i32 {
let mut conf = { let mut conf = {
let args = std::env::args().collect::<Vec<_>>(); let args = std::env::args().collect::<Vec<_>>();
parity::Configuration::parse_cli(&args).unwrap_or_else(|e| e.exit()) parity_ethereum::Configuration::parse_cli(&args).unwrap_or_else(|e| e.exit())
}; };
if let Some(spec_override) = take_spec_name_override() { if let Some(spec_override) = take_spec_name_override() {
@ -331,10 +331,10 @@ fn main() {
// the user has specified to run its originally installed binary (not via `parity-updater`) // the user has specified to run its originally installed binary (not via `parity-updater`)
let force_direct = std::env::args().any(|arg| arg == "--force-direct"); let force_direct = std::env::args().any(|arg| arg == "--force-direct");
// absolute path to the current `binary` // absolute path to the current `binary`
let exe_path = std::env::current_exe().ok(); let exe_path = std::env::current_exe().ok();
// the binary is named `target/xx/yy` // the binary is named `target/xx/yy`
let development = exe_path let development = exe_path
.as_ref() .as_ref()
@ -345,31 +345,31 @@ fn main() {
.map(|n| n == "target") .map(|n| n == "target")
}) })
.unwrap_or(false); .unwrap_or(false);
// the binary is named `parity` // the binary is named `parity`
let same_name = exe_path let same_name = exe_path
.as_ref() .as_ref()
.map_or(false, |p| { .map_or(false, |p| {
p.file_stem().map_or(false, |n| n == PARITY_EXECUTABLE_NAME) p.file_stem().map_or(false, |n| n == PARITY_EXECUTABLE_NAME)
}); });
trace_main!("Starting up {} (force-direct: {}, development: {}, same-name: {})", trace_main!("Starting up {} (force-direct: {}, development: {}, same-name: {})",
std::env::current_exe().ok().map_or_else(|| "<unknown>".into(), |x| format!("{}", x.display())), std::env::current_exe().ok().map_or_else(|| "<unknown>".into(), |x| format!("{}", x.display())),
force_direct, force_direct,
development, development,
same_name); same_name);
if !force_direct && !development && same_name { if !force_direct && !development && same_name {
// Try to run the latest installed version of `parity`, // Try to run the latest installed version of `parity`,
// Upon failure it falls back to the locally installed version of `parity` // Upon failure it falls back to the locally installed version of `parity`
// Everything run inside a loop, so we'll be able to restart from the child into a new version seamlessly. // Everything run inside a loop, so we'll be able to restart from the child into a new version seamlessly.
loop { loop {
// `Path` to the latest downloaded binary // `Path` to the latest downloaded binary
let latest_exe = latest_exe_path().ok(); let latest_exe = latest_exe_path().ok();
// `Latest´ binary exist // `Latest´ binary exist
let have_update = latest_exe.as_ref().map_or(false, |p| p.exists()); let have_update = latest_exe.as_ref().map_or(false, |p| p.exists());
// Canonicalized path to the current binary is not the same as to latest binary // Canonicalized path to the current binary is not the same as to latest binary
let canonicalized_path_not_same = exe_path let canonicalized_path_not_same = exe_path
.as_ref() .as_ref()
@ -381,7 +381,7 @@ fn main() {
trace_main!("Starting... (have-update: {}, non-updated-current: {}, update-is-newer: {})", have_update, canonicalized_path_not_same, update_is_newer); trace_main!("Starting... (have-update: {}, non-updated-current: {}, update-is-newer: {})", have_update, canonicalized_path_not_same, update_is_newer);
let exit_code = if have_update && canonicalized_path_not_same && update_is_newer { let exit_code = if have_update && canonicalized_path_not_same && update_is_newer {
trace_main!("Attempting to run latest update ({})...", trace_main!("Attempting to run latest update ({})...",
latest_exe.as_ref().expect("guarded by have_update; latest_exe must exist for have_update; qed").display()); latest_exe.as_ref().expect("guarded by have_update; latest_exe must exist for have_update; qed").display());
match run_parity() { match run_parity() {
Ok(_) => 0, Ok(_) => 0,
@ -389,7 +389,7 @@ fn main() {
Err(Error::Restart) => PLEASE_RESTART_EXIT_CODE, Err(Error::Restart) => PLEASE_RESTART_EXIT_CODE,
// Fall back to local version // Fall back to local version
Err(e) => { Err(e) => {
error!(target: "updater", "Updated binary could not be executed error: {:?}. Falling back to local version", e); error!(target: "updater", "Updated binary could not be executed error: {:?}. Falling back to local version", e);
main_direct(true) main_direct(true)
} }
} }

View File

@ -75,7 +75,7 @@ impl SyncProvider for TestSyncProvider {
vec![ vec![
PeerInfo { PeerInfo {
id: Some("node1".to_owned()), id: Some("node1".to_owned()),
client_version: "Parity/1".to_owned(), client_version: "Parity-Ethereum/1".to_owned(),
capabilities: vec!["eth/62".to_owned(), "eth/63".to_owned()], capabilities: vec!["eth/62".to_owned(), "eth/63".to_owned()],
remote_address: "127.0.0.1:7777".to_owned(), remote_address: "127.0.0.1:7777".to_owned(),
local_address: "127.0.0.1:8888".to_owned(), local_address: "127.0.0.1:8888".to_owned(),
@ -88,7 +88,7 @@ impl SyncProvider for TestSyncProvider {
}, },
PeerInfo { PeerInfo {
id: None, id: None,
client_version: "Parity/2".to_owned(), client_version: "Parity-Ethereum/2".to_owned(),
capabilities: vec!["eth/63".to_owned(), "eth/64".to_owned()], capabilities: vec!["eth/63".to_owned(), "eth/64".to_owned()],
remote_address: "Handshake".to_owned(), remote_address: "Handshake".to_owned(),
local_address: "127.0.0.1:3333".to_owned(), local_address: "127.0.0.1:3333".to_owned(),

View File

@ -326,7 +326,7 @@ fn rpc_parity_net_peers() {
let io = deps.default_client(); let io = deps.default_client();
let request = r#"{"jsonrpc": "2.0", "method": "parity_netPeers", "params":[], "id": 1}"#; let request = r#"{"jsonrpc": "2.0", "method": "parity_netPeers", "params":[], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":{"active":0,"connected":120,"max":50,"peers":[{"caps":["eth/62","eth/63"],"id":"node1","name":"Parity/1","network":{"localAddress":"127.0.0.1:8888","remoteAddress":"127.0.0.1:7777"},"protocols":{"eth":{"difficulty":"0x28","head":"0000000000000000000000000000000000000000000000000000000000000032","version":62},"pip":null}},{"caps":["eth/63","eth/64"],"id":null,"name":"Parity/2","network":{"localAddress":"127.0.0.1:3333","remoteAddress":"Handshake"},"protocols":{"eth":{"difficulty":null,"head":"000000000000000000000000000000000000000000000000000000000000003c","version":64},"pip":null}}]},"id":1}"#; let response = r#"{"jsonrpc":"2.0","result":{"active":0,"connected":120,"max":50,"peers":[{"caps":["eth/62","eth/63"],"id":"node1","name":"Parity-Ethereum/1","network":{"localAddress":"127.0.0.1:8888","remoteAddress":"127.0.0.1:7777"},"protocols":{"eth":{"difficulty":"0x28","head":"0000000000000000000000000000000000000000000000000000000000000032","version":62},"pip":null}},{"caps":["eth/63","eth/64"],"id":null,"name":"Parity-Ethereum/2","network":{"localAddress":"127.0.0.1:3333","remoteAddress":"Handshake"},"protocols":{"eth":{"difficulty":null,"head":"000000000000000000000000000000000000000000000000000000000000003c","version":64},"pip":null}}]},"id":1}"#;
assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
} }

View File

@ -3,7 +3,7 @@
[package] [package]
name = "parity-version" name = "parity-version"
# NOTE: this value is used for Parity version string (via env CARGO_PKG_VERSION) # NOTE: this value is used for Parity version string (via env CARGO_PKG_VERSION)
version = "1.12.0" version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"

View File

@ -54,7 +54,7 @@ pub fn version() -> String {
let sha3_dash = if sha3.is_empty() { "" } else { "-" }; let sha3_dash = if sha3.is_empty() { "" } else { "-" };
let commit_date = vergen::commit_date().replace("-", ""); let commit_date = vergen::commit_date().replace("-", "");
let date_dash = if commit_date.is_empty() { "" } else { "-" }; 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(), generated::rustc_version()) format!("Parity-Ethereum/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. /// Get the standard version data for this software.
@ -65,7 +65,7 @@ pub fn version_data() -> Bytes {
(env!("CARGO_PKG_VERSION_MINOR").parse::<u32>().expect("Environment variables are known to be valid; qed") << 8) + (env!("CARGO_PKG_VERSION_MINOR").parse::<u32>().expect("Environment variables are known to be valid; qed") << 8) +
env!("CARGO_PKG_VERSION_PATCH").parse::<u32>().expect("Environment variables are known to be valid; qed"); env!("CARGO_PKG_VERSION_PATCH").parse::<u32>().expect("Environment variables are known to be valid; qed");
s.append(&v); s.append(&v);
s.append(&"Parity"); s.append(&"Parity-Ethereum");
s.append(&generated::rustc_version()); s.append(&generated::rustc_version());
s.append(&&Target::os()[0..2]); s.append(&&Target::os()[0..2]);
s.out() s.out()