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

Commit 484ecfa

Browse files
authored
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
1 parent c082af6 commit 484ecfa

File tree

11 files changed

+97
-91
lines changed

11 files changed

+97
-91
lines changed

Cargo.lock

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
description = "Parity Ethereum client"
3-
name = "parity"
3+
name = "parity-ethereum"
44
# NOTE Make sure to update util/version/Cargo.toml as well
5-
version = "1.12.0"
5+
version = "2.0.0"
66
license = "GPL-3.0"
77
authors = ["Parity Technologies <admin@parity.io>"]
88

ethcore/sync/src/chain/propagator.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,21 @@ fn accepts_service_transaction(client_id: &str) -> bool {
4848
// Parity versions starting from this will accept service-transactions
4949
const SERVICE_TRANSACTIONS_VERSION: (u32, u32) = (1u32, 6u32);
5050
// Parity client string prefix
51-
const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity/v";
52-
53-
if !client_id.starts_with(PARITY_CLIENT_ID_PREFIX) {
51+
const LEGACY_CLIENT_ID_PREFIX: &'static str = "Parity/v";
52+
const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity-Ethereum/v";
53+
54+
let splitted = if client_id.starts_with(LEGACY_CLIENT_ID_PREFIX) {
55+
client_id[LEGACY_CLIENT_ID_PREFIX.len()..].split('.')
56+
} else if client_id.starts_with(PARITY_CLIENT_ID_PREFIX) {
57+
client_id[PARITY_CLIENT_ID_PREFIX.len()..].split('.')
58+
} else {
5459
return false;
55-
}
56-
let ver: Vec<u32> = client_id[PARITY_CLIENT_ID_PREFIX.len()..].split('.')
57-
.take(2)
58-
.filter_map(|s| s.parse().ok())
59-
.collect();
60+
};
61+
62+
let ver: Vec<u32> = splitted
63+
.take(2)
64+
.filter_map(|s| s.parse().ok())
65+
.collect();
6066
ver.len() == 2 && (ver[0] > SERVICE_TRANSACTIONS_VERSION.0 || (ver[0] == SERVICE_TRANSACTIONS_VERSION.0 && ver[1] >= SERVICE_TRANSACTIONS_VERSION.1))
6167
}
6268

@@ -577,13 +583,13 @@ mod tests {
577583
io.peers_info.insert(1, "Geth".to_owned());
578584
// and peer#2 is Parity, accepting service transactions
579585
insert_dummy_peer(&mut sync, 2, block_hash);
580-
io.peers_info.insert(2, "Parity/v1.6".to_owned());
586+
io.peers_info.insert(2, "Parity-Ethereum/v2.6".to_owned());
581587
// and peer#3 is Parity, discarding service transactions
582588
insert_dummy_peer(&mut sync, 3, block_hash);
583589
io.peers_info.insert(3, "Parity/v1.5".to_owned());
584590
// and peer#4 is Parity, accepting service transactions
585591
insert_dummy_peer(&mut sync, 4, block_hash);
586-
io.peers_info.insert(4, "Parity/v1.7.3-ABCDEFGH".to_owned());
592+
io.peers_info.insert(4, "Parity-Ethereum/v2.7.3-ABCDEFGH".to_owned());
587593

588594
// and new service transaction is propagated to peers
589595
SyncPropagator::propagate_new_transactions(&mut sync, &mut io);
@@ -607,7 +613,7 @@ mod tests {
607613

608614
// when peer#1 is Parity, accepting service transactions
609615
insert_dummy_peer(&mut sync, 1, block_hash);
610-
io.peers_info.insert(1, "Parity/v1.6".to_owned());
616+
io.peers_info.insert(1, "Parity-Ethereum/v2.6".to_owned());
611617

612618
// and service + non-service transactions are propagated to peers
613619
SyncPropagator::propagate_new_transactions(&mut sync, &mut io);

parity-clib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ name = "parity"
1010
crate-type = ["cdylib", "staticlib"]
1111

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

1515
[features]
1616
default = []
17-
final = ["parity/final"]
17+
final = ["parity-ethereum/final"]

parity-clib/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! Note that all the structs and functions here are documented in `parity.h`, to avoid
1818
//! duplicating documentation.
1919
20-
extern crate parity;
20+
extern crate parity_ethereum;
2121

2222
use std::os::raw::{c_char, c_void, c_int};
2323
use std::panic;
@@ -56,7 +56,7 @@ pub extern fn parity_config_from_cli(args: *const *const c_char, args_lens: *con
5656
args
5757
};
5858

59-
match parity::Configuration::parse_cli(&args) {
59+
match parity_ethereum::Configuration::parse_cli(&args) {
6060
Ok(mut cfg) => {
6161
// Always disable the auto-updater when used as a library.
6262
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
7777
pub extern fn parity_config_destroy(cfg: *mut c_void) {
7878
unsafe {
7979
let _ = panic::catch_unwind(|| {
80-
let _cfg = Box::from_raw(cfg as *mut parity::Configuration);
80+
let _cfg = Box::from_raw(cfg as *mut parity_ethereum::Configuration);
8181
});
8282
}
8383
}
@@ -89,7 +89,7 @@ pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -
8989
*output = ptr::null_mut();
9090
let cfg: &ParityParams = &*cfg;
9191

92-
let config = Box::from_raw(cfg.configuration as *mut parity::Configuration);
92+
let config = Box::from_raw(cfg.configuration as *mut parity_ethereum::Configuration);
9393

9494
let on_client_restart_cb = {
9595
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) -
106106
move |new_chain: String| { cb.call(new_chain); }
107107
};
108108

109-
let action = match parity::start(*config, on_client_restart_cb, || {}) {
109+
let action = match parity_ethereum::start(*config, on_client_restart_cb, || {}) {
110110
Ok(action) => action,
111111
Err(_) => return 1,
112112
};
113113

114114
match action {
115-
parity::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 },
116-
parity::ExecutionAction::Instant(None) => 0,
117-
parity::ExecutionAction::Running(client) => {
118-
*output = Box::into_raw(Box::<parity::RunningClient>::new(client)) as *mut c_void;
115+
parity_ethereum::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 },
116+
parity_ethereum::ExecutionAction::Instant(None) => 0,
117+
parity_ethereum::ExecutionAction::Running(client) => {
118+
*output = Box::into_raw(Box::<parity_ethereum::RunningClient>::new(client)) as *mut c_void;
119119
0
120120
}
121121
}
@@ -127,7 +127,7 @@ pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -
127127
pub extern fn parity_destroy(client: *mut c_void) {
128128
unsafe {
129129
let _ = panic::catch_unwind(|| {
130-
let client = Box::from_raw(client as *mut parity::RunningClient);
130+
let client = Box::from_raw(client as *mut parity_ethereum::RunningClient);
131131
client.shutdown();
132132
});
133133
}
@@ -137,7 +137,7 @@ pub extern fn parity_destroy(client: *mut c_void) {
137137
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 {
138138
unsafe {
139139
panic::catch_unwind(|| {
140-
let client: &mut parity::RunningClient = &mut *(client as *mut parity::RunningClient);
140+
let client: &mut parity_ethereum::RunningClient = &mut *(client as *mut parity_ethereum::RunningClient);
141141

142142
let query_str = {
143143
let string = slice::from_raw_parts(query as *const u8, len);

parity/configuration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Configuration {
102102
/// # Example
103103
///
104104
/// ```
105-
/// let _cfg = parity::Configuration::parse_cli(&["--light", "--chain", "kovan"]).unwrap();
105+
/// let _cfg = parity_ethereum::Configuration::parse_cli(&["--light", "--chain", "kovan"]).unwrap();
106106
/// ```
107107
pub fn parse_cli<S: AsRef<str>>(command: &[S]) -> Result<Self, ArgsError> {
108108
let config = Configuration {
@@ -722,7 +722,7 @@ impl Configuration {
722722
ret.client_version = {
723723
let mut client_version = version();
724724
if !self.args.arg_identity.is_empty() {
725-
// Insert name after the "Parity/" at the beginning of version string.
725+
// Insert name after the "Parity-Ethereum/" at the beginning of version string.
726726
let idx = client_version.find('/').unwrap_or(client_version.len());
727727
client_version.insert_str(idx, &format!("/{}", self.args.arg_identity));
728728
}
@@ -1740,7 +1740,7 @@ mod tests {
17401740
match conf.into_command().unwrap().cmd {
17411741
Cmd::Run(c) => {
17421742
assert_eq!(c.name, "Somebody");
1743-
assert!(c.net_conf.client_version.starts_with("Parity/Somebody/"));
1743+
assert!(c.net_conf.client_version.starts_with("Parity-Ethereum/Somebody/"));
17441744
}
17451745
_ => panic!("Should be Cmd::Run"),
17461746
}

0 commit comments

Comments
 (0)