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

Parity Ethereum 2.0.0 #9052

Merged
merged 19 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from 18 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
160 changes: 80 additions & 80 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
description = "Parity Ethereum client"
name = "parity"
name = "parity-ethereum"
# NOTE Make sure to update util/version/Cargo.toml as well
version = "1.12.0"
version = "2.0.0"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]

Expand Down
28 changes: 17 additions & 11 deletions ethcore/sync/src/chain/propagator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ fn accepts_service_transaction(client_id: &str) -> bool {
// Parity versions starting from this will accept service-transactions
const SERVICE_TRANSACTIONS_VERSION: (u32, u32) = (1u32, 6u32);
// Parity client string prefix
const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity/v";

if !client_id.starts_with(PARITY_CLIENT_ID_PREFIX) {
const LEGACY_CLIENT_ID_PREFIX: &'static str = "Parity/v";
const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity-Ethereum/v";

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;
}
let ver: Vec<u32> = client_id[PARITY_CLIENT_ID_PREFIX.len()..].split('.')
.take(2)
.filter_map(|s| s.parse().ok())
.collect();
};

let ver: Vec<u32> = splitted
.take(2)
.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))
}

Expand Down Expand Up @@ -577,13 +583,13 @@ mod tests {
io.peers_info.insert(1, "Geth".to_owned());
// and peer#2 is Parity, accepting service transactions
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
insert_dummy_peer(&mut sync, 3, block_hash);
io.peers_info.insert(3, "Parity/v1.5".to_owned());
// and peer#4 is Parity, accepting service transactions
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
SyncPropagator::propagate_new_transactions(&mut sync, &mut io);
Expand All @@ -607,7 +613,7 @@ mod tests {

// when peer#1 is Parity, accepting service transactions
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
SyncPropagator::propagate_new_transactions(&mut sync, &mut io);
Expand Down
4 changes: 2 additions & 2 deletions parity-clib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ name = "parity"
crate-type = ["cdylib", "staticlib"]

[dependencies]
parity = { path = "../", default-features = false }
parity-ethereum = { path = "../", default-features = false }

[features]
default = []
final = ["parity/final"]
final = ["parity-ethereum/final"]
22 changes: 11 additions & 11 deletions parity-clib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Note that all the structs and functions here are documented in `parity.h`, to avoid
//! duplicating documentation.

extern crate parity;
extern crate parity_ethereum;

use std::os::raw::{c_char, c_void, c_int};
use std::panic;
Expand Down Expand Up @@ -56,7 +56,7 @@ pub extern fn parity_config_from_cli(args: *const *const c_char, args_lens: *con
args
};

match parity::Configuration::parse_cli(&args) {
match parity_ethereum::Configuration::parse_cli(&args) {
Ok(mut cfg) => {
// Always disable the auto-updater when used as a library.
cfg.args.arg_auto_update = "none".to_owned();
Expand All @@ -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) {
unsafe {
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);
});
}
}
Expand All @@ -89,7 +89,7 @@ pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -
*output = ptr::null_mut();
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 = {
struct Cb(Option<extern "C" fn(*mut c_void, *const c_char, usize)>, *mut c_void);
Expand All @@ -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); }
};

let action = match parity::start(*config, on_client_restart_cb, || {}) {
let action = match parity_ethereum::start(*config, on_client_restart_cb, || {}) {
Ok(action) => action,
Err(_) => return 1,
};

match action {
parity::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 },
parity::ExecutionAction::Instant(None) => 0,
parity::ExecutionAction::Running(client) => {
*output = Box::into_raw(Box::<parity::RunningClient>::new(client)) as *mut c_void;
parity_ethereum::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 },
parity_ethereum::ExecutionAction::Instant(None) => 0,
parity_ethereum::ExecutionAction::Running(client) => {
*output = Box::into_raw(Box::<parity_ethereum::RunningClient>::new(client)) as *mut c_void;
0
}
}
Expand All @@ -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) {
unsafe {
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();
});
}
Expand All @@ -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 {
unsafe {
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 string = slice::from_raw_parts(query as *const u8, len);
Expand Down
6 changes: 3 additions & 3 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,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 {
Expand Down Expand Up @@ -751,7 +751,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));
}
Expand Down Expand Up @@ -1796,7 +1796,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"),
}
Expand Down
Loading