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:
@@ -102,7 +102,7 @@ impl Configuration {
|
||||
/// # 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> {
|
||||
let config = Configuration {
|
||||
@@ -722,7 +722,7 @@ impl Configuration {
|
||||
ret.client_version = {
|
||||
let mut client_version = version();
|
||||
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());
|
||||
client_version.insert_str(idx, &format!("/{}", self.args.arg_identity));
|
||||
}
|
||||
@@ -1740,7 +1740,7 @@ mod tests {
|
||||
match conf.into_command().unwrap().cmd {
|
||||
Cmd::Run(c) => {
|
||||
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"),
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ extern crate fdlimit;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate panic_hook;
|
||||
extern crate parity;
|
||||
extern crate parity_ethereum;
|
||||
extern crate parking_lot;
|
||||
|
||||
#[cfg(windows)] extern crate winapi;
|
||||
@@ -40,7 +40,7 @@ use std::{process, env};
|
||||
use ctrlc::CtrlC;
|
||||
use dir::default_hypervisor_path;
|
||||
use fdlimit::raise_fd_limit;
|
||||
use parity::{start, ExecutionAction};
|
||||
use parity_ethereum::{start, ExecutionAction};
|
||||
use parking_lot::{Condvar, Mutex};
|
||||
|
||||
const PLEASE_RESTART_EXIT_CODE: i32 = 69;
|
||||
@@ -61,9 +61,9 @@ fn update_path(name: &str) -> PathBuf {
|
||||
}
|
||||
|
||||
fn latest_exe_path() -> Result<PathBuf, Error> {
|
||||
File::open(update_path("latest")).and_then(|mut f| {
|
||||
let mut exe_path = String::new();
|
||||
trace!(target: "updater", "latest binary path: {:?}", f);
|
||||
File::open(update_path("latest")).and_then(|mut f| {
|
||||
let mut exe_path = String::new();
|
||||
trace!(target: "updater", "latest binary path: {:?}", f);
|
||||
f.read_to_string(&mut exe_path).map(|_| update_path(&exe_path))
|
||||
})
|
||||
.or(Err(Error::BinaryNotFound))
|
||||
@@ -98,9 +98,9 @@ fn take_spec_name_override() -> Option<String> {
|
||||
let p = update_path("spec_name_override");
|
||||
let r = File::open(p.clone())
|
||||
.ok()
|
||||
.and_then(|mut f| {
|
||||
let mut spec_name = String::new();
|
||||
f.read_to_string(&mut spec_name).ok().map(|_| spec_name)
|
||||
.and_then(|mut f| {
|
||||
let mut spec_name = String::new();
|
||||
f.read_to_string(&mut spec_name).ok().map(|_| spec_name)
|
||||
});
|
||||
let _ = remove_file(p);
|
||||
r
|
||||
@@ -137,7 +137,7 @@ fn run_parity() -> Result<(), Error> {
|
||||
global_init();
|
||||
|
||||
let prefix = vec![OsString::from("--can-restart"), OsString::from("--force-direct")];
|
||||
|
||||
|
||||
let res: Result<(), Error> = latest_exe_path()
|
||||
.and_then(|exe| process::Command::new(exe)
|
||||
.args(&(env::args_os().skip(1).chain(prefix.into_iter()).collect::<Vec<_>>()))
|
||||
@@ -155,7 +155,7 @@ fn run_parity() -> Result<(), Error> {
|
||||
_ => Err(Error::Unknown),
|
||||
}
|
||||
})
|
||||
);
|
||||
);
|
||||
|
||||
global_cleanup();
|
||||
res
|
||||
@@ -181,7 +181,7 @@ fn main_direct(force_can_restart: bool) -> i32 {
|
||||
|
||||
let mut conf = {
|
||||
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() {
|
||||
@@ -331,10 +331,10 @@ fn main() {
|
||||
|
||||
// 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");
|
||||
|
||||
|
||||
// absolute path to the current `binary`
|
||||
let exe_path = std::env::current_exe().ok();
|
||||
|
||||
|
||||
// the binary is named `target/xx/yy`
|
||||
let development = exe_path
|
||||
.as_ref()
|
||||
@@ -345,31 +345,31 @@ fn main() {
|
||||
.map(|n| n == "target")
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
|
||||
// the binary is named `parity`
|
||||
let same_name = exe_path
|
||||
.as_ref()
|
||||
.map_or(false, |p| {
|
||||
p.file_stem().map_or(false, |n| n == PARITY_EXECUTABLE_NAME)
|
||||
.map_or(false, |p| {
|
||||
p.file_stem().map_or(false, |n| n == PARITY_EXECUTABLE_NAME)
|
||||
});
|
||||
|
||||
trace_main!("Starting up {} (force-direct: {}, development: {}, same-name: {})",
|
||||
std::env::current_exe().ok().map_or_else(|| "<unknown>".into(), |x| format!("{}", x.display())),
|
||||
force_direct,
|
||||
development,
|
||||
trace_main!("Starting up {} (force-direct: {}, development: {}, same-name: {})",
|
||||
std::env::current_exe().ok().map_or_else(|| "<unknown>".into(), |x| format!("{}", x.display())),
|
||||
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`
|
||||
// Everything run inside a loop, so we'll be able to restart from the child into a new version seamlessly.
|
||||
loop {
|
||||
// `Path` to the latest downloaded binary
|
||||
let latest_exe = latest_exe_path().ok();
|
||||
|
||||
|
||||
// `Latest´ binary exist
|
||||
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
|
||||
let canonicalized_path_not_same = exe_path
|
||||
.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);
|
||||
|
||||
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());
|
||||
match run_parity() {
|
||||
Ok(_) => 0,
|
||||
@@ -389,7 +389,7 @@ fn main() {
|
||||
Err(Error::Restart) => PLEASE_RESTART_EXIT_CODE,
|
||||
// Fall back to local version
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user