From 56b6adec689561139d7e9b2d7a42c12217b2850c Mon Sep 17 00:00:00 2001 From: efyang Date: Sun, 22 Oct 2017 20:58:06 -0500 Subject: [PATCH 01/31] Iterate over both buffered and unbuffered database entries --- Cargo.lock | 7 +++++++ util/kvdb-rocksdb/Cargo.toml | 1 + util/kvdb-rocksdb/src/lib.rs | 20 +++++++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 935389755..5e5ea3ae3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1218,6 +1218,11 @@ name = "integer-encoding" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "interleaved-ordered" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "iovec" version = "0.1.0" @@ -1402,6 +1407,7 @@ version = "0.1.0" dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.1.3", + "interleaved-ordered 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3609,6 +3615,7 @@ dependencies = [ "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "356a0dc23a4fa0f8ce4777258085d00a01ea4923b2efd93538fc44bf5e1bda76" "checksum integer-encoding 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a053c9c7dcb7db1f2aa012c37dc176c62e4cdf14898dee0eecc606de835b8acb" +"checksum interleaved-ordered 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e385d0f35662722ffac6301494e37d201e884bd27d263cfbcc058febf994d16" "checksum iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29d062ee61fccdf25be172e70f34c9f6efc597e1fb8f6526e8437b2046ab26be" "checksum ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)" = "2134e210e2a024b5684f90e1556d5f71a1ce7f8b12e9ac9924c67fb36f63b336" "checksum isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fa500db770a99afe2a0f2229be2a3d09c7ed9d7e4e8440bf71253141994e240f" diff --git a/util/kvdb-rocksdb/Cargo.toml b/util/kvdb-rocksdb/Cargo.toml index e055c853e..f2eb569dc 100644 --- a/util/kvdb-rocksdb/Cargo.toml +++ b/util/kvdb-rocksdb/Cargo.toml @@ -12,6 +12,7 @@ parking_lot = "0.4" regex = "0.2" rlp = { path = "../rlp" } rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" } +interleaved-ordered = "0.1.0" [dev-dependencies] tempdir = "0.3" diff --git a/util/kvdb-rocksdb/src/lib.rs b/util/kvdb-rocksdb/src/lib.rs index d08c8ec85..69b8164d6 100644 --- a/util/kvdb-rocksdb/src/lib.rs +++ b/util/kvdb-rocksdb/src/lib.rs @@ -21,6 +21,7 @@ extern crate elastic_array; extern crate parking_lot; extern crate regex; extern crate rocksdb; +extern crate interleaved_ordered; extern crate ethcore_bigint as bigint; extern crate kvdb; @@ -36,6 +37,7 @@ use rocksdb::{ DB, Writable, WriteBatch, WriteOptions, IteratorMode, DBIterator, Options, DBCompactionStyle, BlockBasedOptions, Direction, Cache, Column, ReadOptions }; +use interleaved_ordered::{interleave_ordered, InterleaveOrdered}; use elastic_array::ElasticArray32; use rlp::{UntrustedRlp, RlpType, Compressible}; @@ -197,14 +199,14 @@ impl Default for DatabaseConfig { // inner DB (to prevent closing via restoration) may be re-evaluated in the future. // pub struct DatabaseIterator<'a> { - iter: DBIterator, + iter: InterleaveOrdered<::std::vec::IntoIter<(Box<[u8]>, Box<[u8]>)>, DBIterator>, _marker: PhantomData<&'a Database>, } impl<'a> Iterator for DatabaseIterator<'a> { type Item = (Box<[u8]>, Box<[u8]>); - fn next(&mut self) -> Option { + fn next(&mut self) -> Option { self.iter.next() } } @@ -510,9 +512,17 @@ impl Database { /// Get database iterator for flushed data. pub fn iter(&self, col: Option) -> Option { - //TODO: iterate over overlay match *self.db.read() { Some(DBAndColumns { ref db, ref cfs }) => { + let overlay = &self.overlay.read()[Self::to_overlay_column(col)]; + let overlay_data = overlay.iter() + .filter_map(|(k, v)| match v { + &KeyState::Insert(ref value) | + &KeyState::InsertCompressed(ref value) => + Some((k.clone().into_vec().into_boxed_slice(), value.clone().into_vec().into_boxed_slice())), + &KeyState::Delete => None, + }).collect::>(); + let iter = col.map_or_else( || db.iterator_opt(IteratorMode::Start, &self.read_opts), |c| db.iterator_cf_opt(cfs[c as usize], IteratorMode::Start, &self.read_opts) @@ -520,7 +530,7 @@ impl Database { ); Some(DatabaseIterator { - iter: iter, + iter: interleave_ordered(overlay_data, iter), _marker: PhantomData, }) }, @@ -536,7 +546,7 @@ impl Database { .expect("iterator params are valid; qed")); Some(DatabaseIterator { - iter: iter, + iter: interleave_ordered(Vec::new(), iter), _marker: PhantomData, }) }, From 9b4db8b4f0e2e66df76e6284e828431413cf467b Mon Sep 17 00:00:00 2001 From: efyang Date: Sat, 28 Oct 2017 16:59:00 -0500 Subject: [PATCH 02/31] Fix iterator issues --- util/kvdb-rocksdb/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/kvdb-rocksdb/src/lib.rs b/util/kvdb-rocksdb/src/lib.rs index 69b8164d6..cae3b6be4 100644 --- a/util/kvdb-rocksdb/src/lib.rs +++ b/util/kvdb-rocksdb/src/lib.rs @@ -515,13 +515,14 @@ impl Database { match *self.db.read() { Some(DBAndColumns { ref db, ref cfs }) => { let overlay = &self.overlay.read()[Self::to_overlay_column(col)]; - let overlay_data = overlay.iter() - .filter_map(|(k, v)| match v { - &KeyState::Insert(ref value) | - &KeyState::InsertCompressed(ref value) => + let mut overlay_data = overlay.iter() + .filter_map(|(k, v)| match *v { + KeyState::Insert(ref value) | + KeyState::InsertCompressed(ref value) => Some((k.clone().into_vec().into_boxed_slice(), value.clone().into_vec().into_boxed_slice())), - &KeyState::Delete => None, + KeyState::Delete => None, }).collect::>(); + overlay_data.sort(); let iter = col.map_or_else( || db.iterator_opt(IteratorMode::Start, &self.read_opts), From 4c8780f1886ca01346501a25a34e70385b7ee3c2 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Thu, 9 Nov 2017 19:49:34 +0100 Subject: [PATCH 03/31] Use nonce reservation per address --- parity/rpc_apis.rs | 13 ++++++------- rpc/src/v1/helpers/dispatch.rs | 30 ++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index be9dbdeb1..6c48adb69 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -239,10 +239,10 @@ impl FullDependencies { use parity_rpc::v1::*; macro_rules! add_signing_methods { - ($namespace:ident, $handler:expr, $deps:expr, $nonces:expr) => { + ($namespace:ident, $handler:expr, $deps:expr) => { { let deps = &$deps; - let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), $nonces); + let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), deps.fetch.pool()); if deps.signer_service.is_enabled() { $handler.extend_with($namespace::to_delegate(SigningQueueClient::new(&deps.signer_service, dispatcher, deps.remote.clone(), &deps.secret_store))) } else { @@ -252,11 +252,10 @@ impl FullDependencies { } } - let nonces = Arc::new(Mutex::new(dispatch::Reservations::with_pool(self.fetch.pool()))); let dispatcher = FullDispatcher::new( self.client.clone(), self.miner.clone(), - nonces.clone(), + self.fetch.pool(), ); for api in apis { match *api { @@ -286,7 +285,7 @@ impl FullDependencies { let filter_client = EthFilterClient::new(self.client.clone(), self.miner.clone()); handler.extend_with(filter_client.to_delegate()); - add_signing_methods!(EthSigning, handler, self, nonces.clone()); + add_signing_methods!(EthSigning, handler, self); } }, Api::EthPubSub => { @@ -323,7 +322,7 @@ impl FullDependencies { ).to_delegate()); if !for_generic_pubsub { - add_signing_methods!(ParitySigning, handler, self, nonces.clone()); + add_signing_methods!(ParitySigning, handler, self); } }, Api::ParityPubSub => { @@ -440,7 +439,7 @@ impl LightDependencies { self.on_demand.clone(), self.cache.clone(), self.transaction_queue.clone(), - Arc::new(Mutex::new(dispatch::Reservations::with_pool(self.fetch.pool()))), + self.fetch.pool(), ); macro_rules! add_signing_methods { diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index c556226b5..9220790e8 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -19,6 +19,7 @@ use std::fmt::Debug; use std::ops::Deref; use std::sync::Arc; +use std::collections::HashMap; use light::cache::Cache as LightDataCache; use light::client::LightChainClient; @@ -32,6 +33,7 @@ use util::Address; use bytes::Bytes; use parking_lot::{Mutex, RwLock}; use stats::Corpus; +use futures_cpupool::CpuPool; use ethkey::Signature; use ethsync::LightSync; @@ -87,16 +89,20 @@ pub trait Dispatcher: Send + Sync + Clone { pub struct FullDispatcher { client: Arc, miner: Arc, - nonces: Arc>, + nonces: Arc>>, + pool: CpuPool, } impl FullDispatcher { /// Create a `FullDispatcher` from Arc references to a client and miner. - pub fn new(client: Arc, miner: Arc, nonces: Arc>) -> Self { + pub fn new(client: Arc, miner: Arc, pool: CpuPool) -> Self { + let nonces = Arc::new(Mutex::new(HashMap::new())); + FullDispatcher { client, miner, nonces, + pool, } } } @@ -107,6 +113,7 @@ impl Clone for FullDispatcher { client: self.client.clone(), miner: self.miner.clone(), nonces: self.nonces.clone(), + pool: self.pool.clone(), } } } @@ -162,7 +169,10 @@ impl Dispatcher for FullDispatcher>, /// Nonce reservations - pub nonces: Arc>, + pub nonces: Arc>>, + /// Cpu pool + pub pool: CpuPool, } impl LightDispatcher { @@ -265,8 +277,10 @@ impl LightDispatcher { on_demand: Arc, cache: Arc>, transaction_queue: Arc>, - nonces: Arc>, + pool: CpuPool, ) -> Self { + let nonces = Arc::new(Mutex::new(HashMap::new())); + LightDispatcher { sync, client, @@ -274,6 +288,7 @@ impl LightDispatcher { cache, transaction_queue, nonces, + pool, } } @@ -379,10 +394,13 @@ impl Dispatcher for LightDispatcher { } let nonces = self.nonces.clone(); + let pool = self.pool.clone(); Box::new(self.next_nonce(filled.from) .map_err(|_| errors::no_light_peers()) .and_then(move |nonce| { - let reserved = nonces.lock().reserve_nonce(nonce); + let reserved = nonces.lock().entry(filled.from) + .or_insert(nonce::Reservations::with_pool(pool)) + .reserve_nonce(nonce); ProspectiveSigner::new(accounts, filled, chain_id, reserved, password) })) } From 261c0d53684f7f461970a41e90bc965eef8cc70a Mon Sep 17 00:00:00 2001 From: keorn Date: Thu, 9 Nov 2017 23:56:02 +0000 Subject: [PATCH 04/31] no default uncles --- ethcore/res/ethereum/kovan.json | 3 ++- ethcore/src/engines/authority_round/mod.rs | 8 ++++++++ ethcore/src/engines/mod.rs | 2 +- ethcore/src/engines/null_engine.rs | 2 ++ ethcore/src/ethereum/ethash.rs | 2 ++ json/src/spec/authority_round.rs | 2 ++ 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index 325b7cdf6..71eab873d 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -23,7 +23,8 @@ ] }, "validateScoreTransition": 1000000, - "validateStepTransition": 1500000 + "validateStepTransition": 1500000, + "maximumUncleCount": 2 } } }, diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index 27bd678a9..8c693ca07 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -65,6 +65,8 @@ pub struct AuthorityRoundParams { pub immediate_transitions: bool, /// Block reward in base units. pub block_reward: U256, + /// Number of accepted uncles. + pub maximum_uncle_count: usize, } impl From for AuthorityRoundParams { @@ -77,6 +79,7 @@ impl From for AuthorityRoundParams { validate_step_transition: p.validate_step_transition.map_or(0, Into::into), immediate_transitions: p.immediate_transitions.unwrap_or(false), block_reward: p.block_reward.map_or_else(Default::default, Into::into), + maximum_uncle_count: p.maximum_uncle_count.map_or(0, Into::into), } } } @@ -218,6 +221,7 @@ pub struct AuthorityRound { epoch_manager: Mutex, immediate_transitions: bool, block_reward: U256, + maximum_uncle_count: usize, machine: EthereumMachine, } @@ -365,6 +369,7 @@ impl AuthorityRound { epoch_manager: Mutex::new(EpochManager::blank()), immediate_transitions: our_params.immediate_transitions, block_reward: our_params.block_reward, + maximum_uncle_count: our_params.maximum_uncle_count, machine: machine, }); @@ -436,6 +441,8 @@ impl Engine for AuthorityRound { ] } + fn maximum_uncle_count(&self) -> usize { self.maximum_uncle_count } + fn populate_from_parent(&self, header: &mut Header, parent: &Header) { // Chain scoring: total weight is sqrt(U256::max_value())*height - step let new_difficulty = U256::from(U128::max_value()) + header_step(parent).expect("Header has been verified; qed").into() - self.step.load().into(); @@ -949,6 +956,7 @@ mod tests { validate_score_transition: 0, validate_step_transition: 0, immediate_transitions: true, + maximum_uncle_count: 0, block_reward: Default::default(), }; diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 802b4ab88..89de861bb 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -192,7 +192,7 @@ pub trait Engine: Sync + Send { fn extra_info(&self, _header: &M::Header) -> BTreeMap { BTreeMap::new() } /// Maximum number of uncles a block is allowed to declare. - fn maximum_uncle_count(&self) -> usize { 2 } + fn maximum_uncle_count(&self) -> usize { 0 } /// The number of generations back that uncles can be. fn maximum_uncle_age(&self) -> usize { 6 } diff --git a/ethcore/src/engines/null_engine.rs b/ethcore/src/engines/null_engine.rs index 1c7edc99b..518f0f8f5 100644 --- a/ethcore/src/engines/null_engine.rs +++ b/ethcore/src/engines/null_engine.rs @@ -95,6 +95,8 @@ impl Engine for NullEngine { self.machine.note_rewards(block, &[(author, result_block_reward)], &uncle_rewards) } + fn maximum_uncle_count(&self) -> usize { 2 } + fn verify_local_seal(&self, _header: &M::Header) -> Result<(), M::Error> { Ok(()) } diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index a49ba2e2a..3ecccd9a8 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -181,6 +181,8 @@ impl Engine for Arc { } } + fn maximum_uncle_count(&self) -> usize { 2 } + fn populate_from_parent(&self, header: &mut Header, parent: &Header) { let difficulty = self.calculate_difficulty(header, parent); header.set_difficulty(difficulty); diff --git a/json/src/spec/authority_round.rs b/json/src/spec/authority_round.rs index 984e2eff2..b3e75a6b4 100644 --- a/json/src/spec/authority_round.rs +++ b/json/src/spec/authority_round.rs @@ -43,6 +43,8 @@ pub struct AuthorityRoundParams { /// Reward per block in wei. #[serde(rename="blockReward")] pub block_reward: Option, + #[serde(rename="maximumUncleCount")] + pub maximum_uncle_count: Option, } /// Authority engine deserialization. From 15c97336a432e3fbcb899455837feef41442b5db Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Fri, 10 Nov 2017 17:11:04 +0100 Subject: [PATCH 05/31] Create hashmap in RPC Apis --- parity/rpc_apis.rs | 14 ++++++++------ rpc/src/v1/helpers/dispatch.rs | 12 +++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 6c48adb69..281b97589 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -15,8 +15,7 @@ // along with Parity. If not, see . use std::cmp::PartialEq; -use std::collections::BTreeMap; -use std::collections::HashSet; +use std::collections::{BTreeMap, HashSet, HashMap}; use std::str::FromStr; use std::sync::{Arc, Weak}; @@ -239,10 +238,10 @@ impl FullDependencies { use parity_rpc::v1::*; macro_rules! add_signing_methods { - ($namespace:ident, $handler:expr, $deps:expr) => { + ($namespace:ident, $handler:expr, $deps:expr, $nonces:expr) => { { let deps = &$deps; - let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), deps.fetch.pool()); + let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), deps.fetch.pool(), $nonces); if deps.signer_service.is_enabled() { $handler.extend_with($namespace::to_delegate(SigningQueueClient::new(&deps.signer_service, dispatcher, deps.remote.clone(), &deps.secret_store))) } else { @@ -252,10 +251,12 @@ impl FullDependencies { } } + let nonces = Arc::new(Mutex::new(HashMap::new())); let dispatcher = FullDispatcher::new( self.client.clone(), self.miner.clone(), self.fetch.pool(), + nonces.clone(), ); for api in apis { match *api { @@ -285,7 +286,7 @@ impl FullDependencies { let filter_client = EthFilterClient::new(self.client.clone(), self.miner.clone()); handler.extend_with(filter_client.to_delegate()); - add_signing_methods!(EthSigning, handler, self); + add_signing_methods!(EthSigning, handler, self, nonces.clone()); } }, Api::EthPubSub => { @@ -322,7 +323,7 @@ impl FullDependencies { ).to_delegate()); if !for_generic_pubsub { - add_signing_methods!(ParitySigning, handler, self); + add_signing_methods!(ParitySigning, handler, self, nonces.clone()); } }, Api::ParityPubSub => { @@ -440,6 +441,7 @@ impl LightDependencies { self.cache.clone(), self.transaction_queue.clone(), self.fetch.pool(), + Arc::new(Mutex::new(HashMap::new())), ); macro_rules! add_signing_methods { diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index 9220790e8..f17797619 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -95,9 +95,12 @@ pub struct FullDispatcher { impl FullDispatcher { /// Create a `FullDispatcher` from Arc references to a client and miner. - pub fn new(client: Arc, miner: Arc, pool: CpuPool) -> Self { - let nonces = Arc::new(Mutex::new(HashMap::new())); - + pub fn new( + client: Arc, + miner: Arc, + pool: CpuPool, + nonces: Arc>>, + ) -> Self { FullDispatcher { client, miner, @@ -278,9 +281,8 @@ impl LightDispatcher { cache: Arc>, transaction_queue: Arc>, pool: CpuPool, + nonces: Arc>>, ) -> Self { - let nonces = Arc::new(Mutex::new(HashMap::new())); - LightDispatcher { sync, client, From be092e7c092aa0a73f44c9eb0792a9dca8929354 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 18:31:31 +0100 Subject: [PATCH 06/31] prepare cargo configuration for upload of crates --- Cargo.lock | 10 +++++----- ethcore/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/vm/Cargo.toml | 2 +- logger/Cargo.toml | 2 +- util/Cargo.toml | 2 +- util/bytes/Cargo.toml | 2 ++ util/hashdb/Cargo.toml | 4 +++- util/memorydb/Cargo.toml | 10 ++++++---- util/patricia_trie/Cargo.toml | 20 +++++++++----------- util/patricia_trie/src/triedbmut.rs | 1 + util/triehash/Cargo.toml | 2 ++ 12 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d139937f..103e86e7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -529,7 +529,7 @@ dependencies = [ "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia_trie 0.1.0", + "patricia-trie 0.1.0", "price-info 1.7.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -616,7 +616,7 @@ dependencies = [ "memory-cache 0.1.0", "memorydb 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia_trie 0.1.0", + "patricia-trie 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.0", "rlp_derive 0.1.0", @@ -754,7 +754,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia_trie 0.1.0", + "patricia-trie 0.1.0", "rlp 0.2.0", "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2340,7 +2340,7 @@ name = "path" version = "0.1.0" [[package]] -name = "patricia_trie" +name = "patricia-trie" version = "0.1.0" dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3413,7 +3413,7 @@ dependencies = [ "ethjson 0.1.0", "hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia_trie 0.1.0", + "patricia-trie 0.1.0", "rlp 0.2.0", ] diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 2f77b8cb3..581889445 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -19,7 +19,7 @@ ethcore-bloom-journal = { path = "../util/bloom" } ethcore-bytes = { path = "../util/bytes" } hashdb = { path = "../util/hashdb" } memorydb = { path = "../util/memorydb" } -patricia_trie = { path = "../util/patricia_trie" } +patricia-trie = { path = "../util/patricia_trie" } ethcore-devtools = { path = "../devtools" } ethcore-io = { path = "../util/io" } ethcore-logger = { path = "../logger" } diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 2b56a30bd..5f80bb654 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -13,7 +13,7 @@ ethcore-util = { path = "../../util" } ethcore-bigint = { path = "../../util/bigint" } ethcore-bytes = { path = "../../util/bytes" } memorydb = { path = "../../util/memorydb" } -patricia_trie = { path = "../../util/patricia_trie" } +patricia-trie = { path = "../../util/patricia_trie" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } ethcore-devtools = { path = "../../devtools" } diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index 7f497a642..dd066dc7e 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -8,7 +8,7 @@ byteorder = "1.0" ethcore-util = { path = "../../util" } ethcore-bytes = { path = "../../util/bytes" } ethcore-bigint = { path = "../../util/bigint" } -patricia_trie = { path = "../../util/patricia_trie" } +patricia-trie = { path = "../../util/patricia_trie" } log = "0.3" common-types = { path = "../types" } ethjson = { path = "../../json" } diff --git a/logger/Cargo.toml b/logger/Cargo.toml index fc63701c4..b3424ada1 100644 --- a/logger/Cargo.toml +++ b/logger/Cargo.toml @@ -1,5 +1,5 @@ [package] -description = "Ethcore client." +description = "Log implementation for Parity" name = "ethcore-logger" version = "1.9.0" license = "GPL-3.0" diff --git a/util/Cargo.toml b/util/Cargo.toml index 9341a1bdd..a05a4d18f 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -26,7 +26,7 @@ tiny-keccak= "1.0" ethcore-logger = { path = "../logger" } triehash = { path = "triehash" } hashdb = { path = "hashdb" } -patricia_trie = { path = "patricia_trie" } +patricia-trie = { path = "patricia_trie" } ethcore-bytes = { path = "bytes" } memorydb = { path = "memorydb" } util-error = { path = "error" } diff --git a/util/bytes/Cargo.toml b/util/bytes/Cargo.toml index 96dc0abb1..b20e38a2a 100644 --- a/util/bytes/Cargo.toml +++ b/util/bytes/Cargo.toml @@ -2,5 +2,7 @@ name = "ethcore-bytes" version = "0.1.0" authors = ["Parity Technologies "] +description = "byte utilities for Parity" +license = "GPL-3.0" [dependencies] diff --git a/util/hashdb/Cargo.toml b/util/hashdb/Cargo.toml index d74e47a7e..bd4fd8a16 100644 --- a/util/hashdb/Cargo.toml +++ b/util/hashdb/Cargo.toml @@ -2,7 +2,9 @@ name = "hashdb" version = "0.1.0" authors = ["Parity Technologies "] +description = "trait for hash-keyed databases." +license = "GPL-3.0" [dependencies] elastic-array = "0.9" -ethcore-bigint = { path = "../bigint" } +ethcore-bigint = { version = "0.1.3", path = "../bigint" } diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index 1df95a049..f651f92d5 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -2,12 +2,14 @@ name = "memorydb" version = "0.1.0" authors = ["Parity Technologies "] +description = "in-memory implementation of hashdb" +license = "GPL-3.0" [dependencies] bigint = "4.0" elastic-array = "0.9" heapsize = "0.4" -ethcore-bigint = { path = "../bigint", features = ["heapsizeof"] } -hash = { path = "../hash" } -hashdb = { path = "../hashdb" } -rlp = { path = "../rlp" } +ethcore-bigint = { version = "0.1.3", path = "../bigint", features = ["heapsizeof"] } +hash = { version = "0.1.0", path = "../hash" } +hashdb = { version = "0.1.0", path = "../hashdb" } +rlp = { version = "0.2.0", path = "../rlp" } diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index 5886a4e35..295bae867 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "patricia_trie" +name = "patricia-trie" version = "0.1.0" authors = ["Parity Technologies "] @@ -7,13 +7,11 @@ authors = ["Parity Technologies "] elastic-array = "0.9" log = "0.3" rand = "0.3" -ethcore-bytes = { path = "../bytes" } -ethcore-bigint = { path = "../bigint" } -hash = { path = "../hash" } -hashdb = { path = "../hashdb" } -rlp = { path = "../rlp" } -triehash = { path = "../triehash" } -memorydb = { path = "../memorydb" } -ethcore-logger = { path = "../../logger" } - - +ethcore-bytes = { version = "0.1.0", path = "../bytes" } +ethcore-bigint = { version = "0.1.3", path = "../bigint" } +hash = { version = "0.1.0", path = "../hash" } +hashdb = { version = "0.1.0", path = "../hashdb" } +rlp = { version = "0.2.0", path = "../rlp" } +triehash = { version = "0.1.0", path = "../triehash" } +memorydb = { version = "0.1.0", path = "../memorydb" } +ethcore-logger = { version = "1.9.0", path = "../../logger" } diff --git a/util/patricia_trie/src/triedbmut.rs b/util/patricia_trie/src/triedbmut.rs index d0e22d2fb..97c3c93e7 100644 --- a/util/patricia_trie/src/triedbmut.rs +++ b/util/patricia_trie/src/triedbmut.rs @@ -942,6 +942,7 @@ impl<'a> Drop for TrieDBMut<'a> { #[cfg(test)] mod tests { extern crate triehash; + use self::triehash::trie_root; use hashdb::*; use memorydb::*; diff --git a/util/triehash/Cargo.toml b/util/triehash/Cargo.toml index cc18a6ea8..1fae40dfc 100644 --- a/util/triehash/Cargo.toml +++ b/util/triehash/Cargo.toml @@ -2,6 +2,8 @@ name = "triehash" version = "0.1.0" authors = ["Parity Technologies "] +description = "in memory patricia trie operations" +license = "GPL-3.0" [dependencies] rlp = { path = "../rlp" } From 5423518e1efcf64bf4153c634d690f37ab798226 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 18:43:18 +0100 Subject: [PATCH 07/31] update bigint version number --- util/memorydb/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index f651f92d5..0c2f954e1 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0" bigint = "4.0" elastic-array = "0.9" heapsize = "0.4" -ethcore-bigint = { version = "0.1.3", path = "../bigint", features = ["heapsizeof"] } +ethcore-bigint = { version = "0.2", path = "../bigint", features = ["heapsizeof"] } hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.0", path = "../hashdb" } rlp = { version = "0.2.0", path = "../rlp" } From 5c8f39c3bd452174b5126635a9e7a7af2fa3f979 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 18:46:35 +0100 Subject: [PATCH 08/31] update ethcore-bigint version --- Cargo.lock | 12 ++++++------ util/hashdb/Cargo.toml | 4 ++-- util/patricia_trie/Cargo.toml | 4 ++-- util/triehash/Cargo.toml | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 177b1b5be..d2f8485cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -494,7 +494,7 @@ dependencies = [ "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "hardware-wallet 1.9.0", "hash 0.1.0", - "hashdb 0.1.0", + "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -731,7 +731,7 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", "hash 0.1.0", - "hashdb 0.1.0", + "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", "kvdb 0.1.0", @@ -1037,7 +1037,7 @@ dependencies = [ [[package]] name = "hashdb" -version = "0.1.0" +version = "0.1.1" dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", @@ -1223,7 +1223,7 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", "hash 0.1.0", - "hashdb 0.1.0", + "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", @@ -1513,7 +1513,7 @@ dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "hash 0.1.0", - "hashdb 0.1.0", + "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.0", ] @@ -2334,7 +2334,7 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", "hash 0.1.0", - "hashdb 0.1.0", + "hashdb 0.1.1", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/util/hashdb/Cargo.toml b/util/hashdb/Cargo.toml index bd4fd8a16..0060afbaa 100644 --- a/util/hashdb/Cargo.toml +++ b/util/hashdb/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "hashdb" -version = "0.1.0" +version = "0.1.1" authors = ["Parity Technologies "] description = "trait for hash-keyed databases." license = "GPL-3.0" [dependencies] elastic-array = "0.9" -ethcore-bigint = { version = "0.1.3", path = "../bigint" } +ethcore-bigint = { version = "0.2.1", path = "../bigint" } diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index 295bae867..7b5ae3879 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -8,9 +8,9 @@ elastic-array = "0.9" log = "0.3" rand = "0.3" ethcore-bytes = { version = "0.1.0", path = "../bytes" } -ethcore-bigint = { version = "0.1.3", path = "../bigint" } +ethcore-bigint = { version = "0.2.1", path = "../bigint" } hash = { version = "0.1.0", path = "../hash" } -hashdb = { version = "0.1.0", path = "../hashdb" } +hashdb = { version = "0.1.1", path = "../hashdb" } rlp = { version = "0.2.0", path = "../rlp" } triehash = { version = "0.1.0", path = "../triehash" } memorydb = { version = "0.1.0", path = "../memorydb" } diff --git a/util/triehash/Cargo.toml b/util/triehash/Cargo.toml index 1fae40dfc..2731a4685 100644 --- a/util/triehash/Cargo.toml +++ b/util/triehash/Cargo.toml @@ -6,6 +6,6 @@ description = "in memory patricia trie operations" license = "GPL-3.0" [dependencies] -rlp = { path = "../rlp" } -ethcore-bigint = { path = "../bigint" } -hash = { path = "../hash" } +rlp = { version = "0.2", path = "../rlp" } +ethcore-bigint = { version = "0.2.1", path = "../bigint" } +hash = { version = "0.1", path = "../hash" } From ec5519ccd153fd62ebbd501bebe1f8553f85d1cf Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 19:04:55 +0100 Subject: [PATCH 09/31] rename hash crate to keccak-hash --- Cargo.lock | 62 +++++++++++++++++------------------ Cargo.toml | 2 +- dapps/Cargo.toml | 2 +- dapps/src/lib.rs | 2 +- ethash/Cargo.toml | 2 +- ethash/src/keccak.rs | 2 +- ethcore/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/evm/src/lib.rs | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/light/src/lib.rs | 2 +- ethcore/src/lib.rs | 2 +- ethcore/types/Cargo.toml | 2 +- ethcore/types/src/lib.rs | 2 +- ethcore/vm/Cargo.toml | 2 +- ethcore/vm/src/lib.rs | 2 +- hash-fetch/Cargo.toml | 2 +- hash-fetch/src/lib.rs | 2 +- parity/main.rs | 2 +- rpc/Cargo.toml | 2 +- rpc/src/lib.rs | 2 +- rpc_client/Cargo.toml | 2 +- rpc_client/src/lib.rs | 2 +- secret_store/Cargo.toml | 2 +- secret_store/src/lib.rs | 2 +- stratum/Cargo.toml | 2 +- stratum/src/lib.rs | 2 +- sync/Cargo.toml | 2 +- sync/src/lib.rs | 2 +- util/Cargo.toml | 2 +- util/bloomable/Cargo.toml | 2 +- util/bloomable/tests/test.rs | 2 +- util/hash/Cargo.toml | 4 +-- util/journaldb/Cargo.toml | 2 +- util/journaldb/src/lib.rs | 2 +- util/memorydb/Cargo.toml | 2 +- util/memorydb/src/lib.rs | 2 +- util/network/Cargo.toml | 2 +- util/network/src/lib.rs | 2 +- util/patricia_trie/Cargo.toml | 2 +- util/patricia_trie/src/lib.rs | 2 +- util/src/lib.rs | 2 +- util/triehash/Cargo.toml | 2 +- util/triehash/src/lib.rs | 2 +- 44 files changed, 75 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2f8485cb..240765c6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,7 +168,7 @@ name = "bloomable" version = "0.1.0" dependencies = [ "ethcore-bigint 0.2.1", - "hash 0.1.0", + "keccak-hash 0.1.0", ] [[package]] @@ -284,8 +284,8 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethcore-util 1.9.0", "ethjson 0.1.0", - "hash 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "rlp 0.2.0", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -459,7 +459,7 @@ version = "1.9.0" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", + "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -493,12 +493,12 @@ dependencies = [ "evm 0.1.0", "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "hardware-wallet 1.9.0", - "hash 0.1.0", "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "kvdb-rocksdb 0.1.0", @@ -592,9 +592,9 @@ dependencies = [ "ethcore-util 1.9.0", "evm 0.1.0", "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "kvdb-rocksdb 0.1.0", @@ -645,9 +645,9 @@ dependencies = [ "ethcore-util 1.9.0", "ethcrypto 0.1.0", "ethkey 0.2.0", - "hash 0.1.0", "igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -680,8 +680,8 @@ dependencies = [ "ethkey 0.2.0", "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-rocksdb 0.1.0", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -709,10 +709,10 @@ dependencies = [ "ethcore-devtools 1.9.0", "ethcore-logger 1.9.0", "ethcore-util 1.9.0", - "hash 0.1.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -730,10 +730,10 @@ dependencies = [ "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", - "hash 0.1.0", "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -853,9 +853,9 @@ dependencies = [ "ethcore-network 1.9.0", "ethcore-util 1.9.0", "ethkey 0.2.0", - "hash 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -877,8 +877,8 @@ dependencies = [ "ethcore-bigint 0.2.1", "ethcore-util 1.9.0", "evmjit 1.9.0", - "hash 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", @@ -1025,16 +1025,6 @@ dependencies = [ "trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)", ] -[[package]] -name = "hash" -version = "0.1.0" -dependencies = [ - "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-bigint 0.2.1", - "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hashdb" version = "0.1.1" @@ -1222,9 +1212,9 @@ dependencies = [ "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", - "hash 0.1.0", "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1329,6 +1319,16 @@ dependencies = [ "ws 0.7.1 (git+https://github.com/tomusdrw/ws-rs)", ] +[[package]] +name = "keccak-hash" +version = "0.1.0" +dependencies = [ + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethcore-bigint 0.2.1", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1512,9 +1512,9 @@ dependencies = [ "bigint 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", - "hash 0.1.0", "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.1.0", "rlp 0.2.0", ] @@ -1920,11 +1920,11 @@ dependencies = [ "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-rocksdb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1976,10 +1976,10 @@ dependencies = [ "fetch 0.1.0", "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "keccak-hash 0.1.0", "linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2037,7 +2037,7 @@ dependencies = [ "ethcore-util 1.9.0", "fetch 0.1.0", "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", + "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2123,7 +2123,6 @@ dependencies = [ "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hardware-wallet 1.9.0", - "hash 0.1.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", @@ -2131,6 +2130,7 @@ dependencies = [ "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "keccak-hash 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", @@ -2161,9 +2161,9 @@ name = "parity-rpc-client" version = "1.4.0" dependencies = [ "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "hash 0.1.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.9.0", @@ -2333,8 +2333,8 @@ dependencies = [ "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", - "hash 0.1.0", "hashdb 0.1.1", + "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3246,7 +3246,7 @@ name = "triehash" version = "0.1.0" dependencies = [ "ethcore-bigint 0.2.1", - "hash 0.1.0", + "keccak-hash 0.1.0", "rlp 0.2.0", ] @@ -3397,7 +3397,7 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethcore-util 1.9.0", "ethjson 0.1.0", - "hash 0.1.0", + "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "rlp 0.2.0", diff --git a/Cargo.toml b/Cargo.toml index a953dcef8..26dd940a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ parity-updater = { path = "updater" } parity-whisper = { path = "whisper" } path = { path = "util/path" } panic_hook = { path = "panic_hook" } -hash = { path = "util/hash" } +keccak-hash = { path = "util/hash" } migration = { path = "util/migration" } kvdb = { path = "util/kvdb" } kvdb-rocksdb = { path = "util/kvdb-rocksdb" } diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index c0e856791..cd8497954 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -36,7 +36,7 @@ node-health = { path = "./node-health" } parity-hash-fetch = { path = "../hash-fetch" } parity-reactor = { path = "../util/reactor" } parity-ui = { path = "./ui" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } clippy = { version = "0.0.103", optional = true} diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs index 36b5bec4c..9198222ee 100644 --- a/dapps/src/lib.rs +++ b/dapps/src/lib.rs @@ -43,7 +43,7 @@ extern crate node_health; extern crate parity_dapps_glue as parity_dapps; extern crate parity_hash_fetch as hash_fetch; extern crate parity_ui; -extern crate hash; +extern crate keccak_hash as hash; #[macro_use] extern crate futures; diff --git a/ethash/Cargo.toml b/ethash/Cargo.toml index e60d63c22..b6986af83 100644 --- a/ethash/Cargo.toml +++ b/ethash/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] log = "0.3" -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } primal = "0.2.3" parking_lot = "0.4" crunchy = "0.1.0" diff --git a/ethash/src/keccak.rs b/ethash/src/keccak.rs index 752b0230b..8ca4f5438 100644 --- a/ethash/src/keccak.rs +++ b/ethash/src/keccak.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -extern crate hash; +extern crate keccak_hash as hash; pub type H256 = [u8; 32]; diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 581889445..56f06d1bf 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -67,7 +67,7 @@ table = { path = "../util/table" } bloomable = { path = "../util/bloomable" } vm = { path = "vm" } wasm = { path = "wasm" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } triehash = { path = "../util/triehash" } semantic_version = { path = "../util/semantic_version" } unexpected = { path = "../util/unexpected" } diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 5cef517f4..b57e599bb 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -12,7 +12,7 @@ heapsize = "0.4" lazy_static = "0.2" log = "0.3" vm = { path = "../vm" } -hash = { path = "../../util/hash" } +keccak-hash = { path = "../../util/hash" } parking_lot = "0.4" memory-cache = { path = "../../util/memory_cache" } diff --git a/ethcore/evm/src/lib.rs b/ethcore/evm/src/lib.rs index 7ddbed19e..8a250f847 100644 --- a/ethcore/evm/src/lib.rs +++ b/ethcore/evm/src/lib.rs @@ -22,7 +22,7 @@ extern crate ethcore_bigint as bigint; extern crate parking_lot; extern crate heapsize; extern crate vm; -extern crate hash; +extern crate keccak_hash as hash; extern crate memory_cache; #[macro_use] diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 5f80bb654..178a46650 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -32,7 +32,7 @@ serde = "1.0" serde_derive = "1.0" parking_lot = "0.4" stats = { path = "../../util/stats" } -hash = { path = "../../util/hash" } +keccak-hash = { path = "../../util/hash" } triehash = { path = "../../util/triehash" } kvdb = { path = "../../util/kvdb" } kvdb-rocksdb = { path = "../../util/kvdb-rocksdb" } diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index f9c3d89b8..039ed0e79 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -76,7 +76,7 @@ extern crate smallvec; extern crate stats; extern crate time; extern crate vm; -extern crate hash; +extern crate keccak_hash as hash; extern crate triehash; extern crate kvdb; extern crate kvdb_memorydb; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 4620cc892..b969a39dd 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -103,7 +103,7 @@ extern crate price_info; extern crate rand; extern crate rayon; extern crate rlp; -extern crate hash; +extern crate keccak_hash as hash; extern crate heapsize; extern crate memorydb; extern crate patricia_trie as trie; diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 73d7b2932..5e037c2a4 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -12,7 +12,7 @@ ethcore-util = { path = "../../util" } ethcore-bigint = { path = "../../util/bigint" } ethjson = { path = "../../json" } bloomable = { path = "../../util/bloomable" } -hash = { path = "../../util/hash" } +keccak-hash = { path = "../../util/hash" } heapsize = "0.4" [dev-dependencies] diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index 85d36b200..51e2890d4 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -24,7 +24,7 @@ extern crate rlp; #[macro_use] extern crate rlp_derive; extern crate bloomable; -extern crate hash; +extern crate keccak_hash as hash; extern crate heapsize; #[cfg(test)] diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index dd066dc7e..24e75be2e 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -13,4 +13,4 @@ log = "0.3" common-types = { path = "../types" } ethjson = { path = "../../json" } rlp = { path = "../../util/rlp" } -hash = { path = "../../util/hash" } +keccak-hash = { path = "../../util/hash" } diff --git a/ethcore/vm/src/lib.rs b/ethcore/vm/src/lib.rs index 1f88bf625..08f0aa639 100644 --- a/ethcore/vm/src/lib.rs +++ b/ethcore/vm/src/lib.rs @@ -22,7 +22,7 @@ extern crate ethcore_bytes as bytes; extern crate common_types as types; extern crate ethjson; extern crate rlp; -extern crate hash; +extern crate keccak_hash as hash; extern crate patricia_trie as trie; mod action_params; diff --git a/hash-fetch/Cargo.toml b/hash-fetch/Cargo.toml index 7b0e8b7cd..312aa028c 100644 --- a/hash-fetch/Cargo.toml +++ b/hash-fetch/Cargo.toml @@ -19,7 +19,7 @@ ethcore-bigint = { path = "../util/bigint" } ethcore-bytes = { path = "../util/bytes" } parity-reactor = { path = "../util/reactor" } native-contracts = { path = "../ethcore/native_contracts" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } [dev-dependencies] ethabi = "4.0" diff --git a/hash-fetch/src/lib.rs b/hash-fetch/src/lib.rs index 858a04ea5..0610459ee 100644 --- a/hash-fetch/src/lib.rs +++ b/hash-fetch/src/lib.rs @@ -25,7 +25,7 @@ extern crate ethcore_util as util; extern crate ethcore_bigint as bigint; extern crate ethcore_bytes as bytes; extern crate futures; -extern crate hash; +extern crate keccak_hash as hash; extern crate mime; extern crate mime_guess; extern crate native_contracts; diff --git a/parity/main.rs b/parity/main.rs index 10e825d8b..eae471dce 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -75,7 +75,7 @@ extern crate parity_whisper; extern crate path; extern crate rpc_cli; extern crate node_filter; -extern crate hash; +extern crate keccak_hash as hash; extern crate journaldb; #[macro_use] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 360a7b776..f257a0b68 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -56,7 +56,7 @@ parity-updater = { path = "../updater" } rlp = { path = "../util/rlp" } stats = { path = "../util/stats" } vm = { path = "../ethcore/vm" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } hardware-wallet = { path = "../hw" } clippy = { version = "0.0.103", optional = true} diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index ab0b9082d..ed8d1d972 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -65,7 +65,7 @@ extern crate parity_reactor; extern crate parity_updater as updater; extern crate rlp; extern crate stats; -extern crate hash; +extern crate keccak_hash as hash; extern crate hardware_wallet; #[macro_use] diff --git a/rpc_client/Cargo.toml b/rpc_client/Cargo.toml index cada20fa1..d1526661e 100644 --- a/rpc_client/Cargo.toml +++ b/rpc_client/Cargo.toml @@ -17,4 +17,4 @@ parking_lot = "0.4" jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } parity-rpc = { path = "../rpc" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } diff --git a/rpc_client/src/lib.rs b/rpc_client/src/lib.rs index 680c0484b..6b2bfc5cf 100644 --- a/rpc_client/src/lib.rs +++ b/rpc_client/src/lib.rs @@ -9,7 +9,7 @@ extern crate parking_lot; extern crate serde; extern crate serde_json; extern crate url; -extern crate hash; +extern crate keccak_hash as hash; #[macro_use] extern crate log; diff --git a/secret_store/Cargo.toml b/secret_store/Cargo.toml index 8357b530b..5ba7d5773 100644 --- a/secret_store/Cargo.toml +++ b/secret_store/Cargo.toml @@ -29,7 +29,7 @@ ethcore-util = { path = "../util" } ethcore-bigint = { path = "../util/bigint" } kvdb = { path = "../util/kvdb" } kvdb-rocksdb = { path = "../util/kvdb-rocksdb" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } ethcore-logger = { path = "../logger" } ethcrypto = { path = "../ethcrypto" } ethkey = { path = "../ethkey" } diff --git a/secret_store/src/lib.rs b/secret_store/src/lib.rs index 5951be508..80242c078 100644 --- a/secret_store/src/lib.rs +++ b/secret_store/src/lib.rs @@ -45,7 +45,7 @@ extern crate ethcore_logger as logger; extern crate ethcrypto; extern crate ethkey; extern crate native_contracts; -extern crate hash; +extern crate keccak_hash as hash; extern crate kvdb; extern crate kvdb_rocksdb; diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index 911e2ad0e..4216dabb5 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -18,4 +18,4 @@ tokio-core = "0.1" tokio-io = "0.1" parking_lot = "0.4" ethcore-logger = { path = "../logger" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } diff --git a/stratum/src/lib.rs b/stratum/src/lib.rs index 229f36acc..a647ac8e8 100644 --- a/stratum/src/lib.rs +++ b/stratum/src/lib.rs @@ -22,7 +22,7 @@ extern crate jsonrpc_macros; #[macro_use] extern crate log; extern crate ethcore_util as util; extern crate ethcore_bigint as bigint; -extern crate hash; +extern crate keccak_hash as hash; extern crate parking_lot; #[cfg(test)] extern crate tokio_core; diff --git a/sync/Cargo.toml b/sync/Cargo.toml index a1941fec4..9eebda261 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -16,7 +16,7 @@ ethcore-io = { path = "../util/io" } ethcore-light = { path = "../ethcore/light"} ethcore = { path = "../ethcore" } rlp = { path = "../util/rlp" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } triehash = { path = "../util/triehash" } kvdb = { path = "../util/kvdb" } macros = { path = "../util/macros" } diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 0495d72a7..4e9873c6e 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -40,7 +40,7 @@ extern crate parking_lot; extern crate smallvec; extern crate rlp; extern crate ipnetwork; -extern crate hash; +extern crate keccak_hash as hash; extern crate triehash; extern crate kvdb; diff --git a/util/Cargo.toml b/util/Cargo.toml index a05a4d18f..65d1c88b4 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -16,7 +16,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } elastic-array = "0.9" rlp = { path = "rlp" } heapsize = "0.4" -hash = { path = "hash" } +keccak-hash = { path = "hash" } clippy = { version = "0.0.103", optional = true} libc = "0.2.7" target_info = "0.1" diff --git a/util/bloomable/Cargo.toml b/util/bloomable/Cargo.toml index 94ca4856b..d919e2163 100644 --- a/util/bloomable/Cargo.toml +++ b/util/bloomable/Cargo.toml @@ -7,4 +7,4 @@ authors = ["debris "] ethcore-bigint = { path = "../bigint" } [dev-dependencies] -hash = { path = "../hash" } +keccak-hash = { path = "../hash" } diff --git a/util/bloomable/tests/test.rs b/util/bloomable/tests/test.rs index f3fa908e2..6e9cde484 100644 --- a/util/bloomable/tests/test.rs +++ b/util/bloomable/tests/test.rs @@ -1,4 +1,4 @@ -extern crate hash; +extern crate keccak_hash as hash; extern crate ethcore_bigint; extern crate bloomable; diff --git a/util/hash/Cargo.toml b/util/hash/Cargo.toml index 0b0502721..e4225c85c 100644 --- a/util/hash/Cargo.toml +++ b/util/hash/Cargo.toml @@ -2,13 +2,13 @@ description = "Rust bindings for tinykeccak C library" homepage = "http://parity.io" license = "GPL-3.0" -name = "hash" +name = "keccak-hash" version = "0.1.0" authors = ["Parity Technologies "] build = "build.rs" [dependencies] -ethcore-bigint = { path = "../bigint" } +ethcore-bigint = { version = "0.2.1", path = "../bigint" } tiny-keccak = "1.3" [build-dependencies] diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index a70631836..3d92d9ed6 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -19,5 +19,5 @@ util-error = { path = "../error" } [dev-dependencies] ethcore-logger = { path = "../../logger" } -hash = { path = "../hash" } +keccak-hash = { path = "../hash" } kvdb-memorydb = { path = "../kvdb-memorydb" } diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index ef26cb8d6..1e805abe6 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -32,7 +32,7 @@ extern crate util_error as error; #[cfg(test)] extern crate ethcore_logger; #[cfg(test)] -extern crate hash as keccak; +extern crate keccak_hash as keccak; #[cfg(test)] extern crate kvdb_memorydb; diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index 0c2f954e1..a8c6230d1 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -10,6 +10,6 @@ bigint = "4.0" elastic-array = "0.9" heapsize = "0.4" ethcore-bigint = { version = "0.2", path = "../bigint", features = ["heapsizeof"] } -hash = { version = "0.1.0", path = "../hash" } +keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.0", path = "../hashdb" } rlp = { version = "0.2.0", path = "../rlp" } diff --git a/util/memorydb/src/lib.rs b/util/memorydb/src/lib.rs index 041d97250..d8e342d98 100644 --- a/util/memorydb/src/lib.rs +++ b/util/memorydb/src/lib.rs @@ -18,7 +18,7 @@ extern crate heapsize; extern crate ethcore_bigint as bigint; extern crate rlp; -extern crate hash as keccak; +extern crate keccak_hash as keccak; extern crate hashdb; use std::mem; diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index d7928b492..8c4d2398b 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -31,7 +31,7 @@ rlp = { path = "../rlp" } path = { path = "../path" } ethcore-logger = { path ="../../logger" } ipnetwork = "0.12.6" -hash = { path = "../hash" } +keccak-hash = { path = "../hash" } snappy = { path = "../snappy" } serde_json = "1.0" diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index 6cf81fa9d..730a368a6 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -79,7 +79,7 @@ extern crate bytes; extern crate path; extern crate ethcore_logger; extern crate ipnetwork; -extern crate hash; +extern crate keccak_hash as hash; extern crate serde_json; extern crate snappy; diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index 7b5ae3879..a7b1fa421 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -9,7 +9,7 @@ log = "0.3" rand = "0.3" ethcore-bytes = { version = "0.1.0", path = "../bytes" } ethcore-bigint = { version = "0.2.1", path = "../bigint" } -hash = { version = "0.1.0", path = "../hash" } +keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } rlp = { version = "0.2.0", path = "../rlp" } triehash = { version = "0.1.0", path = "../triehash" } diff --git a/util/patricia_trie/src/lib.rs b/util/patricia_trie/src/lib.rs index 8c4c0d3ef..07fd43bdf 100644 --- a/util/patricia_trie/src/lib.rs +++ b/util/patricia_trie/src/lib.rs @@ -17,7 +17,7 @@ //! Trie interface and implementation. extern crate rand; extern crate ethcore_bigint as bigint; -extern crate hash as keccak; +extern crate keccak_hash as keccak; extern crate rlp; extern crate hashdb; extern crate ethcore_bytes as bytes; diff --git a/util/src/lib.rs b/util/src/lib.rs index 6d5db7938..321c85dd4 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -101,7 +101,7 @@ extern crate tiny_keccak; extern crate rlp; extern crate heapsize; extern crate ethcore_logger; -extern crate hash as keccak; +extern crate keccak_hash as keccak; extern crate hashdb; extern crate memorydb; extern crate patricia_trie as trie; diff --git a/util/triehash/Cargo.toml b/util/triehash/Cargo.toml index 2731a4685..d9ff4809c 100644 --- a/util/triehash/Cargo.toml +++ b/util/triehash/Cargo.toml @@ -8,4 +8,4 @@ license = "GPL-3.0" [dependencies] rlp = { version = "0.2", path = "../rlp" } ethcore-bigint = { version = "0.2.1", path = "../bigint" } -hash = { version = "0.1", path = "../hash" } +keccak-hash = { version = "0.1", path = "../hash" } diff --git a/util/triehash/src/lib.rs b/util/triehash/src/lib.rs index d166aa5d0..78c22fb87 100644 --- a/util/triehash/src/lib.rs +++ b/util/triehash/src/lib.rs @@ -19,7 +19,7 @@ //! This module should be used to generate trie root hash. extern crate ethcore_bigint; -extern crate hash; +extern crate keccak_hash as hash; extern crate rlp; use std::collections::BTreeMap; From 75cfab855942ecbe200a8510024d0a4986d13f33 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 20:15:37 +0100 Subject: [PATCH 10/31] update memorydb --- Cargo.lock | 12 ++++++------ util/memorydb/Cargo.toml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 240765c6c..8e5aea5f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -508,7 +508,7 @@ dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memorydb 0.1.0", + "memorydb 0.1.1", "migration 0.1.0", "native-contracts 0.1.0", "num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -600,7 +600,7 @@ dependencies = [ "kvdb-rocksdb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memorydb 0.1.0", + "memorydb 0.1.1", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -738,7 +738,7 @@ dependencies = [ "kvdb-memorydb 0.1.0", "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.0", + "memorydb 0.1.1", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "rlp 0.2.0", @@ -1218,7 +1218,7 @@ dependencies = [ "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.0", + "memorydb 0.1.1", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.0", "util-error 0.1.0", @@ -1507,7 +1507,7 @@ dependencies = [ [[package]] name = "memorydb" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bigint 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2336,7 +2336,7 @@ dependencies = [ "hashdb 0.1.1", "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.0", + "memorydb 0.1.1", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.0", "triehash 0.1.0", diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index a8c6230d1..785f16590 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "memorydb" -version = "0.1.0" +version = "0.1.1" authors = ["Parity Technologies "] description = "in-memory implementation of hashdb" license = "GPL-3.0" @@ -11,5 +11,5 @@ elastic-array = "0.9" heapsize = "0.4" ethcore-bigint = { version = "0.2", path = "../bigint", features = ["heapsizeof"] } keccak-hash = { version = "0.1.0", path = "../hash" } -hashdb = { version = "0.1.0", path = "../hashdb" } +hashdb = { version = "0.1.1", path = "../hashdb" } rlp = { version = "0.2.0", path = "../rlp" } From cffbf3cab1659454a735a56b42a4fe6f39b9d400 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 20:21:24 +0100 Subject: [PATCH 11/31] update rlp --- Cargo.lock | 42 +++++++++++++++++------------------ util/memorydb/Cargo.toml | 2 +- util/patricia_trie/Cargo.toml | 2 +- util/rlp/Cargo.toml | 4 ++-- util/triehash/Cargo.toml | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e5aea5f7..288decc43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,7 +286,7 @@ dependencies = [ "ethjson 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "rlp 0.2.0", + "rlp 0.2.1", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -519,7 +519,7 @@ dependencies = [ "price-info 1.7.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "rlp_derive 0.1.0", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -604,7 +604,7 @@ dependencies = [ "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "rlp_derive 0.1.0", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -654,7 +654,7 @@ dependencies = [ "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -741,7 +741,7 @@ dependencies = [ "memorydb 0.1.1", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", - "rlp 0.2.0", + "rlp 0.2.1", "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -862,7 +862,7 @@ dependencies = [ "macros 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1220,7 +1220,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.1", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "util-error 0.1.0", ] @@ -1353,7 +1353,7 @@ version = "0.1.0" dependencies = [ "kvdb 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", ] [[package]] @@ -1366,7 +1366,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1515,7 +1515,7 @@ dependencies = [ "hashdb 0.1.1", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "rlp 0.2.0", + "rlp 0.2.1", ] [[package]] @@ -1947,7 +1947,7 @@ dependencies = [ "path 0.1.0", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rpc-cli 1.4.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2060,7 +2060,7 @@ dependencies = [ "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "multihash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2075,7 +2075,7 @@ dependencies = [ "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2142,7 +2142,7 @@ dependencies = [ "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2280,7 +2280,7 @@ dependencies = [ "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2338,7 +2338,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.1", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "triehash 0.1.0", ] @@ -2616,7 +2616,7 @@ dependencies = [ [[package]] name = "rlp" -version = "0.2.0" +version = "0.2.1" dependencies = [ "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2630,7 +2630,7 @@ name = "rlp_derive" version = "0.1.0" dependencies = [ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.0", + "rlp 0.2.1", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3247,7 +3247,7 @@ version = "0.1.0" dependencies = [ "ethcore-bigint 0.2.1", "keccak-hash 0.1.0", - "rlp 0.2.0", + "rlp 0.2.1", ] [[package]] @@ -3350,7 +3350,7 @@ dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "kvdb 0.1.0", - "rlp 0.2.0", + "rlp 0.2.1", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3400,7 +3400,7 @@ dependencies = [ "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", - "rlp 0.2.0", + "rlp 0.2.1", ] [[package]] diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index 785f16590..4ea50a736 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -12,4 +12,4 @@ heapsize = "0.4" ethcore-bigint = { version = "0.2", path = "../bigint", features = ["heapsizeof"] } keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } -rlp = { version = "0.2.0", path = "../rlp" } +rlp = { version = "0.2.1", path = "../rlp" } diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index a7b1fa421..ee9d472a0 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -11,7 +11,7 @@ ethcore-bytes = { version = "0.1.0", path = "../bytes" } ethcore-bigint = { version = "0.2.1", path = "../bigint" } keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } -rlp = { version = "0.2.0", path = "../rlp" } +rlp = { version = "0.2.1", path = "../rlp" } triehash = { version = "0.1.0", path = "../triehash" } memorydb = { version = "0.1.0", path = "../memorydb" } ethcore-logger = { version = "1.9.0", path = "../../logger" } diff --git a/util/rlp/Cargo.toml b/util/rlp/Cargo.toml index aa682e469..83ac3a9d6 100644 --- a/util/rlp/Cargo.toml +++ b/util/rlp/Cargo.toml @@ -3,12 +3,12 @@ description = "Recursive-length prefix encoding, decoding, and compression" repository = "https://github.com/paritytech/parity" license = "MIT/Apache-2.0" name = "rlp" -version = "0.2.0" +version = "0.2.1" authors = ["Parity Technologies "] [dependencies] elastic-array = "0.9" -ethcore-bigint = { path = "../bigint" } +ethcore-bigint = { version = "0.2.1", path = "../bigint" } lazy_static = "0.2" rustc-hex = "1.0" byteorder = "1.0" diff --git a/util/triehash/Cargo.toml b/util/triehash/Cargo.toml index d9ff4809c..53d6b56d8 100644 --- a/util/triehash/Cargo.toml +++ b/util/triehash/Cargo.toml @@ -6,6 +6,6 @@ description = "in memory patricia trie operations" license = "GPL-3.0" [dependencies] -rlp = { version = "0.2", path = "../rlp" } +rlp = { version = "0.2.1", path = "../rlp" } ethcore-bigint = { version = "0.2.1", path = "../bigint" } keccak-hash = { version = "0.1", path = "../hash" } From c4466f450b4e2e62df27e686a8497130fb1e0a3d Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 10 Nov 2017 20:26:19 +0100 Subject: [PATCH 12/31] update patricia-trie cargo.toml --- util/patricia_trie/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index ee9d472a0..ae0027cf4 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -2,6 +2,8 @@ name = "patricia-trie" version = "0.1.0" authors = ["Parity Technologies "] +description = "Merkle-Patricia Trie (Ethereum Style)" +license = "GPL-3.0" [dependencies] elastic-array = "0.9" From 72907da2aed962715c6efc5e98162e0d11500089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sun, 12 Nov 2017 12:36:41 +0100 Subject: [PATCH 13/31] Garbage collect hashmap entries. --- parity/rpc_apis.rs | 10 ++-- rpc/src/v1/helpers/dispatch.rs | 28 +++------- rpc/src/v1/helpers/nonce.rs | 95 +++++++++++++++++++++++++++++----- 3 files changed, 93 insertions(+), 40 deletions(-) diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 281b97589..a5bc1e154 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use std::cmp::PartialEq; -use std::collections::{BTreeMap, HashSet, HashMap}; +use std::collections::{BTreeMap, HashSet}; use std::str::FromStr; use std::sync::{Arc, Weak}; @@ -241,7 +241,7 @@ impl FullDependencies { ($namespace:ident, $handler:expr, $deps:expr, $nonces:expr) => { { let deps = &$deps; - let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), deps.fetch.pool(), $nonces); + let dispatcher = FullDispatcher::new(deps.client.clone(), deps.miner.clone(), $nonces); if deps.signer_service.is_enabled() { $handler.extend_with($namespace::to_delegate(SigningQueueClient::new(&deps.signer_service, dispatcher, deps.remote.clone(), &deps.secret_store))) } else { @@ -251,11 +251,10 @@ impl FullDependencies { } } - let nonces = Arc::new(Mutex::new(HashMap::new())); + let nonces = Arc::new(Mutex::new(dispatch::Reservations::with_pool(self.fetch.pool()))); let dispatcher = FullDispatcher::new( self.client.clone(), self.miner.clone(), - self.fetch.pool(), nonces.clone(), ); for api in apis { @@ -440,8 +439,7 @@ impl LightDependencies { self.on_demand.clone(), self.cache.clone(), self.transaction_queue.clone(), - self.fetch.pool(), - Arc::new(Mutex::new(HashMap::new())), + Arc::new(Mutex::new(dispatch::Reservations::with_pool(self.fetch.pool()))), ); macro_rules! add_signing_methods { diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index f17797619..35e16f573 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -19,7 +19,6 @@ use std::fmt::Debug; use std::ops::Deref; use std::sync::Arc; -use std::collections::HashMap; use light::cache::Cache as LightDataCache; use light::client::LightChainClient; @@ -33,7 +32,6 @@ use util::Address; use bytes::Bytes; use parking_lot::{Mutex, RwLock}; use stats::Corpus; -use futures_cpupool::CpuPool; use ethkey::Signature; use ethsync::LightSync; @@ -89,8 +87,7 @@ pub trait Dispatcher: Send + Sync + Clone { pub struct FullDispatcher { client: Arc, miner: Arc, - nonces: Arc>>, - pool: CpuPool, + nonces: Arc>, } impl FullDispatcher { @@ -98,14 +95,12 @@ impl FullDispatcher { pub fn new( client: Arc, miner: Arc, - pool: CpuPool, - nonces: Arc>>, + nonces: Arc>, ) -> Self { FullDispatcher { client, miner, nonces, - pool, } } } @@ -116,7 +111,6 @@ impl Clone for FullDispatcher { client: self.client.clone(), miner: self.miner.clone(), nonces: self.nonces.clone(), - pool: self.pool.clone(), } } } @@ -172,9 +166,7 @@ impl Dispatcher for FullDispatcher>, /// Nonce reservations - pub nonces: Arc>>, - /// Cpu pool - pub pool: CpuPool, + pub nonces: Arc>, } impl LightDispatcher { @@ -280,8 +270,7 @@ impl LightDispatcher { on_demand: Arc, cache: Arc>, transaction_queue: Arc>, - pool: CpuPool, - nonces: Arc>>, + nonces: Arc>, ) -> Self { LightDispatcher { sync, @@ -290,7 +279,6 @@ impl LightDispatcher { cache, transaction_queue, nonces, - pool, } } @@ -396,13 +384,11 @@ impl Dispatcher for LightDispatcher { } let nonces = self.nonces.clone(); - let pool = self.pool.clone(); Box::new(self.next_nonce(filled.from) .map_err(|_| errors::no_light_peers()) .and_then(move |nonce| { - let reserved = nonces.lock().entry(filled.from) - .or_insert(nonce::Reservations::with_pool(pool)) - .reserve_nonce(nonce); + let reserved = nonces.lock().reserve(filled.from, nonce); + ProspectiveSigner::new(accounts, filled, chain_id, reserved, password) })) } diff --git a/rpc/src/v1/helpers/nonce.rs b/rpc/src/v1/helpers/nonce.rs index a048d9a87..2b4df49ae 100644 --- a/rpc/src/v1/helpers/nonce.rs +++ b/rpc/src/v1/helpers/nonce.rs @@ -15,35 +15,84 @@ // along with Parity. If not, see . use std::{cmp, mem}; +use std::collections::HashMap; use std::sync::{atomic, Arc}; -use std::sync::atomic::AtomicUsize; +use std::sync::atomic::{AtomicBool, AtomicUsize}; use bigint::prelude::U256; use futures::{Future, future, Poll, Async}; use futures::future::Either; use futures::sync::oneshot; use futures_cpupool::CpuPool; +use util::Address; -/// Manages currently reserved and prospective nonces. +/// Manages currently reserved and prospective nonces +/// for multiple senders. #[derive(Debug)] pub struct Reservations { - previous: Option>, + nonces: HashMap, pool: CpuPool, - prospective_value: U256, - dropped: Arc, } - impl Reservations { + /// A maximal number of reserved nonces in the hashmap + /// before we start clearing the unused ones. + const CLEAN_AT: usize = 512; + /// Create new nonces manager and spawn a single-threaded cpu pool /// for progressing execution of dropped nonces. pub fn new() -> Self { Self::with_pool(CpuPool::new(1)) } - /// Create new nonces manager with given cpu pool. + /// Create new nonces manager with given cpupool. pub fn with_pool(pool: CpuPool) -> Self { Reservations { + nonces: Default::default(), + pool, + } + } + + /// Reserve a nonce for particular address. + /// + /// The reserved nonce cannot be smaller than the minimal nonce. + pub fn reserve(&mut self, sender: Address, minimal: U256) -> Reserved { + if self.nonces.len() + 1 > Self::CLEAN_AT { + let to_remove = self.nonces.iter().filter(|&(_, v)| v.is_empty()).map(|(k, _)| *k).collect::>(); + for address in to_remove { + self.nonces.remove(&address); + } + } + + let pool = &self.pool; + self.nonces.entry(sender) + .or_insert_with(move || SenderReservations::with_pool(pool.clone())) + .reserve_nonce(minimal) + } +} + +/// Manages currently reserved and prospective nonces. +#[derive(Debug)] +pub struct SenderReservations { + previous: Option>, + previous_ready: Arc, + pool: CpuPool, + prospective_value: U256, + dropped: Arc, +} + +impl SenderReservations { + /// Create new nonces manager and spawn a single-threaded cpu pool + /// for progressing execution of dropped nonces. + #[cfg(test)] + pub fn new() -> Self { + Self::with_pool(CpuPool::new(1)) + } + + /// Create new nonces manager with given cpu pool. + pub fn with_pool(pool: CpuPool) -> Self { + SenderReservations { previous: None, + previous_ready: Arc::new(AtomicBool::new(true)), pool, prospective_value: Default::default(), dropped: Default::default(), @@ -64,12 +113,15 @@ impl Reservations { let (next, rx) = oneshot::channel(); let next = Some(next); + let next_sent = Arc::new(AtomicBool::default()); let pool = self.pool.clone(); let dropped = self.dropped.clone(); + self.previous_ready = next_sent.clone(); match mem::replace(&mut self.previous, Some(rx)) { Some(previous) => Reserved { previous: Either::A(previous), next, + next_sent, minimal, prospective_value, pool, @@ -78,6 +130,7 @@ impl Reservations { None => Reserved { previous: Either::B(future::ok(minimal)), next, + next_sent, minimal, prospective_value, pool, @@ -85,6 +138,11 @@ impl Reservations { }, } } + + /// Returns true if there are no reserved nonces. + pub fn is_empty(&self) -> bool { + self.previous_ready.load(atomic::Ordering::SeqCst) + } } /// Represents a future nonce. @@ -92,9 +150,10 @@ impl Reservations { pub struct Reserved { previous: Either< oneshot::Receiver, - future::FutureResult + future::FutureResult, >, next: Option>, + next_sent: Arc, minimal: U256, prospective_value: U256, pool: CpuPool, @@ -128,6 +187,7 @@ impl Future for Reserved { value, matches_prospective, next: self.next.take(), + next_sent: self.next_sent.clone(), dropped: self.dropped.clone(), })) } @@ -136,10 +196,12 @@ impl Future for Reserved { impl Drop for Reserved { fn drop(&mut self) { if let Some(next) = self.next.take() { + let next_sent = self.next_sent.clone(); self.dropped.fetch_add(1, atomic::Ordering::SeqCst); // If Reserved is dropped just pipe previous and next together. let previous = mem::replace(&mut self.previous, Either::B(future::ok(U256::default()))); - self.pool.spawn(previous.map(|nonce| { + self.pool.spawn(previous.map(move |nonce| { + next_sent.store(true, atomic::Ordering::SeqCst); next.send(nonce).expect(Ready::RECV_PROOF) })).forget() } @@ -156,6 +218,7 @@ pub struct Ready { value: U256, matches_prospective: bool, next: Option>, + next_sent: Arc, dropped: Arc, } @@ -176,15 +239,17 @@ impl Ready { /// Make sure to call that method after this nonce has been consumed. pub fn mark_used(mut self) { let next = self.next.take().expect("Nonce can be marked as used only once; qed"); + self.next_sent.store(true, atomic::Ordering::SeqCst); next.send(self.value + 1.into()).expect(Self::RECV_PROOF); } } impl Drop for Ready { fn drop(&mut self) { - if let Some(send) = self.next.take() { + if let Some(next) = self.next.take() { self.dropped.fetch_add(1, atomic::Ordering::SeqCst); - send.send(self.value).expect(Self::RECV_PROOF); + self.next_sent.store(true, atomic::Ordering::SeqCst); + next.send(self.value).expect(Self::RECV_PROOF); } } } @@ -195,12 +260,14 @@ mod tests { #[test] fn should_reserve_a_set_of_nonces_and_resolve_them() { - let mut nonces = Reservations::new(); + let mut nonces = SenderReservations::new(); + assert!(nonces.is_empty()); let n1 = nonces.reserve_nonce(5.into()); let n2 = nonces.reserve_nonce(5.into()); let n3 = nonces.reserve_nonce(5.into()); let n4 = nonces.reserve_nonce(5.into()); + assert!(!nonces.is_empty()); // Check first nonce let r = n1.wait().unwrap(); @@ -234,11 +301,13 @@ mod tests { assert_eq!(r.value(), &U256::from(10)); assert!(r.matches_prospective()); r.mark_used(); + + assert!(nonces.is_empty()); } #[test] fn should_return_prospective_nonce() { - let mut nonces = Reservations::new(); + let mut nonces = SenderReservations::new(); let n1 = nonces.reserve_nonce(5.into()); let n2 = nonces.reserve_nonce(5.into()); From 3cf52dac59c8c58adc2f49336e370f1021486bd4 Mon Sep 17 00:00:00 2001 From: debris Date: Mon, 13 Nov 2017 14:37:08 +0100 Subject: [PATCH 14/31] use error-chain in ethcore-network --- Cargo.lock | 5 +- ethcore/light/src/net/error.rs | 16 ++-- parity/configuration.rs | 6 +- parity/helpers.rs | 6 +- parity/modules.rs | 4 +- sync/src/api.rs | 16 ++-- sync/src/blocks.rs | 14 +-- sync/src/chain.rs | 6 +- sync/src/lib.rs | 2 +- sync/src/sync_io.rs | 14 +-- sync/src/tests/helpers.rs | 8 +- util/error/Cargo.toml | 2 +- util/io/src/lib.rs | 10 ++- util/kvdb/Cargo.toml | 2 +- util/migration/Cargo.toml | 2 +- util/network/Cargo.toml | 1 + util/network/src/connection.rs | 26 +++--- util/network/src/discovery.rs | 24 ++--- util/network/src/error.rs | 157 ++++++++++++++------------------- util/network/src/handshake.rs | 34 +++---- util/network/src/host.rs | 30 +++---- util/network/src/lib.rs | 6 +- util/network/src/node_table.rs | 16 ++-- util/network/src/service.rs | 14 +-- util/network/src/session.rs | 48 +++++----- util/snappy/Cargo.toml | 1 + util/snappy/src/lib.rs | 1 + whisper/src/net.rs | 8 +- 28 files changed, 235 insertions(+), 244 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0c390d8d..846a3f83f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -424,9 +424,6 @@ dependencies = [ name = "error-chain" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "eth-secp256k1" @@ -637,6 +634,7 @@ dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", "ethcore-devtools 1.9.0", @@ -2939,6 +2937,7 @@ name = "snappy" version = "0.1.0" dependencies = [ "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", ] [[package]] diff --git a/ethcore/light/src/net/error.rs b/ethcore/light/src/net/error.rs index 578978348..35349c553 100644 --- a/ethcore/light/src/net/error.rs +++ b/ethcore/light/src/net/error.rs @@ -17,10 +17,8 @@ //! Defines error types and levels of punishment to use upon //! encountering. -use rlp::DecoderError; -use network::NetworkError; - use std::fmt; +use {rlp, network}; /// Levels of punishment. /// @@ -41,9 +39,9 @@ pub enum Punishment { #[derive(Debug)] pub enum Error { /// An RLP decoding error. - Rlp(DecoderError), + Rlp(rlp::DecoderError), /// A network error. - Network(NetworkError), + Network(network::Error), /// Out of credits. NoCredits, /// Unrecognized packet code. @@ -92,14 +90,14 @@ impl Error { } } -impl From for Error { - fn from(err: DecoderError) -> Self { +impl From for Error { + fn from(err: rlp::DecoderError) -> Self { Error::Rlp(err) } } -impl From for Error { - fn from(err: NetworkError) -> Self { +impl From for Error { + fn from(err: network::Error) -> Self { Error::Network(err) } } diff --git a/parity/configuration.rs b/parity/configuration.rs index 249c64acb..7cb3a84bd 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -28,7 +28,7 @@ use bigint::hash::H256; use util::{version_data, Address}; use bytes::Bytes; use ansi_term::Colour; -use ethsync::{NetworkConfiguration, validate_node_url, NetworkError}; +use ethsync::{NetworkConfiguration, validate_node_url, self}; use ethcore::ethstore::ethkey::{Secret, Public}; use ethcore::client::{VMType}; use ethcore::miner::{MinerOptions, Banning, StratumOptions}; @@ -700,9 +700,9 @@ impl Configuration { let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| !s.is_empty() && !s.starts_with("#")).collect::>(); for line in &lines { - match validate_node_url(line) { + match validate_node_url(line).map(Into::into) { None => continue, - Some(NetworkError::AddressResolve(_)) => return Err(format!("Failed to resolve hostname of a boot node: {}", line)), + Some(ethsync::ErrorKind::AddressResolve(_)) => return Err(format!("Failed to resolve hostname of a boot node: {}", line)), Some(_) => return Err(format!("Invalid node address format given for a boot node: {}", line)), } } diff --git a/parity/helpers.rs b/parity/helpers.rs index 8527850e8..d5db19c2c 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -29,7 +29,7 @@ use cache::CacheConfig; use dir::DatabaseDirectories; use upgrade::{upgrade, upgrade_data_paths}; use migration::migrate; -use ethsync::{validate_node_url, NetworkError}; +use ethsync::{validate_node_url, self}; use path; pub fn to_duration(s: &str) -> Result { @@ -181,9 +181,9 @@ pub fn parity_ipc_path(base: &str, path: &str, shift: u16) -> String { pub fn to_bootnodes(bootnodes: &Option) -> Result, String> { match *bootnodes { Some(ref x) if !x.is_empty() => x.split(',').map(|s| { - match validate_node_url(s) { + match validate_node_url(s).map(Into::into) { None => Ok(s.to_owned()), - Some(NetworkError::AddressResolve(_)) => Err(format!("Failed to resolve hostname of a boot node: {}", s)), + Some(ethsync::ErrorKind::AddressResolve(_)) => Err(format!("Failed to resolve hostname of a boot node: {}", s)), Some(_) => Err(format!("Invalid node address format given for a boot node: {}", s)), } }).collect(), diff --git a/parity/modules.rs b/parity/modules.rs index f66f275aa..36cffe2ec 100644 --- a/parity/modules.rs +++ b/parity/modules.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use ethcore::client::BlockChainClient; -use ethsync::{AttachedProtocol, SyncConfig, NetworkConfiguration, NetworkError, Params, ConnectionFilter}; +use ethsync::{self, AttachedProtocol, SyncConfig, NetworkConfiguration, Params, ConnectionFilter}; use ethcore::snapshot::SnapshotService; use light::Provider; @@ -36,7 +36,7 @@ pub fn sync( _log_settings: &LogConfig, attached_protos: Vec, connection_filter: Option>, -) -> Result { +) -> Result { let eth_sync = EthSync::new(Params { config: sync_cfg, chain: client, diff --git a/sync/src/api.rs b/sync/src/api.rs index 48c48880d..2bc69ae31 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -19,7 +19,7 @@ use std::collections::{HashMap, BTreeMap}; use std::io; use bytes::Bytes; use network::{NetworkProtocolHandler, NetworkService, NetworkContext, HostInfo, PeerId, ProtocolId, - NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, NetworkError, ConnectionFilter}; + NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ErrorKind, ConnectionFilter}; use bigint::prelude::U256; use bigint::hash::{H256, H512}; use io::{TimerToken}; @@ -207,7 +207,7 @@ pub struct EthSync { impl EthSync { /// Creates and register protocol with the network service - pub fn new(params: Params, connection_filter: Option>) -> Result, NetworkError> { + pub fn new(params: Params, connection_filter: Option>) -> Result, Error> { const MAX_LIGHTSERV_LOAD: f64 = 0.5; let pruning_info = params.chain.pruning_info(); @@ -397,8 +397,8 @@ impl ChainNotify for EthSync { } fn start(&self) { - match self.network.start() { - Err(NetworkError::StdIo(ref e)) if e.kind() == io::ErrorKind::AddrInUse => warn!("Network port {:?} is already in use, make sure that another instance of an Ethereum client is not running or change the port using the --port option.", self.network.config().listen_address.expect("Listen address is not set.")), + match self.network.start().map_err(Into::into) { + Err(ErrorKind::Io(ref e)) if e.kind() == io::ErrorKind::AddrInUse => warn!("Network port {:?} is already in use, make sure that another instance of an Ethereum client is not running or change the port using the --port option.", self.network.config().listen_address.expect("Listen address is not set.")), Err(err) => warn!("Error starting network: {}", err), _ => {}, } @@ -675,7 +675,7 @@ pub struct LightSync { impl LightSync { /// Create a new light sync service. - pub fn new(params: LightSyncParams) -> Result + pub fn new(params: LightSyncParams) -> Result where L: AsLightClient + Provider + Sync + Send + 'static { use light_sync::LightSync as SyncHandler; @@ -752,8 +752,10 @@ impl ManageNetwork for LightSync { } fn start_network(&self) { - match self.network.start() { - Err(NetworkError::StdIo(ref e)) if e.kind() == io::ErrorKind::AddrInUse => warn!("Network port {:?} is already in use, make sure that another instance of an Ethereum client is not running or change the port using the --port option.", self.network.config().listen_address.expect("Listen address is not set.")), + match self.network.start().map_err(Into::into) { + Err(ErrorKind::Io(ref e)) if e.kind() == io::ErrorKind::AddrInUse => { + warn!("Network port {:?} is already in use, make sure that another instance of an Ethereum client is not running or change the port using the --port option.", self.network.config().listen_address.expect("Listen address is not set.")) + } Err(err) => warn!("Error starting network: {}", err), _ => {}, } diff --git a/sync/src/blocks.rs b/sync/src/blocks.rs index 44f693159..8ad65e9a8 100644 --- a/sync/src/blocks.rs +++ b/sync/src/blocks.rs @@ -23,7 +23,7 @@ use bigint::hash::H256; use triehash::ordered_trie_root; use bytes::Bytes; use rlp::*; -use network::NetworkError; +use network; use ethcore::header::Header as BlockHeader; known_heap_size!(0, HeaderId); @@ -341,7 +341,7 @@ impl BlockCollection { self.downloading_headers.contains(hash) || self.downloading_bodies.contains(hash) } - fn insert_body(&mut self, b: Bytes) -> Result<(), NetworkError> { + fn insert_body(&mut self, b: Bytes) -> Result<(), network::Error> { let header_id = { let body = UntrustedRlp::new(&b); let tx = body.at(0)?; @@ -365,18 +365,18 @@ impl BlockCollection { }, None => { warn!("Got body with no header {}", h); - Err(NetworkError::BadProtocol) + Err(network::ErrorKind::BadProtocol.into()) } } } None => { trace!(target: "sync", "Ignored unknown/stale block body. tx_root = {:?}, uncles = {:?}", header_id.transactions_root, header_id.uncles); - Err(NetworkError::BadProtocol) + Err(network::ErrorKind::BadProtocol.into()) } } } - fn insert_receipt(&mut self, r: Bytes) -> Result<(), NetworkError> { + fn insert_receipt(&mut self, r: Bytes) -> Result<(), network::Error> { let receipt_root = { let receipts = UntrustedRlp::new(&r); ordered_trie_root(receipts.iter().map(|r| r.as_raw().to_vec())) //TODO: get rid of vectors here @@ -392,7 +392,7 @@ impl BlockCollection { }, None => { warn!("Got receipt with no header {}", h); - return Err(NetworkError::BadProtocol) + return Err(network::ErrorKind::BadProtocol.into()) } } } @@ -400,7 +400,7 @@ impl BlockCollection { } _ => { trace!(target: "sync", "Ignored unknown/stale block receipt {:?}", receipt_root); - Err(NetworkError::BadProtocol) + Err(network::ErrorKind::BadProtocol.into()) } } } diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 396f031b6..837fa4223 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -97,7 +97,7 @@ use bigint::hash::{H256, H256FastMap}; use parking_lot::RwLock; use bytes::Bytes; use rlp::*; -use network::*; +use network::{self, PeerId, PacketId}; use ethcore::header::{BlockNumber, Header as BlockHeader}; use ethcore::client::{BlockChainClient, BlockStatus, BlockId, BlockChainInfo, BlockImportError, BlockQueueInfo}; use ethcore::error::*; @@ -1493,7 +1493,7 @@ impl ChainSync { } /// Send Status message - fn send_status(&mut self, io: &mut SyncIo, peer: PeerId) -> Result<(), NetworkError> { + fn send_status(&mut self, io: &mut SyncIo, peer: PeerId) -> Result<(), network::Error> { let warp_protocol_version = io.protocol_version(&WARP_SYNC_PROTOCOL_ID, peer); let warp_protocol = warp_protocol_version != 0; let protocol = if warp_protocol { warp_protocol_version } else { PROTOCOL_VERSION_63 }; @@ -1705,7 +1705,7 @@ impl ChainSync { fn return_rlp(io: &mut SyncIo, rlp: &UntrustedRlp, peer: PeerId, rlp_func: FRlp, error_func: FError) -> Result<(), PacketDecodeError> where FRlp : Fn(&SyncIo, &UntrustedRlp, PeerId) -> RlpResponseResult, - FError : FnOnce(NetworkError) -> String + FError : FnOnce(network::Error) -> String { let response = rlp_func(io, rlp, peer); match response { diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 0495d72a7..cf225e360 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -73,7 +73,7 @@ mod api; pub use api::*; pub use chain::{SyncStatus, SyncState}; -pub use network::{validate_node_url, NonReservedPeerMode, NetworkError, ConnectionFilter, ConnectionDirection}; +pub use network::{validate_node_url, NonReservedPeerMode, Error, ErrorKind, ConnectionFilter, ConnectionDirection}; #[cfg(test)] pub(crate) type Address = bigint::hash::H160; diff --git a/sync/src/sync_io.rs b/sync/src/sync_io.rs index 0c3bd38e6..b383a51cd 100644 --- a/sync/src/sync_io.rs +++ b/sync/src/sync_io.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use std::collections::HashMap; -use network::{NetworkContext, PeerId, PacketId, NetworkError, SessionInfo, ProtocolId}; +use network::{NetworkContext, PeerId, PacketId, Error, SessionInfo, ProtocolId}; use bytes::Bytes; use ethcore::client::BlockChainClient; use ethcore::header::BlockNumber; @@ -31,11 +31,11 @@ pub trait SyncIo { /// Disconnect peer fn disconnect_peer(&mut self, peer_id: PeerId); /// Respond to current request with a packet. Can be called from an IO handler for incoming packet. - fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), NetworkError>; + fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), Error>; /// Send a packet to a peer. - fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError>; + fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), Error>; /// Send a packet to a peer using specified protocol. - fn send_protocol(&mut self, protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError>; + fn send_protocol(&mut self, protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), Error>; /// Get the blockchain fn chain(&self) -> &BlockChainClient; /// Get the snapshot service. @@ -92,15 +92,15 @@ impl<'s, 'h> SyncIo for NetSyncIo<'s, 'h> { self.network.disconnect_peer(peer_id); } - fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), NetworkError>{ + fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), Error>{ self.network.respond(packet_id, data) } - fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError>{ + fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), Error>{ self.network.send(peer_id, packet_id, data) } - fn send_protocol(&mut self, protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError>{ + fn send_protocol(&mut self, protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), Error>{ self.network.send_protocol(protocol, peer_id, packet_id, data) } diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index b37ab89ba..49ab9bdb8 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use bigint::hash::H256; use parking_lot::RwLock; use bytes::Bytes; -use network::*; +use network::{self, PeerId, ProtocolId, PacketId, SessionInfo}; use tests::snapshot::*; use ethcore::client::{TestBlockChainClient, BlockChainClient, Client as EthcoreClient, ClientConfig, ChainNotify}; use ethcore::header::BlockNumber; @@ -90,7 +90,7 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { false } - fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), NetworkError> { + fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), network::Error> { self.packets.push(TestPacket { data: data, packet_id: packet_id, @@ -99,7 +99,7 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { Ok(()) } - fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError> { + fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), network::Error> { self.packets.push(TestPacket { data: data, packet_id: packet_id, @@ -108,7 +108,7 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { Ok(()) } - fn send_protocol(&mut self, _protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError> { + fn send_protocol(&mut self, _protocol: ProtocolId, peer_id: PeerId, packet_id: PacketId, data: Vec) -> Result<(), network::Error> { self.send(peer_id, packet_id, data) } diff --git a/util/error/Cargo.toml b/util/error/Cargo.toml index 390a38d4b..8f1aa9e0c 100644 --- a/util/error/Cargo.toml +++ b/util/error/Cargo.toml @@ -7,5 +7,5 @@ authors = ["Parity Technologies "] rlp = { path = "../rlp" } kvdb = { path = "../kvdb" } ethcore-bigint = { path = "../bigint" } -error-chain = "0.11.0" +error-chain = { version = "0.11", default-features = false } rustc-hex = "1.0" diff --git a/util/io/src/lib.rs b/util/io/src/lib.rs index cc3597fb4..22241a2f5 100644 --- a/util/io/src/lib.rs +++ b/util/io/src/lib.rs @@ -67,9 +67,9 @@ extern crate parking_lot; mod service; mod worker; -use mio::{Token}; +use std::{fmt, error}; use mio::deprecated::{EventLoop, NotifyError}; -use std::fmt; +use mio::Token; pub use worker::LOCAL_STACK_SIZE; @@ -93,6 +93,12 @@ impl fmt::Display for IoError { } } +impl error::Error for IoError { + fn description(&self) -> &str { + "IO error" + } +} + impl From<::std::io::Error> for IoError { fn from(err: ::std::io::Error) -> IoError { IoError::StdIo(err) diff --git a/util/kvdb/Cargo.toml b/util/kvdb/Cargo.toml index 5900d861f..af87524a2 100644 --- a/util/kvdb/Cargo.toml +++ b/util/kvdb/Cargo.toml @@ -5,5 +5,5 @@ authors = ["Parity Technologies "] [dependencies] elastic-array = "0.9" -error-chain = "0.11.0" +error-chain = { version = "0.11", default-features = false } ethcore-bytes = { path = "../bytes" } diff --git a/util/migration/Cargo.toml b/util/migration/Cargo.toml index 66d78b0a7..d938822ba 100644 --- a/util/migration/Cargo.toml +++ b/util/migration/Cargo.toml @@ -8,7 +8,7 @@ log = "0.3" macros = { path = "../macros" } kvdb = { path = "../kvdb" } kvdb-rocksdb = { path = "../kvdb-rocksdb" } -error-chain = "0.11.0" +error-chain = { version = "0.11", default-features = false } [dev-dependencies] tempdir = "0.3" diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index d7928b492..156059300 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -34,6 +34,7 @@ ipnetwork = "0.12.6" hash = { path = "../hash" } snappy = { path = "../snappy" } serde_json = "1.0" +error-chain = { version = "0.11", default-features = false } [dev-dependencies] ethcore-devtools = { path = "../../devtools" } diff --git a/util/network/src/connection.rs b/util/network/src/connection.rs index 91e5e9889..9bbe1186a 100644 --- a/util/network/src/connection.rs +++ b/util/network/src/connection.rs @@ -26,7 +26,6 @@ use bigint::hash::*; use ethcore_bytes::*; use rlp::*; use std::io::{self, Cursor, Read, Write}; -use error::*; use io::{IoContext, StreamToken}; use handshake::Handshake; use stats::NetworkStats; @@ -37,6 +36,7 @@ use rcrypto::buffer::*; use tiny_keccak::Keccak; use bytes::{Buf, BufMut}; use crypto; +use error::{Error, ErrorKind}; const ENCRYPTED_HEADER_LEN: usize = 32; const RECIEVE_PAYLOAD_TIMEOUT: u64 = 30000; @@ -125,7 +125,7 @@ impl GenericConnection { } /// Writable IO handler. Called when the socket is ready to send. - pub fn writable(&mut self, io: &IoContext) -> Result where Message: Send + Clone + Sync + 'static { + pub fn writable(&mut self, io: &IoContext) -> Result where Message: Send + Clone + Sync + 'static { { let buf = match self.send_queue.front_mut() { Some(buf) => buf, @@ -300,7 +300,7 @@ pub struct EncryptedConnection { impl EncryptedConnection { /// Create an encrypted connection out of the handshake. - pub fn new(handshake: &mut Handshake) -> Result { + pub fn new(handshake: &mut Handshake) -> Result { let shared = crypto::ecdh::agree(handshake.ecdhe.secret(), &handshake.remote_ephemeral)?; let mut nonce_material = H512::new(); if handshake.originated { @@ -353,11 +353,11 @@ impl EncryptedConnection { } /// Send a packet - pub fn send_packet(&mut self, io: &IoContext, payload: &[u8]) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + pub fn send_packet(&mut self, io: &IoContext, payload: &[u8]) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { let mut header = RlpStream::new(); let len = payload.len(); if len > MAX_PAYLOAD_SIZE { - return Err(NetworkError::OversizedPacket); + bail!(ErrorKind::OversizedPacket); } header.append_raw(&[(len >> 16) as u8, (len >> 8) as u8, len as u8], 1); header.append_raw(&[0xc2u8, 0x80u8, 0x80u8], 1); @@ -383,16 +383,16 @@ impl EncryptedConnection { } /// Decrypt and authenticate an incoming packet header. Prepare for receiving payload. - fn read_header(&mut self, header: &[u8]) -> Result<(), NetworkError> { + fn read_header(&mut self, header: &[u8]) -> Result<(), Error> { if header.len() != ENCRYPTED_HEADER_LEN { - return Err(From::from(NetworkError::Auth)); + return Err(ErrorKind::Auth.into()); } EncryptedConnection::update_mac(&mut self.ingress_mac, &mut self.mac_encoder, &header[0..16]); let mac = &header[16..]; let mut expected = H256::new(); self.ingress_mac.clone().finalize(&mut expected); if mac != &expected[0..16] { - return Err(From::from(NetworkError::Auth)); + return Err(ErrorKind::Auth.into()); } let mut hdec = H128::new(); @@ -413,11 +413,11 @@ impl EncryptedConnection { } /// Decrypt and authenticate packet payload. - fn read_payload(&mut self, payload: &[u8]) -> Result { + fn read_payload(&mut self, payload: &[u8]) -> Result { let padding = (16 - (self.payload_len % 16)) % 16; let full_length = self.payload_len + padding + 16; if payload.len() != full_length { - return Err(From::from(NetworkError::Auth)); + return Err(ErrorKind::Auth.into()); } self.ingress_mac.update(&payload[0..payload.len() - 16]); EncryptedConnection::update_mac(&mut self.ingress_mac, &mut self.mac_encoder, &[0u8; 0]); @@ -425,7 +425,7 @@ impl EncryptedConnection { let mut expected = H128::new(); self.ingress_mac.clone().finalize(&mut expected); if mac != &expected[..] { - return Err(From::from(NetworkError::Auth)); + return Err(ErrorKind::Auth.into()); } let mut packet = vec![0u8; self.payload_len]; @@ -451,7 +451,7 @@ impl EncryptedConnection { } /// Readable IO handler. Tracker receive status and returns decoded packet if avaialable. - pub fn readable(&mut self, io: &IoContext) -> Result, NetworkError> where Message: Send + Clone + Sync + 'static { + pub fn readable(&mut self, io: &IoContext) -> Result, Error> where Message: Send + Clone + Sync + 'static { io.clear_timer(self.connection.token)?; if let EncryptedConnectionState::Header = self.read_state { if let Some(data) = self.connection.readable()? { @@ -474,7 +474,7 @@ impl EncryptedConnection { } /// Writable IO handler. Processes send queeue. - pub fn writable(&mut self, io: &IoContext) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + pub fn writable(&mut self, io: &IoContext) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { self.connection.writable(io)?; Ok(()) } diff --git a/util/network/src/discovery.rs b/util/network/src/discovery.rs index 6d8e906b7..c2804f594 100644 --- a/util/network/src/discovery.rs +++ b/util/network/src/discovery.rs @@ -27,7 +27,7 @@ use time; use bigint::hash::*; use rlp::*; use node_table::*; -use error::NetworkError; +use error::{Error, ErrorKind}; use io::{StreamToken, IoContext}; use ethkey::{Secret, KeyPair, sign, recover}; use IpFilter; @@ -362,15 +362,15 @@ impl Discovery { res } - fn on_packet(&mut self, packet: &[u8], from: SocketAddr) -> Result, NetworkError> { + fn on_packet(&mut self, packet: &[u8], from: SocketAddr) -> Result, Error> { // validate packet if packet.len() < 32 + 65 + 4 + 1 { - return Err(NetworkError::BadProtocol); + return Err(ErrorKind::BadProtocol.into()); } let hash_signed = keccak(&packet[32..]); if hash_signed[..] != packet[0..32] { - return Err(NetworkError::BadProtocol); + return Err(ErrorKind::BadProtocol.into()); } let signed = &packet[(32 + 65)..]; @@ -391,10 +391,10 @@ impl Discovery { } } - fn check_timestamp(&self, timestamp: u64) -> Result<(), NetworkError> { + fn check_timestamp(&self, timestamp: u64) -> Result<(), Error> { if self.check_timestamps && timestamp < time::get_time().sec as u64{ debug!(target: "discovery", "Expired packet"); - return Err(NetworkError::Expired); + return Err(ErrorKind::Expired.into()); } Ok(()) } @@ -403,7 +403,7 @@ impl Discovery { entry.endpoint.is_allowed(&self.ip_filter) && entry.id != self.id } - fn on_ping(&mut self, rlp: &UntrustedRlp, node: &NodeId, from: &SocketAddr) -> Result, NetworkError> { + fn on_ping(&mut self, rlp: &UntrustedRlp, node: &NodeId, from: &SocketAddr) -> Result, Error> { trace!(target: "discovery", "Got Ping from {:?}", &from); let source = NodeEndpoint::from_rlp(&rlp.at(1)?)?; let dest = NodeEndpoint::from_rlp(&rlp.at(2)?)?; @@ -428,7 +428,7 @@ impl Discovery { Ok(Some(TableUpdates { added: added_map, removed: HashSet::new() })) } - fn on_pong(&mut self, rlp: &UntrustedRlp, node: &NodeId, from: &SocketAddr) -> Result, NetworkError> { + fn on_pong(&mut self, rlp: &UntrustedRlp, node: &NodeId, from: &SocketAddr) -> Result, Error> { trace!(target: "discovery", "Got Pong from {:?}", &from); // TODO: validate pong packet let dest = NodeEndpoint::from_rlp(&rlp.at(0)?)?; @@ -445,7 +445,7 @@ impl Discovery { Ok(None) } - fn on_find_node(&mut self, rlp: &UntrustedRlp, _node: &NodeId, from: &SocketAddr) -> Result, NetworkError> { + fn on_find_node(&mut self, rlp: &UntrustedRlp, _node: &NodeId, from: &SocketAddr) -> Result, Error> { trace!(target: "discovery", "Got FindNode from {:?}", &from); let target: NodeId = rlp.val_at(0)?; let timestamp: u64 = rlp.val_at(1)?; @@ -478,7 +478,7 @@ impl Discovery { packets.collect() } - fn on_neighbours(&mut self, rlp: &UntrustedRlp, _node: &NodeId, from: &SocketAddr) -> Result, NetworkError> { + fn on_neighbours(&mut self, rlp: &UntrustedRlp, _node: &NodeId, from: &SocketAddr) -> Result, Error> { // TODO: validate packet let mut added = HashMap::new(); trace!(target: "discovery", "Got {} Neighbours from {:?}", rlp.at(0)?.item_count()?, &from); @@ -536,12 +536,12 @@ impl Discovery { self.start(); } - pub fn register_socket(&self, event_loop: &mut EventLoop) -> Result<(), NetworkError> { + pub fn register_socket(&self, event_loop: &mut EventLoop) -> Result<(), Error> { event_loop.register(&self.udp_socket, Token(self.token), Ready::all(), PollOpt::edge()).expect("Error registering UDP socket"); Ok(()) } - pub fn update_registration(&self, event_loop: &mut EventLoop) -> Result<(), NetworkError> { + pub fn update_registration(&self, event_loop: &mut EventLoop) -> Result<(), Error> { let registration = if !self.send_queue.is_empty() { Ready::readable() | Ready::writable() } else { diff --git a/util/network/src/error.rs b/util/network/src/error.rs index 96fc1ff23..48bcf7596 100644 --- a/util/network/src/error.rs +++ b/util/network/src/error.rs @@ -14,12 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::{io, net, fmt}; use io::IoError; -use rlp::*; -use std::fmt; -use ethkey::Error as KeyError; -use crypto::Error as CryptoError; -use snappy; +use {rlp, ethkey, crypto, snappy}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum DisconnectReason @@ -83,98 +80,80 @@ impl fmt::Display for DisconnectReason { } } -#[derive(Debug)] -/// Network error. -pub enum NetworkError { - /// Authentication error. - Auth, - /// Unrecognised protocol. - BadProtocol, - /// Message expired. - Expired, - /// Peer not found. - PeerNotFound, - /// Peer is diconnected. - Disconnect(DisconnectReason), - /// Invalid NodeId - InvalidNodeId, - /// Socket IO error. - Io(IoError), - /// Error concerning the network address parsing subsystem. - AddressParse(::std::net::AddrParseError), - /// Error concerning the network address resolution subsystem. - AddressResolve(Option<::std::io::Error>), - /// Error concerning the Rust standard library's IO subsystem. - StdIo(::std::io::Error), - /// Packet size is over the protocol limit. - OversizedPacket, - /// Decompression error. - Decompression(snappy::InvalidInput), -} +error_chain! { + foreign_links { + SocketIo(IoError) #[doc = "Socket IO error."]; + Io(io::Error) #[doc = "Error concerning the Rust standard library's IO subsystem."]; + AddressParse(net::AddrParseError) #[doc = "Error concerning the network address parsing subsystem."]; + Decompression(snappy::InvalidInput) #[doc = "Decompression error."]; + } -impl fmt::Display for NetworkError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use self::NetworkError::*; + errors { + #[doc = "Error concerning the network address resolution subsystem."] + AddressResolve(err: Option) { + description("Failed to resolve network address"), + display("Failed to resolve network address {}", err.as_ref().map_or("".to_string(), |e| e.to_string())), + } - let msg = match *self { - Auth => "Authentication failure".into(), - BadProtocol => "Bad protocol".into(), - Expired => "Expired message".into(), - PeerNotFound => "Peer not found".into(), - Disconnect(ref reason) => format!("Peer disconnected: {}", reason), - Io(ref err) => format!("Socket I/O error: {}", err), - AddressParse(ref err) => format!("{}", err), - AddressResolve(Some(ref err)) => format!("{}", err), - AddressResolve(_) => "Failed to resolve network address.".into(), - StdIo(ref err) => format!("{}", err), - InvalidNodeId => "Invalid node id".into(), - OversizedPacket => "Packet is too large".into(), - Decompression(ref err) => format!("Error decompressing packet: {}", err), - }; + #[doc = "Authentication failure"] + Auth { + description("Authentication failure"), + display("Authentication failure"), + } - f.write_fmt(format_args!("Network error ({})", msg)) + #[doc = "Unrecognised protocol"] + BadProtocol { + description("Bad protocol"), + display("Bad protocol"), + } + + #[doc = "Expired message"] + Expired { + description("Expired message"), + display("Expired message"), + } + + #[doc = "Peer not found"] + PeerNotFound { + description("Peer not found"), + display("Peer not found"), + } + + #[doc = "Peer is disconnected"] + Disconnect(reason: DisconnectReason) { + description("Peer disconnected"), + display("Peer disconnected: {}", reason), + } + + #[doc = "Invalid node id"] + InvalidNodeId { + description("Invalid node id"), + display("Invalid node id"), + } + + #[doc = "Packet size is over the protocol limit"] + OversizedPacket { + description("Packet is too large"), + display("Packet is too large"), + } } } -impl From for NetworkError { - fn from(_err: DecoderError) -> NetworkError { - NetworkError::Auth +impl From for Error { + fn from(_err: rlp::DecoderError) -> Self { + ErrorKind::Auth.into() } } -impl From<::std::io::Error> for NetworkError { - fn from(err: ::std::io::Error) -> NetworkError { - NetworkError::StdIo(err) +impl From for Error { + fn from(_err: ethkey::Error) -> Self { + ErrorKind::Auth.into() } } -impl From for NetworkError { - fn from(err: IoError) -> NetworkError { - NetworkError::Io(err) - } -} - -impl From for NetworkError { - fn from(_err: KeyError) -> Self { - NetworkError::Auth - } -} - -impl From for NetworkError { - fn from(_err: CryptoError) -> NetworkError { - NetworkError::Auth - } -} - -impl From for NetworkError { - fn from(err: snappy::InvalidInput) -> NetworkError { - NetworkError::Decompression(err) - } -} - -impl From<::std::net::AddrParseError> for NetworkError { - fn from(err: ::std::net::AddrParseError) -> NetworkError { - NetworkError::AddressParse(err) +impl From for Error { + fn from(_err: crypto::Error) -> Self { + ErrorKind::Auth.into() } } @@ -187,13 +166,13 @@ fn test_errors() { } assert_eq!(DisconnectReason::Unknown, r); - match >::from(DecoderError::RlpIsTooBig) { - NetworkError::Auth => {}, + match *>::from(rlp::DecoderError::RlpIsTooBig).kind() { + ErrorKind::Auth => {}, _ => panic!("Unexpeceted error"), } - match >::from(CryptoError::InvalidMessage) { - NetworkError::Auth => {}, + match *>::from(crypto::Error::InvalidMessage).kind() { + ErrorKind::Auth => {}, _ => panic!("Unexpeceted error"), } } diff --git a/util/network/src/handshake.rs b/util/network/src/handshake.rs index bb5a5cb5d..09671205f 100644 --- a/util/network/src/handshake.rs +++ b/util/network/src/handshake.rs @@ -24,11 +24,11 @@ use rlp::*; use connection::{Connection}; use host::{HostInfo}; use node_table::NodeId; -use error::*; use stats::NetworkStats; use io::{IoContext, StreamToken}; use ethkey::{KeyPair, Public, Secret, recover, sign, Generator, Random}; use crypto::{ecdh, ecies}; +use error::{Error, ErrorKind}; #[derive(PartialEq, Eq, Debug)] enum HandshakeState { @@ -83,7 +83,7 @@ const ECIES_OVERHEAD: usize = 113; impl Handshake { /// Create a new handshake object - pub fn new(token: StreamToken, id: Option<&NodeId>, socket: TcpStream, nonce: &H256, stats: Arc) -> Result { + pub fn new(token: StreamToken, id: Option<&NodeId>, socket: TcpStream, nonce: &H256, stats: Arc) -> Result { Ok(Handshake { id: if let Some(id) = id { id.clone()} else { NodeId::new() }, connection: Connection::new(token, socket, stats), @@ -106,7 +106,7 @@ impl Handshake { } /// Start a handhsake - pub fn start(&mut self, io: &IoContext, host: &HostInfo, originated: bool) -> Result<(), NetworkError> where Message: Send + Clone+ Sync + 'static { + pub fn start(&mut self, io: &IoContext, host: &HostInfo, originated: bool) -> Result<(), Error> where Message: Send + Clone+ Sync + 'static { self.originated = originated; io.register_timer(self.connection.token, HANDSHAKE_TIMEOUT).ok(); if originated { @@ -125,7 +125,7 @@ impl Handshake { } /// Readable IO handler. Drives the state change. - pub fn readable(&mut self, io: &IoContext, host: &HostInfo) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + pub fn readable(&mut self, io: &IoContext, host: &HostInfo) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { if !self.expired() { while let Some(data) = self.connection.readable()? { match self.state { @@ -154,14 +154,14 @@ impl Handshake { } /// Writabe IO handler. - pub fn writable(&mut self, io: &IoContext) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + pub fn writable(&mut self, io: &IoContext) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { if !self.expired() { self.connection.writable(io)?; } Ok(()) } - fn set_auth(&mut self, host_secret: &Secret, sig: &[u8], remote_public: &[u8], remote_nonce: &[u8], remote_version: u64) -> Result<(), NetworkError> { + fn set_auth(&mut self, host_secret: &Secret, sig: &[u8], remote_public: &[u8], remote_nonce: &[u8], remote_version: u64) -> Result<(), Error> { self.id.clone_from_slice(remote_public); self.remote_nonce.clone_from_slice(remote_nonce); self.remote_version = remote_version; @@ -172,11 +172,11 @@ impl Handshake { } /// Parse, validate and confirm auth message - fn read_auth(&mut self, io: &IoContext, secret: &Secret, data: &[u8]) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + fn read_auth(&mut self, io: &IoContext, secret: &Secret, data: &[u8]) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { trace!(target: "network", "Received handshake auth from {:?}", self.connection.remote_addr_str()); if data.len() != V4_AUTH_PACKET_SIZE { debug!(target: "network", "Wrong auth packet size"); - return Err(From::from(NetworkError::BadProtocol)); + return Err(ErrorKind::BadProtocol.into()); } self.auth_cipher = data.to_vec(); match ecies::decrypt(secret, &[], data) { @@ -193,7 +193,7 @@ impl Handshake { let total = (((data[0] as u16) << 8 | (data[1] as u16)) as usize) + 2; if total < V4_AUTH_PACKET_SIZE { debug!(target: "network", "Wrong EIP8 auth packet size"); - return Err(From::from(NetworkError::BadProtocol)); + return Err(ErrorKind::BadProtocol.into()); } let rest = total - data.len(); self.state = HandshakeState::ReadingAuthEip8; @@ -203,7 +203,7 @@ impl Handshake { Ok(()) } - fn read_auth_eip8(&mut self, io: &IoContext, secret: &Secret, data: &[u8]) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + fn read_auth_eip8(&mut self, io: &IoContext, secret: &Secret, data: &[u8]) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { trace!(target: "network", "Received EIP8 handshake auth from {:?}", self.connection.remote_addr_str()); self.auth_cipher.extend_from_slice(data); let auth = ecies::decrypt(secret, &self.auth_cipher[0..2], &self.auth_cipher[2..])?; @@ -218,11 +218,11 @@ impl Handshake { } /// Parse and validate ack message - fn read_ack(&mut self, secret: &Secret, data: &[u8]) -> Result<(), NetworkError> { + fn read_ack(&mut self, secret: &Secret, data: &[u8]) -> Result<(), Error> { trace!(target: "network", "Received handshake ack from {:?}", self.connection.remote_addr_str()); if data.len() != V4_ACK_PACKET_SIZE { debug!(target: "network", "Wrong ack packet size"); - return Err(From::from(NetworkError::BadProtocol)); + return Err(ErrorKind::BadProtocol.into()); } self.ack_cipher = data.to_vec(); match ecies::decrypt(secret, &[], data) { @@ -236,7 +236,7 @@ impl Handshake { let total = (((data[0] as u16) << 8 | (data[1] as u16)) as usize) + 2; if total < V4_ACK_PACKET_SIZE { debug!(target: "network", "Wrong EIP8 ack packet size"); - return Err(From::from(NetworkError::BadProtocol)); + return Err(ErrorKind::BadProtocol.into()); } let rest = total - data.len(); self.state = HandshakeState::ReadingAckEip8; @@ -246,7 +246,7 @@ impl Handshake { Ok(()) } - fn read_ack_eip8(&mut self, secret: &Secret, data: &[u8]) -> Result<(), NetworkError> { + fn read_ack_eip8(&mut self, secret: &Secret, data: &[u8]) -> Result<(), Error> { trace!(target: "network", "Received EIP8 handshake auth from {:?}", self.connection.remote_addr_str()); self.ack_cipher.extend_from_slice(data); let ack = ecies::decrypt(secret, &self.ack_cipher[0..2], &self.ack_cipher[2..])?; @@ -259,7 +259,7 @@ impl Handshake { } /// Sends auth message - fn write_auth(&mut self, io: &IoContext, secret: &Secret, public: &Public) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + fn write_auth(&mut self, io: &IoContext, secret: &Secret, public: &Public) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { trace!(target: "network", "Sending handshake auth to {:?}", self.connection.remote_addr_str()); let mut data = [0u8; /*Signature::SIZE*/ 65 + /*H256::SIZE*/ 32 + /*Public::SIZE*/ 64 + /*H256::SIZE*/ 32 + 1]; //TODO: use associated constants let len = data.len(); @@ -286,7 +286,7 @@ impl Handshake { } /// Sends ack message - fn write_ack(&mut self, io: &IoContext) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + fn write_ack(&mut self, io: &IoContext) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { trace!(target: "network", "Sending handshake ack to {:?}", self.connection.remote_addr_str()); let mut data = [0u8; 1 + /*Public::SIZE*/ 64 + /*H256::SIZE*/ 32]; //TODO: use associated constants let len = data.len(); @@ -305,7 +305,7 @@ impl Handshake { } /// Sends EIP8 ack message - fn write_ack_eip8(&mut self, io: &IoContext) -> Result<(), NetworkError> where Message: Send + Clone + Sync + 'static { + fn write_ack_eip8(&mut self, io: &IoContext) -> Result<(), Error> where Message: Send + Clone + Sync + 'static { trace!(target: "network", "Sending EIP8 handshake ack to {:?}", self.connection.remote_addr_str()); let mut rlp = RlpStream::new_list(3); rlp.append(self.ecdhe.public()); diff --git a/util/network/src/host.rs b/util/network/src/host.rs index cfecb5ed4..ec22a8f63 100644 --- a/util/network/src/host.rs +++ b/util/network/src/host.rs @@ -22,7 +22,7 @@ use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; use std::ops::*; use std::cmp::min; use std::path::{Path, PathBuf}; -use std::io::{Read, Write, ErrorKind}; +use std::io::{Read, Write, self}; use std::fs; use ethkey::{KeyPair, Secret, Random, Generator}; use hash::keccak; @@ -33,7 +33,6 @@ use bigint::hash::*; use util::version; use rlp::*; use session::{Session, SessionInfo, SessionData}; -use error::*; use io::*; use {NetworkProtocolHandler, NonReservedPeerMode, PROTOCOL_VERSION, IpFilter}; use node_table::*; @@ -43,6 +42,7 @@ use ip_utils::{map_external_address, select_public_address}; use path::restrict_permissions_owner; use parking_lot::{Mutex, RwLock}; use connection_filter::{ConnectionFilter, ConnectionDirection}; +use error::{Error, ErrorKind, DisconnectReason}; type Slab = ::slab::Slab; @@ -248,12 +248,12 @@ impl<'s> NetworkContext<'s> { } /// Send a packet over the network to another peer. - pub fn send(&self, peer: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError> { + pub fn send(&self, peer: PeerId, packet_id: PacketId, data: Vec) -> Result<(), Error> { self.send_protocol(self.protocol, peer, packet_id, data) } /// Send a packet over the network to another peer using specified protocol. - pub fn send_protocol(&self, protocol: ProtocolId, peer: PeerId, packet_id: PacketId, data: Vec) -> Result<(), NetworkError> { + pub fn send_protocol(&self, protocol: ProtocolId, peer: PeerId, packet_id: PacketId, data: Vec) -> Result<(), Error> { let session = self.resolve_session(peer); if let Some(session) = session { session.lock().send_packet(self.io, Some(protocol), packet_id as u8, &data)?; @@ -264,9 +264,9 @@ impl<'s> NetworkContext<'s> { } /// Respond to a current network message. Panics if no there is no packet in the context. If the session is expired returns nothing. - pub fn respond(&self, packet_id: PacketId, data: Vec) -> Result<(), NetworkError> { + pub fn respond(&self, packet_id: PacketId, data: Vec) -> Result<(), Error> { assert!(self.session.is_some(), "Respond called without network context"); - self.session_id.map_or_else(|| Err(NetworkError::Expired), |id| self.send(id, packet_id, data)) + self.session_id.map_or_else(|| Err(ErrorKind::Expired.into()), |id| self.send(id, packet_id, data)) } /// Get an IoChannel. @@ -292,7 +292,7 @@ impl<'s> NetworkContext<'s> { } /// Register a new IO timer. 'IoHandler::timeout' will be called with the token. - pub fn register_timer(&self, token: TimerToken, ms: u64) -> Result<(), NetworkError> { + pub fn register_timer(&self, token: TimerToken, ms: u64) -> Result<(), Error> { self.io.message(NetworkIoMessage::AddTimer { token: token, delay: ms, @@ -386,7 +386,7 @@ pub struct Host { impl Host { /// Create a new instance - pub fn new(mut config: NetworkConfiguration, stats: Arc, filter: Option>) -> Result { + pub fn new(mut config: NetworkConfiguration, stats: Arc, filter: Option>) -> Result { let mut listen_address = match config.listen_address { None => SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), DEFAULT_PORT)), Some(addr) => addr, @@ -468,7 +468,7 @@ impl Host { } } - pub fn add_reserved_node(&self, id: &str) -> Result<(), NetworkError> { + pub fn add_reserved_node(&self, id: &str) -> Result<(), Error> { let n = Node::from_str(id)?; let entry = NodeEntry { endpoint: n.endpoint.clone(), id: n.id.clone() }; @@ -512,7 +512,7 @@ impl Host { } } - pub fn remove_reserved_node(&self, id: &str) -> Result<(), NetworkError> { + pub fn remove_reserved_node(&self, id: &str) -> Result<(), Error> { let n = Node::from_str(id)?; self.reserved_nodes.write().remove(&n.id); @@ -533,7 +533,7 @@ impl Host { format!("{}", Node::new(info.id().clone(), info.local_endpoint.clone())) } - pub fn stop(&self, io: &IoContext) -> Result<(), NetworkError> { + pub fn stop(&self, io: &IoContext) -> Result<(), Error> { self.stopping.store(true, AtomicOrdering::Release); let mut to_kill = Vec::new(); for e in self.sessions.write().iter_mut() { @@ -563,7 +563,7 @@ impl Host { peers } - fn init_public_interface(&self, io: &IoContext) -> Result<(), NetworkError> { + fn init_public_interface(&self, io: &IoContext) -> Result<(), Error> { if self.info.read().public_endpoint.is_some() { return Ok(()); } @@ -746,7 +746,7 @@ impl Host { } #[cfg_attr(feature="dev", allow(block_in_if_condition_stmt))] - fn create_connection(&self, socket: TcpStream, id: Option<&NodeId>, io: &IoContext) -> Result<(), NetworkError> { + fn create_connection(&self, socket: TcpStream, id: Option<&NodeId>, io: &IoContext) -> Result<(), Error> { let nonce = self.info.write().next_nonce(); let mut sessions = self.sessions.write(); @@ -775,7 +775,7 @@ impl Host { let socket = match self.tcp_listener.lock().accept() { Ok((sock, _addr)) => sock, Err(e) => { - if e.kind() != ErrorKind::WouldBlock { + if e.kind() != io::ErrorKind::WouldBlock { debug!(target: "network", "Error accepting connection: {:?}", e); } break @@ -821,7 +821,7 @@ impl Host { match session_result { Err(e) => { trace!(target: "network", "Session read error: {}:{:?} ({:?}) {:?}", token, s.id(), s.remote_addr(), e); - if let NetworkError::Disconnect(DisconnectReason::IncompatibleProtocol) = e { + if let ErrorKind::Disconnect(DisconnectReason::IncompatibleProtocol) = *e.kind() { if let Some(id) = s.id() { if !self.reserved_nodes.read().contains(id) { self.nodes.write().mark_as_useless(id); diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index 6cf81fa9d..8e57fd0d1 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -56,6 +56,7 @@ //TODO: use Poll from mio #![allow(deprecated)] +#![recursion_limit="128"] extern crate ethcore_io as io; extern crate ethcore_util as util; @@ -83,6 +84,9 @@ extern crate hash; extern crate serde_json; extern crate snappy; +#[macro_use] +extern crate error_chain; + #[macro_use] extern crate log; @@ -109,7 +113,7 @@ mod tests; pub use host::{HostInfo, PeerId, PacketId, ProtocolId, NetworkContext, NetworkIoMessage, NetworkConfiguration}; pub use service::NetworkService; -pub use error::NetworkError; +pub use error::{Error, ErrorKind}; pub use stats::NetworkStats; pub use session::SessionInfo; pub use connection_filter::{ConnectionFilter, ConnectionDirection}; diff --git a/util/network/src/node_table.rs b/util/network/src/node_table.rs index 6ba598291..e19da8280 100644 --- a/util/network/src/node_table.rs +++ b/util/network/src/node_table.rs @@ -28,7 +28,7 @@ use std::io::{Read, Write}; use bigint::hash::*; use rlp::*; use time::Tm; -use NetworkError; +use error::{Error, ErrorKind}; use {AllowIP, IpFilter}; use discovery::{TableUpdates, NodeEntry}; use ip_utils::*; @@ -117,18 +117,18 @@ impl NodeEndpoint { } impl FromStr for NodeEndpoint { - type Err = NetworkError; + type Err = Error; /// Create endpoint from string. Performs name resolution if given a host name. - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { let address = s.to_socket_addrs().map(|mut i| i.next()); match address { Ok(Some(a)) => Ok(NodeEndpoint { address: a, udp_port: a.port() }), - Ok(_) => Err(NetworkError::AddressResolve(None)), - Err(e) => Err(NetworkError::AddressResolve(Some(e))) + Ok(_) => Err(ErrorKind::AddressResolve(None).into()), + Err(e) => Err(ErrorKind::AddressResolve(Some(e)).into()) } } } @@ -171,10 +171,10 @@ impl Display for Node { } impl FromStr for Node { - type Err = NetworkError; + type Err = Error; fn from_str(s: &str) -> Result { let (id, endpoint) = if s.len() > 136 && &s[0..8] == "enode://" && &s[136..137] == "@" { - (s[8..136].parse().map_err(|_| NetworkError::InvalidNodeId)?, NodeEndpoint::from_str(&s[137..])?) + (s[8..136].parse().map_err(|_| ErrorKind::InvalidNodeId)?, NodeEndpoint::from_str(&s[137..])?) } else { (NodeId::new(), NodeEndpoint::from_str(s)?) @@ -363,7 +363,7 @@ impl Drop for NodeTable { } /// Check if node url is valid -pub fn validate_node_url(url: &str) -> Option { +pub fn validate_node_url(url: &str) -> Option { use std::str::FromStr; match Node::from_str(url) { Ok(_) => None, diff --git a/util/network/src/service.rs b/util/network/src/service.rs index bce31e00a..ae312e2dc 100644 --- a/util/network/src/service.rs +++ b/util/network/src/service.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use {NetworkProtocolHandler, NetworkConfiguration, NonReservedPeerMode}; -use error::NetworkError; +use error::Error; use host::{Host, NetworkContext, NetworkIoMessage, PeerId, ProtocolId}; use stats::NetworkStats; use io::*; @@ -54,7 +54,7 @@ pub struct NetworkService { impl NetworkService { /// Starts IO event loop - pub fn new(config: NetworkConfiguration, filter: Option>) -> Result { + pub fn new(config: NetworkConfiguration, filter: Option>) -> Result { let host_handler = Arc::new(HostHandler { public_url: RwLock::new(None) }); let io_service = IoService::::start()?; @@ -72,7 +72,7 @@ impl NetworkService { } /// Regiter a new protocol handler with the event loop. - pub fn register_protocol(&self, handler: Arc, protocol: ProtocolId, packet_count: u8, versions: &[u8]) -> Result<(), NetworkError> { + pub fn register_protocol(&self, handler: Arc, protocol: ProtocolId, packet_count: u8, versions: &[u8]) -> Result<(), Error> { self.io_service.send_message(NetworkIoMessage::AddHandler { handler: handler, protocol: protocol, @@ -115,7 +115,7 @@ impl NetworkService { } /// Start network IO - pub fn start(&self) -> Result<(), NetworkError> { + pub fn start(&self) -> Result<(), Error> { let mut host = self.host.write(); if host.is_none() { let h = Arc::new(Host::new(self.config.clone(), self.stats.clone(), self.filter.clone())?); @@ -131,7 +131,7 @@ impl NetworkService { } /// Stop network IO - pub fn stop(&self) -> Result<(), NetworkError> { + pub fn stop(&self) -> Result<(), Error> { let mut host = self.host.write(); if let Some(ref host) = *host { let io = IoContext::new(self.io_service.channel(), 0); //TODO: take token id from host @@ -147,7 +147,7 @@ impl NetworkService { } /// Try to add a reserved peer. - pub fn add_reserved_peer(&self, peer: &str) -> Result<(), NetworkError> { + pub fn add_reserved_peer(&self, peer: &str) -> Result<(), Error> { let host = self.host.read(); if let Some(ref host) = *host { host.add_reserved_node(peer) @@ -157,7 +157,7 @@ impl NetworkService { } /// Try to remove a reserved peer. - pub fn remove_reserved_peer(&self, peer: &str) -> Result<(), NetworkError> { + pub fn remove_reserved_peer(&self, peer: &str) -> Result<(), Error> { let host = self.host.read(); if let Some(ref host) = *host { host.remove_reserved_node(peer) diff --git a/util/network/src/session.rs b/util/network/src/session.rs index cf6c196e3..961e3c95c 100644 --- a/util/network/src/session.rs +++ b/util/network/src/session.rs @@ -28,7 +28,7 @@ use rlp::*; use connection::{EncryptedConnection, Packet, Connection, MAX_PAYLOAD_SIZE}; use handshake::Handshake; use io::{IoContext, StreamToken}; -use error::{NetworkError, DisconnectReason}; +use error::{Error, ErrorKind, DisconnectReason}; use host::*; use node_table::NodeId; use stats::NetworkStats; @@ -178,7 +178,7 @@ impl Session { /// Create a new session out of comepleted handshake. This clones the handshake connection object /// and leaves the handhsake in limbo to be deregistered from the event loop. pub fn new(io: &IoContext, socket: TcpStream, token: StreamToken, id: Option<&NodeId>, - nonce: &H256, stats: Arc, host: &HostInfo) -> Result + nonce: &H256, stats: Arc, host: &HostInfo) -> Result where Message: Send + Clone + Sync + 'static { let originated = id.is_some(); let mut handshake = Handshake::new(token, id, socket, nonce, stats).expect("Can't create handshake"); @@ -206,7 +206,7 @@ impl Session { }) } - fn complete_handshake(&mut self, io: &IoContext, host: &HostInfo) -> Result<(), NetworkError> where Message: Send + Sync + Clone { + fn complete_handshake(&mut self, io: &IoContext, host: &HostInfo) -> Result<(), Error> where Message: Send + Sync + Clone { let connection = if let State::Handshake(ref mut h) = self.state { self.info.id = Some(h.id.clone()); self.info.remote_address = h.connection.remote_addr_str(); @@ -260,7 +260,7 @@ impl Session { } /// Readable IO handler. Returns packet data if available. - pub fn readable(&mut self, io: &IoContext, host: &HostInfo) -> Result where Message: Send + Sync + Clone { + pub fn readable(&mut self, io: &IoContext, host: &HostInfo) -> Result where Message: Send + Sync + Clone { if self.expired() { return Ok(SessionData::None) } @@ -291,7 +291,7 @@ impl Session { } /// Writable IO handler. Sends pending packets. - pub fn writable(&mut self, io: &IoContext, _host: &HostInfo) -> Result<(), NetworkError> where Message: Send + Sync + Clone { + pub fn writable(&mut self, io: &IoContext, _host: &HostInfo) -> Result<(), Error> where Message: Send + Sync + Clone { match self.state { State::Handshake(ref mut h) => h.writable(io), State::Session(ref mut s) => s.writable(io), @@ -309,7 +309,7 @@ impl Session { } /// Register the session socket with the event loop - pub fn register_socket>(&self, reg: Token, event_loop: &mut EventLoop) -> Result<(), NetworkError> { + pub fn register_socket>(&self, reg: Token, event_loop: &mut EventLoop) -> Result<(), Error> { if self.expired() { return Ok(()); } @@ -318,26 +318,26 @@ impl Session { } /// Update registration with the event loop. Should be called at the end of the IO handler. - pub fn update_socket(&self, reg:Token, event_loop: &mut EventLoop) -> Result<(), NetworkError> { + pub fn update_socket(&self, reg:Token, event_loop: &mut EventLoop) -> Result<(), Error> { self.connection().update_socket(reg, event_loop)?; Ok(()) } /// Delete registration - pub fn deregister_socket(&self, event_loop: &mut EventLoop) -> Result<(), NetworkError> { + pub fn deregister_socket(&self, event_loop: &mut EventLoop) -> Result<(), Error> { self.connection().deregister_socket(event_loop)?; Ok(()) } /// Send a protocol packet to peer. - pub fn send_packet(&mut self, io: &IoContext, protocol: Option<[u8; 3]>, packet_id: u8, data: &[u8]) -> Result<(), NetworkError> + pub fn send_packet(&mut self, io: &IoContext, protocol: Option<[u8; 3]>, packet_id: u8, data: &[u8]) -> Result<(), Error> where Message: Send + Sync + Clone { if protocol.is_some() && (self.info.capabilities.is_empty() || !self.had_hello) { debug!(target: "network", "Sending to unconfirmed session {}, protocol: {:?}, packet: {}", self.token(), protocol.as_ref().map(|p| str::from_utf8(&p[..]).unwrap_or("??")), packet_id); - return Err(From::from(NetworkError::BadProtocol)); + bail!(ErrorKind::BadProtocol); } if self.expired() { - return Err(From::from(NetworkError::Expired)); + return Err(ErrorKind::Expired.into()); } let mut i = 0usize; let pid = match protocol { @@ -359,7 +359,7 @@ impl Session { let mut payload = data; // create a reference with local lifetime if self.compression { if payload.len() > MAX_PAYLOAD_SIZE { - return Err(NetworkError::OversizedPacket); + bail!(ErrorKind::OversizedPacket); } let len = snappy::compress_into(&payload, &mut compressed); trace!(target: "network", "compressed {} to {}", payload.len(), len); @@ -406,19 +406,19 @@ impl Session { } } - fn read_packet(&mut self, io: &IoContext, packet: Packet, host: &HostInfo) -> Result + fn read_packet(&mut self, io: &IoContext, packet: Packet, host: &HostInfo) -> Result where Message: Send + Sync + Clone { if packet.data.len() < 2 { - return Err(From::from(NetworkError::BadProtocol)); + return Err(ErrorKind::BadProtocol.into()); } let packet_id = packet.data[0]; if packet_id != PACKET_HELLO && packet_id != PACKET_DISCONNECT && !self.had_hello { - return Err(From::from(NetworkError::BadProtocol)); + return Err(ErrorKind::BadProtocol.into()); } let data = if self.compression { let compressed = &packet.data[1..]; if snappy::decompressed_len(&compressed)? > MAX_PAYLOAD_SIZE { - return Err(NetworkError::OversizedPacket); + bail!(ErrorKind::OversizedPacket); } snappy::decompress(&compressed)? } else { @@ -436,7 +436,7 @@ impl Session { if self.had_hello { debug!(target:"network", "Disconnected: {}: {:?}", self.token(), DisconnectReason::from_u8(reason)); } - Err(From::from(NetworkError::Disconnect(DisconnectReason::from_u8(reason)))) + Err(ErrorKind::Disconnect(DisconnectReason::from_u8(reason)).into()) } PACKET_PING => { self.send_pong(io)?; @@ -484,7 +484,7 @@ impl Session { } } - fn write_hello(&mut self, io: &IoContext, host: &HostInfo) -> Result<(), NetworkError> where Message: Send + Sync + Clone { + fn write_hello(&mut self, io: &IoContext, host: &HostInfo) -> Result<(), Error> where Message: Send + Sync + Clone { let mut rlp = RlpStream::new(); rlp.append_raw(&[PACKET_HELLO as u8], 0); rlp.begin_list(5) @@ -496,7 +496,7 @@ impl Session { self.send(io, &rlp.drain()) } - fn read_hello(&mut self, io: &IoContext, rlp: &UntrustedRlp, host: &HostInfo) -> Result<(), NetworkError> + fn read_hello(&mut self, io: &IoContext, rlp: &UntrustedRlp, host: &HostInfo) -> Result<(), Error> where Message: Send + Sync + Clone { let protocol = rlp.val_at::(0)?; let client_version = rlp.val_at::(1)?; @@ -558,29 +558,29 @@ impl Session { } /// Senf ping packet - pub fn send_ping(&mut self, io: &IoContext) -> Result<(), NetworkError> where Message: Send + Sync + Clone { + pub fn send_ping(&mut self, io: &IoContext) -> Result<(), Error> where Message: Send + Sync + Clone { self.send_packet(io, None, PACKET_PING, &EMPTY_LIST_RLP)?; self.ping_time_ns = time::precise_time_ns(); self.pong_time_ns = None; Ok(()) } - fn send_pong(&mut self, io: &IoContext) -> Result<(), NetworkError> where Message: Send + Sync + Clone { + fn send_pong(&mut self, io: &IoContext) -> Result<(), Error> where Message: Send + Sync + Clone { self.send_packet(io, None, PACKET_PONG, &EMPTY_LIST_RLP) } /// Disconnect this session - pub fn disconnect(&mut self, io: &IoContext, reason: DisconnectReason) -> NetworkError where Message: Send + Sync + Clone { + pub fn disconnect(&mut self, io: &IoContext, reason: DisconnectReason) -> Error where Message: Send + Sync + Clone { if let State::Session(_) = self.state { let mut rlp = RlpStream::new(); rlp.begin_list(1); rlp.append(&(reason as u32)); self.send_packet(io, None, PACKET_DISCONNECT, &rlp.drain()).ok(); } - NetworkError::Disconnect(reason) + ErrorKind::Disconnect(reason).into() } - fn send(&mut self, io: &IoContext, data: &[u8]) -> Result<(), NetworkError> where Message: Send + Sync + Clone { + fn send(&mut self, io: &IoContext, data: &[u8]) -> Result<(), Error> where Message: Send + Sync + Clone { match self.state { State::Handshake(_) => { warn!(target:"network", "Unexpected send request"); diff --git a/util/snappy/Cargo.toml b/util/snappy/Cargo.toml index c65e9824d..25ded14dd 100644 --- a/util/snappy/Cargo.toml +++ b/util/snappy/Cargo.toml @@ -5,3 +5,4 @@ authors = ["Parity Technologies "] [dependencies] libc = "0.2.7" +rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" } diff --git a/util/snappy/src/lib.rs b/util/snappy/src/lib.rs index 545ff1e5b..29b042125 100644 --- a/util/snappy/src/lib.rs +++ b/util/snappy/src/lib.rs @@ -24,6 +24,7 @@ const SNAPPY_OK: c_int = 0; const SNAPPY_INVALID_INPUT: c_int = 1; const SNAPPY_BUFFER_TOO_SMALL: c_int = 2; +#[link(name = "snappy")] extern { fn snappy_compress( input: *const c_char, diff --git a/whisper/src/net.rs b/whisper/src/net.rs index dab32ad2c..4a051b3df 100644 --- a/whisper/src/net.rs +++ b/whisper/src/net.rs @@ -23,7 +23,7 @@ use std::time::{Duration, SystemTime}; use std::sync::Arc; use bigint::hash::{H256, H512}; -use network::{HostInfo, NetworkContext, NetworkError, NodeId, PeerId, ProtocolId, TimerToken}; +use network::{self, HostInfo, NetworkContext, NodeId, PeerId, ProtocolId, TimerToken}; use ordered_float::OrderedFloat; use parking_lot::{Mutex, RwLock}; use rlp::{DecoderError, RlpStream, UntrustedRlp}; @@ -79,7 +79,7 @@ pub trait MessageHandler: Send + Sync { #[derive(Debug)] enum Error { Decoder(DecoderError), - Network(NetworkError), + Network(network::Error), Message(MessageError), UnknownPeer(PeerId), UnexpectedMessage, @@ -92,8 +92,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: NetworkError) -> Self { +impl From for Error { + fn from(err: network::Error) -> Self { Error::Network(err) } } From 8b85f648ca6e02f77fd9370e54904e860f4b006f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 13 Nov 2017 17:09:30 +0100 Subject: [PATCH 15/31] HashMap::retain --- rpc/src/v1/helpers/nonce.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rpc/src/v1/helpers/nonce.rs b/rpc/src/v1/helpers/nonce.rs index 2b4df49ae..30ad15211 100644 --- a/rpc/src/v1/helpers/nonce.rs +++ b/rpc/src/v1/helpers/nonce.rs @@ -57,10 +57,7 @@ impl Reservations { /// The reserved nonce cannot be smaller than the minimal nonce. pub fn reserve(&mut self, sender: Address, minimal: U256) -> Reserved { if self.nonces.len() + 1 > Self::CLEAN_AT { - let to_remove = self.nonces.iter().filter(|&(_, v)| v.is_empty()).map(|(k, _)| *k).collect::>(); - for address in to_remove { - self.nonces.remove(&address); - } + self.nonces.retain(|_, v| !v.is_empty()); } let pool = &self.pool; From 7e512c637aaa3b0cc7d26067e4c6a309dbaf23e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 13 Nov 2017 22:52:25 +0100 Subject: [PATCH 16/31] Bump version. --- Cargo.lock | 95 ++++++++++++++++++++++--------------------- Cargo.toml | 2 +- dapps/Cargo.toml | 4 +- ipfs/Cargo.toml | 4 +- rpc/Cargo.toml | 12 +++--- rpc_client/Cargo.toml | 4 +- stratum/Cargo.toml | 6 +-- whisper/Cargo.toml | 6 +-- 8 files changed, 67 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3922dc48..e1c089df2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,9 +710,9 @@ dependencies = [ "ethcore-logger 1.9.0", "ethcore-util 1.9.0", "hash 0.1.0", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1237,7 +1237,7 @@ dependencies = [ [[package]] name = "jsonrpc-core" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1249,11 +1249,11 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ "hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1262,10 +1262,10 @@ dependencies = [ [[package]] name = "jsonrpc-ipc-server" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-tokio-ipc 0.1.5 (git+https://github.com/nikvolf/parity-tokio-ipc)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1274,19 +1274,19 @@ dependencies = [ [[package]] name = "jsonrpc-macros" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-pubsub" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1294,11 +1294,11 @@ dependencies = [ [[package]] name = "jsonrpc-server-utils" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ "bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1307,10 +1307,10 @@ dependencies = [ [[package]] name = "jsonrpc-tcp-server" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1319,10 +1319,11 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" version = "8.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8#cf6f3481760f6ee8fbef7a987954ffc720ff4acf" +source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9#8f921ed65cda3fba0ce55d31ed62c7f0c3b32966" dependencies = [ - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1924,7 +1925,7 @@ dependencies = [ "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "kvdb 0.1.0", "kvdb-rocksdb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1978,8 +1979,8 @@ dependencies = [ "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "hash 0.1.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2057,8 +2058,8 @@ dependencies = [ "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", "ethcore-util 1.9.0", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "multihash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.0", "unicase 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2125,12 +2126,12 @@ dependencies = [ "hardware-wallet 1.9.0", "hash 0.1.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-ipc-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-ipc-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", @@ -2162,8 +2163,8 @@ version = "1.4.0" dependencies = [ "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "hash 0.1.0", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.9.0", @@ -2272,9 +2273,9 @@ dependencies = [ "ethcrypto 0.1.0", "ethkey 0.2.0", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", - "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", + "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3585,14 +3586,14 @@ dependencies = [ "checksum isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fa500db770a99afe2a0f2229be2a3d09c7ed9d7e4e8440bf71253141994e240f" "checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" -"checksum jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-ipc-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" -"checksum jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)" = "" +"checksum jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-ipc-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-server-utils 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" +"checksum jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)" = "" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" diff --git a/Cargo.toml b/Cargo.toml index a953dcef8..f20872a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ futures-cpupool = "0.1" fdlimit = "0.1" ws2_32-sys = "0.2" ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" } -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } ethsync = { path = "sync" } ethcore = { path = "ethcore" } ethcore-util = { path = "util" } diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index c0e856791..8abbfe27d 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -25,8 +25,8 @@ unicase = "1.4" zip = { version = "0.1", default-features = false } itertools = "0.5" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } ethcore-util = { path = "../util" } ethcore-bigint = { path = "../util/bigint" } diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml index c34e0d521..0e8b21c15 100644 --- a/ipfs/Cargo.toml +++ b/ipfs/Cargo.toml @@ -10,8 +10,8 @@ ethcore = { path = "../ethcore" } ethcore-util = { path = "../util" } ethcore-bigint = { path = "../util/bigint" } ethcore-bytes = { path = "../util/bytes" } -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } rlp = { path = "../util/rlp" } cid = "0.2" multihash = "0.6" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 360a7b776..9fd178dd8 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -28,12 +28,12 @@ tokio-timer = "0.1" transient-hashmap = "0.4" itertools = "0.5" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-ipc-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-ipc-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } ethcore-io = { path = "../util/io" } ethcore-util = { path = "../util" } diff --git a/rpc_client/Cargo.toml b/rpc_client/Cargo.toml index cada20fa1..4cd2fd551 100644 --- a/rpc_client/Cargo.toml +++ b/rpc_client/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0" url = "1.2.0" matches = "0.1" parking_lot = "0.4" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } parity-rpc = { path = "../rpc" } hash = { path = "../util/hash" } diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index 911e2ad0e..c62c9c81b 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -7,9 +7,9 @@ authors = ["Parity Technologies "] [dependencies] log = "0.3" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } ethcore-util = { path = "../util" } ethcore-bigint = { path = "../util/bigint" } ethcore-devtools = { path = "../devtools" } diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index 3aa482cc3..20d52666b 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -26,6 +26,6 @@ smallvec = "0.4" time = "0.1" tiny-keccak = "1.3" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } -jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.8" } +jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } +jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } From f7fa9f6e9dd02fa5c14ab866485920a24c1f46c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 14 Nov 2017 11:38:17 +0100 Subject: [PATCH 17/31] Drop jsonrpc_core::Error --- dapps/src/endpoint.rs | 4 +- dapps/src/handlers/fetch.rs | 5 +- dapps/src/lib.rs | 5 +- dapps/src/tests/helpers/mod.rs | 7 +- parity/dapps.rs | 5 +- parity/rpc.rs | 4 +- rpc/src/lib.rs | 22 +---- rpc/src/v1/helpers/dispatch.rs | 44 ++++----- rpc/src/v1/helpers/light_fetch.rs | 22 ++--- rpc/src/v1/helpers/subscription_manager.rs | 4 +- rpc/src/v1/impls/eth.rs | 86 ++++++++--------- rpc/src/v1/impls/eth_filter.rs | 18 ++-- rpc/src/v1/impls/eth_pubsub.rs | 8 +- rpc/src/v1/impls/light/eth.rs | 78 +++++++-------- rpc/src/v1/impls/light/net.rs | 8 +- rpc/src/v1/impls/light/parity.rs | 92 +++++++++--------- rpc/src/v1/impls/light/parity_set.rs | 46 ++++----- rpc/src/v1/impls/light/trace.rs | 18 ++-- rpc/src/v1/impls/net.rs | 8 +- rpc/src/v1/impls/parity.rs | 96 +++++++++---------- rpc/src/v1/impls/parity_accounts.rs | 74 +++++++------- rpc/src/v1/impls/parity_set.rs | 46 ++++----- rpc/src/v1/impls/personal.rs | 14 +-- rpc/src/v1/impls/pubsub.rs | 4 +- rpc/src/v1/impls/rpc.rs | 6 +- rpc/src/v1/impls/secretstore.rs | 14 +-- rpc/src/v1/impls/signer.rs | 26 ++--- rpc/src/v1/impls/signing.rs | 22 ++--- rpc/src/v1/impls/signing_unsafe.rs | 22 ++--- rpc/src/v1/impls/traces.rs | 20 ++-- rpc/src/v1/impls/web3.rs | 6 +- rpc/src/v1/traits/eth.rs | 86 ++++++++--------- rpc/src/v1/traits/eth_pubsub.rs | 4 +- rpc/src/v1/traits/eth_signing.rs | 8 +- rpc/src/v1/traits/net.rs | 8 +- rpc/src/v1/traits/parity.rs | 92 +++++++++--------- rpc/src/v1/traits/parity_accounts.rs | 72 +++++++------- rpc/src/v1/traits/parity_set.rs | 46 ++++----- rpc/src/v1/traits/parity_signing.rs | 12 +-- rpc/src/v1/traits/personal.rs | 12 +-- rpc/src/v1/traits/pubsub.rs | 4 +- rpc/src/v1/traits/rpc.rs | 6 +- rpc/src/v1/traits/secretstore.rs | 8 +- rpc/src/v1/traits/signer.rs | 18 ++-- rpc/src/v1/traits/traces.rs | 18 ++-- rpc/src/v1/traits/web3.rs | 6 +- rpc_client/src/client.rs | 4 +- rpc_client/src/lib.rs | 2 + rpc_client/src/signer_client.rs | 2 +- .../admin_sessions/share_add_session.rs | 8 +- 50 files changed, 616 insertions(+), 634 deletions(-) diff --git a/dapps/src/endpoint.rs b/dapps/src/endpoint.rs index c612ad5b8..2dbcf209f 100644 --- a/dapps/src/endpoint.rs +++ b/dapps/src/endpoint.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; -use jsonrpc_core::BoxFuture; +use futures::Future; use hyper; #[derive(Debug, PartialEq, Default, Clone)] @@ -47,7 +47,7 @@ pub struct EndpointInfo { } pub type Endpoints = BTreeMap>; -pub type Response = BoxFuture; +pub type Response = Box + Send>; pub type Request = hyper::Request; pub trait Endpoint : Send + Sync { diff --git a/dapps/src/handlers/fetch.rs b/dapps/src/handlers/fetch.rs index 27429bd01..8e0fc021e 100644 --- a/dapps/src/handlers/fetch.rs +++ b/dapps/src/handlers/fetch.rs @@ -24,7 +24,6 @@ use fetch::{self, Fetch}; use futures::sync::oneshot; use futures::{self, Future}; use hyper::{self, Method, StatusCode}; -use jsonrpc_core::BoxFuture; use parking_lot::Mutex; use endpoint::{self, EndpointPath}; @@ -212,7 +211,7 @@ impl Errors { enum FetchState { Error(ContentHandler), - InProgress(BoxFuture), + InProgress(Box + Send>), Streaming(hyper::Response), Done(local::Dapp, endpoint::Response), Empty, @@ -289,7 +288,7 @@ impl ContentFetcherHandler { path: EndpointPath, errors: Errors, installer: H, - ) -> BoxFuture { + ) -> Box + Send> { // Start fetching the content let fetch2 = fetch.clone(); let future = fetch.fetch_with_abort(url, abort.into()).then(move |result| { diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs index 36b5bec4c..e63f30c23 100644 --- a/dapps/src/lib.rs +++ b/dapps/src/lib.rs @@ -32,7 +32,6 @@ extern crate serde_json; extern crate unicase; extern crate zip; -extern crate jsonrpc_core; extern crate jsonrpc_http_server; extern crate ethcore_util as util; @@ -52,10 +51,12 @@ extern crate log; #[macro_use] extern crate serde_derive; +#[cfg(test)] +extern crate env_logger; #[cfg(test)] extern crate ethcore_devtools as devtools; #[cfg(test)] -extern crate env_logger; +extern crate jsonrpc_core; #[cfg(test)] extern crate parity_reactor; diff --git a/dapps/src/tests/helpers/mod.rs b/dapps/src/tests/helpers/mod.rs index 81ed5ed41..fd60e5bf4 100644 --- a/dapps/src/tests/helpers/mod.rs +++ b/dapps/src/tests/helpers/mod.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::env; -use std::str; +use std::{env, io, str}; use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -187,7 +186,7 @@ impl ServerBuilder { /// Asynchronously start server with no authentication, /// returns result with `Server` handle on success or an error. - pub fn start_unsecured_http(self, addr: &SocketAddr, io: IoHandler) -> Result { + pub fn start_unsecured_http(self, addr: &SocketAddr, io: IoHandler) -> io::Result { let fetch = self.fetch_client(); Server::start_http( addr, @@ -234,7 +233,7 @@ impl Server { remote: Remote, fetch: F, serve_ui: bool, - ) -> Result { + ) -> io::Result { let health = NodeHealth::new( sync_status.clone(), TimeChecker::new::(&[], CpuPool::new(1)), diff --git a/parity/dapps.rs b/parity/dapps.rs index 364f563c5..c15b16337 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -22,7 +22,6 @@ use ethcore::client::{Client, BlockChainClient, BlockId}; use ethcore::transaction::{Transaction, Action}; use ethsync::LightSync; use futures::{future, IntoFuture, Future}; -use jsonrpc_core::BoxFuture; use hash_fetch::fetch::Client as FetchClient; use hash_fetch::urlhint::ContractClient; use helpers::replace_home; @@ -80,7 +79,7 @@ impl ContractClient for FullRegistrar { }) } - fn call(&self, address: Address, data: Bytes) -> BoxFuture { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { Box::new(self.client.call_contract(BlockId::Latest, address, data) .into_future()) } @@ -105,7 +104,7 @@ impl ContractClient for LightRegistrar { }) } - fn call(&self, address: Address, data: Bytes) -> BoxFuture { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { let header = self.client.best_block_header(); let env_info = self.client.env_info(BlockId::Hash(header.hash())) .ok_or_else(|| format!("Cannot fetch env info for header {}", header.hash())); diff --git a/parity/rpc.rs b/parity/rpc.rs index d67362b5f..3a202b590 100644 --- a/parity/rpc.rs +++ b/parity/rpc.rs @@ -246,7 +246,7 @@ pub fn new_ws( match start_result { Ok(server) => Ok(Some(server)), - Err(rpc::ws::Error::Io(ref err)) if err.kind() == io::ErrorKind::AddrInUse => Err( + Err(rpc::ws::Error(rpc::ws::ErrorKind::Io(ref err), _)) if err.kind() == io::ErrorKind::AddrInUse => Err( format!("WebSockets address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --ws-port and --ws-interface options.", url) ), Err(e) => Err(format!("WebSockets error: {:?}", e)), @@ -286,7 +286,7 @@ pub fn new_http( match start_result { Ok(server) => Ok(Some(server)), - Err(rpc::HttpServerError::Io(ref err)) if err.kind() == io::ErrorKind::AddrInUse => Err( + Err(ref err) if err.kind() == io::ErrorKind::AddrInUse => Err( format!("{} address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --{}-port and --{}-interface options.", id, url, options, options) ), Err(e) => Err(format!("{} error: {:?}", id, e)), diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index ab0b9082d..3d782d419 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -117,26 +117,6 @@ use http::tokio_core; /// RPC HTTP Server instance pub type HttpServer = http::Server; - -/// RPC HTTP Server error -#[derive(Debug)] -pub enum HttpServerError { - /// IO error - Io(::std::io::Error), - /// Other hyper error - Hyper(hyper::Error), -} - -impl From for HttpServerError { - fn from(e: http::Error) -> Self { - use self::HttpServerError::*; - match e { - http::Error::Io(io) => Io(io), - http::Error::Other(hyper) => Hyper(hyper), - } - } -} - /// Start http server asynchronously and returns result with `Server` handle on success or an error. pub fn start_http( addr: &SocketAddr, @@ -147,7 +127,7 @@ pub fn start_http( extractor: T, middleware: Option, threads: usize, -) -> Result where +) -> ::std::io::Result where M: jsonrpc_core::Metadata, S: jsonrpc_core::Middleware, H: Into>, diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index c556226b5..52d8e3aa6 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -42,7 +42,7 @@ use ethcore::transaction::{Action, SignedTransaction, PendingTransaction, Transa use ethcore::account_provider::AccountProvider; use crypto::DEFAULT_MAC; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{future, Future, Poll, Async}; use jsonrpc_core::futures::future::Either; use v1::helpers::{errors, nonce, TransactionRequest, FilledTransactionRequest, ConfirmationPayload}; @@ -67,18 +67,18 @@ pub trait Dispatcher: Send + Sync + Clone { /// Fill optional fields of a transaction request, fetching gas price but not nonce. fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool) - -> BoxFuture; + -> BoxFuture; /// Sign the given transaction request without dispatching, fetching appropriate nonce. fn sign(&self, accounts: Arc, filled: FilledTransactionRequest, password: SignWith) - -> BoxFuture, Error>; + -> BoxFuture>; /// Converts a `SignedTransaction` into `RichRawTransaction` fn enrich(&self, SignedTransaction) -> RpcRichRawTransaction; /// "Dispatch" a local transaction. fn dispatch_transaction(&self, signed_transaction: PendingTransaction) - -> Result; + -> Result; } /// A dispatcher which uses references to a client and miner in order to sign @@ -118,7 +118,7 @@ impl FullDispatcher { } /// Imports transaction to the miner's queue. - pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result { + pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result { let hash = signed_transaction.transaction.hash(); miner.import_own_transaction(client, signed_transaction) @@ -129,7 +129,7 @@ impl FullDispatcher { impl Dispatcher for FullDispatcher { fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool) - -> BoxFuture + -> BoxFuture { let request = request; let from = request.from.unwrap_or(default_sender); @@ -153,7 +153,7 @@ impl Dispatcher for FullDispatcher, filled: FilledTransactionRequest, password: SignWith) - -> BoxFuture, Error> + -> BoxFuture> { let chain_id = self.client.signing_chain_id(); @@ -171,7 +171,7 @@ impl Dispatcher for FullDispatcher Result { + fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result { Self::dispatch_transaction(&*self.client, &*self.miner, signed_transaction) } } @@ -183,7 +183,7 @@ pub fn fetch_gas_price_corpus( client: Arc, on_demand: Arc, cache: Arc>, -) -> BoxFuture, Error> { +) -> BoxFuture> { const GAS_PRICE_SAMPLE_SIZE: usize = 100; if let Some(cached) = { cache.lock().gas_price_corpus() } { @@ -279,7 +279,7 @@ impl LightDispatcher { /// Get a recent gas price corpus. // TODO: this could be `impl Trait`. - pub fn gas_price_corpus(&self) -> BoxFuture, Error> { + pub fn gas_price_corpus(&self) -> BoxFuture> { fetch_gas_price_corpus( self.sync.clone(), self.client.clone(), @@ -289,7 +289,7 @@ impl LightDispatcher { } /// Get an account's next nonce. - pub fn next_nonce(&self, addr: Address) -> BoxFuture { + pub fn next_nonce(&self, addr: Address) -> BoxFuture { // fast path where we don't go to network; nonce provided or can be gotten from queue. let maybe_nonce = self.transaction_queue.read().next_nonce(&addr); if let Some(nonce) = maybe_nonce { @@ -315,7 +315,7 @@ impl LightDispatcher { impl Dispatcher for LightDispatcher { fn fill_optional_fields(&self, request: TransactionRequest, default_sender: Address, force_nonce: bool) - -> BoxFuture + -> BoxFuture { const DEFAULT_GAS_PRICE: U256 = U256([0, 0, 0, 21_000_000]); @@ -369,7 +369,7 @@ impl Dispatcher for LightDispatcher { } fn sign(&self, accounts: Arc, filled: FilledTransactionRequest, password: SignWith) - -> BoxFuture, Error> + -> BoxFuture> { let chain_id = self.client.signing_chain_id(); @@ -392,7 +392,7 @@ impl Dispatcher for LightDispatcher { RpcRichRawTransaction::from_signed(signed_transaction, block_number, self.client.eip86_transition()) } - fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result { + fn dispatch_transaction(&self, signed_transaction: PendingTransaction) -> Result { let hash = signed_transaction.transaction.hash(); self.transaction_queue.write().import(signed_transaction) @@ -408,7 +408,7 @@ fn sign_transaction( chain_id: Option, nonce: U256, password: SignWith, -) -> Result, Error> { +) -> Result> { let t = Transaction { nonce: nonce, action: filled.to.map_or(Action::Create, Action::Call), @@ -445,7 +445,7 @@ struct ProspectiveSigner { reserved: nonce::Reserved, password: SignWith, state: ProspectiveSignerState, - prospective: Option, Error>>, + prospective: Option>>, ready: Option, } @@ -479,7 +479,7 @@ impl ProspectiveSigner { } } - fn sign(&self, nonce: &U256) -> Result, Error> { + fn sign(&self, nonce: &U256) -> Result> { sign_transaction( &*self.accounts, self.filled.clone(), @@ -637,7 +637,7 @@ pub fn execute( accounts: Arc, payload: ConfirmationPayload, pass: SignWith -) -> BoxFuture, Error> { +) -> BoxFuture> { match payload { ConfirmationPayload::SendTransaction(request) => { let condition = request.condition.clone().map(Into::into); @@ -688,7 +688,7 @@ pub fn execute( } } -fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: SignWith) -> Result, Error> { +fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: SignWith) -> Result> { match password.clone() { SignWith::Nothing => accounts.sign(address, None, hash).map(WithToken::No), SignWith::Password(pass) => accounts.sign(address, Some(pass), hash).map(WithToken::No), @@ -701,7 +701,7 @@ fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: // obtain a hardware signature from the given account. fn hardware_signature(accounts: &AccountProvider, address: Address, t: Transaction, chain_id: Option) - -> Result + -> Result { debug_assert!(accounts.is_hardware_address(&address)); @@ -720,7 +720,7 @@ fn hardware_signature(accounts: &AccountProvider, address: Address, t: Transacti }) } -fn decrypt(accounts: &AccountProvider, address: Address, msg: Bytes, password: SignWith) -> Result, Error> { +fn decrypt(accounts: &AccountProvider, address: Address, msg: Bytes, password: SignWith) -> Result> { match password.clone() { SignWith::Nothing => accounts.decrypt(address, None, &DEFAULT_MAC, &msg).map(WithToken::No), SignWith::Password(pass) => accounts.decrypt(address, Some(pass), &DEFAULT_MAC, &msg).map(WithToken::No), @@ -741,7 +741,7 @@ pub fn default_gas_price(client: &C, miner: &M) -> U256 where /// Convert RPC confirmation payload to signer confirmation payload. /// May need to resolve in the future to fetch things like gas price. -pub fn from_rpc(payload: RpcConfirmationPayload, default_account: Address, dispatcher: &D) -> BoxFuture +pub fn from_rpc(payload: RpcConfirmationPayload, default_account: Address, dispatcher: &D) -> BoxFuture where D: Dispatcher { match payload { diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 2544f66b0..64f075b01 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -26,7 +26,7 @@ use ethcore::filter::Filter as EthcoreFilter; use ethcore::transaction::{Action, Transaction as EthTransaction, SignedTransaction, LocalizedTransaction}; use ethcore::receipt::Receipt; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; use jsonrpc_macros::Trailing; @@ -87,7 +87,7 @@ pub fn extract_transaction_at_index(block: encoded::Block, index: usize, eip86_t /// Type alias for convenience. -pub type ExecutionResult = Result; +pub type ExecutionResult = ::std::result::Result; // extract the header indicated by the given `HeaderRef` from the given responses. // fails only if they do not correspond. @@ -104,7 +104,7 @@ fn extract_header(res: &[OnDemandResponse], header: HeaderRef) -> Option) -> Result { + fn make_header_requests(&self, id: BlockId, reqs: &mut Vec) -> Result { if let Some(h) = self.client.block_header(id) { return Ok(h.into()); } @@ -138,7 +138,7 @@ impl LightFetch { } /// Get a block header from the on demand service or client, or error. - pub fn header(&self, id: BlockId) -> BoxFuture { + pub fn header(&self, id: BlockId) -> BoxFuture { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -162,7 +162,7 @@ impl LightFetch { /// Helper for getting account info at a given block. /// `None` indicates the account doesn't exist at the given block. - pub fn account(&self, address: Address, id: BlockId) -> BoxFuture, Error> { + pub fn account(&self, address: Address, id: BlockId) -> BoxFuture> { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -188,7 +188,7 @@ impl LightFetch { } /// Helper for getting proved execution. - pub fn proved_execution(&self, req: CallRequest, num: Trailing) -> BoxFuture { + pub fn proved_execution(&self, req: CallRequest, num: Trailing) -> BoxFuture { const DEFAULT_GAS_PRICE: u64 = 21_000; // starting gas when gas not provided. const START_GAS: u64 = 50_000; @@ -265,7 +265,7 @@ impl LightFetch { } /// Get a block itself. Fails on unknown block ID. - pub fn block(&self, id: BlockId) -> BoxFuture { + pub fn block(&self, id: BlockId) -> BoxFuture { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -291,7 +291,7 @@ impl LightFetch { } /// Get the block receipts. Fails on unknown block ID. - pub fn receipts(&self, id: BlockId) -> BoxFuture, Error> { + pub fn receipts(&self, id: BlockId) -> BoxFuture> { let mut reqs = Vec::new(); let header_ref = match self.make_header_requests(id, &mut reqs) { Ok(r) => r, @@ -317,7 +317,7 @@ impl LightFetch { } /// Get transaction logs - pub fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error> { + pub fn logs(&self, filter: EthcoreFilter) -> BoxFuture> { use std::collections::BTreeMap; use jsonrpc_core::futures::stream::{self, Stream}; @@ -375,7 +375,7 @@ impl LightFetch { // Get a transaction by hash. also returns the index in the block. // Only returns transactions in the canonical chain. pub fn transaction_by_hash(&self, tx_hash: H256, eip86_transition: u64) - -> BoxFuture, Error> + -> BoxFuture> { let params = (self.sync.clone(), self.on_demand.clone()); let fetcher: Self = self.clone(); @@ -445,7 +445,7 @@ struct ExecuteParams { // has a peer execute the transaction with given params. If `gas_known` is false, // this will double the gas on each `OutOfGas` error. -fn execute_tx(gas_known: bool, params: ExecuteParams) -> BoxFuture { +fn execute_tx(gas_known: bool, params: ExecuteParams) -> BoxFuture { if !gas_known { Box::new(future::loop_fn(params, |mut params| { execute_tx(true, params.clone()).and_then(move |res| { diff --git a/rpc/src/v1/helpers/subscription_manager.rs b/rpc/src/v1/helpers/subscription_manager.rs index a6d6f9d51..5988824b6 100644 --- a/rpc/src/v1/helpers/subscription_manager.rs +++ b/rpc/src/v1/helpers/subscription_manager.rs @@ -23,7 +23,7 @@ use parking_lot::Mutex; use jsonrpc_core::futures::future::{self, Either}; use jsonrpc_core::futures::sync::mpsc; use jsonrpc_core::futures::{Sink, Future}; -use jsonrpc_core::{self as core, MetaIoHandler, BoxFuture}; +use jsonrpc_core::{self as core, MetaIoHandler}; use jsonrpc_pubsub::SubscriptionId; use v1::helpers::Subscribers; @@ -87,7 +87,7 @@ impl> GenericPollManager { }).is_some() } - pub fn tick(&self) -> BoxFuture<(), ()> { + pub fn tick(&self) -> Box + Send> { let mut futures = Vec::new(); // poll all subscriptions for (id, subscription) in self.subscribers.iter() { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 8de7a31db..f9b684a31 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -40,7 +40,7 @@ use ethcore::transaction::SignedTransaction; use ethcore::snapshot::SnapshotService; use ethsync::{SyncProvider}; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::future; use jsonrpc_macros::Trailing; @@ -139,11 +139,11 @@ impl EthClient where /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn block(&self, id: BlockId, include_txs: bool) -> Result, Error> { + fn block(&self, id: BlockId, include_txs: bool) -> Result> { let client = &self.client; match (client.block(id.clone()), client.block_total_difficulty(id)) { (Some(block), Some(total_difficulty)) => { @@ -181,14 +181,14 @@ impl EthClient where } } - fn transaction(&self, id: TransactionId) -> Result, Error> { + fn transaction(&self, id: TransactionId) -> Result> { match self.client.transaction(id) { Some(t) => Ok(Some(Transaction::from_localized(t, self.eip86_transition))), None => Ok(None), } } - fn uncle(&self, id: UncleId) -> Result, Error> { + fn uncle(&self, id: UncleId) -> Result> { let client = &self.client; let uncle: BlockHeader = match client.uncle(id) { Some(hdr) => hdr.decode(), @@ -232,7 +232,7 @@ impl EthClient where Ok(Some(block)) } - fn dapp_accounts(&self, dapp: DappId) -> Result, Error> { + fn dapp_accounts(&self, dapp: DappId) -> Result> { let store = self.account_provider()?; store .note_dapp_used(dapp.clone()) @@ -260,7 +260,7 @@ pub fn pending_logs(miner: &M, best_block: EthBlockNumber, filter: &EthcoreFi result } -fn check_known(client: &C, number: BlockNumber) -> Result<(), Error> where C: MiningBlockChainClient { +fn check_known(client: &C, number: BlockNumber) -> Result<()> where C: MiningBlockChainClient { use ethcore::block_status::BlockStatus; match client.block_status(number.into()) { @@ -281,12 +281,12 @@ impl Eth for EthClient where { type Metadata = Metadata; - fn protocol_version(&self) -> Result { + fn protocol_version(&self) -> Result { let version = self.sync.status().protocol_version.to_owned(); Ok(format!("{}", version)) } - fn syncing(&self) -> Result { + fn syncing(&self) -> Result { use ethcore::snapshot::RestorationStatus; let status = self.sync.status(); @@ -318,7 +318,7 @@ impl Eth for EthClient where } } - fn author(&self, meta: Metadata) -> Result { + fn author(&self, meta: Metadata) -> Result { let dapp = meta.dapp_id(); let mut miner = self.miner.author(); @@ -329,30 +329,30 @@ impl Eth for EthClient where Ok(RpcH160::from(miner)) } - fn is_mining(&self) -> Result { + fn is_mining(&self) -> Result { Ok(self.miner.is_currently_sealing()) } - fn hashrate(&self) -> Result { + fn hashrate(&self) -> Result { Ok(RpcU256::from(self.external_miner.hashrate())) } - fn gas_price(&self) -> Result { + fn gas_price(&self) -> Result { Ok(RpcU256::from(default_gas_price(&*self.client, &*self.miner))) } - fn accounts(&self, meta: Metadata) -> Result, Error> { + fn accounts(&self, meta: Metadata) -> Result> { let dapp = meta.dapp_id(); let accounts = self.dapp_accounts(dapp.into())?; Ok(accounts.into_iter().map(Into::into).collect()) } - fn block_number(&self) -> Result { + fn block_number(&self) -> Result { Ok(RpcU256::from(self.client.chain_info().best_block_number)) } - fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address = address.into(); let id = num.unwrap_or_default(); @@ -366,7 +366,7 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { + fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(pos); @@ -381,7 +381,7 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let res = match num.unwrap_or_default() { @@ -406,12 +406,12 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { Box::new(future::ok(self.client.block(BlockId::Hash(hash.into())) .map(|block| block.transactions_count().into()))) } - fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture> { Box::new(future::ok(match num { BlockNumber::Pending => Some( self.miner.status().transactions_in_pending_block.into() @@ -422,12 +422,12 @@ impl Eth for EthClient where })) } - fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { Box::new(future::ok(self.client.block(BlockId::Hash(hash.into())) .map(|block| block.uncles_count().into()))) } - fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture> { Box::new(future::ok(match num { BlockNumber::Pending => Some(0.into()), _ => self.client.block(num.into()) @@ -436,7 +436,7 @@ impl Eth for EthClient where })) } - fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let id = num.unwrap_or_default(); @@ -450,15 +450,15 @@ impl Eth for EthClient where Box::new(future::done(res)) } - fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture, Error> { + fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture> { Box::new(future::done(self.block(BlockId::Hash(hash.into()), include_txs))) } - fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture, Error> { + fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture> { Box::new(future::done(self.block(num.into(), include_txs))) } - fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture> { let hash: H256 = hash.into(); let block_number = self.client.chain_info().best_block_number; let tx = try_bf!(self.transaction(TransactionId::Hash(hash))).or_else(|| { @@ -469,19 +469,19 @@ impl Eth for EthClient where Box::new(future::ok(tx)) } - fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture, Error> { + fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture> { Box::new(future::done( self.transaction(TransactionId::Location(BlockId::Hash(hash.into()), index.value())) )) } - fn transaction_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture, Error> { + fn transaction_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture> { Box::new(future::done( self.transaction(TransactionId::Location(num.into(), index.value())) )) } - fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture> { let best_block = self.client.chain_info().best_block_number; let hash: H256 = hash.into(); @@ -494,25 +494,25 @@ impl Eth for EthClient where } } - fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture, Error> { + fn uncle_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> BoxFuture> { Box::new(future::done(self.uncle(UncleId { block: BlockId::Hash(hash.into()), position: index.value() }))) } - fn uncle_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture, Error> { + fn uncle_by_block_number_and_index(&self, num: BlockNumber, index: Index) -> BoxFuture> { Box::new(future::done(self.uncle(UncleId { block: num.into(), position: index.value() }))) } - fn compilers(&self) -> Result, Error> { + fn compilers(&self) -> Result> { Err(errors::deprecated("Compilation functionality is deprecated.".to_string())) } - fn logs(&self, filter: Filter) -> BoxFuture, Error> { + fn logs(&self, filter: Filter) -> BoxFuture> { let include_pending = filter.to_block == Some(BlockNumber::Pending); let filter: EthcoreFilter = filter.into(); let mut logs = self.client.logs(filter.clone()) @@ -531,7 +531,7 @@ impl Eth for EthClient where Box::new(future::ok(logs)) } - fn work(&self, no_new_work_timeout: Trailing) -> Result { + fn work(&self, no_new_work_timeout: Trailing) -> Result { if !self.miner.can_produce_work_package() { warn!(target: "miner", "Cannot give work package - engine seals internally."); return Err(errors::no_work_required()) @@ -585,7 +585,7 @@ impl Eth for EthClient where }).unwrap_or(Err(errors::internal("No work found.", ""))) } - fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result { + fn submit_work(&self, nonce: RpcH64, pow_hash: RpcH256, mix_hash: RpcH256) -> Result { if !self.miner.can_produce_work_package() { warn!(target: "miner", "Cannot submit work - engine seals internally."); return Err(errors::no_work_required()) @@ -600,12 +600,12 @@ impl Eth for EthClient where Ok(self.miner.submit_seal(&*self.client, pow_hash, seal).is_ok()) } - fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result { + fn submit_hashrate(&self, rate: RpcU256, id: RpcH256) -> Result { self.external_miner.submit_hashrate(rate.into(), id.into()); Ok(true) } - fn send_raw_transaction(&self, raw: Bytes) -> Result { + fn send_raw_transaction(&self, raw: Bytes) -> Result { UntrustedRlp::new(&raw.into_vec()).as_val() .map_err(errors::rlp) .and_then(|tx| SignedTransaction::new(tx).map_err(errors::transaction)) @@ -619,11 +619,11 @@ impl Eth for EthClient where .map(Into::into) } - fn submit_transaction(&self, raw: Bytes) -> Result { + fn submit_transaction(&self, raw: Bytes) -> Result { self.send_raw_transaction(raw) } - fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { + fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { let request = CallRequest::into(request); let signed = try_bf!(fake_sign::sign_call(request, meta.is_dapp())); @@ -636,7 +636,7 @@ impl Eth for EthClient where )) } - fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { + fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing) -> BoxFuture { let request = CallRequest::into(request); let signed = try_bf!(fake_sign::sign_call(request, meta.is_dapp())); Box::new(future::done(self.client.estimate_gas(&signed, num.unwrap_or_default().into()) @@ -645,15 +645,15 @@ impl Eth for EthClient where )) } - fn compile_lll(&self, _: String) -> Result { + fn compile_lll(&self, _: String) -> Result { Err(errors::deprecated("Compilation of LLL via RPC is deprecated".to_string())) } - fn compile_serpent(&self, _: String) -> Result { + fn compile_serpent(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Serpent via RPC is deprecated".to_string())) } - fn compile_solidity(&self, _: String) -> Result { + fn compile_solidity(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Solidity via RPC is deprecated".to_string())) } } diff --git a/rpc/src/v1/impls/eth_filter.rs b/rpc/src/v1/impls/eth_filter.rs index a7a4a3ed2..f90a969da 100644 --- a/rpc/src/v1/impls/eth_filter.rs +++ b/rpc/src/v1/impls/eth_filter.rs @@ -25,7 +25,7 @@ use ethcore::client::{BlockChainClient, BlockId}; use bigint::hash::H256; use parking_lot::Mutex; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; use v1::traits::EthFilter; @@ -45,7 +45,7 @@ pub trait Filterable { fn pending_transactions_hashes(&self, block_number: u64) -> Vec; /// Get logs that match the given filter. - fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error>; + fn logs(&self, filter: EthcoreFilter) -> BoxFuture>; /// Get logs from the pending block. fn pending_logs(&self, block_number: u64, filter: &EthcoreFilter) -> Vec; @@ -88,7 +88,7 @@ impl Filterable for EthFilterClient where C: BlockChainClient, M: Mi self.miner.pending_transactions_hashes(best) } - fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error> { + fn logs(&self, filter: EthcoreFilter) -> BoxFuture> { Box::new(future::ok(self.client.logs(filter).into_iter().map(Into::into).collect())) } @@ -102,20 +102,20 @@ impl Filterable for EthFilterClient where C: BlockChainClient, M: Mi impl EthFilter for T { - fn new_filter(&self, filter: Filter) -> Result { + fn new_filter(&self, filter: Filter) -> Result { let mut polls = self.polls().lock(); let block_number = self.best_block_number(); let id = polls.create_poll(PollFilter::Logs(block_number, Default::default(), filter)); Ok(id.into()) } - fn new_block_filter(&self) -> Result { + fn new_block_filter(&self) -> Result { let mut polls = self.polls().lock(); let id = polls.create_poll(PollFilter::Block(self.best_block_number())); Ok(id.into()) } - fn new_pending_transaction_filter(&self) -> Result { + fn new_pending_transaction_filter(&self) -> Result { let mut polls = self.polls().lock(); let best_block = self.best_block_number(); let pending_transactions = self.pending_transactions_hashes(best_block); @@ -123,7 +123,7 @@ impl EthFilter for T { Ok(id.into()) } - fn filter_changes(&self, index: Index) -> BoxFuture { + fn filter_changes(&self, index: Index) -> BoxFuture { let mut polls = self.polls().lock(); Box::new(match polls.poll_mut(&index.value()) { None => Either::A(future::ok(FilterChanges::Empty)), @@ -209,7 +209,7 @@ impl EthFilter for T { }) } - fn filter_logs(&self, index: Index) -> BoxFuture, Error> { + fn filter_logs(&self, index: Index) -> BoxFuture> { let filter = { let mut polls = self.polls().lock(); @@ -240,7 +240,7 @@ impl EthFilter for T { ) } - fn uninstall_filter(&self, index: Index) -> Result { + fn uninstall_filter(&self, index: Index) -> Result { self.polls().lock().remove_poll(&index.value()); Ok(true) } diff --git a/rpc/src/v1/impls/eth_pubsub.rs b/rpc/src/v1/impls/eth_pubsub.rs index 74b37d7d0..cc6e0d260 100644 --- a/rpc/src/v1/impls/eth_pubsub.rs +++ b/rpc/src/v1/impls/eth_pubsub.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use std::collections::BTreeMap; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{self, Future, IntoFuture}; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::{Sink, Subscriber}; @@ -170,7 +170,7 @@ pub trait LightClient: Send + Sync { fn block_header(&self, id: BlockId) -> Option; /// Fetch logs. - fn logs(&self, filter: EthFilter) -> BoxFuture, Error>; + fn logs(&self, filter: EthFilter) -> BoxFuture>; } impl LightClient for LightFetch { @@ -178,7 +178,7 @@ impl LightClient for LightFetch { self.client.block_header(id) } - fn logs(&self, filter: EthFilter) -> BoxFuture, Error> { + fn logs(&self, filter: EthFilter) -> BoxFuture> { LightFetch::logs(self, filter) } } @@ -272,7 +272,7 @@ impl EthPubSub for EthPubSubClient { let _ = subscriber.reject(error); } - fn unsubscribe(&self, id: SubscriptionId) -> Result { + fn unsubscribe(&self, id: SubscriptionId) -> Result { let res = self.heads_subscribers.write().remove(&id).is_some(); let res2 = self.logs_subscribers.write().remove(&id).is_some(); diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index d498c6ccd..768fd4705 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -18,7 +18,7 @@ use std::sync::Arc; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; use jsonrpc_macros::Trailing; @@ -112,7 +112,7 @@ impl EthClient { } // get a "rich" block structure. Fails on unknown block. - fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture { + fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture { let (on_demand, sync) = (self.on_demand.clone(), self.sync.clone()); let (client, engine) = (self.client.clone(), self.client.engine().clone()); let eip86_transition = self.client.eip86_transition(); @@ -202,11 +202,11 @@ impl EthClient { impl Eth for EthClient { type Metadata = Metadata; - fn protocol_version(&self) -> Result { + fn protocol_version(&self) -> Result { Ok(format!("{}", ::light::net::MAX_PROTOCOL_VERSION)) } - fn syncing(&self) -> Result { + fn syncing(&self) -> Result { if self.sync.is_major_importing() { let chain_info = self.client.chain_info(); let current_block = U256::from(chain_info.best_block_number); @@ -225,26 +225,26 @@ impl Eth for EthClient { } } - fn author(&self, _meta: Self::Metadata) -> Result { + fn author(&self, _meta: Self::Metadata) -> Result { Ok(Default::default()) } - fn is_mining(&self) -> Result { + fn is_mining(&self) -> Result { Ok(false) } - fn hashrate(&self) -> Result { + fn hashrate(&self) -> Result { Ok(Default::default()) } - fn gas_price(&self) -> Result { + fn gas_price(&self) -> Result { Ok(self.cache.lock().gas_price_corpus() .and_then(|c| c.median().cloned()) .map(RpcU256::from) .unwrap_or_else(Default::default)) } - fn accounts(&self, meta: Metadata) -> Result, Error> { + fn accounts(&self, meta: Metadata) -> Result> { let dapp: DappId = meta.dapp_id().into(); self.accounts @@ -254,33 +254,33 @@ impl Eth for EthClient { .map(|accs| accs.into_iter().map(Into::::into).collect()) } - fn block_number(&self) -> Result { + fn block_number(&self) -> Result { Ok(self.client.chain_info().best_block_number.into()) } - fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().into()) .map(|acc| acc.map_or(0.into(), |a| a.balance).into())) } - fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing) -> BoxFuture { + fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } - fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture, Error> { + fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture> { Box::new(self.rich_block(BlockId::Hash(hash.into()), include_txs).map(Some)) } - fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture, Error> { + fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture> { Box::new(self.rich_block(num.into(), include_txs).map(Some)) } - fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().into()) .map(|acc| acc.map_or(0.into(), |a| a.nonce).into())) } - fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| { @@ -296,7 +296,7 @@ impl Eth for EthClient { })) } - fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(num.into()).and_then(move |hdr| { @@ -312,7 +312,7 @@ impl Eth for EthClient { })) } - fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| { @@ -328,7 +328,7 @@ impl Eth for EthClient { })) } - fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture, Error> { + fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture> { let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone()); Box::new(self.fetcher().header(num.into()).and_then(move |hdr| { @@ -344,11 +344,11 @@ impl Eth for EthClient { })) } - fn code_at(&self, _address: RpcH160, _num: Trailing) -> BoxFuture { + fn code_at(&self, _address: RpcH160, _num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } - fn send_raw_transaction(&self, raw: Bytes) -> Result { + fn send_raw_transaction(&self, raw: Bytes) -> Result { let best_header = self.client.best_block_header().decode(); UntrustedRlp::new(&raw.into_vec()).as_val() @@ -368,11 +368,11 @@ impl Eth for EthClient { .map(Into::into) } - fn submit_transaction(&self, raw: Bytes) -> Result { + fn submit_transaction(&self, raw: Bytes) -> Result { self.send_raw_transaction(raw) } - fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { + fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { Box::new(self.fetcher().proved_execution(req, num).and_then(|res| { match res { Ok(exec) => Ok(exec.output.into()), @@ -381,7 +381,7 @@ impl Eth for EthClient { })) } - fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { + fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing) -> BoxFuture { // TODO: binary chop for more accurate estimates. Box::new(self.fetcher().proved_execution(req, num).and_then(|res| { match res { @@ -391,7 +391,7 @@ impl Eth for EthClient { })) } - fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_by_hash(&self, hash: RpcH256) -> BoxFuture> { let hash = hash.into(); let eip86 = self.client.eip86_transition(); @@ -409,21 +409,21 @@ impl Eth for EthClient { Box::new(self.fetcher().transaction_by_hash(hash, eip86).map(|x| x.map(|(tx, _)| tx))) } - fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture, Error> { + fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture> { let eip86 = self.client.eip86_transition(); Box::new(self.fetcher().block(BlockId::Hash(hash.into())).map(move |block| { light_fetch::extract_transaction_at_index(block, idx.value(), eip86) })) } - fn transaction_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture, Error> { + fn transaction_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture> { let eip86 = self.client.eip86_transition(); Box::new(self.fetcher().block(num.into()).map(move |block| { light_fetch::extract_transaction_at_index(block, idx.value(), eip86) })) } - fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture, Error> { + fn transaction_receipt(&self, hash: RpcH256) -> BoxFuture> { let eip86 = self.client.eip86_transition(); let fetcher = self.fetcher(); Box::new(fetcher.transaction_by_hash(hash.clone().into(), eip86).and_then(move |tx| { @@ -454,52 +454,52 @@ impl Eth for EthClient { })) } - fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture, Error> { + fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> BoxFuture> { let client = self.client.clone(); Box::new(self.fetcher().block(BlockId::Hash(hash.into())).map(move |block| { extract_uncle_at_index(block, idx, client) })) } - fn uncle_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture, Error> { + fn uncle_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> BoxFuture> { let client = self.client.clone(); Box::new(self.fetcher().block(num.into()).map(move |block| { extract_uncle_at_index(block, idx, client) })) } - fn compilers(&self) -> Result, Error> { + fn compilers(&self) -> Result> { Err(errors::deprecated("Compilation functionality is deprecated.".to_string())) } - fn compile_lll(&self, _: String) -> Result { + fn compile_lll(&self, _: String) -> Result { Err(errors::deprecated("Compilation of LLL via RPC is deprecated".to_string())) } - fn compile_serpent(&self, _: String) -> Result { + fn compile_serpent(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Serpent via RPC is deprecated".to_string())) } - fn compile_solidity(&self, _: String) -> Result { + fn compile_solidity(&self, _: String) -> Result { Err(errors::deprecated("Compilation of Solidity via RPC is deprecated".to_string())) } - fn logs(&self, filter: Filter) -> BoxFuture, Error> { + fn logs(&self, filter: Filter) -> BoxFuture> { let limit = filter.limit; Box::new(Filterable::logs(self, filter.into()) .map(move|logs| limit_logs(logs, limit))) } - fn work(&self, _timeout: Trailing) -> Result { + fn work(&self, _timeout: Trailing) -> Result { Err(errors::light_unimplemented(None)) } - fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result { + fn submit_work(&self, _nonce: RpcH64, _pow_hash: RpcH256, _mix_hash: RpcH256) -> Result { Err(errors::light_unimplemented(None)) } - fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result { + fn submit_hashrate(&self, _rate: RpcU256, _id: RpcH256) -> Result { Err(errors::light_unimplemented(None)) } } @@ -516,7 +516,7 @@ impl Filterable for EthClient { Vec::new() } - fn logs(&self, filter: EthcoreFilter) -> BoxFuture, Error> { + fn logs(&self, filter: EthcoreFilter) -> BoxFuture> { self.fetcher().logs(filter) } diff --git a/rpc/src/v1/impls/light/net.rs b/rpc/src/v1/impls/light/net.rs index 4f0ede48f..3491b35ba 100644 --- a/rpc/src/v1/impls/light/net.rs +++ b/rpc/src/v1/impls/light/net.rs @@ -16,7 +16,7 @@ //! Net rpc implementation. use std::sync::Arc; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use ethsync::LightSyncProvider; use v1::traits::Net; @@ -35,15 +35,15 @@ impl NetClient where S: LightSyncProvider { } impl Net for NetClient where S: LightSyncProvider { - fn version(&self) -> Result { + fn version(&self) -> Result { Ok(format!("{}", self.sync.network_id()).to_owned()) } - fn peer_count(&self) -> Result { + fn peer_count(&self) -> Result { Ok(format!("0x{:x}", self.sync.peer_numbers().connected as u64).to_owned()) } - fn is_listening(&self) -> Result { + fn is_listening(&self) -> Result { Ok(true) } } diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index a896a5f4d..6987f8082 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -30,7 +30,7 @@ use node_health::{NodeHealth, Health}; use light::client::LightChainClient; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::Future; use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, ipfs, SigningQueue, SignerService, NetworkSettings}; @@ -103,7 +103,7 @@ impl ParityClient { impl Parity for ParityClient { type Metadata = Metadata; - fn accounts_info(&self, dapp: Trailing) -> Result, Error> { + fn accounts_info(&self, dapp: Trailing) -> Result> { let dapp = dapp.unwrap_or_default(); let store = &self.accounts; @@ -125,7 +125,7 @@ impl Parity for ParityClient { ) } - fn hardware_accounts_info(&self) -> Result, Error> { + fn hardware_accounts_info(&self) -> Result> { let store = &self.accounts; let info = store.hardware_accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?; Ok(info @@ -135,12 +135,12 @@ impl Parity for ParityClient { ) } - fn locked_hardware_accounts_info(&self) -> Result, Error> { + fn locked_hardware_accounts_info(&self) -> Result> { let store = &self.accounts; Ok(store.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))?) } - fn default_account(&self, meta: Self::Metadata) -> Result { + fn default_account(&self, meta: Self::Metadata) -> Result { let dapp_id = meta.dapp_id(); Ok(self.accounts .dapp_addresses(dapp_id.into()) @@ -150,40 +150,40 @@ impl Parity for ParityClient { .unwrap_or_default()) } - fn transactions_limit(&self) -> Result { + fn transactions_limit(&self) -> Result { Ok(usize::max_value()) } - fn min_gas_price(&self) -> Result { + fn min_gas_price(&self) -> Result { Ok(U256::default()) } - fn extra_data(&self) -> Result { + fn extra_data(&self) -> Result { Ok(Bytes::default()) } - fn gas_floor_target(&self) -> Result { + fn gas_floor_target(&self) -> Result { Ok(U256::default()) } - fn gas_ceil_target(&self) -> Result { + fn gas_ceil_target(&self) -> Result { Ok(U256::default()) } - fn dev_logs(&self) -> Result, Error> { + fn dev_logs(&self) -> Result> { let logs = self.logger.logs(); Ok(logs.as_slice().to_owned()) } - fn dev_logs_levels(&self) -> Result { + fn dev_logs_levels(&self) -> Result { Ok(self.logger.levels().to_owned()) } - fn net_chain(&self) -> Result { + fn net_chain(&self) -> Result { Ok(self.settings.chain.clone()) } - fn net_peers(&self) -> Result { + fn net_peers(&self) -> Result { let peers = self.light_dispatch.sync.peers().into_iter().map(Into::into).collect(); let peer_numbers = self.light_dispatch.sync.peer_numbers(); @@ -195,19 +195,19 @@ impl Parity for ParityClient { }) } - fn net_port(&self) -> Result { + fn net_port(&self) -> Result { Ok(self.settings.network_port) } - fn node_name(&self) -> Result { + fn node_name(&self) -> Result { Ok(self.settings.name.clone()) } - fn registry_address(&self) -> Result, Error> { + fn registry_address(&self) -> Result> { Err(errors::light_unimplemented(None)) } - fn rpc_settings(&self) -> Result { + fn rpc_settings(&self) -> Result { Ok(RpcSettings { enabled: self.settings.rpc_enabled, interface: self.settings.rpc_interface.clone(), @@ -215,46 +215,46 @@ impl Parity for ParityClient { }) } - fn default_extra_data(&self) -> Result { + fn default_extra_data(&self) -> Result { Ok(Bytes::new(version_data())) } - fn gas_price_histogram(&self) -> BoxFuture { + fn gas_price_histogram(&self) -> BoxFuture { Box::new(self.light_dispatch.gas_price_corpus() .and_then(|corpus| corpus.histogram(10).ok_or_else(errors::not_enough_data)) .map(Into::into)) } - fn unsigned_transactions_count(&self) -> Result { + fn unsigned_transactions_count(&self) -> Result { match self.signer { None => Err(errors::signer_disabled()), Some(ref signer) => Ok(signer.len()), } } - fn generate_secret_phrase(&self) -> Result { + fn generate_secret_phrase(&self) -> Result { Ok(random_phrase(12)) } - fn phrase_to_address(&self, phrase: String) -> Result { + fn phrase_to_address(&self, phrase: String) -> Result { Ok(Brain::new(phrase).generate().unwrap().address().into()) } - fn list_accounts(&self, _: u64, _: Option, _: Trailing) -> Result>, Error> { + fn list_accounts(&self, _: u64, _: Option, _: Trailing) -> Result>> { Err(errors::light_unimplemented(None)) } - fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Trailing) -> Result>, Error> { + fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Trailing) -> Result>> { Err(errors::light_unimplemented(None)) } - fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { + fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { ecies::encrypt(&key.into(), &DEFAULT_MAC, &phrase.0) .map_err(errors::encryption) .map(Into::into) } - fn pending_transactions(&self) -> Result, Error> { + fn pending_transactions(&self) -> Result> { let txq = self.light_dispatch.transaction_queue.read(); let chain_info = self.light_dispatch.client.chain_info(); Ok( @@ -265,7 +265,7 @@ impl Parity for ParityClient { ) } - fn future_transactions(&self) -> Result, Error> { + fn future_transactions(&self) -> Result> { let txq = self.light_dispatch.transaction_queue.read(); let chain_info = self.light_dispatch.client.chain_info(); Ok( @@ -276,7 +276,7 @@ impl Parity for ParityClient { ) } - fn pending_transactions_stats(&self) -> Result, Error> { + fn pending_transactions_stats(&self) -> Result> { let stats = self.light_dispatch.sync.transactions_stats(); Ok(stats.into_iter() .map(|(hash, stats)| (hash.into(), stats.into())) @@ -284,7 +284,7 @@ impl Parity for ParityClient { ) } - fn local_transactions(&self) -> Result, Error> { + fn local_transactions(&self) -> Result> { let mut map = BTreeMap::new(); let chain_info = self.light_dispatch.client.chain_info(); let (best_num, best_tm) = (chain_info.best_block_number, chain_info.best_block_timestamp); @@ -303,49 +303,49 @@ impl Parity for ParityClient { Ok(map) } - fn dapps_url(&self) -> Result { + fn dapps_url(&self) -> Result { helpers::to_url(&self.dapps_address) .ok_or_else(|| errors::dapps_disabled()) } - fn ws_url(&self) -> Result { + fn ws_url(&self) -> Result { helpers::to_url(&self.ws_address) .ok_or_else(|| errors::ws_disabled()) } - fn next_nonce(&self, address: H160) -> BoxFuture { + fn next_nonce(&self, address: H160) -> BoxFuture { Box::new(self.light_dispatch.next_nonce(address.into()).map(Into::into)) } - fn mode(&self) -> Result { + fn mode(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn chain_id(&self) -> Result, Error> { + fn chain_id(&self) -> Result> { Ok(self.client.signing_chain_id().map(U64::from)) } - fn chain(&self) -> Result { + fn chain(&self) -> Result { Ok(self.settings.chain.clone()) } - fn enode(&self) -> Result { + fn enode(&self) -> Result { self.light_dispatch.sync.enode().ok_or_else(errors::network_disabled) } - fn consensus_capability(&self) -> Result { + fn consensus_capability(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn version_info(&self) -> Result { + fn version_info(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn releases_info(&self) -> Result, Error> { + fn releases_info(&self) -> Result> { Err(errors::light_unimplemented(None)) } - fn chain_status(&self) -> Result { + fn chain_status(&self) -> Result { let chain_info = self.light_dispatch.client.chain_info(); let gap = chain_info.ancient_block_number.map(|x| U256::from(x + 1)) @@ -356,7 +356,7 @@ impl Parity for ParityClient { }) } - fn node_kind(&self) -> Result<::v1::types::NodeKind, Error> { + fn node_kind(&self) -> Result<::v1::types::NodeKind> { use ::v1::types::{NodeKind, Availability, Capability}; Ok(NodeKind { @@ -365,7 +365,7 @@ impl Parity for ParityClient { }) } - fn block_header(&self, number: Trailing) -> BoxFuture { + fn block_header(&self, number: Trailing) -> BoxFuture { use ethcore::encoded; let engine = self.light_dispatch.client.engine().clone(); @@ -399,15 +399,15 @@ impl Parity for ParityClient { Box::new(self.fetcher().header(number.unwrap_or_default().into()).map(from_encoded)) } - fn ipfs_cid(&self, content: Bytes) -> Result { + fn ipfs_cid(&self, content: Bytes) -> Result { ipfs::cid(content) } - fn call(&self, _meta: Self::Metadata, _requests: Vec, _block: Trailing) -> Result, Error> { + fn call(&self, _meta: Self::Metadata, _requests: Vec, _block: Trailing) -> Result> { Err(errors::light_unimplemented(None)) } - fn node_health(&self) -> BoxFuture { + fn node_health(&self) -> BoxFuture { Box::new(self.health.health() .map_err(|err| errors::internal("Health API failure.", err))) } diff --git a/rpc/src/v1/impls/light/parity_set.rs b/rpc/src/v1/impls/light/parity_set.rs index 2887f2836..6b8f0dc4d 100644 --- a/rpc/src/v1/impls/light/parity_set.rs +++ b/rpc/src/v1/impls/light/parity_set.rs @@ -24,7 +24,7 @@ use ethsync::ManageNetwork; use fetch::Fetch; use hash::keccak_buffer; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::Future; use v1::helpers::dapps::DappsService; use v1::helpers::errors; @@ -50,81 +50,81 @@ impl ParitySetClient { } impl ParitySet for ParitySetClient { - fn set_min_gas_price(&self, _gas_price: U256) -> Result { + fn set_min_gas_price(&self, _gas_price: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn set_gas_floor_target(&self, _target: U256) -> Result { + fn set_gas_floor_target(&self, _target: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn set_gas_ceil_target(&self, _target: U256) -> Result { + fn set_gas_ceil_target(&self, _target: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn set_extra_data(&self, _extra_data: Bytes) -> Result { + fn set_extra_data(&self, _extra_data: Bytes) -> Result { Err(errors::light_unimplemented(None)) } - fn set_author(&self, _author: H160) -> Result { + fn set_author(&self, _author: H160) -> Result { Err(errors::light_unimplemented(None)) } - fn set_engine_signer(&self, _address: H160, _password: String) -> Result { + fn set_engine_signer(&self, _address: H160, _password: String) -> Result { Err(errors::light_unimplemented(None)) } - fn set_transactions_limit(&self, _limit: usize) -> Result { + fn set_transactions_limit(&self, _limit: usize) -> Result { Err(errors::light_unimplemented(None)) } - fn set_tx_gas_limit(&self, _limit: U256) -> Result { + fn set_tx_gas_limit(&self, _limit: U256) -> Result { Err(errors::light_unimplemented(None)) } - fn add_reserved_peer(&self, peer: String) -> Result { + fn add_reserved_peer(&self, peer: String) -> Result { match self.net.add_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn remove_reserved_peer(&self, peer: String) -> Result { + fn remove_reserved_peer(&self, peer: String) -> Result { match self.net.remove_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn drop_non_reserved_peers(&self) -> Result { + fn drop_non_reserved_peers(&self) -> Result { self.net.deny_unreserved_peers(); Ok(true) } - fn accept_non_reserved_peers(&self) -> Result { + fn accept_non_reserved_peers(&self) -> Result { self.net.accept_unreserved_peers(); Ok(true) } - fn start_network(&self) -> Result { + fn start_network(&self) -> Result { self.net.start_network(); Ok(true) } - fn stop_network(&self) -> Result { + fn stop_network(&self) -> Result { self.net.stop_network(); Ok(true) } - fn set_mode(&self, _mode: String) -> Result { + fn set_mode(&self, _mode: String) -> Result { Err(errors::light_unimplemented(None)) } - fn set_spec_name(&self, _spec_name: String) -> Result { + fn set_spec_name(&self, _spec_name: String) -> Result { Err(errors::light_unimplemented(None)) } - fn hash_content(&self, url: String) -> BoxFuture { + fn hash_content(&self, url: String) -> BoxFuture { self.fetch.process(self.fetch.fetch(&url).then(move |result| { result .map_err(errors::fetch) @@ -135,23 +135,23 @@ impl ParitySet for ParitySetClient { })) } - fn dapps_refresh(&self) -> Result { + fn dapps_refresh(&self) -> Result { self.dapps.as_ref().map(|dapps| dapps.refresh_local_dapps()).ok_or_else(errors::dapps_disabled) } - fn dapps_list(&self) -> Result, Error> { + fn dapps_list(&self) -> Result> { self.dapps.as_ref().map(|dapps| dapps.list_dapps()).ok_or_else(errors::dapps_disabled) } - fn upgrade_ready(&self) -> Result, Error> { + fn upgrade_ready(&self) -> Result> { Err(errors::light_unimplemented(None)) } - fn execute_upgrade(&self) -> Result { + fn execute_upgrade(&self) -> Result { Err(errors::light_unimplemented(None)) } - fn remove_transaction(&self, _hash: H256) -> Result, Error> { + fn remove_transaction(&self, _hash: H256) -> Result> { Err(errors::light_unimplemented(None)) } } diff --git a/rpc/src/v1/impls/light/trace.rs b/rpc/src/v1/impls/light/trace.rs index 742944e36..ae2763545 100644 --- a/rpc/src/v1/impls/light/trace.rs +++ b/rpc/src/v1/impls/light/trace.rs @@ -16,7 +16,7 @@ //! Traces api implementation. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use v1::Metadata; use v1::traits::Traces; @@ -30,35 +30,35 @@ pub struct TracesClient; impl Traces for TracesClient { type Metadata = Metadata; - fn filter(&self, _filter: TraceFilter) -> Result>, Error> { + fn filter(&self, _filter: TraceFilter) -> Result>> { Err(errors::light_unimplemented(None)) } - fn block_traces(&self, _block_number: BlockNumber) -> Result>, Error> { + fn block_traces(&self, _block_number: BlockNumber) -> Result>> { Err(errors::light_unimplemented(None)) } - fn transaction_traces(&self, _transaction_hash: H256) -> Result>, Error> { + fn transaction_traces(&self, _transaction_hash: H256) -> Result>> { Err(errors::light_unimplemented(None)) } - fn trace(&self, _transaction_hash: H256, _address: Vec) -> Result, Error> { + fn trace(&self, _transaction_hash: H256, _address: Vec) -> Result> { Err(errors::light_unimplemented(None)) } - fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing) -> Result { + fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing) -> Result { Err(errors::light_unimplemented(None)) } - fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing) -> Result, Error> { + fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing) -> Result> { Err(errors::light_unimplemented(None)) } - fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing) -> Result { + fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing) -> Result { Err(errors::light_unimplemented(None)) } - fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result { + fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result { Err(errors::light_unimplemented(None)) } } diff --git a/rpc/src/v1/impls/net.rs b/rpc/src/v1/impls/net.rs index 97f50b633..50dbffdc7 100644 --- a/rpc/src/v1/impls/net.rs +++ b/rpc/src/v1/impls/net.rs @@ -16,7 +16,7 @@ //! Net rpc implementation. use std::sync::Arc; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use ethsync::SyncProvider; use v1::traits::Net; @@ -35,15 +35,15 @@ impl NetClient where S: SyncProvider { } impl Net for NetClient where S: SyncProvider + 'static { - fn version(&self) -> Result { + fn version(&self) -> Result { Ok(format!("{}", self.sync.status().network_id).to_owned()) } - fn peer_count(&self) -> Result { + fn peer_count(&self) -> Result { Ok(format!("0x{:x}", self.sync.status().num_peers as u64).to_owned()) } - fn is_listening(&self) -> Result { + fn is_listening(&self) -> Result { // right now (11 march 2016), we are always listening for incoming connections // // (this may not be true now -- 26 september 2016) diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index c586ea985..b10659322 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -35,7 +35,7 @@ use ethcore_logger::RotatingLogger; use node_health::{NodeHealth, Health}; use updater::{Service as UpdateService}; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, fake_sign, ipfs, SigningQueue, SignerService, NetworkSettings}; @@ -107,7 +107,7 @@ impl ParityClient where /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } } @@ -119,7 +119,7 @@ impl Parity for ParityClient where { type Metadata = Metadata; - fn accounts_info(&self, dapp: Trailing) -> Result, Error> { + fn accounts_info(&self, dapp: Trailing) -> Result> { let dapp = dapp.unwrap_or_default(); let store = self.account_provider()?; @@ -141,7 +141,7 @@ impl Parity for ParityClient where ) } - fn hardware_accounts_info(&self) -> Result, Error> { + fn hardware_accounts_info(&self) -> Result> { let store = self.account_provider()?; let info = store.hardware_accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?; Ok(info @@ -151,12 +151,12 @@ impl Parity for ParityClient where ) } - fn locked_hardware_accounts_info(&self) -> Result, Error> { + fn locked_hardware_accounts_info(&self) -> Result> { let store = self.account_provider()?; Ok(store.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))?) } - fn default_account(&self, meta: Self::Metadata) -> Result { + fn default_account(&self, meta: Self::Metadata) -> Result { let dapp_id = meta.dapp_id(); Ok(self.account_provider()? @@ -166,48 +166,48 @@ impl Parity for ParityClient where .unwrap_or_default()) } - fn transactions_limit(&self) -> Result { + fn transactions_limit(&self) -> Result { Ok(self.miner.transactions_limit()) } - fn min_gas_price(&self) -> Result { + fn min_gas_price(&self) -> Result { Ok(U256::from(self.miner.minimal_gas_price())) } - fn extra_data(&self) -> Result { + fn extra_data(&self) -> Result { Ok(Bytes::new(self.miner.extra_data())) } - fn gas_floor_target(&self) -> Result { + fn gas_floor_target(&self) -> Result { Ok(U256::from(self.miner.gas_floor_target())) } - fn gas_ceil_target(&self) -> Result { + fn gas_ceil_target(&self) -> Result { Ok(U256::from(self.miner.gas_ceil_target())) } - fn dev_logs(&self) -> Result, Error> { + fn dev_logs(&self) -> Result> { let logs = self.logger.logs(); Ok(logs.as_slice().to_owned()) } - fn dev_logs_levels(&self) -> Result { + fn dev_logs_levels(&self) -> Result { Ok(self.logger.levels().to_owned()) } - fn net_chain(&self) -> Result { + fn net_chain(&self) -> Result { Ok(self.settings.chain.clone()) } - fn chain_id(&self) -> Result, Error> { + fn chain_id(&self) -> Result> { Ok(self.client.signing_chain_id().map(U64::from)) } - fn chain(&self) -> Result { + fn chain(&self) -> Result { Ok(self.client.spec_name()) } - fn net_peers(&self) -> Result { + fn net_peers(&self) -> Result { let sync_status = self.sync.status(); let net_config = self.net.network_config(); let peers = self.sync.peers().into_iter().map(Into::into).collect(); @@ -220,15 +220,15 @@ impl Parity for ParityClient where }) } - fn net_port(&self) -> Result { + fn net_port(&self) -> Result { Ok(self.settings.network_port) } - fn node_name(&self) -> Result { + fn node_name(&self) -> Result { Ok(self.settings.name.clone()) } - fn registry_address(&self) -> Result, Error> { + fn registry_address(&self) -> Result> { Ok( self.client .additional_params() @@ -238,7 +238,7 @@ impl Parity for ParityClient where ) } - fn rpc_settings(&self) -> Result { + fn rpc_settings(&self) -> Result { Ok(RpcSettings { enabled: self.settings.rpc_enabled, interface: self.settings.rpc_interface.clone(), @@ -246,11 +246,11 @@ impl Parity for ParityClient where }) } - fn default_extra_data(&self) -> Result { + fn default_extra_data(&self) -> Result { Ok(Bytes::new(version_data())) } - fn gas_price_histogram(&self) -> BoxFuture { + fn gas_price_histogram(&self) -> BoxFuture { Box::new(future::done(self.client .gas_price_corpus(100) .histogram(10) @@ -259,50 +259,50 @@ impl Parity for ParityClient where )) } - fn unsigned_transactions_count(&self) -> Result { + fn unsigned_transactions_count(&self) -> Result { match self.signer { None => Err(errors::signer_disabled()), Some(ref signer) => Ok(signer.len()), } } - fn generate_secret_phrase(&self) -> Result { + fn generate_secret_phrase(&self) -> Result { Ok(random_phrase(12)) } - fn phrase_to_address(&self, phrase: String) -> Result { + fn phrase_to_address(&self, phrase: String) -> Result { Ok(Brain::new(phrase).generate().unwrap().address().into()) } - fn list_accounts(&self, count: u64, after: Option, block_number: Trailing) -> Result>, Error> { + fn list_accounts(&self, count: u64, after: Option, block_number: Trailing) -> Result>> { Ok(self.client .list_accounts(block_number.unwrap_or_default().into(), after.map(Into::into).as_ref(), count) .map(|a| a.into_iter().map(Into::into).collect())) } - fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Trailing) -> Result>, Error> { + fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Trailing) -> Result>> { Ok(self.client .list_storage(block_number.unwrap_or_default().into(), &address.into(), after.map(Into::into).as_ref(), count) .map(|a| a.into_iter().map(Into::into).collect())) } - fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { + fn encrypt_message(&self, key: H512, phrase: Bytes) -> Result { ecies::encrypt(&key.into(), &DEFAULT_MAC, &phrase.0) .map_err(errors::encryption) .map(Into::into) } - fn pending_transactions(&self) -> Result, Error> { + fn pending_transactions(&self) -> Result> { let block_number = self.client.chain_info().best_block_number; Ok(self.miner.pending_transactions().into_iter().map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)).collect::>()) } - fn future_transactions(&self) -> Result, Error> { + fn future_transactions(&self) -> Result> { let block_number = self.client.chain_info().best_block_number; Ok(self.miner.future_transactions().into_iter().map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)).collect::>()) } - fn pending_transactions_stats(&self) -> Result, Error> { + fn pending_transactions_stats(&self) -> Result> { let stats = self.sync.transactions_stats(); Ok(stats.into_iter() .map(|(hash, stats)| (hash.into(), stats.into())) @@ -310,7 +310,7 @@ impl Parity for ParityClient where ) } - fn local_transactions(&self) -> Result, Error> { + fn local_transactions(&self) -> Result> { // Return nothing if accounts are disabled (running as public node) if self.accounts.is_none() { return Ok(BTreeMap::new()); @@ -325,17 +325,17 @@ impl Parity for ParityClient where ) } - fn dapps_url(&self) -> Result { + fn dapps_url(&self) -> Result { helpers::to_url(&self.dapps_address) .ok_or_else(|| errors::dapps_disabled()) } - fn ws_url(&self) -> Result { + fn ws_url(&self) -> Result { helpers::to_url(&self.ws_address) .ok_or_else(|| errors::ws_disabled()) } - fn next_nonce(&self, address: H160) -> BoxFuture { + fn next_nonce(&self, address: H160) -> BoxFuture { let address: Address = address.into(); Box::new(future::ok(self.miner.last_nonce(&address) @@ -345,7 +345,7 @@ impl Parity for ParityClient where )) } - fn mode(&self) -> Result { + fn mode(&self) -> Result { Ok(match self.client.mode() { Mode::Off => "offline", Mode::Dark(..) => "dark", @@ -354,23 +354,23 @@ impl Parity for ParityClient where }.into()) } - fn enode(&self) -> Result { + fn enode(&self) -> Result { self.sync.enode().ok_or_else(errors::network_disabled) } - fn consensus_capability(&self) -> Result { + fn consensus_capability(&self) -> Result { Ok(self.updater.capability().into()) } - fn version_info(&self) -> Result { + fn version_info(&self) -> Result { Ok(self.updater.version_info().into()) } - fn releases_info(&self) -> Result, Error> { + fn releases_info(&self) -> Result> { Ok(self.updater.info().map(Into::into)) } - fn chain_status(&self) -> Result { + fn chain_status(&self) -> Result { let chain_info = self.client.chain_info(); let gap = chain_info.ancient_block_number.map(|x| U256::from(x + 1)) @@ -381,7 +381,7 @@ impl Parity for ParityClient where }) } - fn node_kind(&self) -> Result<::v1::types::NodeKind, Error> { + fn node_kind(&self) -> Result<::v1::types::NodeKind> { use ::v1::types::{NodeKind, Availability, Capability}; let availability = match self.accounts { @@ -395,7 +395,7 @@ impl Parity for ParityClient where }) } - fn block_header(&self, number: Trailing) -> BoxFuture { + fn block_header(&self, number: Trailing) -> BoxFuture { const EXTRA_INFO_PROOF: &'static str = "Object exists in in blockchain (fetched earlier), extra_info is always available if object exists; qed"; let id: BlockId = number.unwrap_or_default().into(); @@ -410,18 +410,18 @@ impl Parity for ParityClient where })) } - fn ipfs_cid(&self, content: Bytes) -> Result { + fn ipfs_cid(&self, content: Bytes) -> Result { ipfs::cid(content) } - fn call(&self, meta: Self::Metadata, requests: Vec, block: Trailing) -> Result, Error> { + fn call(&self, meta: Self::Metadata, requests: Vec, block: Trailing) -> Result> { let requests = requests .into_iter() .map(|request| Ok(( fake_sign::sign_call(request.into(), meta.is_dapp())?, Default::default() ))) - .collect::, Error>>()?; + .collect::>>()?; let block = block.unwrap_or_default(); @@ -430,7 +430,7 @@ impl Parity for ParityClient where .map_err(errors::call) } - fn node_health(&self) -> BoxFuture { + fn node_health(&self) -> BoxFuture { Box::new(self.health.health() .map_err(|err| errors::internal("Health API failure.", err))) } diff --git a/rpc/src/v1/impls/parity_accounts.rs b/rpc/src/v1/impls/parity_accounts.rs index d41837186..4aa1232f3 100644 --- a/rpc/src/v1/impls/parity_accounts.rs +++ b/rpc/src/v1/impls/parity_accounts.rs @@ -23,7 +23,7 @@ use ethkey::{Brain, Generator, Secret}; use ethstore::KeyFile; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::helpers::errors; use v1::helpers::accounts::unwrap_provider; use v1::traits::ParityAccounts; @@ -44,13 +44,13 @@ impl ParityAccountsClient { /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } } impl ParityAccounts for ParityAccountsClient { - fn all_accounts_info(&self) -> Result, Error> { + fn all_accounts_info(&self) -> Result> { let store = self.account_provider()?; let info = store.accounts_info().map_err(|e| errors::account("Could not fetch account info.", e))?; let other = store.addresses_info(); @@ -82,7 +82,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(accounts) } - fn new_account_from_phrase(&self, phrase: String, pass: String) -> Result { + fn new_account_from_phrase(&self, phrase: String, pass: String) -> Result { let store = self.account_provider()?; let brain = Brain::new(phrase).generate().unwrap(); @@ -91,7 +91,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn new_account_from_wallet(&self, json: String, pass: String) -> Result { + fn new_account_from_wallet(&self, json: String, pass: String) -> Result { let store = self.account_provider()?; store.import_presale(json.as_bytes(), &pass) @@ -100,7 +100,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn new_account_from_secret(&self, secret: RpcH256, pass: String) -> Result { + fn new_account_from_secret(&self, secret: RpcH256, pass: String) -> Result { let store = self.account_provider()?; let secret = Secret::from_unsafe_slice(&secret.0) @@ -110,7 +110,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn test_password(&self, account: RpcH160, password: String) -> Result { + fn test_password(&self, account: RpcH160, password: String) -> Result { let account: Address = account.into(); self.account_provider()? @@ -118,7 +118,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not fetch account info.", e)) } - fn change_password(&self, account: RpcH160, password: String, new_password: String) -> Result { + fn change_password(&self, account: RpcH160, password: String, new_password: String) -> Result { let account: Address = account.into(); self.account_provider()? .change_password(&account, password, new_password) @@ -126,7 +126,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not fetch account info.", e)) } - fn kill_account(&self, account: RpcH160, password: String) -> Result { + fn kill_account(&self, account: RpcH160, password: String) -> Result { let account: Address = account.into(); self.account_provider()? .kill_account(&account, &password) @@ -134,7 +134,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not delete account.", e)) } - fn remove_address(&self, addr: RpcH160) -> Result { + fn remove_address(&self, addr: RpcH160) -> Result { let store = self.account_provider()?; let addr: Address = addr.into(); @@ -142,7 +142,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(true) } - fn set_account_name(&self, addr: RpcH160, name: String) -> Result { + fn set_account_name(&self, addr: RpcH160, name: String) -> Result { let store = self.account_provider()?; let addr: Address = addr.into(); @@ -151,7 +151,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(true) } - fn set_account_meta(&self, addr: RpcH160, meta: String) -> Result { + fn set_account_meta(&self, addr: RpcH160, meta: String) -> Result { let store = self.account_provider()?; let addr: Address = addr.into(); @@ -160,7 +160,7 @@ impl ParityAccounts for ParityAccountsClient { Ok(true) } - fn set_dapp_addresses(&self, dapp: DappId, addresses: Option>) -> Result { + fn set_dapp_addresses(&self, dapp: DappId, addresses: Option>) -> Result { let store = self.account_provider()?; store.set_dapp_addresses(dapp.into(), addresses.map(into_vec)) @@ -168,7 +168,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn dapp_addresses(&self, dapp: DappId) -> Result, Error> { + fn dapp_addresses(&self, dapp: DappId) -> Result> { let store = self.account_provider()?; store.dapp_addresses(dapp.into()) @@ -176,7 +176,7 @@ impl ParityAccounts for ParityAccountsClient { .map(into_vec) } - fn set_dapp_default_address(&self, dapp: DappId, address: RpcH160) -> Result { + fn set_dapp_default_address(&self, dapp: DappId, address: RpcH160) -> Result { let store = self.account_provider()?; store.set_dapp_default_address(dapp.into(), address.into()) @@ -184,7 +184,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn dapp_default_address(&self, dapp: DappId) -> Result { + fn dapp_default_address(&self, dapp: DappId) -> Result { let store = self.account_provider()?; store.dapp_default_address(dapp.into()) @@ -192,7 +192,7 @@ impl ParityAccounts for ParityAccountsClient { .map(Into::into) } - fn set_new_dapps_addresses(&self, addresses: Option>) -> Result { + fn set_new_dapps_addresses(&self, addresses: Option>) -> Result { let store = self.account_provider()?; store @@ -201,7 +201,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn new_dapps_addresses(&self) -> Result>, Error> { + fn new_dapps_addresses(&self) -> Result>> { let store = self.account_provider()?; store.new_dapps_addresses() @@ -209,7 +209,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|accounts| accounts.map(into_vec)) } - fn set_new_dapps_default_address(&self, address: RpcH160) -> Result { + fn set_new_dapps_default_address(&self, address: RpcH160) -> Result { let store = self.account_provider()?; store.set_new_dapps_default_address(address.into()) @@ -217,7 +217,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|_| true) } - fn new_dapps_default_address(&self) -> Result { + fn new_dapps_default_address(&self) -> Result { let store = self.account_provider()?; store.new_dapps_default_address() @@ -225,7 +225,7 @@ impl ParityAccounts for ParityAccountsClient { .map(Into::into) } - fn recent_dapps(&self) -> Result, Error> { + fn recent_dapps(&self) -> Result> { let store = self.account_provider()?; store.recent_dapps() @@ -233,7 +233,7 @@ impl ParityAccounts for ParityAccountsClient { .map(|map| map.into_iter().map(|(k, v)| (k.into(), v)).collect()) } - fn import_geth_accounts(&self, addresses: Vec) -> Result, Error> { + fn import_geth_accounts(&self, addresses: Vec) -> Result> { let store = self.account_provider()?; store @@ -242,73 +242,73 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Couldn't import Geth accounts", e)) } - fn geth_accounts(&self) -> Result, Error> { + fn geth_accounts(&self) -> Result> { let store = self.account_provider()?; Ok(into_vec(store.list_geth_accounts(false))) } - fn create_vault(&self, name: String, password: String) -> Result { + fn create_vault(&self, name: String, password: String) -> Result { self.account_provider()? .create_vault(&name, &password) .map_err(|e| errors::account("Could not create vault.", e)) .map(|_| true) } - fn open_vault(&self, name: String, password: String) -> Result { + fn open_vault(&self, name: String, password: String) -> Result { self.account_provider()? .open_vault(&name, &password) .map_err(|e| errors::account("Could not open vault.", e)) .map(|_| true) } - fn close_vault(&self, name: String) -> Result { + fn close_vault(&self, name: String) -> Result { self.account_provider()? .close_vault(&name) .map_err(|e| errors::account("Could not close vault.", e)) .map(|_| true) } - fn list_vaults(&self) -> Result, Error> { + fn list_vaults(&self) -> Result> { self.account_provider()? .list_vaults() .map_err(|e| errors::account("Could not list vaults.", e)) } - fn list_opened_vaults(&self) -> Result, Error> { + fn list_opened_vaults(&self) -> Result> { self.account_provider()? .list_opened_vaults() .map_err(|e| errors::account("Could not list vaults.", e)) } - fn change_vault_password(&self, name: String, new_password: String) -> Result { + fn change_vault_password(&self, name: String, new_password: String) -> Result { self.account_provider()? .change_vault_password(&name, &new_password) .map_err(|e| errors::account("Could not change vault password.", e)) .map(|_| true) } - fn change_vault(&self, address: RpcH160, new_vault: String) -> Result { + fn change_vault(&self, address: RpcH160, new_vault: String) -> Result { self.account_provider()? .change_vault(address.into(), &new_vault) .map_err(|e| errors::account("Could not change vault.", e)) .map(|_| true) } - fn get_vault_meta(&self, name: String) -> Result { + fn get_vault_meta(&self, name: String) -> Result { self.account_provider()? .get_vault_meta(&name) .map_err(|e| errors::account("Could not get vault metadata.", e)) } - fn set_vault_meta(&self, name: String, meta: String) -> Result { + fn set_vault_meta(&self, name: String, meta: String) -> Result { self.account_provider()? .set_vault_meta(&name, &meta) .map_err(|e| errors::account("Could not update vault metadata.", e)) .map(|_| true) } - fn derive_key_index(&self, addr: RpcH160, password: String, derivation: DeriveHierarchical, save_as_account: bool) -> Result { + fn derive_key_index(&self, addr: RpcH160, password: String, derivation: DeriveHierarchical, save_as_account: bool) -> Result { let addr: Address = addr.into(); self.account_provider()? .derive_account( @@ -321,7 +321,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not derive account.", e)) } - fn derive_key_hash(&self, addr: RpcH160, password: String, derivation: DeriveHash, save_as_account: bool) -> Result { + fn derive_key_hash(&self, addr: RpcH160, password: String, derivation: DeriveHash, save_as_account: bool) -> Result { let addr: Address = addr.into(); self.account_provider()? .derive_account( @@ -334,7 +334,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not derive account.", e)) } - fn export_account(&self, addr: RpcH160, password: String) -> Result { + fn export_account(&self, addr: RpcH160, password: String) -> Result { let addr = addr.into(); self.account_provider()? .export_account( @@ -345,7 +345,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not export account.", e)) } - fn sign_message(&self, addr: RpcH160, password: String, message: RpcH256) -> Result { + fn sign_message(&self, addr: RpcH160, password: String, message: RpcH256) -> Result { self.account_provider()? .sign( addr.into(), @@ -356,7 +356,7 @@ impl ParityAccounts for ParityAccountsClient { .map_err(|e| errors::account("Could not sign message.", e)) } - fn hardware_pin_matrix_ack(&self, path: String, pin: String) -> Result { + fn hardware_pin_matrix_ack(&self, path: String, pin: String) -> Result { let store = self.account_provider()?; Ok(store.hardware_pin_matrix_ack(&path, &pin).map_err(|e| errors::account("Error communicating with hardware wallet.", e))?) } diff --git a/rpc/src/v1/impls/parity_set.rs b/rpc/src/v1/impls/parity_set.rs index 5e01455be..4864e7806 100644 --- a/rpc/src/v1/impls/parity_set.rs +++ b/rpc/src/v1/impls/parity_set.rs @@ -26,7 +26,7 @@ use fetch::{self, Fetch}; use hash::keccak_buffer; use updater::{Service as UpdateService}; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::Future; use v1::helpers::dapps::DappsService; use v1::helpers::errors; @@ -75,81 +75,81 @@ impl ParitySet for ParitySetClient where F: Fetch + 'static, { - fn set_min_gas_price(&self, gas_price: U256) -> Result { + fn set_min_gas_price(&self, gas_price: U256) -> Result { self.miner.set_minimal_gas_price(gas_price.into()); Ok(true) } - fn set_gas_floor_target(&self, target: U256) -> Result { + fn set_gas_floor_target(&self, target: U256) -> Result { self.miner.set_gas_floor_target(target.into()); Ok(true) } - fn set_gas_ceil_target(&self, target: U256) -> Result { + fn set_gas_ceil_target(&self, target: U256) -> Result { self.miner.set_gas_ceil_target(target.into()); Ok(true) } - fn set_extra_data(&self, extra_data: Bytes) -> Result { + fn set_extra_data(&self, extra_data: Bytes) -> Result { self.miner.set_extra_data(extra_data.into_vec()); Ok(true) } - fn set_author(&self, author: H160) -> Result { + fn set_author(&self, author: H160) -> Result { self.miner.set_author(author.into()); Ok(true) } - fn set_engine_signer(&self, address: H160, password: String) -> Result { + fn set_engine_signer(&self, address: H160, password: String) -> Result { self.miner.set_engine_signer(address.into(), password).map_err(Into::into).map_err(errors::password)?; Ok(true) } - fn set_transactions_limit(&self, limit: usize) -> Result { + fn set_transactions_limit(&self, limit: usize) -> Result { self.miner.set_transactions_limit(limit); Ok(true) } - fn set_tx_gas_limit(&self, limit: U256) -> Result { + fn set_tx_gas_limit(&self, limit: U256) -> Result { self.miner.set_tx_gas_limit(limit.into()); Ok(true) } - fn add_reserved_peer(&self, peer: String) -> Result { + fn add_reserved_peer(&self, peer: String) -> Result { match self.net.add_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn remove_reserved_peer(&self, peer: String) -> Result { + fn remove_reserved_peer(&self, peer: String) -> Result { match self.net.remove_reserved_peer(peer) { Ok(()) => Ok(true), Err(e) => Err(errors::invalid_params("Peer address", e)), } } - fn drop_non_reserved_peers(&self) -> Result { + fn drop_non_reserved_peers(&self) -> Result { self.net.deny_unreserved_peers(); Ok(true) } - fn accept_non_reserved_peers(&self) -> Result { + fn accept_non_reserved_peers(&self) -> Result { self.net.accept_unreserved_peers(); Ok(true) } - fn start_network(&self) -> Result { + fn start_network(&self) -> Result { self.net.start_network(); Ok(true) } - fn stop_network(&self) -> Result { + fn stop_network(&self) -> Result { self.net.stop_network(); Ok(true) } - fn set_mode(&self, mode: String) -> Result { + fn set_mode(&self, mode: String) -> Result { self.client.set_mode(match mode.as_str() { "offline" => Mode::Off, "dark" => Mode::Dark(300), @@ -160,12 +160,12 @@ impl ParitySet for ParitySetClient where Ok(true) } - fn set_spec_name(&self, spec_name: String) -> Result { + fn set_spec_name(&self, spec_name: String) -> Result { self.client.set_spec_name(spec_name); Ok(true) } - fn hash_content(&self, url: String) -> BoxFuture { + fn hash_content(&self, url: String) -> BoxFuture { self.fetch.process(self.fetch.fetch(&url).then(move |result| { result .map_err(errors::fetch) @@ -176,23 +176,23 @@ impl ParitySet for ParitySetClient where })) } - fn dapps_refresh(&self) -> Result { + fn dapps_refresh(&self) -> Result { self.dapps.as_ref().map(|dapps| dapps.refresh_local_dapps()).ok_or_else(errors::dapps_disabled) } - fn dapps_list(&self) -> Result, Error> { + fn dapps_list(&self) -> Result> { self.dapps.as_ref().map(|dapps| dapps.list_dapps()).ok_or_else(errors::dapps_disabled) } - fn upgrade_ready(&self) -> Result, Error> { + fn upgrade_ready(&self) -> Result> { Ok(self.updater.upgrade_ready().map(Into::into)) } - fn execute_upgrade(&self) -> Result { + fn execute_upgrade(&self) -> Result { Ok(self.updater.execute_upgrade()) } - fn remove_transaction(&self, hash: H256) -> Result, Error> { + fn remove_transaction(&self, hash: H256) -> Result> { let block_number = self.client.chain_info().best_block_number; let hash = hash.into(); diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index 6ad2285f9..03e4ef573 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -24,7 +24,7 @@ use bigint::prelude::U128; use util::Address; use bytes::ToPretty; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use v1::helpers::errors; use v1::helpers::dispatch::{Dispatcher, SignWith}; @@ -50,7 +50,7 @@ impl PersonalClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } } @@ -58,13 +58,13 @@ impl PersonalClient { impl Personal for PersonalClient { type Metadata = Metadata; - fn accounts(&self) -> Result, Error> { + fn accounts(&self) -> Result> { let store = self.account_provider()?; let accounts = store.accounts().map_err(|e| errors::account("Could not fetch accounts.", e))?; Ok(accounts.into_iter().map(Into::into).collect::>()) } - fn new_account(&self, pass: String) -> Result { + fn new_account(&self, pass: String) -> Result { let store = self.account_provider()?; store.new_account(&pass) @@ -72,7 +72,7 @@ impl Personal for PersonalClient { .map_err(|e| errors::account("Could not create account.", e)) } - fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option) -> Result { + fn unlock_account(&self, account: RpcH160, account_pass: String, duration: Option) -> Result { let account: Address = account.into(); let store = self.account_provider()?; let duration = match duration { @@ -104,7 +104,7 @@ impl Personal for PersonalClient { } } - fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { + fn send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { let dispatcher = self.dispatcher.clone(); let accounts = try_bf!(self.account_provider()); @@ -137,7 +137,7 @@ impl Personal for PersonalClient { })) } - fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { + fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture { warn!("Using deprecated personal_signAndSendTransaction, use personal_sendTransaction instead."); self.send_transaction(meta, request, password) } diff --git a/rpc/src/v1/impls/pubsub.rs b/rpc/src/v1/impls/pubsub.rs index 04234bf2a..59eef1953 100644 --- a/rpc/src/v1/impls/pubsub.rs +++ b/rpc/src/v1/impls/pubsub.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use std::time::Duration; use parking_lot::RwLock; -use jsonrpc_core::{self as core, Error, MetaIoHandler}; +use jsonrpc_core::{self as core, Result, MetaIoHandler}; use jsonrpc_core::futures::{Future, Stream, Sink}; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; @@ -94,7 +94,7 @@ impl> PubSub for PubSubClient { } } - fn parity_unsubscribe(&self, id: SubscriptionId) -> Result { + fn parity_unsubscribe(&self, id: SubscriptionId) -> Result { let res = self.poll_manager.write().unsubscribe(&id); Ok(res) } diff --git a/rpc/src/v1/impls/rpc.rs b/rpc/src/v1/impls/rpc.rs index d0b10cddb..3c76a3164 100644 --- a/rpc/src/v1/impls/rpc.rs +++ b/rpc/src/v1/impls/rpc.rs @@ -16,7 +16,7 @@ //! RPC generic methods implementation. use std::collections::BTreeMap; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::traits::Rpc; /// RPC generic methods implementation. @@ -39,7 +39,7 @@ impl RpcClient { } impl Rpc for RpcClient { - fn rpc_modules(&self) -> Result, Error> { + fn rpc_modules(&self) -> Result> { let modules = self.modules.iter() .fold(BTreeMap::new(), |mut map, (k, v)| { map.insert(k.to_owned(), v.to_owned()); @@ -49,7 +49,7 @@ impl Rpc for RpcClient { Ok(modules) } - fn modules(&self) -> Result, Error> { + fn modules(&self) -> Result> { let modules = self.modules.iter() .filter(|&(k, _v)| { self.valid_apis.contains(k) diff --git a/rpc/src/v1/impls/secretstore.rs b/rpc/src/v1/impls/secretstore.rs index 26a09705d..6ddb4a7a0 100644 --- a/rpc/src/v1/impls/secretstore.rs +++ b/rpc/src/v1/impls/secretstore.rs @@ -22,7 +22,7 @@ use crypto::DEFAULT_MAC; use ethkey::Secret; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::helpers::errors; use v1::helpers::accounts::unwrap_provider; use v1::helpers::secretstore::{encrypt_document, decrypt_document, decrypt_document_with_shadow}; @@ -44,36 +44,36 @@ impl SecretStoreClient { /// Attempt to get the `Arc`, errors if provider was not /// set. - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } /// Decrypt public key using account' private key - fn decrypt_key(&self, address: H160, password: String, key: Bytes) -> Result, Error> { + fn decrypt_key(&self, address: H160, password: String, key: Bytes) -> Result> { let store = self.account_provider()?; store.decrypt(address.into(), Some(password), &DEFAULT_MAC, &key.0) .map_err(|e| errors::account("Could not decrypt key.", e)) } /// Decrypt secret key using account' private key - fn decrypt_secret(&self, address: H160, password: String, key: Bytes) -> Result { + fn decrypt_secret(&self, address: H160, password: String, key: Bytes) -> Result { self.decrypt_key(address, password, key) .and_then(|s| Secret::from_unsafe_slice(&s).map_err(|e| errors::account("invalid secret", e))) } } impl SecretStore for SecretStoreClient { - fn encrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { + fn encrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { encrypt_document(self.decrypt_key(address, password, key)?, data.0) .map(Into::into) } - fn decrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { + fn decrypt(&self, address: H160, password: String, key: Bytes, data: Bytes) -> Result { decrypt_document(self.decrypt_key(address, password, key)?, data.0) .map(Into::into) } - fn shadow_decrypt(&self, address: H160, password: String, decrypted_secret: H512, common_point: H512, decrypt_shadows: Vec, data: Bytes) -> Result { + fn shadow_decrypt(&self, address: H160, password: String, decrypted_secret: H512, common_point: H512, decrypt_shadows: Vec, data: Bytes) -> Result { let mut shadows = Vec::with_capacity(decrypt_shadows.len()); for decrypt_shadow in decrypt_shadows { shadows.push(self.decrypt_secret(address.clone(), password.clone(), decrypt_shadow)?); diff --git a/rpc/src/v1/impls/signer.rs b/rpc/src/v1/impls/signer.rs index cecd1f2db..04f510702 100644 --- a/rpc/src/v1/impls/signer.rs +++ b/rpc/src/v1/impls/signer.rs @@ -25,7 +25,7 @@ use parity_reactor::Remote; use rlp::UntrustedRlp; use parking_lot::Mutex; -use jsonrpc_core::{Error, BoxFuture}; +use jsonrpc_core::{Result, BoxFuture, Error}; use jsonrpc_core::futures::{future, Future, IntoFuture}; use jsonrpc_core::futures::future::Either; use jsonrpc_pubsub::SubscriptionId; @@ -78,11 +78,11 @@ impl SignerClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn confirm_internal(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture, Error> where + fn confirm_internal(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture> where F: FnOnce(D, Arc, ConfirmationPayload) -> T, T: IntoFuture, Error=Error>, T::Future: Send + 'static @@ -124,8 +124,8 @@ impl SignerClient { .unwrap_or_else(|| Either::B(future::err(errors::invalid_params("Unknown RequestID", id))))) } - fn verify_transaction(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result where - F: FnOnce(PendingTransaction) -> Result, + fn verify_transaction(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result where + F: FnOnce(PendingTransaction) -> Result, { let signed_transaction = UntrustedRlp::new(&bytes.0).as_val().map_err(errors::rlp)?; let signed_transaction = SignedTransaction::new(signed_transaction).map_err(|e| errors::invalid_params("Invalid signature.", e))?; @@ -159,7 +159,7 @@ impl SignerClient { impl Signer for SignerClient { type Metadata = Metadata; - fn requests_to_confirm(&self) -> Result, Error> { + fn requests_to_confirm(&self) -> Result> { Ok(self.signer.requests() .into_iter() .map(Into::into) @@ -170,7 +170,7 @@ impl Signer for SignerClient { // TODO [ToDr] TransactionModification is redundant for some calls // might be better to replace it in future fn confirm_request(&self, id: U256, modification: TransactionModification, pass: String) - -> BoxFuture + -> BoxFuture { Box::new(self.confirm_internal(id, modification, move |dis, accounts, payload| { dispatch::execute(dis, accounts, payload, dispatch::SignWith::Password(pass)) @@ -178,7 +178,7 @@ impl Signer for SignerClient { } fn confirm_request_with_token(&self, id: U256, modification: TransactionModification, token: String) - -> BoxFuture + -> BoxFuture { Box::new(self.confirm_internal(id, modification, move |dis, accounts, payload| { dispatch::execute(dis, accounts, payload, dispatch::SignWith::Token(token)) @@ -191,7 +191,7 @@ impl Signer for SignerClient { })) } - fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result { + fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result { let id = id.into(); self.signer.peek(&id).map(|confirmation| { @@ -230,17 +230,17 @@ impl Signer for SignerClient { }).unwrap_or_else(|| Err(errors::invalid_params("Unknown RequestID", id))) } - fn reject_request(&self, id: U256) -> Result { + fn reject_request(&self, id: U256) -> Result { let res = self.signer.request_rejected(id.into()); Ok(res.is_some()) } - fn generate_token(&self) -> Result { + fn generate_token(&self) -> Result { self.signer.generate_token() .map_err(|e| errors::token(e)) } - fn generate_web_proxy_token(&self, domain: String) -> Result { + fn generate_web_proxy_token(&self, domain: String) -> Result { Ok(self.signer.generate_web_proxy_access_token(domain.into())) } @@ -248,7 +248,7 @@ impl Signer for SignerClient { self.subscribers.lock().push(sub) } - fn unsubscribe_pending(&self, id: SubscriptionId) -> Result { + fn unsubscribe_pending(&self, id: SubscriptionId) -> Result { let res = self.subscribers.lock().remove(&id).is_some(); Ok(res) } diff --git a/rpc/src/v1/impls/signing.rs b/rpc/src/v1/impls/signing.rs index 139e554ca..dd6507c42 100644 --- a/rpc/src/v1/impls/signing.rs +++ b/rpc/src/v1/impls/signing.rs @@ -23,7 +23,7 @@ use parking_lot::Mutex; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{future, Future, Poll, Async}; use jsonrpc_core::futures::future::Either; use v1::helpers::{ @@ -109,11 +109,11 @@ impl SigningQueueClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn dispatch(&self, payload: RpcConfirmationPayload, default_account: DefaultAccount, origin: Origin) -> BoxFuture { + fn dispatch(&self, payload: RpcConfirmationPayload, default_account: DefaultAccount, origin: Origin) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default_account = match default_account { DefaultAccount::Provided(acc) => acc, @@ -143,13 +143,13 @@ impl SigningQueueClient { impl ParitySigning for SigningQueueClient { type Metadata = Metadata; - fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { + fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default_account = accounts.dapp_default_address(meta.dapp_id().into()).ok().unwrap_or_default(); Box::new(self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into)) } - fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture, Error> { + fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture> { let remote = self.remote.clone(); let confirmations = self.confirmations.clone(); @@ -166,7 +166,7 @@ impl ParitySigning for SigningQueueClient { })) } - fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture, Error> { + fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture> { let remote = self.remote.clone(); let confirmations = self.confirmations.clone(); @@ -180,7 +180,7 @@ impl ParitySigning for SigningQueueClient { })) } - fn check_request(&self, id: RpcU256) -> Result, Error> { + fn check_request(&self, id: RpcU256) -> Result> { let id: U256 = id.into(); match self.confirmations.lock().get(&id) { None => Err(errors::request_not_found()), // Request info has been dropped, or even never been there @@ -189,7 +189,7 @@ impl ParitySigning for SigningQueueClient { } } - fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn decrypt_message(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into(), @@ -209,7 +209,7 @@ impl ParitySigning for SigningQueueClient { impl EthSigning for SigningQueueClient { type Metadata = Metadata; - fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into(), @@ -224,7 +224,7 @@ impl EthSigning for SigningQueueClient { })) } - fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into(), @@ -239,7 +239,7 @@ impl EthSigning for SigningQueueClient { })) } - fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { let res = self.dispatch( RpcConfirmationPayload::SignTransaction(request), meta.dapp_id().into(), diff --git a/rpc/src/v1/impls/signing_unsafe.rs b/rpc/src/v1/impls/signing_unsafe.rs index 779e9f20e..e2bf27d39 100644 --- a/rpc/src/v1/impls/signing_unsafe.rs +++ b/rpc/src/v1/impls/signing_unsafe.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use ethcore::account_provider::AccountProvider; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::{future, Future}; use v1::helpers::{errors, DefaultAccount}; use v1::helpers::dispatch::{self, Dispatcher}; @@ -52,11 +52,11 @@ impl SigningUnsafeClient { } } - fn account_provider(&self) -> Result, Error> { + fn account_provider(&self) -> Result> { unwrap_provider(&self.accounts) } - fn handle(&self, payload: RpcConfirmationPayload, account: DefaultAccount) -> BoxFuture { + fn handle(&self, payload: RpcConfirmationPayload, account: DefaultAccount) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default = match account { DefaultAccount::Provided(acc) => acc, @@ -76,7 +76,7 @@ impl EthSigning for SigningUnsafeClient { type Metadata = Metadata; - fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into()) .then(|res| match res { Ok(RpcConfirmationResponse::Signature(signature)) => Ok(signature), @@ -85,7 +85,7 @@ impl EthSigning for SigningUnsafeClient })) } - fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into()) .then(|res| match res { Ok(RpcConfirmationResponse::SendTransaction(hash)) => Ok(hash), @@ -94,7 +94,7 @@ impl EthSigning for SigningUnsafeClient })) } - fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { + fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::SignTransaction(request), meta.dapp_id().into()) .then(|res| match res { Ok(RpcConfirmationResponse::SignTransaction(tx)) => Ok(tx), @@ -107,13 +107,13 @@ impl EthSigning for SigningUnsafeClient impl ParitySigning for SigningUnsafeClient { type Metadata = Metadata; - fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { + fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture { let accounts = try_bf!(self.account_provider()); let default_account = accounts.dapp_default_address(meta.dapp_id().into()).ok().unwrap_or_default(); Box::new(self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into)) } - fn decrypt_message(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { + fn decrypt_message(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture { Box::new(self.handle(RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into()) .then(|res| match res { Ok(RpcConfirmationResponse::Decrypt(data)) => Ok(data), @@ -122,17 +122,17 @@ impl ParitySigning for SigningUnsafeClient { })) } - fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture, Error> { + fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture> { // We don't support this in non-signer mode. Box::new(future::err(errors::signer_disabled())) } - fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture, Error> { + fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture> { // We don't support this in non-signer mode. Box::new(future::err((errors::signer_disabled()))) } - fn check_request(&self, _: RpcU256) -> Result, Error> { + fn check_request(&self, _: RpcU256) -> Result> { // We don't support this in non-signer mode. Err(errors::signer_disabled()) } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 8fca11efe..34fe36e67 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -22,7 +22,7 @@ use ethcore::client::{MiningBlockChainClient, CallAnalytics, TransactionId, Trac use ethcore::transaction::SignedTransaction; use rlp::UntrustedRlp; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use v1::Metadata; use v1::traits::Traces; @@ -54,22 +54,22 @@ impl TracesClient { impl Traces for TracesClient where C: MiningBlockChainClient + 'static { type Metadata = Metadata; - fn filter(&self, filter: TraceFilter) -> Result>, Error> { + fn filter(&self, filter: TraceFilter) -> Result>> { Ok(self.client.filter_traces(filter.into()) .map(|traces| traces.into_iter().map(LocalizedTrace::from).collect())) } - fn block_traces(&self, block_number: BlockNumber) -> Result>, Error> { + fn block_traces(&self, block_number: BlockNumber) -> Result>> { Ok(self.client.block_traces(block_number.into()) .map(|traces| traces.into_iter().map(LocalizedTrace::from).collect())) } - fn transaction_traces(&self, transaction_hash: H256) -> Result>, Error> { + fn transaction_traces(&self, transaction_hash: H256) -> Result>> { Ok(self.client.transaction_traces(TransactionId::Hash(transaction_hash.into())) .map(|traces| traces.into_iter().map(LocalizedTrace::from).collect())) } - fn trace(&self, transaction_hash: H256, address: Vec) -> Result, Error> { + fn trace(&self, transaction_hash: H256, address: Vec) -> Result> { let id = TraceId { transaction: TransactionId::Hash(transaction_hash.into()), address: address.into_iter().map(|i| i.value()).collect() @@ -79,7 +79,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { .map(LocalizedTrace::from)) } - fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing) -> Result { + fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing) -> Result { let block = block.unwrap_or_default(); let request = CallRequest::into(request); @@ -90,7 +90,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { .map_err(errors::call) } - fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing) -> Result, Error> { + fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing) -> Result> { let block = block.unwrap_or_default(); let requests = requests.into_iter() @@ -99,14 +99,14 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { let signed = fake_sign::sign_call(request, meta.is_dapp())?; Ok((signed, to_call_analytics(flags))) }) - .collect::, Error>>()?; + .collect::>>()?; self.client.call_many(&requests, block.into()) .map(|results| results.into_iter().map(TraceResults::from).collect()) .map_err(errors::call) } - fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing) -> Result { + fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing) -> Result { let block = block.unwrap_or_default(); let tx = UntrustedRlp::new(&raw_transaction.into_vec()).as_val().map_err(|e| errors::invalid_params("Transaction is not valid RLP", e))?; @@ -117,7 +117,7 @@ impl Traces for TracesClient where C: MiningBlockChainClient + 'static { .map_err(errors::call) } - fn replay_transaction(&self, transaction_hash: H256, flags: TraceOptions) -> Result { + fn replay_transaction(&self, transaction_hash: H256, flags: TraceOptions) -> Result { self.client.replay(TransactionId::Hash(transaction_hash.into()), to_call_analytics(flags)) .map(TraceResults::from) .map_err(errors::call) diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index b636ba608..44055507f 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -16,7 +16,7 @@ //! Web3 rpc implementation. use hash::keccak; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use util::version; use v1::traits::Web3; use v1::types::{H256, Bytes}; @@ -30,11 +30,11 @@ impl Web3Client { } impl Web3 for Web3Client { - fn client_version(&self) -> Result { + fn client_version(&self) -> Result { Ok(version().to_owned().replace("Parity/", "Parity//")) } - fn sha3(&self, data: Bytes) -> Result { + fn sha3(&self, data: Bytes) -> Result { Ok(keccak(&data.0).into()) } } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 6c052bf31..f4ea1e10d 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Eth rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_macros::Trailing; use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index}; @@ -29,151 +29,151 @@ build_rpc_trait! { /// Returns protocol version encoded as a string (quotes are necessary). #[rpc(name = "eth_protocolVersion")] - fn protocol_version(&self) -> Result; + fn protocol_version(&self) -> Result; /// Returns an object with data about the sync status or false. (wtf?) #[rpc(name = "eth_syncing")] - fn syncing(&self) -> Result; + fn syncing(&self) -> Result; /// Returns the number of hashes per second that the node is mining with. #[rpc(name = "eth_hashrate")] - fn hashrate(&self) -> Result; + fn hashrate(&self) -> Result; /// Returns block author. #[rpc(meta, name = "eth_coinbase")] - fn author(&self, Self::Metadata) -> Result; + fn author(&self, Self::Metadata) -> Result; /// Returns true if client is actively mining new blocks. #[rpc(name = "eth_mining")] - fn is_mining(&self) -> Result; + fn is_mining(&self) -> Result; /// Returns current gas_price. #[rpc(name = "eth_gasPrice")] - fn gas_price(&self) -> Result; + fn gas_price(&self) -> Result; /// Returns accounts list. #[rpc(meta, name = "eth_accounts")] - fn accounts(&self, Self::Metadata) -> Result, Error>; + fn accounts(&self, Self::Metadata) -> Result>; /// Returns highest block number. #[rpc(name = "eth_blockNumber")] - fn block_number(&self) -> Result; + fn block_number(&self) -> Result; /// Returns balance of the given account. #[rpc(name = "eth_getBalance")] - fn balance(&self, H160, Trailing) -> BoxFuture; + fn balance(&self, H160, Trailing) -> BoxFuture; /// Returns content of the storage at given address. #[rpc(name = "eth_getStorageAt")] - fn storage_at(&self, H160, U256, Trailing) -> BoxFuture; + fn storage_at(&self, H160, U256, Trailing) -> BoxFuture; /// Returns block with given hash. #[rpc(name = "eth_getBlockByHash")] - fn block_by_hash(&self, H256, bool) -> BoxFuture, Error>; + fn block_by_hash(&self, H256, bool) -> BoxFuture>; /// Returns block with given number. #[rpc(name = "eth_getBlockByNumber")] - fn block_by_number(&self, BlockNumber, bool) -> BoxFuture, Error>; + fn block_by_number(&self, BlockNumber, bool) -> BoxFuture>; /// Returns the number of transactions sent from given address at given time (block number). #[rpc(name = "eth_getTransactionCount")] - fn transaction_count(&self, H160, Trailing) -> BoxFuture; + fn transaction_count(&self, H160, Trailing) -> BoxFuture; /// Returns the number of transactions in a block with given hash. #[rpc(name = "eth_getBlockTransactionCountByHash")] - fn block_transaction_count_by_hash(&self, H256) -> BoxFuture, Error>; + fn block_transaction_count_by_hash(&self, H256) -> BoxFuture>; /// Returns the number of transactions in a block with given block number. #[rpc(name = "eth_getBlockTransactionCountByNumber")] - fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture, Error>; + fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture>; /// Returns the number of uncles in a block with given hash. #[rpc(name = "eth_getUncleCountByBlockHash")] - fn block_uncles_count_by_hash(&self, H256) -> BoxFuture, Error>; + fn block_uncles_count_by_hash(&self, H256) -> BoxFuture>; /// Returns the number of uncles in a block with given block number. #[rpc(name = "eth_getUncleCountByBlockNumber")] - fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture, Error>; + fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture>; /// Returns the code at given address at given time (block number). #[rpc(name = "eth_getCode")] - fn code_at(&self, H160, Trailing) -> BoxFuture; + fn code_at(&self, H160, Trailing) -> BoxFuture; /// Sends signed transaction, returning its hash. #[rpc(name = "eth_sendRawTransaction")] - fn send_raw_transaction(&self, Bytes) -> Result; + fn send_raw_transaction(&self, Bytes) -> Result; /// @alias of `eth_sendRawTransaction`. #[rpc(name = "eth_submitTransaction")] - fn submit_transaction(&self, Bytes) -> Result; + fn submit_transaction(&self, Bytes) -> Result; /// Call contract, returning the output data. #[rpc(meta, name = "eth_call")] - fn call(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; + fn call(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; /// Estimate gas needed for execution of given contract. #[rpc(meta, name = "eth_estimateGas")] - fn estimate_gas(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; + fn estimate_gas(&self, Self::Metadata, CallRequest, Trailing) -> BoxFuture; /// Get transaction by its hash. #[rpc(name = "eth_getTransactionByHash")] - fn transaction_by_hash(&self, H256) -> BoxFuture, Error>; + fn transaction_by_hash(&self, H256) -> BoxFuture>; /// Returns transaction at given block hash and index. #[rpc(name = "eth_getTransactionByBlockHashAndIndex")] - fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture, Error>; + fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; /// Returns transaction by given block number and index. #[rpc(name = "eth_getTransactionByBlockNumberAndIndex")] - fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture, Error>; + fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; /// Returns transaction receipt by transaction hash. #[rpc(name = "eth_getTransactionReceipt")] - fn transaction_receipt(&self, H256) -> BoxFuture, Error>; + fn transaction_receipt(&self, H256) -> BoxFuture>; /// Returns an uncles at given block and index. #[rpc(name = "eth_getUncleByBlockHashAndIndex")] - fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture, Error>; + fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; /// Returns an uncles at given block and index. #[rpc(name = "eth_getUncleByBlockNumberAndIndex")] - fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture, Error>; + fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; /// Returns available compilers. /// @deprecated #[rpc(name = "eth_getCompilers")] - fn compilers(&self) -> Result, Error>; + fn compilers(&self) -> Result>; /// Compiles lll code. /// @deprecated #[rpc(name = "eth_compileLLL")] - fn compile_lll(&self, String) -> Result; + fn compile_lll(&self, String) -> Result; /// Compiles solidity. /// @deprecated #[rpc(name = "eth_compileSolidity")] - fn compile_solidity(&self, String) -> Result; + fn compile_solidity(&self, String) -> Result; /// Compiles serpent. /// @deprecated #[rpc(name = "eth_compileSerpent")] - fn compile_serpent(&self, String) -> Result; + fn compile_serpent(&self, String) -> Result; /// Returns logs matching given filter object. #[rpc(name = "eth_getLogs")] - fn logs(&self, Filter) -> BoxFuture, Error>; + fn logs(&self, Filter) -> BoxFuture>; /// Returns the hash of the current block, the seedHash, and the boundary condition to be met. #[rpc(name = "eth_getWork")] - fn work(&self, Trailing) -> Result; + fn work(&self, Trailing) -> Result; /// Used for submitting a proof-of-work solution. #[rpc(name = "eth_submitWork")] - fn submit_work(&self, H64, H256, H256) -> Result; + fn submit_work(&self, H64, H256, H256) -> Result; /// Used for submitting mining hashrate. #[rpc(name = "eth_submitHashrate")] - fn submit_hashrate(&self, U256, H256) -> Result; + fn submit_hashrate(&self, U256, H256) -> Result; } } @@ -183,26 +183,26 @@ build_rpc_trait! { pub trait EthFilter { /// Returns id of new filter. #[rpc(name = "eth_newFilter")] - fn new_filter(&self, Filter) -> Result; + fn new_filter(&self, Filter) -> Result; /// Returns id of new block filter. #[rpc(name = "eth_newBlockFilter")] - fn new_block_filter(&self) -> Result; + fn new_block_filter(&self) -> Result; /// Returns id of new block filter. #[rpc(name = "eth_newPendingTransactionFilter")] - fn new_pending_transaction_filter(&self) -> Result; + fn new_pending_transaction_filter(&self) -> Result; /// Returns filter changes since last poll. #[rpc(name = "eth_getFilterChanges")] - fn filter_changes(&self, Index) -> BoxFuture; + fn filter_changes(&self, Index) -> BoxFuture; /// Returns all logs matching given filter (in a range 'from' - 'to'). #[rpc(name = "eth_getFilterLogs")] - fn filter_logs(&self, Index) -> BoxFuture, Error>; + fn filter_logs(&self, Index) -> BoxFuture>; /// Uninstalls filter. #[rpc(name = "eth_uninstallFilter")] - fn uninstall_filter(&self, Index) -> Result; + fn uninstall_filter(&self, Index) -> Result; } } diff --git a/rpc/src/v1/traits/eth_pubsub.rs b/rpc/src/v1/traits/eth_pubsub.rs index 12d637862..cfbe4c54b 100644 --- a/rpc/src/v1/traits/eth_pubsub.rs +++ b/rpc/src/v1/traits/eth_pubsub.rs @@ -16,7 +16,7 @@ //! Eth PUB-SUB rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; use jsonrpc_pubsub::SubscriptionId; @@ -35,7 +35,7 @@ build_rpc_trait! { /// Unsubscribe from existing Eth subscription. #[rpc(name = "eth_unsubscribe")] - fn unsubscribe(&self, SubscriptionId) -> Result; + fn unsubscribe(&self, SubscriptionId) -> Result; } } } diff --git a/rpc/src/v1/traits/eth_signing.rs b/rpc/src/v1/traits/eth_signing.rs index 1b84fe3f8..9830ac54d 100644 --- a/rpc/src/v1/traits/eth_signing.rs +++ b/rpc/src/v1/traits/eth_signing.rs @@ -16,7 +16,7 @@ //! Eth rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::BoxFuture; use v1::types::{Bytes, H160, H256, H520, TransactionRequest, RichRawTransaction}; @@ -27,18 +27,18 @@ build_rpc_trait! { /// Signs the hash of data with given address signature. #[rpc(meta, name = "eth_sign")] - fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture; + fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture; /// Sends transaction; will block waiting for signer to return the /// transaction hash. /// If Signer is disable it will require the account to be unlocked. #[rpc(meta, name = "eth_sendTransaction")] - fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; /// Signs transactions without dispatching it to the network. /// Returns signed transaction RLP representation and the transaction itself. /// It can be later submitted using `eth_sendRawTransaction/eth_submitTransaction`. #[rpc(meta, name = "eth_signTransaction")] - fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/net.rs b/rpc/src/v1/traits/net.rs index 109c10344..bc2068ff9 100644 --- a/rpc/src/v1/traits/net.rs +++ b/rpc/src/v1/traits/net.rs @@ -15,22 +15,22 @@ // along with Parity. If not, see . //! Net rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; build_rpc_trait! { /// Net rpc interface. pub trait Net { /// Returns protocol version. #[rpc(name = "net_version")] - fn version(&self) -> Result; + fn version(&self) -> Result; /// Returns number of peers connected to node. #[rpc(name = "net_peerCount")] - fn peer_count(&self) -> Result; + fn peer_count(&self) -> Result; /// Returns true if client is actively listening for network connections. /// Otherwise false. #[rpc(name = "net_listening")] - fn is_listening(&self) -> Result; + fn is_listening(&self) -> Result; } } diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 7e1fc9a21..81c406fb3 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_macros::Trailing; use node_health::Health; @@ -38,188 +38,188 @@ build_rpc_trait! { /// Returns accounts information. #[rpc(name = "parity_accountsInfo")] - fn accounts_info(&self, Trailing) -> Result, Error>; + fn accounts_info(&self, Trailing) -> Result>; /// Returns hardware accounts information. #[rpc(name = "parity_hardwareAccountsInfo")] - fn hardware_accounts_info(&self) -> Result, Error>; + fn hardware_accounts_info(&self) -> Result>; /// Get a list of paths to locked hardware wallets #[rpc(name = "parity_lockedHardwareAccountsInfo")] - fn locked_hardware_accounts_info(&self) -> Result, Error>; + fn locked_hardware_accounts_info(&self) -> Result>; /// Returns default account for dapp. #[rpc(meta, name = "parity_defaultAccount")] - fn default_account(&self, Self::Metadata) -> Result; + fn default_account(&self, Self::Metadata) -> Result; /// Returns current transactions limit. #[rpc(name = "parity_transactionsLimit")] - fn transactions_limit(&self) -> Result; + fn transactions_limit(&self) -> Result; /// Returns mining extra data. #[rpc(name = "parity_extraData")] - fn extra_data(&self) -> Result; + fn extra_data(&self) -> Result; /// Returns mining gas floor target. #[rpc(name = "parity_gasFloorTarget")] - fn gas_floor_target(&self) -> Result; + fn gas_floor_target(&self) -> Result; /// Returns mining gas floor cap. #[rpc(name = "parity_gasCeilTarget")] - fn gas_ceil_target(&self) -> Result; + fn gas_ceil_target(&self) -> Result; /// Returns minimal gas price for transaction to be included in queue. #[rpc(name = "parity_minGasPrice")] - fn min_gas_price(&self) -> Result; + fn min_gas_price(&self) -> Result; /// Returns latest logs #[rpc(name = "parity_devLogs")] - fn dev_logs(&self) -> Result, Error>; + fn dev_logs(&self) -> Result>; /// Returns logs levels #[rpc(name = "parity_devLogsLevels")] - fn dev_logs_levels(&self) -> Result; + fn dev_logs_levels(&self) -> Result; /// Returns chain name - DEPRECATED. Use `parity_chainName` instead. #[rpc(name = "parity_netChain")] - fn net_chain(&self) -> Result; + fn net_chain(&self) -> Result; /// Returns peers details #[rpc(name = "parity_netPeers")] - fn net_peers(&self) -> Result; + fn net_peers(&self) -> Result; /// Returns network port #[rpc(name = "parity_netPort")] - fn net_port(&self) -> Result; + fn net_port(&self) -> Result; /// Returns rpc settings #[rpc(name = "parity_rpcSettings")] - fn rpc_settings(&self) -> Result; + fn rpc_settings(&self) -> Result; /// Returns node name #[rpc(name = "parity_nodeName")] - fn node_name(&self) -> Result; + fn node_name(&self) -> Result; /// Returns default extra data #[rpc(name = "parity_defaultExtraData")] - fn default_extra_data(&self) -> Result; + fn default_extra_data(&self) -> Result; /// Returns distribution of gas price in latest blocks. #[rpc(name = "parity_gasPriceHistogram")] - fn gas_price_histogram(&self) -> BoxFuture; + fn gas_price_histogram(&self) -> BoxFuture; /// Returns number of unsigned transactions waiting in the signer queue (if signer enabled) /// Returns error when signer is disabled #[rpc(name = "parity_unsignedTransactionsCount")] - fn unsigned_transactions_count(&self) -> Result; + fn unsigned_transactions_count(&self) -> Result; /// Returns a cryptographically random phrase sufficient for securely seeding a secret key. #[rpc(name = "parity_generateSecretPhrase")] - fn generate_secret_phrase(&self) -> Result; + fn generate_secret_phrase(&self) -> Result; /// Returns whatever address would be derived from the given phrase if it were to seed a brainwallet. #[rpc(name = "parity_phraseToAddress")] - fn phrase_to_address(&self, String) -> Result; + fn phrase_to_address(&self, String) -> Result; /// Returns the value of the registrar for this network. #[rpc(name = "parity_registryAddress")] - fn registry_address(&self) -> Result, Error>; + fn registry_address(&self) -> Result>; /// Returns all addresses if Fat DB is enabled (`--fat-db`), or null if not. #[rpc(name = "parity_listAccounts")] - fn list_accounts(&self, u64, Option, Trailing) -> Result>, Error>; + fn list_accounts(&self, u64, Option, Trailing) -> Result>>; /// Returns all storage keys of the given address (first parameter) if Fat DB is enabled (`--fat-db`), /// or null if not. #[rpc(name = "parity_listStorageKeys")] - fn list_storage_keys(&self, H160, u64, Option, Trailing) -> Result>, Error>; + fn list_storage_keys(&self, H160, u64, Option, Trailing) -> Result>>; /// Encrypt some data with a public key under ECIES. /// First parameter is the 512-byte destination public key, second is the message. #[rpc(name = "parity_encryptMessage")] - fn encrypt_message(&self, H512, Bytes) -> Result; + fn encrypt_message(&self, H512, Bytes) -> Result; /// Returns all pending transactions from transaction queue. #[rpc(name = "parity_pendingTransactions")] - fn pending_transactions(&self) -> Result, Error>; + fn pending_transactions(&self) -> Result>; /// Returns all future transactions from transaction queue. #[rpc(name = "parity_futureTransactions")] - fn future_transactions(&self) -> Result, Error>; + fn future_transactions(&self) -> Result>; /// Returns propagation statistics on transactions pending in the queue. #[rpc(name = "parity_pendingTransactionsStats")] - fn pending_transactions_stats(&self) -> Result, Error>; + fn pending_transactions_stats(&self) -> Result>; /// Returns a list of current and past local transactions with status details. #[rpc(name = "parity_localTransactions")] - fn local_transactions(&self) -> Result, Error>; + fn local_transactions(&self) -> Result>; /// Returns current Dapps Server interface and port or an error if dapps server is disabled. #[rpc(name = "parity_dappsUrl")] - fn dapps_url(&self) -> Result; + fn dapps_url(&self) -> Result; /// Returns current WS Server interface and port or an error if ws server is disabled. #[rpc(name = "parity_wsUrl")] - fn ws_url(&self) -> Result; + fn ws_url(&self) -> Result; /// Returns next nonce for particular sender. Should include all transactions in the queue. #[rpc(name = "parity_nextNonce")] - fn next_nonce(&self, H160) -> BoxFuture; + fn next_nonce(&self, H160) -> BoxFuture; /// Get the mode. Returns one of: "active", "passive", "dark", "offline". #[rpc(name = "parity_mode")] - fn mode(&self) -> Result; + fn mode(&self) -> Result; /// Returns the chain ID used for transaction signing at the /// current best block. An empty string is returned if not /// available. #[rpc(name = "parity_chainId")] - fn chain_id(&self) -> Result, Error>; + fn chain_id(&self) -> Result>; /// Get the chain name. Returns one of: "foundation", "kovan", &c. of a filename. #[rpc(name = "parity_chain")] - fn chain(&self) -> Result; + fn chain(&self) -> Result; /// Get the enode of this node. #[rpc(name = "parity_enode")] - fn enode(&self) -> Result; + fn enode(&self) -> Result; /// Returns information on current consensus capability. #[rpc(name = "parity_consensusCapability")] - fn consensus_capability(&self) -> Result; + fn consensus_capability(&self) -> Result; /// Get our version information in a nice object. #[rpc(name = "parity_versionInfo")] - fn version_info(&self) -> Result; + fn version_info(&self) -> Result; /// Get information concerning the latest releases if available. #[rpc(name = "parity_releasesInfo")] - fn releases_info(&self) -> Result, Error>; + fn releases_info(&self) -> Result>; /// Get the current chain status. #[rpc(name = "parity_chainStatus")] - fn chain_status(&self) -> Result; + fn chain_status(&self) -> Result; /// Get node kind info. #[rpc(name = "parity_nodeKind")] - fn node_kind(&self) -> Result<::v1::types::NodeKind, Error>; + fn node_kind(&self) -> Result<::v1::types::NodeKind>; /// Get block header. /// Same as `eth_getBlockByNumber` but without uncles and transactions. #[rpc(name = "parity_getBlockHeaderByNumber")] - fn block_header(&self, Trailing) -> BoxFuture; + fn block_header(&self, Trailing) -> BoxFuture; /// Get IPFS CIDv0 given protobuf encoded bytes. #[rpc(name = "parity_cidV0")] - fn ipfs_cid(&self, Bytes) -> Result; + fn ipfs_cid(&self, Bytes) -> Result; /// Call contract, returning the output data. #[rpc(meta, name = "parity_call")] - fn call(&self, Self::Metadata, Vec, Trailing) -> Result, Error>; + fn call(&self, Self::Metadata, Vec, Trailing) -> Result>; /// Returns node's health report. #[rpc(name = "parity_nodeHealth")] - fn node_health(&self) -> BoxFuture; + fn node_health(&self) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/parity_accounts.rs b/rpc/src/v1/traits/parity_accounts.rs index f7bdc1172..494f1576c 100644 --- a/rpc/src/v1/traits/parity_accounts.rs +++ b/rpc/src/v1/traits/parity_accounts.rs @@ -17,7 +17,7 @@ //! Parity Accounts-related rpc interface. use std::collections::BTreeMap; -use jsonrpc_core::Error; +use jsonrpc_core::Result; use ethstore::KeyFile; use v1::types::{H160, H256, H520, DappId, DeriveHash, DeriveHierarchical, ExtAccountInfo}; @@ -26,167 +26,167 @@ build_rpc_trait! { pub trait ParityAccounts { /// Returns accounts information. #[rpc(name = "parity_allAccountsInfo")] - fn all_accounts_info(&self) -> Result, Error>; + fn all_accounts_info(&self) -> Result>; /// Creates new account from the given phrase using standard brainwallet mechanism. /// Second parameter is password for the new account. #[rpc(name = "parity_newAccountFromPhrase")] - fn new_account_from_phrase(&self, String, String) -> Result; + fn new_account_from_phrase(&self, String, String) -> Result; /// Creates new account from the given JSON wallet. /// Second parameter is password for the wallet and the new account. #[rpc(name = "parity_newAccountFromWallet")] - fn new_account_from_wallet(&self, String, String) -> Result; + fn new_account_from_wallet(&self, String, String) -> Result; /// Creates new account from the given raw secret. /// Second parameter is password for the new account. #[rpc(name = "parity_newAccountFromSecret")] - fn new_account_from_secret(&self, H256, String) -> Result; + fn new_account_from_secret(&self, H256, String) -> Result; /// Returns true if given `password` would unlock given `account`. /// Arguments: `account`, `password`. #[rpc(name = "parity_testPassword")] - fn test_password(&self, H160, String) -> Result; + fn test_password(&self, H160, String) -> Result; /// Changes an account's password. /// Arguments: `account`, `password`, `new_password`. #[rpc(name = "parity_changePassword")] - fn change_password(&self, H160, String, String) -> Result; + fn change_password(&self, H160, String, String) -> Result; /// Permanently deletes an account. /// Arguments: `account`, `password`. #[rpc(name = "parity_killAccount")] - fn kill_account(&self, H160, String) -> Result; + fn kill_account(&self, H160, String) -> Result; /// Permanently deletes an address from the addressbook /// Arguments: `address` #[rpc(name = "parity_removeAddress")] - fn remove_address(&self, H160) -> Result; + fn remove_address(&self, H160) -> Result; /// Set an account's name. #[rpc(name = "parity_setAccountName")] - fn set_account_name(&self, H160, String) -> Result; + fn set_account_name(&self, H160, String) -> Result; /// Set an account's metadata string. #[rpc(name = "parity_setAccountMeta")] - fn set_account_meta(&self, H160, String) -> Result; + fn set_account_meta(&self, H160, String) -> Result; /// Sets addresses exposed for particular dapp. /// Setting a non-empty list will also override default account. /// Setting `None` will resets visible account to what's visible for new dapps /// (does not affect default account though) #[rpc(name = "parity_setDappAddresses")] - fn set_dapp_addresses(&self, DappId, Option>) -> Result; + fn set_dapp_addresses(&self, DappId, Option>) -> Result; /// Gets accounts exposed for particular dapp. #[rpc(name = "parity_getDappAddresses")] - fn dapp_addresses(&self, DappId) -> Result, Error>; + fn dapp_addresses(&self, DappId) -> Result>; /// Changes dapp default address. /// Does not affect other accounts exposed for this dapp, but /// default account will always be retured as the first one. #[rpc(name = "parity_setDappDefaultAddress")] - fn set_dapp_default_address(&self, DappId, H160) -> Result; + fn set_dapp_default_address(&self, DappId, H160) -> Result; /// Returns current dapp default address. /// If not set explicite for the dapp will return global default. #[rpc(name = "parity_getDappDefaultAddress")] - fn dapp_default_address(&self, DappId) -> Result; + fn dapp_default_address(&self, DappId) -> Result; /// Sets accounts exposed for new dapps. /// Setting a non-empty list will also override default account. /// Setting `None` exposes all internal-managed accounts. /// (does not affect default account though) #[rpc(name = "parity_setNewDappsAddresses")] - fn set_new_dapps_addresses(&self, Option>) -> Result; + fn set_new_dapps_addresses(&self, Option>) -> Result; /// Gets accounts exposed for new dapps. /// `None` means that all accounts are exposes. #[rpc(name = "parity_getNewDappsAddresses")] - fn new_dapps_addresses(&self) -> Result>, Error>; + fn new_dapps_addresses(&self) -> Result>>; /// Changes default address for new dapps (global default address) /// Does not affect other accounts exposed for new dapps, but /// default account will always be retured as the first one. #[rpc(name = "parity_setNewDappsDefaultAddress")] - fn set_new_dapps_default_address(&self, H160) -> Result; + fn set_new_dapps_default_address(&self, H160) -> Result; /// Returns current default address for new dapps (global default address) /// In case it's not set explicite will return first available account. /// If no accounts are available will return `0x0` #[rpc(name = "parity_getNewDappsDefaultAddress")] - fn new_dapps_default_address(&self) -> Result; + fn new_dapps_default_address(&self) -> Result; /// Returns identified dapps that recently used RPC /// Includes last usage timestamp. #[rpc(name = "parity_listRecentDapps")] - fn recent_dapps(&self) -> Result, Error>; + fn recent_dapps(&self) -> Result>; /// Imports a number of Geth accounts, with the list provided as the argument. #[rpc(name = "parity_importGethAccounts")] - fn import_geth_accounts(&self, Vec) -> Result, Error>; + fn import_geth_accounts(&self, Vec) -> Result>; /// Returns the accounts available for importing from Geth. #[rpc(name = "parity_listGethAccounts")] - fn geth_accounts(&self) -> Result, Error>; + fn geth_accounts(&self) -> Result>; /// Create new vault. #[rpc(name = "parity_newVault")] - fn create_vault(&self, String, String) -> Result; + fn create_vault(&self, String, String) -> Result; /// Open existing vault. #[rpc(name = "parity_openVault")] - fn open_vault(&self, String, String) -> Result; + fn open_vault(&self, String, String) -> Result; /// Close previously opened vault. #[rpc(name = "parity_closeVault")] - fn close_vault(&self, String) -> Result; + fn close_vault(&self, String) -> Result; /// List all vaults. #[rpc(name = "parity_listVaults")] - fn list_vaults(&self) -> Result, Error>; + fn list_vaults(&self) -> Result>; /// List all currently opened vaults. #[rpc(name = "parity_listOpenedVaults")] - fn list_opened_vaults(&self) -> Result, Error>; + fn list_opened_vaults(&self) -> Result>; /// Change vault password. #[rpc(name = "parity_changeVaultPassword")] - fn change_vault_password(&self, String, String) -> Result; + fn change_vault_password(&self, String, String) -> Result; /// Change vault of the given address. #[rpc(name = "parity_changeVault")] - fn change_vault(&self, H160, String) -> Result; + fn change_vault(&self, H160, String) -> Result; /// Get vault metadata string. #[rpc(name = "parity_getVaultMeta")] - fn get_vault_meta(&self, String) -> Result; + fn get_vault_meta(&self, String) -> Result; /// Set vault metadata string. #[rpc(name = "parity_setVaultMeta")] - fn set_vault_meta(&self, String, String) -> Result; + fn set_vault_meta(&self, String, String) -> Result; /// Derive new address from given account address using specific hash. /// Resulting address can be either saved as a new account (with the same password). #[rpc(name = "parity_deriveAddressHash")] - fn derive_key_hash(&self, H160, String, DeriveHash, bool) -> Result; + fn derive_key_hash(&self, H160, String, DeriveHash, bool) -> Result; /// Derive new address from given account address using /// hierarchical derivation (sequence of 32-bit integer indices). /// Resulting address can be either saved as a new account (with the same password). #[rpc(name = "parity_deriveAddressIndex")] - fn derive_key_index(&self, H160, String, DeriveHierarchical, bool) -> Result; + fn derive_key_index(&self, H160, String, DeriveHierarchical, bool) -> Result; /// Exports an account with given address if provided password matches. #[rpc(name = "parity_exportAccount")] - fn export_account(&self, H160, String) -> Result; + fn export_account(&self, H160, String) -> Result; /// Sign raw hash with the key corresponding to address and password. #[rpc(name = "parity_signMessage")] - fn sign_message(&self, H160, String, H256) -> Result; + fn sign_message(&self, H160, String, H256) -> Result; /// Send a PinMatrixAck to a hardware wallet, unlocking it #[rpc(name = "parity_hardwarePinMatrixAck")] - fn hardware_pin_matrix_ack(&self, String, String) -> Result; + fn hardware_pin_matrix_ack(&self, String, String) -> Result; } } diff --git a/rpc/src/v1/traits/parity_set.rs b/rpc/src/v1/traits/parity_set.rs index 7b3c593dc..40aad1a4b 100644 --- a/rpc/src/v1/traits/parity_set.rs +++ b/rpc/src/v1/traits/parity_set.rs @@ -16,7 +16,7 @@ //! Parity-specific rpc interface for operations altering the settings. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction, LocalDapp}; @@ -25,91 +25,91 @@ build_rpc_trait! { pub trait ParitySet { /// Sets new minimal gas price for mined blocks. #[rpc(name = "parity_setMinGasPrice")] - fn set_min_gas_price(&self, U256) -> Result; + fn set_min_gas_price(&self, U256) -> Result; /// Sets new gas floor target for mined blocks. #[rpc(name = "parity_setGasFloorTarget")] - fn set_gas_floor_target(&self, U256) -> Result; + fn set_gas_floor_target(&self, U256) -> Result; /// Sets new gas ceiling target for mined blocks. #[rpc(name = "parity_setGasCeilTarget")] - fn set_gas_ceil_target(&self, U256) -> Result; + fn set_gas_ceil_target(&self, U256) -> Result; /// Sets new extra data for mined blocks. #[rpc(name = "parity_setExtraData")] - fn set_extra_data(&self, Bytes) -> Result; + fn set_extra_data(&self, Bytes) -> Result; /// Sets new author for mined block. #[rpc(name = "parity_setAuthor")] - fn set_author(&self, H160) -> Result; + fn set_author(&self, H160) -> Result; /// Sets account for signing consensus messages. #[rpc(name = "parity_setEngineSigner")] - fn set_engine_signer(&self, H160, String) -> Result; + fn set_engine_signer(&self, H160, String) -> Result; /// Sets the limits for transaction queue. #[rpc(name = "parity_setTransactionsLimit")] - fn set_transactions_limit(&self, usize) -> Result; + fn set_transactions_limit(&self, usize) -> Result; /// Sets the maximum amount of gas a single transaction may consume. #[rpc(name = "parity_setMaxTransactionGas")] - fn set_tx_gas_limit(&self, U256) -> Result; + fn set_tx_gas_limit(&self, U256) -> Result; /// Add a reserved peer. #[rpc(name = "parity_addReservedPeer")] - fn add_reserved_peer(&self, String) -> Result; + fn add_reserved_peer(&self, String) -> Result; /// Remove a reserved peer. #[rpc(name = "parity_removeReservedPeer")] - fn remove_reserved_peer(&self, String) -> Result; + fn remove_reserved_peer(&self, String) -> Result; /// Drop all non-reserved peers. #[rpc(name = "parity_dropNonReservedPeers")] - fn drop_non_reserved_peers(&self) -> Result; + fn drop_non_reserved_peers(&self) -> Result; /// Accept non-reserved peers (default behavior) #[rpc(name = "parity_acceptNonReservedPeers")] - fn accept_non_reserved_peers(&self) -> Result; + fn accept_non_reserved_peers(&self) -> Result; /// Start the network. /// /// @deprecated - Use `set_mode("active")` instead. #[rpc(name = "parity_startNetwork")] - fn start_network(&self) -> Result; + fn start_network(&self) -> Result; /// Stop the network. /// /// @deprecated - Use `set_mode("offline")` instead. #[rpc(name = "parity_stopNetwork")] - fn stop_network(&self) -> Result; + fn stop_network(&self) -> Result; /// Set the mode. Argument must be one of: "active", "passive", "dark", "offline". #[rpc(name = "parity_setMode")] - fn set_mode(&self, String) -> Result; + fn set_mode(&self, String) -> Result; /// Set the network spec. Argument must be one of: "foundation", "ropsten", "morden", "kovan", "olympic", "classic", "dev", "expanse", "musicoin" or a filename. #[rpc(name = "parity_setChain")] - fn set_spec_name(&self, String) -> Result; + fn set_spec_name(&self, String) -> Result; /// Hash a file content under given URL. #[rpc(name = "parity_hashContent")] - fn hash_content(&self, String) -> BoxFuture; + fn hash_content(&self, String) -> BoxFuture; /// Returns true if refresh successful, error if unsuccessful or server is disabled. #[rpc(name = "parity_dappsRefresh")] - fn dapps_refresh(&self) -> Result; + fn dapps_refresh(&self) -> Result; /// Returns a list of local dapps #[rpc(name = "parity_dappsList")] - fn dapps_list(&self) -> Result, Error>; + fn dapps_list(&self) -> Result>; /// Is there a release ready for install? #[rpc(name = "parity_upgradeReady")] - fn upgrade_ready(&self) -> Result, Error>; + fn upgrade_ready(&self) -> Result>; /// Execute a release which is ready according to upgrade_ready(). #[rpc(name = "parity_executeUpgrade")] - fn execute_upgrade(&self) -> Result; + fn execute_upgrade(&self) -> Result; /// Removes transaction from transaction queue. /// Makes sense only for transactions that were not propagated to other peers yet @@ -118,6 +118,6 @@ build_rpc_trait! { /// or excessive gas limit that are not accepted by other peers whp. /// Returns `true` when transaction was removed, `false` if it was not found. #[rpc(name = "parity_removeTransaction")] - fn remove_transaction(&self, H256) -> Result, Error>; + fn remove_transaction(&self, H256) -> Result>; } } diff --git a/rpc/src/v1/traits/parity_signing.rs b/rpc/src/v1/traits/parity_signing.rs index cf20dba36..8015b0431 100644 --- a/rpc/src/v1/traits/parity_signing.rs +++ b/rpc/src/v1/traits/parity_signing.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! ParitySigning rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use v1::types::{U256, H160, Bytes, ConfirmationResponse, TransactionRequest, Either}; @@ -27,26 +27,26 @@ build_rpc_trait! { /// Given partial transaction request produces transaction with all fields filled in. /// Such transaction can be then signed externally. #[rpc(meta, name = "parity_composeTransaction")] - fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; /// Posts sign request asynchronously. /// Will return a confirmation ID for later use with check_transaction. #[rpc(meta, name = "parity_postSign")] - fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture, Error>; + fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture>; /// Posts transaction asynchronously. /// Will return a transaction ID for later use with check_transaction. #[rpc(meta, name = "parity_postTransaction")] - fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture, Error>; + fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture>; /// Checks the progress of a previously posted request (transaction/sign). /// Should be given a valid send_transaction ID. #[rpc(name = "parity_checkRequest")] - fn check_request(&self, U256) -> Result, Error>; + fn check_request(&self, U256) -> Result>; /// Decrypt some ECIES-encrypted message. /// First parameter is the address with which it is encrypted, second is the ciphertext. #[rpc(meta, name = "parity_decryptMessage")] - fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture; + fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/personal.rs b/rpc/src/v1/traits/personal.rs index a8f575c30..3d6d29b28 100644 --- a/rpc/src/v1/traits/personal.rs +++ b/rpc/src/v1/traits/personal.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Personal rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use v1::types::{U128, H160, H256, TransactionRequest}; @@ -26,24 +26,24 @@ build_rpc_trait! { /// Lists all stored accounts #[rpc(name = "personal_listAccounts")] - fn accounts(&self) -> Result, Error>; + fn accounts(&self) -> Result>; /// Creates new account (it becomes new current unlocked account) /// Param is the password for the account. #[rpc(name = "personal_newAccount")] - fn new_account(&self, String) -> Result; + fn new_account(&self, String) -> Result; /// Unlocks specified account for use (can only be one unlocked account at one moment) #[rpc(name = "personal_unlockAccount")] - fn unlock_account(&self, H160, String, Option) -> Result; + fn unlock_account(&self, H160, String, Option) -> Result; /// Sends transaction and signs it in single call. The account is not unlocked in such case. #[rpc(meta, name = "personal_sendTransaction")] - fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; /// @deprecated alias for `personal_sendTransaction`. #[rpc(meta, name = "personal_signAndSendTransaction")] - fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; } } diff --git a/rpc/src/v1/traits/pubsub.rs b/rpc/src/v1/traits/pubsub.rs index 27d79c911..0b77fc64d 100644 --- a/rpc/src/v1/traits/pubsub.rs +++ b/rpc/src/v1/traits/pubsub.rs @@ -16,7 +16,7 @@ //! Parity-specific PUB-SUB rpc interface. -use jsonrpc_core::{Error, Value, Params}; +use jsonrpc_core::{Result, Value, Params}; use jsonrpc_pubsub::SubscriptionId; use jsonrpc_macros::Trailing; use jsonrpc_macros::pubsub::Subscriber; @@ -33,7 +33,7 @@ build_rpc_trait! { /// Unsubscribe from existing Parity subscription. #[rpc(name = "parity_unsubscribe")] - fn parity_unsubscribe(&self, SubscriptionId) -> Result; + fn parity_unsubscribe(&self, SubscriptionId) -> Result; } } } diff --git a/rpc/src/v1/traits/rpc.rs b/rpc/src/v1/traits/rpc.rs index 96a3f48ac..a813aa94e 100644 --- a/rpc/src/v1/traits/rpc.rs +++ b/rpc/src/v1/traits/rpc.rs @@ -18,7 +18,7 @@ use std::collections::BTreeMap; -use jsonrpc_core::Error; +use jsonrpc_core::Result; build_rpc_trait! { /// RPC Interface. @@ -26,11 +26,11 @@ build_rpc_trait! { /// Returns supported modules for Geth 1.3.6 /// @ignore #[rpc(name = "modules")] - fn modules(&self) -> Result, Error>; + fn modules(&self) -> Result>; /// Returns supported modules for Geth 1.4.0 /// @ignore #[rpc(name = "rpc_modules")] - fn rpc_modules(&self) -> Result, Error>; + fn rpc_modules(&self) -> Result>; } } diff --git a/rpc/src/v1/traits/secretstore.rs b/rpc/src/v1/traits/secretstore.rs index c13367562..e625cf331 100644 --- a/rpc/src/v1/traits/secretstore.rs +++ b/rpc/src/v1/traits/secretstore.rs @@ -16,7 +16,7 @@ //! SecretStore-specific rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::types::{H160, H512, Bytes}; @@ -26,16 +26,16 @@ build_rpc_trait! { /// Encrypt data with key, received from secret store. /// Arguments: `account`, `password`, `key`, `data`. #[rpc(name = "secretstore_encrypt")] - fn encrypt(&self, H160, String, Bytes, Bytes) -> Result; + fn encrypt(&self, H160, String, Bytes, Bytes) -> Result; /// Decrypt data with key, received from secret store. /// Arguments: `account`, `password`, `key`, `data`. #[rpc(name = "secretstore_decrypt")] - fn decrypt(&self, H160, String, Bytes, Bytes) -> Result; + fn decrypt(&self, H160, String, Bytes, Bytes) -> Result; /// Decrypt data with shadow key, received from secret store. /// Arguments: `account`, `password`, `decrypted_secret`, `common_point`, `decrypt_shadows`, `data`. #[rpc(name = "secretstore_shadowDecrypt")] - fn shadow_decrypt(&self, H160, String, H512, H512, Vec, Bytes) -> Result; + fn shadow_decrypt(&self, H160, String, H512, H512, Vec, Bytes) -> Result; } } diff --git a/rpc/src/v1/traits/signer.rs b/rpc/src/v1/traits/signer.rs index 107def9f2..b7f60619e 100644 --- a/rpc/src/v1/traits/signer.rs +++ b/rpc/src/v1/traits/signer.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Parity Signer-related rpc interface. -use jsonrpc_core::{BoxFuture, Error}; +use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_pubsub::SubscriptionId; use jsonrpc_macros::pubsub::Subscriber; @@ -28,31 +28,31 @@ build_rpc_trait! { /// Returns a list of items to confirm. #[rpc(name = "signer_requestsToConfirm")] - fn requests_to_confirm(&self) -> Result, Error>; + fn requests_to_confirm(&self) -> Result>; /// Confirm specific request. #[rpc(name = "signer_confirmRequest")] - fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture; + fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture; /// Confirm specific request with token. #[rpc(name = "signer_confirmRequestWithToken")] - fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture; + fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture; /// Confirm specific request with already signed data. #[rpc(name = "signer_confirmRequestRaw")] - fn confirm_request_raw(&self, U256, Bytes) -> Result; + fn confirm_request_raw(&self, U256, Bytes) -> Result; /// Reject the confirmation request. #[rpc(name = "signer_rejectRequest")] - fn reject_request(&self, U256) -> Result; + fn reject_request(&self, U256) -> Result; /// Generates new authorization token. #[rpc(name = "signer_generateAuthorizationToken")] - fn generate_token(&self) -> Result; + fn generate_token(&self) -> Result; /// Generates new web proxy access token for particular domain. #[rpc(name = "signer_generateWebProxyAccessToken")] - fn generate_web_proxy_token(&self, String) -> Result; + fn generate_web_proxy_token(&self, String) -> Result; #[pubsub(name = "signer_pending")] { /// Subscribe to new pending requests on signer interface. @@ -61,7 +61,7 @@ build_rpc_trait! { /// Unsubscribe from pending requests subscription. #[rpc(name = "signer_unsubscribePending")] - fn unsubscribe_pending(&self, SubscriptionId) -> Result; + fn unsubscribe_pending(&self, SubscriptionId) -> Result; } } } diff --git a/rpc/src/v1/traits/traces.rs b/rpc/src/v1/traits/traces.rs index a6cb43810..35b601e3f 100644 --- a/rpc/src/v1/traits/traces.rs +++ b/rpc/src/v1/traits/traces.rs @@ -16,7 +16,7 @@ //! Traces specific rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use jsonrpc_macros::Trailing; use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults, H256, TraceOptions}; @@ -27,34 +27,34 @@ build_rpc_trait! { /// Returns traces matching given filter. #[rpc(name = "trace_filter")] - fn filter(&self, TraceFilter) -> Result>, Error>; + fn filter(&self, TraceFilter) -> Result>>; /// Returns transaction trace at given index. #[rpc(name = "trace_get")] - fn trace(&self, H256, Vec) -> Result, Error>; + fn trace(&self, H256, Vec) -> Result>; /// Returns all traces of given transaction. #[rpc(name = "trace_transaction")] - fn transaction_traces(&self, H256) -> Result>, Error>; + fn transaction_traces(&self, H256) -> Result>>; /// Returns all traces produced at given block. #[rpc(name = "trace_block")] - fn block_traces(&self, BlockNumber) -> Result>, Error>; + fn block_traces(&self, BlockNumber) -> Result>>; /// Executes the given call and returns a number of possible traces for it. #[rpc(meta, name = "trace_call")] - fn call(&self, Self::Metadata, CallRequest, TraceOptions, Trailing) -> Result; + fn call(&self, Self::Metadata, CallRequest, TraceOptions, Trailing) -> Result; /// Executes all given calls and returns a number of possible traces for each of it. #[rpc(meta, name = "trace_callMany")] - fn call_many(&self, Self::Metadata, Vec<(CallRequest, TraceOptions)>, Trailing) -> Result, Error>; + fn call_many(&self, Self::Metadata, Vec<(CallRequest, TraceOptions)>, Trailing) -> Result>; /// Executes the given raw transaction and returns a number of possible traces for it. #[rpc(name = "trace_rawTransaction")] - fn raw_transaction(&self, Bytes, TraceOptions, Trailing) -> Result; + fn raw_transaction(&self, Bytes, TraceOptions, Trailing) -> Result; /// Executes the transaction with the given hash and returns a number of possible traces for it. #[rpc(name = "trace_replayTransaction")] - fn replay_transaction(&self, H256, TraceOptions) -> Result; + fn replay_transaction(&self, H256, TraceOptions) -> Result; } } diff --git a/rpc/src/v1/traits/web3.rs b/rpc/src/v1/traits/web3.rs index b56f028d7..e4fb8b0d1 100644 --- a/rpc/src/v1/traits/web3.rs +++ b/rpc/src/v1/traits/web3.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . //! Web3 rpc interface. -use jsonrpc_core::Error; +use jsonrpc_core::Result; use v1::types::{H256, Bytes}; @@ -24,10 +24,10 @@ build_rpc_trait! { pub trait Web3 { /// Returns current client version. #[rpc(name = "web3_clientVersion")] - fn client_version(&self) -> Result; + fn client_version(&self) -> Result; /// Returns sha3 of the given data #[rpc(name = "web3_sha3")] - fn sha3(&self, Bytes) -> Result; + fn sha3(&self, Bytes) -> Result; } } diff --git a/rpc_client/src/client.rs b/rpc_client/src/client.rs index fa6144fd2..8f330629b 100644 --- a/rpc_client/src/client.rs +++ b/rpc_client/src/client.rs @@ -33,10 +33,12 @@ use serde_json::{ use futures::{Canceled, Complete, Future, oneshot, done}; -use jsonrpc_core::{BoxFuture, Id, Version, Params, Error as JsonRpcError}; +use jsonrpc_core::{Id, Version, Params, Error as JsonRpcError}; use jsonrpc_core::request::MethodCall; use jsonrpc_core::response::{Output, Success, Failure}; +use BoxFuture; + /// The actual websocket connection handler, passed into the /// event loop of ws-rs struct RpcHandler { diff --git a/rpc_client/src/lib.rs b/rpc_client/src/lib.rs index 680c0484b..7981052ed 100644 --- a/rpc_client/src/lib.rs +++ b/rpc_client/src/lib.rs @@ -18,6 +18,8 @@ extern crate log; #[macro_use] extern crate matches; +/// Boxed future response. +pub type BoxFuture = Box + Send>; #[cfg(test)] mod tests { diff --git a/rpc_client/src/signer_client.rs b/rpc_client/src/signer_client.rs index df3744052..cee063109 100644 --- a/rpc_client/src/signer_client.rs +++ b/rpc_client/src/signer_client.rs @@ -4,7 +4,7 @@ use serde; use serde_json::{Value as JsonValue, to_value}; use std::path::PathBuf; use futures::{Canceled}; -use jsonrpc_core::BoxFuture; +use {BoxFuture}; pub struct SignerRpc { rpc: Rpc, diff --git a/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs b/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs index 9c5f4087e..040360d7d 100644 --- a/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs +++ b/secret_store/src/key_server_cluster/admin_sessions/share_add_session.rs @@ -450,7 +450,7 @@ impl SessionImpl where T: SessionTransport { data.key_share_common_point = message.common_point.clone().map(Into::into); data.key_share_encrypted_point = message.encrypted_point.clone().map(Into::into); - let mut id_numbers = data.id_numbers.as_mut() + let id_numbers = data.id_numbers.as_mut() .expect("common key share data is expected after initialization; id_numers are filled during initialization; qed"); for (node, id_number) in &message.id_numbers { let id_number: Secret = id_number.clone().into(); @@ -1153,7 +1153,7 @@ pub mod tests { // check that session has completed on all nodes assert!(ml.nodes.values().all(|n| n.session.is_finished())); - + // check that secret is still the same as before adding the share check_secret_is_preserved(ml.original_key_pair.clone(), ml.nodes.iter().map(|(k, v)| (k.clone(), v.key_storage.clone())).collect()); } @@ -1187,7 +1187,7 @@ pub mod tests { // check that session has completed on all nodes assert!(ml.nodes.values().all(|n| n.session.is_finished())); - + // check that secret is still the same as before adding the share check_secret_is_preserved(ml.original_key_pair.clone(), ml.nodes .iter() @@ -1245,7 +1245,7 @@ pub mod tests { .iter() .map(|(k, v)| (k.clone(), v.key_storage.clone())) .collect()); - + // check that all oldest nodes have versions A, B, C // isolated node has version A, C // new nodes have versions B, C From 7ed2fa84519429a16ebcd4dc66ceac37e39f46bd Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 14 Nov 2017 14:33:05 +0300 Subject: [PATCH 18/31] fixed ethstore-cli output --- ethstore/cli/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ethstore/cli/src/main.rs b/ethstore/cli/src/main.rs index 09ccc8cd4..849985167 100644 --- a/ethstore/cli/src/main.rs +++ b/ethstore/cli/src/main.rs @@ -209,8 +209,8 @@ fn execute(command: I) -> Result where I: IntoIterator(command: I) -> Result where I: IntoIterator Date: Tue, 14 Nov 2017 12:59:01 +0100 Subject: [PATCH 19/31] interleaved-ordered 0.1.1 --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2212967b..5f25c5419 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1180,7 +1180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "interleaved-ordered" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1367,7 +1367,7 @@ version = "0.1.0" dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", - "interleaved-ordered 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3586,7 +3586,7 @@ dependencies = [ "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "356a0dc23a4fa0f8ce4777258085d00a01ea4923b2efd93538fc44bf5e1bda76" "checksum integer-encoding 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a053c9c7dcb7db1f2aa012c37dc176c62e4cdf14898dee0eecc606de835b8acb" -"checksum interleaved-ordered 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e385d0f35662722ffac6301494e37d201e884bd27d263cfbcc058febf994d16" +"checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29d062ee61fccdf25be172e70f34c9f6efc597e1fb8f6526e8437b2046ab26be" "checksum ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)" = "2134e210e2a024b5684f90e1556d5f71a1ce7f8b12e9ac9924c67fb36f63b336" "checksum isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fa500db770a99afe2a0f2229be2a3d09c7ed9d7e4e8440bf71253141994e240f" From 6ddabc0f4903b07fe03bf4425a4e1140c5aca6f0 Mon Sep 17 00:00:00 2001 From: Kirill Pimenov Date: Tue, 14 Nov 2017 13:06:50 +0100 Subject: [PATCH 20/31] Small performance gain in allocations As measured in https://gist.github.com/kirushik/e0d93759b0cd102f814408595c20a9d0, it's much faster not to iterate over zeroes, and just allocate a contiguous array of zeroes directly. --- ethstore/src/account/crypto.rs | 9 ++------- rpc/src/v1/helpers/secretstore.rs | 15 ++++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ethstore/src/account/crypto.rs b/ethstore/src/account/crypto.rs index 7d87b1c69..cc7489514 100755 --- a/ethstore/src/account/crypto.rs +++ b/ethstore/src/account/crypto.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::iter::repeat; use std::str; use ethkey::Secret; use {json, Error, crypto}; @@ -90,9 +89,7 @@ impl Crypto { // preallocated (on-stack in case of `Secret`) buffer to hold cipher // length = length(plain) as we are using CTR-approach let plain_len = plain.len(); - let mut ciphertext: SmallVec<[u8; 32]> = SmallVec::new(); - ciphertext.grow(plain_len); - ciphertext.extend(repeat(0).take(plain_len)); + let mut ciphertext: SmallVec<[u8; 32]> = SmallVec::from_vec(vec![0; plain_len]); // aes-128-ctr with initial vector of iv crypto::aes::encrypt(&derived_left_bits, &iv, plain, &mut *ciphertext); @@ -143,9 +140,7 @@ impl Crypto { return Err(Error::InvalidPassword); } - let mut plain: SmallVec<[u8; 32]> = SmallVec::new(); - plain.grow(expected_len); - plain.extend(repeat(0).take(expected_len)); + let mut plain: SmallVec<[u8; 32]> = SmallVec::from_vec(vec![0; expected_len]); match self.cipher { Cipher::Aes128Ctr(ref params) => { diff --git a/rpc/src/v1/helpers/secretstore.rs b/rpc/src/v1/helpers/secretstore.rs index b5528c778..39709e78e 100644 --- a/rpc/src/v1/helpers/secretstore.rs +++ b/rpc/src/v1/helpers/secretstore.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::iter::repeat; use rand::{Rng, OsRng}; use ethkey::{Public, Secret, math}; use crypto; @@ -32,10 +31,13 @@ pub fn encrypt_document(key: Bytes, document: Bytes) -> Result { // use symmetric encryption to encrypt document let iv = initialization_vector(); - let mut encrypted_document = Vec::with_capacity(document.len() + iv.len()); - encrypted_document.extend(repeat(0).take(document.len())); - crypto::aes::encrypt(&key, &iv, &document, &mut encrypted_document); - encrypted_document.extend_from_slice(&iv); + let mut encrypted_document = vec![0; document.len() + iv.len()]; + { + let (mut encryption_buffer, iv_buffer) = encrypted_document.split_at_mut(document.len()); + + crypto::aes::encrypt(&key, &iv, &document, &mut encryption_buffer); + iv_buffer.copy_from_slice(&iv); + } Ok(encrypted_document) } @@ -53,8 +55,7 @@ pub fn decrypt_document(key: Bytes, mut encrypted_document: Bytes) -> Result Date: Tue, 14 Nov 2017 13:20:36 +0100 Subject: [PATCH 21/31] static linking for snappy --- util/snappy/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/snappy/src/lib.rs b/util/snappy/src/lib.rs index 29b042125..230c336b5 100644 --- a/util/snappy/src/lib.rs +++ b/util/snappy/src/lib.rs @@ -24,7 +24,7 @@ const SNAPPY_OK: c_int = 0; const SNAPPY_INVALID_INPUT: c_int = 1; const SNAPPY_BUFFER_TOO_SMALL: c_int = 2; -#[link(name = "snappy")] +#[link(name = "snappy", kind = "static")] extern { fn snappy_compress( input: *const c_char, From a22c48b6b001735c7bd40d57afc2e8ebec4de3f3 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 14 Nov 2017 17:47:41 +0100 Subject: [PATCH 22/31] removed redundant imports --- Cargo.lock | 9 ++------- ethcore/light/Cargo.toml | 4 +++- ethcore/light/src/client/service.rs | 6 +++--- ethcore/light/src/lib.rs | 2 +- ethcore/light/src/net/load_timer.rs | 5 +++-- ipfs/Cargo.toml | 1 - ipfs/src/lib.rs | 1 - local-store/Cargo.toml | 1 - local-store/src/lib.rs | 1 - secret_store/Cargo.toml | 4 +++- secret_store/src/key_storage.rs | 16 +++++++++------- secret_store/src/lib.rs | 1 - stratum/Cargo.toml | 14 +++++++------- stratum/src/lib.rs | 2 -- sync/Cargo.toml | 1 - sync/src/lib.rs | 1 - 16 files changed, 31 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1c089df2..7d77935fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -586,7 +586,6 @@ dependencies = [ "ethcore 1.9.0", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", - "ethcore-devtools 1.9.0", "ethcore-io 1.9.0", "ethcore-network 1.9.0", "ethcore-util 1.9.0", @@ -610,6 +609,7 @@ dependencies = [ "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", "triehash 0.1.0", "vm 0.1.0", @@ -673,7 +673,6 @@ dependencies = [ "ethcore 1.9.0", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", - "ethcore-devtools 1.9.0", "ethcore-logger 1.9.0", "ethcore-util 1.9.0", "ethcrypto 0.1.0", @@ -692,6 +691,7 @@ dependencies = [ "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -706,9 +706,7 @@ version = "1.9.0" dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", - "ethcore-devtools 1.9.0", "ethcore-logger 1.9.0", - "ethcore-util 1.9.0", "hash 0.1.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", @@ -847,7 +845,6 @@ dependencies = [ "ethcore 1.9.0", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", - "ethcore-devtools 1.9.0", "ethcore-io 1.9.0", "ethcore-light 1.9.0", "ethcore-network 1.9.0", @@ -2057,7 +2054,6 @@ dependencies = [ "ethcore 1.9.0", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", - "ethcore-util 1.9.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "multihash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2071,7 +2067,6 @@ version = "0.1.0" dependencies = [ "ethcore 1.9.0", "ethcore-io 1.9.0", - "ethcore-util 1.9.0", "ethkey 0.2.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 2b56a30bd..c8b42f4ec 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -16,7 +16,6 @@ memorydb = { path = "../../util/memorydb" } patricia_trie = { path = "../../util/patricia_trie" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } -ethcore-devtools = { path = "../../devtools" } evm = { path = "../evm" } heapsize = "0.4" vm = { path = "../vm" } @@ -39,5 +38,8 @@ kvdb-rocksdb = { path = "../../util/kvdb-rocksdb" } kvdb-memorydb = { path = "../../util/kvdb-memorydb" } memory-cache = { path = "../../util/memory_cache" } +[dev-dependencies] +tempdir = "0.3" + [features] default = [] diff --git a/ethcore/light/src/client/service.rs b/ethcore/light/src/client/service.rs index b05c7dacb..b28169c5d 100644 --- a/ethcore/light/src/client/service.rs +++ b/ethcore/light/src/client/service.rs @@ -120,7 +120,6 @@ impl IoHandler for ImportBlocks { #[cfg(test)] mod tests { use super::Service; - use devtools::RandomTempPath; use ethcore::spec::Spec; use std::sync::Arc; @@ -128,13 +127,14 @@ mod tests { use client::fetch; use time::Duration; use parking_lot::Mutex; + use tempdir::TempDir; #[test] fn it_works() { + let tempdir = TempDir::new("").unwrap(); let spec = Spec::new_test(); - let temp_path = RandomTempPath::new(); let cache = Arc::new(Mutex::new(Cache::new(Default::default(), Duration::hours(6)))); - Service::start(Default::default(), &spec, fetch::unavailable(), temp_path.as_path(), cache).unwrap(); + Service::start(Default::default(), &spec, fetch::unavailable(), tempdir.path(), cache).unwrap(); } } diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index f9c3d89b8..529aed608 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -84,4 +84,4 @@ extern crate kvdb_rocksdb; extern crate memory_cache; #[cfg(test)] -extern crate ethcore_devtools as devtools; +extern crate tempdir; diff --git a/ethcore/light/src/net/load_timer.rs b/ethcore/light/src/net/load_timer.rs index 8df8fdf17..6b522f920 100644 --- a/ethcore/light/src/net/load_timer.rs +++ b/ethcore/light/src/net/load_timer.rs @@ -264,8 +264,9 @@ mod tests { #[test] fn file_store() { - let path = ::devtools::RandomTempPath::new(); - let store = FileStore(path.as_path().clone()); + let tempdir = ::tempdir::TempDir::new("").unwrap(); + let path = tempdir.path().join("file"); + let store = FileStore(path); let mut samples = store.load(); assert!(samples.is_empty()); diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml index 0e8b21c15..da3b48eef 100644 --- a/ipfs/Cargo.toml +++ b/ipfs/Cargo.toml @@ -7,7 +7,6 @@ authors = ["Parity Technologies "] [dependencies] ethcore = { path = "../ethcore" } -ethcore-util = { path = "../util" } ethcore-bigint = { path = "../util/bigint" } ethcore-bytes = { path = "../util/bytes" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } diff --git a/ipfs/src/lib.rs b/ipfs/src/lib.rs index ef6184b1b..b92108b52 100644 --- a/ipfs/src/lib.rs +++ b/ipfs/src/lib.rs @@ -20,7 +20,6 @@ extern crate unicase; extern crate rlp; extern crate ethcore; -extern crate ethcore_util as util; extern crate ethcore_bigint as bigint; extern crate ethcore_bytes as bytes; extern crate jsonrpc_core as core; diff --git a/local-store/Cargo.toml b/local-store/Cargo.toml index e4b97f7a4..7dd73d464 100644 --- a/local-store/Cargo.toml +++ b/local-store/Cargo.toml @@ -5,7 +5,6 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -ethcore-util = { path = "../util" } ethcore-io = { path = "../util/io" } ethcore = { path = "../ethcore" } rlp = { path = "../util/rlp" } diff --git a/local-store/src/lib.rs b/local-store/src/lib.rs index 694fa7aea..ccd2b11b7 100644 --- a/local-store/src/lib.rs +++ b/local-store/src/lib.rs @@ -29,7 +29,6 @@ use rlp::UntrustedRlp; use kvdb::KeyValueDB; extern crate ethcore; -extern crate ethcore_util as util; extern crate ethcore_io as io; extern crate rlp; extern crate serde_json; diff --git a/secret_store/Cargo.toml b/secret_store/Cargo.toml index 8357b530b..432b08c42 100644 --- a/secret_store/Cargo.toml +++ b/secret_store/Cargo.toml @@ -24,7 +24,6 @@ tokio-proto = "0.1" url = "1.0" ethcore = { path = "../ethcore" } ethcore-bytes = { path = "../util/bytes" } -ethcore-devtools = { path = "../devtools" } ethcore-util = { path = "../util" } ethcore-bigint = { path = "../util/bigint" } kvdb = { path = "../util/kvdb" } @@ -35,3 +34,6 @@ ethcrypto = { path = "../ethcrypto" } ethkey = { path = "../ethkey" } native-contracts = { path = "../ethcore/native_contracts" } lazy_static = "0.2" + +[dev-dependencies] +tempdir = "0.3" diff --git a/secret_store/src/key_storage.rs b/secret_store/src/key_storage.rs index eb100f388..fec58de2b 100644 --- a/secret_store/src/key_storage.rs +++ b/secret_store/src/key_storage.rs @@ -366,10 +366,12 @@ impl From for DocumentKeyShare { #[cfg(test)] pub mod tests { + extern crate tempdir; + use std::collections::{BTreeMap, HashMap}; use parking_lot::RwLock; use serde_json; - use devtools::RandomTempPath; + use self::tempdir::TempDir; use ethkey::{Random, Generator, Public, Secret}; use kvdb_rocksdb::Database; use types::all::{Error, NodeAddress, ServiceConfiguration, ClusterConfiguration, ServerKeyId}; @@ -419,11 +421,11 @@ pub mod tests { #[test] fn persistent_key_storage() { - let path = RandomTempPath::create_dir(); + let tempdir = TempDir::new("").unwrap(); let config = ServiceConfiguration { listener_address: None, acl_check_enabled: true, - data_path: path.as_str().to_owned(), + data_path: tempdir.path().display().to_string(), cluster_config: ClusterConfiguration { threads: 1, listener_address: NodeAddress { @@ -482,8 +484,8 @@ pub mod tests { #[test] fn upgrade_db_from_0() { - let db_path = RandomTempPath::create_dir(); - let db = Database::open_default(db_path.as_str()).unwrap(); + let tempdir = TempDir::new("").unwrap(); + let db = Database::open_default(&tempdir.path().display().to_string()).unwrap(); // prepare v0 database { @@ -523,8 +525,8 @@ pub mod tests { #[test] fn upgrade_db_from_1() { - let db_path = RandomTempPath::create_dir(); - let db = Database::open_default(db_path.as_str()).unwrap(); + let tempdir = TempDir::new("").unwrap(); + let db = Database::open_default(&tempdir.path().display().to_string()).unwrap(); // prepare v1 database { diff --git a/secret_store/src/lib.rs b/secret_store/src/lib.rs index 5951be508..9979578c7 100644 --- a/secret_store/src/lib.rs +++ b/secret_store/src/lib.rs @@ -37,7 +37,6 @@ extern crate tokio_proto; extern crate url; extern crate ethcore; -extern crate ethcore_devtools as devtools; extern crate ethcore_bytes as bytes; extern crate ethcore_util as util; extern crate ethcore_bigint as bigint; diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index c62c9c81b..35d8d07b4 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -6,16 +6,16 @@ license = "GPL-3.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +ethcore-bigint = { path = "../util/bigint" } +ethcore-logger = { path = "../logger" } +hash = { path = "../util/hash" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } -ethcore-util = { path = "../util" } -ethcore-bigint = { path = "../util/bigint" } -ethcore-devtools = { path = "../devtools" } +log = "0.3" +parking_lot = "0.4" + +[dev-dependencies] env_logger = "0.4" tokio-core = "0.1" tokio-io = "0.1" -parking_lot = "0.4" -ethcore-logger = { path = "../logger" } -hash = { path = "../util/hash" } diff --git a/stratum/src/lib.rs b/stratum/src/lib.rs index 229f36acc..63a2804e0 100644 --- a/stratum/src/lib.rs +++ b/stratum/src/lib.rs @@ -20,7 +20,6 @@ extern crate jsonrpc_tcp_server; extern crate jsonrpc_core; extern crate jsonrpc_macros; #[macro_use] extern crate log; -extern crate ethcore_util as util; extern crate ethcore_bigint as bigint; extern crate hash; extern crate parking_lot; @@ -28,7 +27,6 @@ extern crate parking_lot; #[cfg(test)] extern crate tokio_core; #[cfg(test)] extern crate tokio_io; #[cfg(test)] extern crate ethcore_logger; -#[cfg(test)] extern crate env_logger; mod traits; diff --git a/sync/Cargo.toml b/sync/Cargo.toml index a1941fec4..970d47bca 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -34,7 +34,6 @@ ipnetwork = "0.12.6" [dev-dependencies] ethkey = { path = "../ethkey" } kvdb-memorydb = { path = "../util/kvdb-memorydb" } -ethcore-devtools = { path = "../devtools" } [features] default = [] diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 0495d72a7..caa8cb22d 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -46,7 +46,6 @@ extern crate kvdb; extern crate ethcore_light as light; -#[cfg(test)] extern crate ethcore_devtools as devtools; #[cfg(test)] extern crate ethkey; #[cfg(test)] extern crate kvdb_memorydb; From 4dd30974935940e7adf7d3bac2cb2863e26c13c2 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Tue, 14 Nov 2017 19:30:35 +0000 Subject: [PATCH 23/31] Add the desktop file for the snap Now that we have added plugs to allow accessing the display, the snap needs a desktop file. And bonus point, it will appear on the menu when it's installed, and once you make a stable relase, it will appear in the gnome software center app! So, one-click install for parity :) Closes: #7056 --- snap/gui/icon.png | Bin 0 -> 4386 bytes snap/gui/parity.desktop | 8 ++++++++ 2 files changed, 8 insertions(+) create mode 100644 snap/gui/icon.png create mode 100644 snap/gui/parity.desktop diff --git a/snap/gui/icon.png b/snap/gui/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b2aea789e82472d574be6e74a9f3bb9dc92004df GIT binary patch literal 4386 zcmcgw^;Z*)+Z~{EgY<@of^;`SK{`eWf}^{0gpvaR=@do{3_w(JbPkZx5d#zkQcA~| zbO~QRf5iKq=iGbGx#!$-e|Ua+o(`R(a}~nxzWY{Ku&tY!DpnxH$v*5 zr=iQk-O1T*;qZjF zfKB;W^XU%xLko%5G53f*tfb=%t4o?OJEJ@J&XbcOR6^j={wN+A>{8JoM$Yq!UhV&y zjLoDoDb?e@kbB+o0vrMqi9Q2%;j-ue?2r1)no*K9l0{-$B3pndJQ2N(PDZO$K6_mz zO>#_%Pb7BLL2sKbDcZfB65YzLg4e-gt0rVfXCUSDN4=uh3_qQ;>OFXNG>c^VN6j`8 zEuv{aMABs#on63aO!bTmrG@4i^NVuZDQHS^Q7})fZ{i}-_O|Nu>3OWa@cvk*9|;funl! zFwi>5hM_FI7iRw>-AjZ(R>9qhJhJ<-w(U%F)jO}f4f>&2W+$sBe5uhiL%ij*J z^=bbl8LPaZGW7?~i6(`C9xCJc`xRDcPnZ6M&ad`8Ry2892)oTkG$P`439RKK7_3+=C}SoB@8!Tj`mHL+93sIaQ*R zQ5Ci1hQVMdpM_VuRunc^h_s%;Rm2VtJ6MNgJPTP`oUdQvOz=8H@d%O6+BKaL3N~3P zA!4m=yZf@os0>>L>h5sT1!oX4(9BM6NqNcL&INvHiPc+W#4sk;^dIrf>`@DbFzZd- zJ&{*b)6#3rR;HCAyC2&16HSEG>ucQgg+GBefewpcrxC4IjZN|xEKzWMP8hNRUC4A) z>L1n$1s``zJ4)K}+w1p+ZHVSo(X=UXT-D?TOz*GkNJ%I;{H|qP&XpZSJAF(0&Py?S z_1Fi>8NP0J*vz$ZK2&p7nXvA8dnW;xt-#Pd*Ry6XYdyI7_m(#|?{t-ql}VMD-v%7g zXIKztMBT#-&fgXwPuG%a<@NPC3FV7M;V;7yg=2jelJ9zEjYt@)ISQGkwW%g{{lq@zaD5FsN!PicOX=oItK4v>mCKdZLULxpW0H!}} z0A~3(Qbctr!sfxbXHuBzDAchj$eS9B7hoOZw+7N|W`Tv=RkJ+`tHQqhJ^Pu4OZyBe z$u3-H$_x5ZmsX!G{B+Nv?7X9YnSC!EH;^cCSn1KC@W-ilw?IDme7-n}ec6?lRdMU^ zB;e$7{2Mk@G%=xopS)vO=G~%@a7l=h{uwXuNYPxhgc}qn{%bO=-WNh2-q;{|RNH?L zne({I1^hWfHBHlV{cd|;44U(KY#VaNvODhA?#IQWm2=!dV{8w^Kj+^b0v=+Ty44of zkJ@83J!VN$T(GS!5m~4ADfT`BcAl^GuMD-*R#f+_X zEQZFZUh!Mf2IqiTs0o+0)}7_x6l-Hdv)5bv4<wBTSM68KZ>V@D!C00ttMW`y#2zL+db*!O8E*RwzOY$(uOh4 z>AjSVVEQ&YJHf*A;~;MJdBP$RE)ej$_b;vQb8%d5|Jd1t@!Y z>`oYaoQ#Plpj#AOIGe)cUB7dgQxDv)--oAKuj#HXcX6xvhy^IL5(wGVzZ1J7c8pDv#Tw5Awy230Wasvq<(`dbWQKO%j79 zR|}F_Thet6Bb+90Y^_GO!1Sn85|PzMyn#+J-fQ(FWrE!uzv;uj4|?^<%IV#7F(Jp- zAD>ePlXsvToBX58E+?JR^lPhb1)-j<=CS7{U8|^aF48ykrfCmI$?hhQh2}n93;tMzb1el8rH_wFKaVilob&B_1#Tk4MjB2=F+_v_H zvHDYidy{^1?X`C0u-M6S(uJv4yB(IQk%l)lpxWAN$D8(-3|AS#Pa$%lsrs4h>!sfe z^Tm5433$lNsOQ5uGZ2ohopEgBgJAcLzM_JuY|Y(^W=Rdc9Xt1nJ0AqEXV&!Db8Cz9 zuq^c*b;V`7b2?^M3OJLqKTJ)gm56uoQk#xp@g@RF#CC-&b`;|R_Rz66nGw>Ob!Ea&xW@ip5%He z4b)v%6mz&+&OF~qp!Uyv4EULe17A5Woz2wQY(Wh*m?j-l;;J4^e%0;bv&=H7o;H0~ zOxTIWwHOVL4(ga~5^9~7cJXhk*7b(EtX#--$(Bf{I1L|fhg8}ZlCM`rciQ}n6E4&e z%l%web7UhToSqM^c3O->ms2K$)5<|fca9?SnIfe7yy&CITi$FfC^pKjo?v7l9>3I= zGeocN6^l3-DV|L%27D?!Myn#+PhF$oW)72?=n58D>sP~hlUDW_Dq%N^Kp|&^f^GKN z1+hQ25cAvz5@+gK*){c(S|oc8&vGv!vVhl&poOibz7ccKEay|T<2AF7?V^Y(UmE`Q z3dbx(YjUqlwF`rHtm}UelmD86xhTG@omREPsr5hNw&d_?j^3R&A$e&StwHAp^K;5gj&`s-B7MlL~NK|Tj<~1)u{;5#8a4wMpel%m-MCjGco<& z%SZ3KZNcXdUxw32AHYI}<)!0AQ|FLlVX9$Y)IF({-0kRoER|~L3Mjc0O5K648*w0$ zGUJdhk@l)LkFy=)`YrzJ@P%4y-42selGQ%tux>~)qt_OFXoPZ8m;jDN4rkWsr7>II zuyc(4aV5ShK>^?Ih10@Aid@03W>~krDI#WRIR!@}2h4@7^OOZX7qb1fv@u)~V;5?o zS!H69>AJ$V{u_AXnc(y#9fa;jcO@yHF>bOmF6y~*^^{jaiw*t4M!vcGDC&o7-E&sS z5*H#76Y_VK3={&|kmzFcSr7-z^Y0|hbnJnjDT%hZbp z(go?Y(kvAf6f#`Lv=FCIGE)X2-Ybt`#nU}LQJ()b^q9L?2r#YbTO>t5X}2j7_#e5;v(^T4g*3;PuDb52`$9}a>cz(;%ZQE3GiSc z5SMFeG@`&RR0TD&iIoI(%0+?scj?z*(fKTJNs`c8QoIVa>gfS(PnO~knVq?_L;dv> zYs?pnn9O1is;{w0x8}DW4|=?aW)<&Ons92>R<)KWbW(D71de)j6Ok`zg!C8%tEEy; zKPS4Vl}_K3!cvK*C&ta%yNGxDI&Hr|WN(=b&bYDF+l=lVcqO1Y={G}BpN&T!BYq}! z%`Xat;`0&tlgZ+fCqlPh5>cmnUEL{TqTRC*NopAW2@_nCCQP{n+^37X_p{fD2n8JU zWpx*Ak2V1Vk9xV)^aMgX%K_1 zj<-ZUC$Y%h*E2ha7J_rWx2auYvmgYw786`Qee(w$>rn)fx2OFOZ~sKh5ig21TKc33 ze!sW<0r0sJ!$u3(3|L=buYf+R~MQ={mgzV7;AK-X=f#!^eM;L z%U?ProDEgpPNiEm)|#3FA8AMUUIPP|=u+r<>``Vjkxu0V5o-$cW?4F!v@ zS$@eW4~lY5p-Yy4_gjR79LKuhpzy0JdK!sYyJPoY$oTQf2Jdwh^WhIt6ni_j zOL{4N>$2TWHkPlmJS(zsd>Fd|r*AEjbJ4k{J`M)axK6HF=?^&be2P~^XpG<2F)8WW z@o~$?N_kOp37IA-M;_oNm;=>6vet^O4H-dm@pMHA3O(XL6y$_&lOH5_R3)c}zxV%e e;b)Rv(FvmFqH~_)VsE|~038j8dbOHe%>MvaNmQT! literal 0 HcmV?d00001 diff --git a/snap/gui/parity.desktop b/snap/gui/parity.desktop new file mode 100644 index 000000000..46453b7fd --- /dev/null +++ b/snap/gui/parity.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Encoding=UTF-8 +Name=parity +Comment=Fast, light, robust Ethereum implementation +Exec=parity +Icon=${SNAP}/meta/gui/icon.png +Terminal=true From cab5b09591310b25202ee623dbb347d741d7f89c Mon Sep 17 00:00:00 2001 From: "Denis S. Soldatov aka General-Beck" Date: Tue, 14 Nov 2017 22:45:14 +0300 Subject: [PATCH 24/31] update icon for desktop --- snap/gui/icon.png | Bin 4386 -> 10671 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/snap/gui/icon.png b/snap/gui/icon.png index b2aea789e82472d574be6e74a9f3bb9dc92004df..35238121adfd1fdb130497498b1a33f74bceff92 100644 GIT binary patch literal 10671 zcmY*~Ju{kS; zkW=VDMRTfQa)|Z2=l%Kq@q2i9nBDh%UH5feufy~8e7<5#jP>{Ni1C0xpnaDNbj&~? zFz^u!f^z|X?7j0{fj?Z%SM+s2|2RLCro2Spo4t1pYh^e6CEN0V*q^1hV7 zCccQO^U62+$0J`>*-WNBX>WVLJcEG5wZILr2?t67RDv--7HyQjs2wy^=D)xAXz3%) zX^)g8euiWMr%HEW+Kl^N7?Q0QPt6kf<^Yu3lD>)Eh zFC7}BoV3NRE3zzkT;#;%?7bJd)0tXPq4;GrBZ=7Cz78_Th<-G1&`X?MYX5?%$+_MN z75JKIi0_{|1+ArTMT$+o^sd{ku|FmS(iBPl`|byfcM-x+K_+;M>Rk9vrM~|CxnbSP zJ1GJL71WkVJfC#v=N*hPEiR?M;=0lPbtF;F>Jl6)&`}m99eO^oN|`VYu4XarNHCHx(wbi^)Ytp_0+4(K5WoN++7%6FQB1{k97m z)11arv-5LzLerOP!Y>j8&ntpPPl=}^H=iH2Sx!n0+x%enzxR<#Qa#1>3D)TfdcI(~ z1wQ0nSx#pL{C81D;mMn)F|YRoW-c(DTs=-$c29!N{Womza#vRsUx&ZY^w6oR{fT^o zN;zh8N_CgDK;-Bwg_Y13a68aRpPd41gwdw=Ci;imUNBrbT5)LZ>N&ovd(KVz1;)d_ z=0oh-JLQ2TND9TY2kV_&2*bP?V1)><`Om+<@y2X3cy~OwI$~UB%S}K7KIJ>Mtdeps z+4zaq=X$^6htGQ-y{3?ie?BP;2t&r>(_~dfV^Nw)4lyo~#oB}&?wYQ=m+hNWCtxU!mT}gvP?FP*Im~FL1_31FOc;(E61gtW^y7_ z7_@NiNd_D8PQ2`qG+?7wv}c|E@K`+5u=3&&Ev7iAja zE>jMJ%u3t3qM6N%SW$fNTu!nvR&58n@JOF{*LjwZgtC+xvbia72Uj{95-xxpc5)G(>%Si;PYP&={|7NtLCWQHX`$3o zcVKZ=sL@Vm-Ap=`Gv2GAxz*wzrzL6$e&UJS+7&c?YhKFX=hG`WGAXC`IF>9hCv`Sd zzb*e=+1iFdq)4}}ug#Af&kXr+DFCy&4^(I5fEEZm<29-A!9Z&tQFDQj^%*ZI0Exah zd!#n#AnDZt(^T4HpZ*W`KS)sEK0_5zxg0M|9d#*CxLEOF3A_WX_^%zk8X8vUYLj*) z=V{4u5%EqaYvX1KHR=vA91EA6zZD(A4+%_O*w7dy8Y8qhBMIQ3t2bI|h_bJ*02}C5 zmuZ;MuhY=H@pz$pPb=|N;5Ps2=JvlKKZO@JR?a{?qrhyk{h6KLDI1Pi_Uz1+XK=6% z-_KH8+Be3^%)g8SDy<_`UCsUD+4}%LIbQ!hCyG9GAl~L$hx5HmWufjHqb7YXxbE&H z;d?85{Bz8Lv@=lu9xpZLhOG(D^(2r2NT+`hmJ>+#u2z_Z32YJm%6pE3?|ivV$nyLWcJ&+qt_aAu>b?}}1b?DYzx4(E#O1^W+kte_uE z1(L>xvjkG+Ib4y0#)S)i>q~v!$s}e%Z;4ICvmrs=H=w9nhM?uk(zKXpI?up~QjMnW zsfE~@oxJ+@E`#`iiv$7YMR+3M+FpL?SLBii#JJ6HK5Ex5F{jJhFfGuY1P|#7agj+F zbE|{8susLFI5@ff>+@gvbgF*S&hcs0kY{kas}6N5U(|yC^v)5KJMe&|+^!}3QLdv` zgEFpnO_+SbZ_|O zx^gOByq3F2Xj9@mVbUt9DP!!$xXTmhv#{`Z& zW+>P2_EEyk7tR-Wmy!0(I*RGrFyQPC`q`!_#`OLcI6v9q8?{|238gI7zcBM39KvHi zn#(5tdtH-U5=Ez|6SmENG6sdx{iF51(WM-qeSi&zNvz~nK7_G(a~7r5GT0l__oH%S zCU#)*@rN6hBFAtSvhT5KU%Jy|+5|EY8T`2iWI}5FSOUawf#weqC+~MF%u9de1LZaFrOl#i zYi><`9rZIJ=;n366U(0UXgtrehBvDaB1~_g8{Wpd_(WUefw#YEu&rv~nu-$Lfj? z9K6sL^XOvhR6i|VJbspOR*D2~c~$w)Ue52dVy;s>osvd74<%|&GVYO5N_(s>|8vN2 zmI8gn6f9<^(MbosCJ0`A<2?C~vefZ=8eQ&2dly<&Rpxdf`Nj$) z4Lu5}dI^|q*z*oW(0l&`@vKb*Z?v&6Bzk{+q-g|jl%MfahNALGzjss26kFNd2hJud z#pvYfjq-sqZy#3Mbv)?^y>VSTly1HY(uhsIt`mr@qEnWOy6)flgKTVxYw+Dd)Z3&T zkQEF}e80O3n!vfmiE~o3<>YNLo#NwbdyWkRdAJj)TS0utK&$6l^C?eilnooQGZ=yiFGDg1!r(8`zJ+4GJe|h|RNn%bF znYaxbukeU3nc$NSQC%FQ7NkDH*vKXa>;?1Ad(-vDbq$8`$)XLq)*18YA+c2ul~}wZZi6mphj!LjEX9I?KsmpHd*CMT{si42jXT#&92rYXPCpg-V?7UfGf&t^P4%{g?^i&3ln8kE1{<+Yl{#d&imbIN>aBfaeL_PTIu*M2rulfJc13!LlSmuR-&8`a zrp1H^*2;G+($D+c9ha77RTNn2n5+>24iM>F`)v4A3Nz6v8!MHfn^GRB`rP5;M2|x4 z^>JMfvj)24{=Y|D-&7_Ev^_Mwe!XzKw#Q9Wuw3|Bro>9A3$oq|*hiL_+C*_*?j}M8 zNH>d^QcLcqpjV68ioiKC{vcVg#t2|bMm$WVK)?c32`E9m!M=&!UHmYulShjQ>A%~X z`e7c8$xro^-0Nu4tspD@RU{0h8_kAPQHLJXr+S*~#da&GWTC7mG!%}Ri2hiV+E?`UwX4S>Zok+jC`>wu5E=~g%s)7$kWY~d|0$hAJ!e#>{A5%EW!?GAeE(s@<($eqBhyE2%3Rz9u2q#Wte@`fcHlch zh{iYDP1~?~E6yrE_b6x~s43tLtu+^sp9Yoxq_ z{}y<^StRFyUrwto0vUDyf%=q-EZ1+MoFT{nqxs|m?joVyb2D!0}mcAaZ#RxUt7 z!$P6h@-Sa0O*Q{W^FV~@jjpPn1F}uubkQcFdRba%>qLVaZsq=5F~-+&koinxexbL@ zTRbKO>S#UQam=qnS;z$`*D7zJn^!P^FyBO&o7b%~k+;fR4;nxKe=4Qw=V5s8Z1OL= zter@!KXMIBH&6dL*x^4%tl2Cwi4D=U_@!53sehWF=T!4pLYDJT22~$OJLi>Wl;X5> z16|505#J`b%0_3mLit`Hhp9s~dupqV(9Bz&87Ag4cN~=_&w>UFwl5~`K<~ZYST%MM z(KR}rWSrMuBwr)pSCZ3qs$t5QO@49#q0WMIP1p1t+yAnlap?;BBlwP(+B`w?T{5n@ z{qP!@%-=-eVat(}nPI2yXz=?9rP({ zF}s+)*g8E4swHysmn@PGXtv6#-if@!fa!iEfCGjRvFa?c8?s3fU!%4F`+K71VeIk zL=0`i`c#I1P^gK{KOe4~%*huz4lJ_SiO2Nj{xGO0o2)midVex|bov^aQEA(xjz6I> zcNIOwFT5cS2CQ!h9sN^2r_1LZ>-U-R2FGN7Eqr%OlF=&-yizxQ3c7+k+b%K7H=T53 z`LEUhqUQdEO+?%vqV!Z?oNfQHMC2m3zhLA7ZTW`*bkirCUDggw5@y~o}^%UQm<5W~~94NEWlba2!a zPXI&AtBhm;(|w1>03*>VAL8t?S}xj@FG*|-A_ORlTFYS(qi)Lhzk+}PUzII%y(UPz z^YoxU5Wb|zfQ2h3>zJb%X9>K;I7btuNk<{(NZXdc}DeHoCgq~glRPc zb_GGjSfj0(NazqEM7N|U-_?EFd|cIe>yfR>ZO#S^JPdD&)!@-jFo-l|4IrM^NJwGF zBV*;(afFr-rL=X%+3bnxy@ZwlA*@J`!t71kpI1|@PH*oQ{CwI{!E18K$tT8?pow2U zvhmQ?%Cv8^4bRj*SF!I+aUWN)CAj@e%&@C;*y&rTBW4w^yax=WS1anTHkB+o2ccY$ z7WzPfKiQe-j0=(dL!3fX(A8wQg4;R|4gQ`n^Dkt|er4@|?AL`8Q z*nvMgNc)BdG4m^+18Lz`fRtzJB@^<%)E9i8De+uLPm_lQaRrh)xbPFQXuOt+n>s?5 zygN)#ep1U|w%k|L@ilf2)08b5sdG~yw(wn7BGKH(-V|;9SxyEQiyVp1ayHe$-< z^5JD6-2UQgVqafLtCl3=1h~DvxKADvWW&O?%dyR7hTG!?A;a7{ldUVZEud)b8@@dQURC zjF7IoKxpChVY<}_$FE)_I z1CYpMaU~A`lxqz!5!B0?bLD$U$4)cuUE_X& zu6C=jB!Wr5ZKh5nupvtQmyyKq%pEx3tA)V)pL;3ON!{;t!-4w^-K~}EFvRe0BlG*A z9}_4L4yTeWK_{D{RD{*r_lL7p2F>1vx|rNWtt2`Y_N4`nIk4hJt6XHn`pN0e1%AEb+Kl0$ zsVG{bBA=p5$liu7conPjK>a1Cr*v@kwN{=(RPqnBNtLa|H#9urKj>qp@8!z$JO$YG z_a0&rh!Pj^tQ6!O(>`uEnhAbe>m`H5+xd6D|K77k3hQ|=~1C1$2?Yl_Sv>PVK zvLT;~EOO*Y)DgF!&FEm**hhOag3TDrp0~`Nz}faoM-?Wnp4G+zbr*_FKCk}l-~Sc#@cJt#Qfm2{ROd5H$h0i#Rw8-GtsTIyA7)~BL`_6-1&o%b zm{?={Yu~NLtuUzYHY|Moi0sjy&87>T0@&*X1s2u|PW$&>sn8{P_o^p|J6TkHZjYM; z#nrNJJfk=357z^S@PRt|=qSj6F@t6ThdSG#(ua36Kt%?z$+IN`QUD);FX58|^O9}a zUu~1`7LK>$9a(OEl7RgL=2XtSiZJ!n0)nC>kStEvN{M|(WB!Y~YpxIG(b$_rO@K3O zeuas(KNF;$;yUkw+!ry6mK@-NMjJnzaPxEAOA*uqL;0yD%$$8j6-yWb3W%~j_^G^9 zBN#y^Z*Cols5yu1;OC6=w*d8{AU}WN)vD>hTHd(O| z570#6_=9mgMcOSiAHdPAvb;TLOzVW9;aJoZy7vAHFVNd1x6p9-LEaeS$tCNv1wNcS z;b?}6yv>GOYn3%z*@a7-Vj)DYL|!_}<#be7e?NT)4q-U&Kj79e3alnz7p@g`IuoIt zNhMT$gTdS3*`t3eY+ab5x(UbXvV^b!9m>$EXwBFXCnu3_XlA|bu||X5gFwlBolo4E zNxyekT>!64c%Ce3W8DN=RT1WjG#!39AUfH}m_GOEd|c}&Qg4un#B3;f?!ZT$6p(T5 ztDA<^h+faZ+W^(FHX>IgRb6g_EG6tMKUVQdJknNhmK%K+S zzOx1uOR0DPGvCw=#Dg0&F&^*_?>f_73*!4`8|cNW5&IrQm~NPQoJclggM~wD=VVtk zMxw>#l6x}5Zkk7!a&A^PZQ|Qs+4obc?Bs=+ANoyUN#+{}vx4Eb$AD*b)G-t zJ(J?sqkp|QupcVJD*$(RcVo6eNS zVq))TSZwVpGoMB?Xc8?8mW-G$gSW?mENI9za*lpUz(F-$yArv3ZF(6X4!Xva%g1G} zxo+*Hnq(vM^IZW@enU8Bjq*`}H1;}P90!b@J-TrH^VN$&&SP%MeWR|Y?tC;5CIJCn zn#)p1Z%~&L62A=Lr>Ln$FK`$yPd*@CWFb-e({uaw9lQiFdG%4w$x+lvq;!y~JzP(_ zcXthv!F9LOY>fjINj3R?Wp-J?b1*5ryxTr)dXGTQWNUUt5!-<83?hsLrl-S45ROZ{ z04_5@qqZ2;Zv{v^9hRbdir`d}A|$lPbs-N2qQIH1{RGW3K~l5$iDOoEY36Swmi*6n{m>;!L+8?mwubQe4_>oEEJzd`{8+k)1et?TCic%d5?Xc% zk52#q@|_T3k)IFl>8}u8%|i~m&042v`?v9(1+(NDWKSAZ98=kIp*^i<#;mTKl?LDp zM`W{S+Le=E3E{%l=zMy0`Wo5nT@-E#I)W&@ap$4!`cHJqzXI>SAxZ~nbFdDn5>7?K zsB&JgLgz=B-c7^ZZM19%^Y{PbCxI>zYa*qw$gg9VesS%;!2l`lvXZ9Y+Y(7Z4~{AyH_?LI0{BrB1^no}5_ zK}5(rOg($FDyCgmGIcL-+V&-4-_YfNS6E20lVJ@Z9nFBu(JD)rgB_}pdD!ty{Wsdv zcN?~rzjmAAfM$x(6h=ILSKFrl^Lv<5s+<8bH1iORG?m?3WHFEKTv4e_mY^&`5NP396kUg5g zK&PDi_@@fD2664B1j(}+aZ`g6#Q>WuM*Fppv$Q{5Zz`|Y*3IGO$Koh89{wz08gvE&) ze$+ZO;-T{~1wA=I9jc|$&hIx2g8$IDyXFghytQ@hN1G^CfjM`YB$F>Y z^v2zW5n6T}^b$^J5WsJP0>0Gz8+xky23+Q<_=WrNS2~@t@O1=Eb-Zhbg8k*C<_rA- zzg~cCULH@zf$rXIYM#atG>@o0s=JSy8p1b!&K~W_0K&j)EuSbi<;hF{%x20=$zKVw z6w|P6t2WBg5{FtM7$2!cl>UorA*SmDX7 zt%AxL;lnIQY?q2?NSrwEiQa0$h0kxYg7*h@UstjN z_)iUsU#0+gAP2#mjLUWp%<*cXXa^pHC#wHBVy{P8!s1!v&q}T4k9Xi#s+7n4{R_R< z#c1j$M?ADOK|CtStW%BN1q86Ia*1mxi1D8Fe5+%g}#h^U8A0zWuaPNmZkJ z!&@fiRk|4<)hMe%UaCM7_6cqvfpIp85Ps99Q27SXGJxUq0=QRIj<_}FuVu-A_O!{r z-cvhl($oyz*egm1&-Cs!JQH*RJGs|DUlYyv=|;nkcsw~uf^utW@MdKY3F#V@{PCv88a>i-gsFN3TH0lvLW ztb7k%1%tR}@gfUGcbDFi1FGK6^tQ0bdnMJ=E<3a>+VePi?GQmj9-j)n{Bptnjd0h1 z_zfT$fso~UPIUpiePg*K2U+rDV?R)8@O|ZSY+pMLd|I>lC+=#zXM^2ZClI=>CU2$w z!$tJ_1kdMO*U^R1q(6Dck^RCu}#=Smy*E$ysVJ7?C_h}Ty+Y4{MX% z`ZHoBKr0Po!OdqB{u`mNS;vdmLergO*OadIX`%_@;r~ss&b&-yLqttx&?aC}yR4+!r+Kzv-SCPkdb8DVy#VP%Pbdsv zCiD|Vy?Z+uS*Py#w*u5Iz|zDT80adc36S_U#?%Iej70YW@#00$^@^SeTxPL-iabzJ*v6%e)+kpJ<**iG`o8#>CbPwqb~x z1NnYZpv33f5_UE=T0}8jWe7c)6U-=uKzID#tTSd*srej=JWGImZjUm=)Gs$ zcByo|2-AFke*pu;AkeSj%34A4`k*3Du*osMOcwyS$WdV~0TghnEY~qrBS1rhOI}vJ zPxkH&ix-DW#bxKw4m8^2(Xkes-J|&BDs|#Hh&a|wIfoi`fU`Za4%*kYVLG-0Fnc0rWDCQ+v0q#w9pxuI4usl|0F7QcY@AM#DjCYQkRK&e8GbV zULGo@A1_c0h!ofXo@2miF!`KB5@C~Jmf!25Iqx=cPBCdq^1??KgYga*=mZ}i74ohl zZ^d)eEdfB?0;Fm|$_B!hW05-W7t6g-Z@t<2tB2ls2@W0xR5VkA z@yH6GAOpB}ti6J!qOo^8@@MfA!SzFP?apaDQW2)0Lj;s=+eGgtDOJy-VR$KCA~;|L z`K)>qaRVlB?}qT)SMKG|HhcfUwuy_woOMdoDF8*QUnLuU$EQc3{FWzsKMN?7%3OsZ z0xXz&SC>`4&FB$mefDN2gP)3dH{tPgw`t>$@aHyJKF2TbkZH^e$ zi>^aNaO*k}egih}4~b3=R_V9+7Zx@U<;Kb;1;M<9T8NkTEjwrwGNUz9;b_E87bg0<&3>(}|$AtBL!ro$ig4P8r$ zaW!Nj;eh1&NOKuEte=qCeVDVcT7-)`_j# z*q6uZeAkf!;&(l@v&_bi1Q`C;sdCwYx083z%{sm)GyjT#swiW%;QtzH-cqf`b>jk8 zL?_wYp6EB4yKOu_o?Mdo*9`G=nQAI+qeF)tNv$nmcZmRZ@?du- zs||9@ZkAYAWale#_X80V2#6Fxprr#aB8U;@9mh}vZbbl*hhyBroCR|UuP9EDgw{j) zGgbvq^jYWCu@`fr&N(b2gZ>O)zCoa$&PH45rdac_(zdK!bA*KU?9B9hTTYuK{6Uog zY8tR>P%)ruLSyg1SrTox0Sd%vHrm|2S9ck()@Z4u%S{@c+t{d#rq65d=}q2AzzYdB zqB&h>(qXkO!cSO>dm}*EalWddr87(gkc8i1SCWK8fhC=_QdB1XwCE@h-B9yt!76|< z*NlK>^iKXs09xLFCd2Cjed6wE>T8j6PB9t z(znz}>ZU(uexHl@dSZMgucy-es${e}P&HS2oLTdbd9nS{eqXr4HnD7BW$c^PHA$eg P5_Cz|Sf^CWk^KJvUAPuQ literal 4386 zcmcgw^;Z*)+Z~{EgY<@of^;`SK{`eWf}^{0gpvaR=@do{3_w(JbPkZx5d#zkQcA~| zbO~QRf5iKq=iGbGx#!$-e|Ua+o(`R(a}~nxzWY{Ku&tY!DpnxH$v*5 zr=iQk-O1T*;qZjF zfKB;W^XU%xLko%5G53f*tfb=%t4o?OJEJ@J&XbcOR6^j={wN+A>{8JoM$Yq!UhV&y zjLoDoDb?e@kbB+o0vrMqi9Q2%;j-ue?2r1)no*K9l0{-$B3pndJQ2N(PDZO$K6_mz zO>#_%Pb7BLL2sKbDcZfB65YzLg4e-gt0rVfXCUSDN4=uh3_qQ;>OFXNG>c^VN6j`8 zEuv{aMABs#on63aO!bTmrG@4i^NVuZDQHS^Q7})fZ{i}-_O|Nu>3OWa@cvk*9|;funl! zFwi>5hM_FI7iRw>-AjZ(R>9qhJhJ<-w(U%F)jO}f4f>&2W+$sBe5uhiL%ij*J z^=bbl8LPaZGW7?~i6(`C9xCJc`xRDcPnZ6M&ad`8Ry2892)oTkG$P`439RKK7_3+=C}SoB@8!Tj`mHL+93sIaQ*R zQ5Ci1hQVMdpM_VuRunc^h_s%;Rm2VtJ6MNgJPTP`oUdQvOz=8H@d%O6+BKaL3N~3P zA!4m=yZf@os0>>L>h5sT1!oX4(9BM6NqNcL&INvHiPc+W#4sk;^dIrf>`@DbFzZd- zJ&{*b)6#3rR;HCAyC2&16HSEG>ucQgg+GBefewpcrxC4IjZN|xEKzWMP8hNRUC4A) z>L1n$1s``zJ4)K}+w1p+ZHVSo(X=UXT-D?TOz*GkNJ%I;{H|qP&XpZSJAF(0&Py?S z_1Fi>8NP0J*vz$ZK2&p7nXvA8dnW;xt-#Pd*Ry6XYdyI7_m(#|?{t-ql}VMD-v%7g zXIKztMBT#-&fgXwPuG%a<@NPC3FV7M;V;7yg=2jelJ9zEjYt@)ISQGkwW%g{{lq@zaD5FsN!PicOX=oItK4v>mCKdZLULxpW0H!}} z0A~3(Qbctr!sfxbXHuBzDAchj$eS9B7hoOZw+7N|W`Tv=RkJ+`tHQqhJ^Pu4OZyBe z$u3-H$_x5ZmsX!G{B+Nv?7X9YnSC!EH;^cCSn1KC@W-ilw?IDme7-n}ec6?lRdMU^ zB;e$7{2Mk@G%=xopS)vO=G~%@a7l=h{uwXuNYPxhgc}qn{%bO=-WNh2-q;{|RNH?L zne({I1^hWfHBHlV{cd|;44U(KY#VaNvODhA?#IQWm2=!dV{8w^Kj+^b0v=+Ty44of zkJ@83J!VN$T(GS!5m~4ADfT`BcAl^GuMD-*R#f+_X zEQZFZUh!Mf2IqiTs0o+0)}7_x6l-Hdv)5bv4<wBTSM68KZ>V@D!C00ttMW`y#2zL+db*!O8E*RwzOY$(uOh4 z>AjSVVEQ&YJHf*A;~;MJdBP$RE)ej$_b;vQb8%d5|Jd1t@!Y z>`oYaoQ#Plpj#AOIGe)cUB7dgQxDv)--oAKuj#HXcX6xvhy^IL5(wGVzZ1J7c8pDv#Tw5Awy230Wasvq<(`dbWQKO%j79 zR|}F_Thet6Bb+90Y^_GO!1Sn85|PzMyn#+J-fQ(FWrE!uzv;uj4|?^<%IV#7F(Jp- zAD>ePlXsvToBX58E+?JR^lPhb1)-j<=CS7{U8|^aF48ykrfCmI$?hhQh2}n93;tMzb1el8rH_wFKaVilob&B_1#Tk4MjB2=F+_v_H zvHDYidy{^1?X`C0u-M6S(uJv4yB(IQk%l)lpxWAN$D8(-3|AS#Pa$%lsrs4h>!sfe z^Tm5433$lNsOQ5uGZ2ohopEgBgJAcLzM_JuY|Y(^W=Rdc9Xt1nJ0AqEXV&!Db8Cz9 zuq^c*b;V`7b2?^M3OJLqKTJ)gm56uoQk#xp@g@RF#CC-&b`;|R_Rz66nGw>Ob!Ea&xW@ip5%He z4b)v%6mz&+&OF~qp!Uyv4EULe17A5Woz2wQY(Wh*m?j-l;;J4^e%0;bv&=H7o;H0~ zOxTIWwHOVL4(ga~5^9~7cJXhk*7b(EtX#--$(Bf{I1L|fhg8}ZlCM`rciQ}n6E4&e z%l%web7UhToSqM^c3O->ms2K$)5<|fca9?SnIfe7yy&CITi$FfC^pKjo?v7l9>3I= zGeocN6^l3-DV|L%27D?!Myn#+PhF$oW)72?=n58D>sP~hlUDW_Dq%N^Kp|&^f^GKN z1+hQ25cAvz5@+gK*){c(S|oc8&vGv!vVhl&poOibz7ccKEay|T<2AF7?V^Y(UmE`Q z3dbx(YjUqlwF`rHtm}UelmD86xhTG@omREPsr5hNw&d_?j^3R&A$e&StwHAp^K;5gj&`s-B7MlL~NK|Tj<~1)u{;5#8a4wMpel%m-MCjGco<& z%SZ3KZNcXdUxw32AHYI}<)!0AQ|FLlVX9$Y)IF({-0kRoER|~L3Mjc0O5K648*w0$ zGUJdhk@l)LkFy=)`YrzJ@P%4y-42selGQ%tux>~)qt_OFXoPZ8m;jDN4rkWsr7>II zuyc(4aV5ShK>^?Ih10@Aid@03W>~krDI#WRIR!@}2h4@7^OOZX7qb1fv@u)~V;5?o zS!H69>AJ$V{u_AXnc(y#9fa;jcO@yHF>bOmF6y~*^^{jaiw*t4M!vcGDC&o7-E&sS z5*H#76Y_VK3={&|kmzFcSr7-z^Y0|hbnJnjDT%hZbp z(go?Y(kvAf6f#`Lv=FCIGE)X2-Ybt`#nU}LQJ()b^q9L?2r#YbTO>t5X}2j7_#e5;v(^T4g*3;PuDb52`$9}a>cz(;%ZQE3GiSc z5SMFeG@`&RR0TD&iIoI(%0+?scj?z*(fKTJNs`c8QoIVa>gfS(PnO~knVq?_L;dv> zYs?pnn9O1is;{w0x8}DW4|=?aW)<&Ons92>R<)KWbW(D71de)j6Ok`zg!C8%tEEy; zKPS4Vl}_K3!cvK*C&ta%yNGxDI&Hr|WN(=b&bYDF+l=lVcqO1Y={G}BpN&T!BYq}! z%`Xat;`0&tlgZ+fCqlPh5>cmnUEL{TqTRC*NopAW2@_nCCQP{n+^37X_p{fD2n8JU zWpx*Ak2V1Vk9xV)^aMgX%K_1 zj<-ZUC$Y%h*E2ha7J_rWx2auYvmgYw786`Qee(w$>rn)fx2OFOZ~sKh5ig21TKc33 ze!sW<0r0sJ!$u3(3|L=buYf+R~MQ={mgzV7;AK-X=f#!^eM;L z%U?ProDEgpPNiEm)|#3FA8AMUUIPP|=u+r<>``Vjkxu0V5o-$cW?4F!v@ zS$@eW4~lY5p-Yy4_gjR79LKuhpzy0JdK!sYyJPoY$oTQf2Jdwh^WhIt6ni_j zOL{4N>$2TWHkPlmJS(zsd>Fd|r*AEjbJ4k{J`M)axK6HF=?^&be2P~^XpG<2F)8WW z@o~$?N_kOp37IA-M;_oNm;=>6vet^O4H-dm@pMHA3O(XL6y$_&lOH5_R3)c}zxV%e e;b)Rv(FvmFqH~_)VsE|~038j8dbOHe%>MvaNmQT! From 0bf48e94cc2e30634022bbb84b4a6526d5b5e535 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 15 Nov 2017 11:28:42 +0100 Subject: [PATCH 25/31] Properly display Signer errors (Snackbar display popup) (#7053) * Update to fixed @parity/ui (Errors component) * Update ParityBar radius to align with Snackbar/Errors * Update to latest @parity/ui * Update dependencies @parity/signer-plugin-* * Really pull in @parity/signer-plugin-* deps --- js/package-lock.json | 44 +++++++++++++++++----------------- js/package.json | 4 ++-- js/src/ParityBar/parityBar.css | 4 ++-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/js/package-lock.json b/js/package-lock.json index f444927bc..0c1c2ff8e 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -118,16 +118,16 @@ } }, "@parity/plugin-signer-account": { - "version": "github:paritytech/plugin-signer-account#a00e131273becccab59e9852ec3313cb0fe19663" + "version": "github:paritytech/plugin-signer-account#90ca570e550fe0ff7f06fc9b67426982a083c928" }, "@parity/plugin-signer-default": { - "version": "github:paritytech/plugin-signer-default#54e7fa63063f2dcae409ead222ff87fbcc19f1f9" + "version": "github:paritytech/plugin-signer-default#0299349a7ea1aacca9a598057103e6e9cd6f8fa8" }, "@parity/plugin-signer-hardware": { - "version": "github:paritytech/plugin-signer-hardware#34b5562062bb1fe8ea6246c06d45624d7f309aa7" + "version": "github:paritytech/plugin-signer-hardware#ebdb81997a310709cbd261b7904b0ab93afbf6c8" }, "@parity/plugin-signer-qr": { - "version": "github:paritytech/plugin-signer-qr#8d937dd5f5d726fb22be72967fd9a472fa467bfd" + "version": "github:paritytech/plugin-signer-qr#4ae59a9e6867356596c1d13ae605bcd7934df932" }, "@parity/shared": { "version": "2.2.5", @@ -151,9 +151,9 @@ } }, "@parity/ui": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/@parity/ui/-/ui-2.2.6.tgz", - "integrity": "sha512-QBvAoD7sjrGCCWet/nb25Md3kub/86x/kim4CYse0qVnsc46myWLB4ijURSXhWnGUaeVJEeQLWr8usSIRk9iIg==", + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/@parity/ui/-/ui-2.2.13.tgz", + "integrity": "sha512-hMs151GydqeU6fKNt4abptUU91df0GvDzO4I7P9WJ9L/GJYYl2plYZCdhysAg3eYSaKCSMUqD5LZt+JsqoHROQ==", "requires": { "@parity/api": "2.1.3", "@parity/etherscan": "2.1.3", @@ -561,7 +561,7 @@ "dev": true, "requires": { "browserslist": "1.7.7", - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "normalize-range": "0.1.2", "num2fraction": "1.2.2", "postcss": "5.2.18", @@ -574,7 +574,7 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "electron-to-chromium": "1.3.27" } } @@ -1949,7 +1949,7 @@ "integrity": "sha512-vJEBcDTANoDhSHL46NeOEW5hvQw7It9uCqzeFPQhpawXfnOwnpvW5C97vn1eGJ7iCkSg8wWU0nYObE7d/N95Iw==", "dev": true, "requires": { - "caniuse-lite": "1.0.30000760", + "caniuse-lite": "1.0.30000764", "electron-to-chromium": "1.3.27" } }, @@ -2045,7 +2045,7 @@ "dev": true, "requires": { "browserslist": "1.7.7", - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "lodash.memoize": "4.1.2", "lodash.uniq": "4.5.0" }, @@ -2056,22 +2056,22 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "electron-to-chromium": "1.3.27" } } } }, "caniuse-db": { - "version": "1.0.30000760", - "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000760.tgz", - "integrity": "sha1-PqKUc+t4psywny63Osnh3r/sUo0=", + "version": "1.0.30000764", + "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000764.tgz", + "integrity": "sha1-1zqxGuYvap4vaYZ9bZwjrj8uXY0=", "dev": true }, "caniuse-lite": { - "version": "1.0.30000760", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", - "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=", + "version": "1.0.30000764", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000764.tgz", + "integrity": "sha1-l+p0cvnT5pHu3jTyGYPPwhmseEI=", "dev": true }, "caseless": { @@ -3335,7 +3335,7 @@ "dev": true, "requires": { "browserslist": "1.7.7", - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "css-rule-stream": "1.1.0", "duplexer2": "0.0.2", "jsonfilter": "1.1.2", @@ -3354,7 +3354,7 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "electron-to-chromium": "1.3.27" } }, @@ -9128,7 +9128,7 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "electron-to-chromium": "1.3.27" } } @@ -11693,7 +11693,7 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000760", + "caniuse-db": "1.0.30000764", "electron-to-chromium": "1.3.27" } }, diff --git a/js/package.json b/js/package.json index d7e96512b..31c9ccc7b 100644 --- a/js/package.json +++ b/js/package.json @@ -27,7 +27,7 @@ "build:embed": "cross-env EMBED=1 node webpack/embed", "build:i18n": "npm run clean && npm run build && babel-node ./scripts/build-i18n.js", "ci:build": "cross-env NODE_ENV=production npm run build", - "clean": "rimraf ./.build ./.coverage ./.happypack ./build ./node_modules/.cache", + "clean": "rimraf ./.build ./.coverage ./.happypack ./build", "coveralls": "npm run testCoverage && coveralls < coverage/lcov.info", "lint": "npm run lint:css && npm run lint:js", "lint:cached": "npm run lint:css && npm run lint:js:cached", @@ -143,12 +143,12 @@ "@parity/dapp-signaturereg": "paritytech/dapp-signaturereg", "@parity/dapp-tokendeploy": "paritytech/dapp-tokendeploy", "@parity/dapp-tokenreg": "paritytech/dapp-tokenreg", + "@parity/dapp-vaults": "paritytech/dapp-vaults", "@parity/dapp-web": "paritytech/dapp-web", "@parity/plugin-signer-account": "paritytech/plugin-signer-account", "@parity/plugin-signer-default": "paritytech/plugin-signer-default", "@parity/plugin-signer-hardware": "paritytech/plugin-signer-hardware", "@parity/plugin-signer-qr": "paritytech/plugin-signer-qr", - "@parity/dapp-vaults": "paritytech/dapp-vaults", "@parity/shared": "2.2.x", "@parity/ui": "2.2.x", "keythereum": "1.0.2", diff --git a/js/src/ParityBar/parityBar.css b/js/src/ParityBar/parityBar.css index 49c71aa6a..c1ec5c08e 100644 --- a/js/src/ParityBar/parityBar.css +++ b/js/src/ParityBar/parityBar.css @@ -189,9 +189,9 @@ $modalZ: 10001; } .header { - /* height: 2em; */ - padding: 0.5em 1em; + border-radius: 4px 4px 0 0; margin-bottom: 0; + padding: 0.5em 1em; &::after { clear: both; From 95d3741e32f7c673b95cbe7ea917a06b72b34ff8 Mon Sep 17 00:00:00 2001 From: Afri Schoedon <5chdn@users.noreply.github.com> Date: Wed, 15 Nov 2017 11:29:07 +0100 Subject: [PATCH 26/31] CHANGELOG for 1.7.8, 1.7.9, 1.8.2, and 1.8.3 (#7055) * Update changelog for 1.7.8 stable * Update changelog for 1.7.9 stable * Improve wording in Changelog * Update changelog for 1.8.2 beta * Update changelog for 1.8.3 beta --- CHANGELOG.md | 43 +++++++++++++++++++++++++++++++++++++++-- docs/CHANGELOG-1.7.md | 45 +++++++++++++++++++++++-------------------- 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7110201e1..a50ac02db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,42 @@ +## Parity [v1.8.3](https://github.com/paritytech/parity/releases/tag/v1.8.3) (2017-11-15) + +Parity 1.8.3 contains several bug-fixes and removes the ability to deploy built-in multi-signature wallets. + +The full list of included changes: + +- Backports to beta ([#7043](https://github.com/paritytech/parity/pull/7043)) + - pwasm-std update ([#7018](https://github.com/paritytech/parity/pull/7018)) + - Version 1.8.3 + - Make CLI arguments parsing more backwards compatible ([#7004](https://github.com/paritytech/parity/pull/7004)) + - Skip nonce check for gas estimation ([#6997](https://github.com/paritytech/parity/pull/6997)) + - Events in WASM runtime ([#6967](https://github.com/paritytech/parity/pull/6967)) + - Return decoded seal fields. ([#6932](https://github.com/paritytech/parity/pull/6932)) + - Fix serialization of status in transaction receipts. ([#6926](https://github.com/paritytech/parity/pull/6926)) + - Windows fixes ([#6921](https://github.com/paritytech/parity/pull/6921)) +- Disallow built-in multi-sig deploy (only watch) ([#7014](https://github.com/paritytech/parity/pull/7014)) +- Add hint in ActionParams for splitting code/data ([#6968](https://github.com/paritytech/parity/pull/6968)) + - Action params and embedded params handling + - Fix name-spaces + +## Parity [v1.8.2](https://github.com/paritytech/parity/releases/tag/v1.8.2) (2017-10-26) + +Parity 1.8.2 fixes an important potential consensus issue and a few additional minor issues: + +- `blockNumber` transaction field is now returned correctly in RPC calls. +- Possible crash when `--force-sealing` option is used. + +The full list of included changes: + +- Beta Backports ([#6891](https://github.com/paritytech/parity/pull/6891)) + - Bump to v1.8.2 + - Refactor static context check in CREATE. ([#6886](https://github.com/paritytech/parity/pull/6886)) + - Refactor static context check in CREATE. + - Fix wasm. + - Fix serialization of non-localized transactions ([#6868](https://github.com/paritytech/parity/pull/6868)) + - Fix serialization of non-localized transactions. + - Return proper SignedTransactions representation. + - Allow force sealing and reseal=0 for non-dev chains. ([#6878](https://github.com/paritytech/parity/pull/6878)) + ## Parity [v1.8.1](https://github.com/paritytech/parity/releases/tag/v1.8.1) (2017-10-20) Parity 1.8.1 fixes several bugs with token balances, tweaks snapshot-sync, improves the performance of nodes with huge amounts of accounts and changes the Trezor account derivation path. @@ -13,7 +52,7 @@ Parity 1.8.1 fixes several bugs with token balances, tweaks snapshot-sync, impro If you don't want to downgrade or move your funds off your Trezor-device, you can also use the official Trezor application or other wallets allowing to select the derivation path to access the funds. -Full list of included changes: +The full list of included changes: - Add ECIP1017 to Morden config ([#6845](https://github.com/paritytech/parity/pull/6845)) - Ethstore optimizations ([#6844](https://github.com/paritytech/parity/pull/6844)) @@ -45,7 +84,7 @@ Further, users upgrading from 1.7 should acknowledge the following changes: - `trace_filter` RPC method now comes with pagination. [#6312](https://github.com/paritytech/parity/pull/6312) - Added tracing of rewards on closing blocks. [#6194](https://github.com/paritytech/parity/pull/6194) -Full list of included changes: +The full list of included changes: - Updated ethabi to fix auto-update ([#6771](https://github.com/paritytech/parity/pull/6771)) - Fixed kovan chain validation ([#6760](https://github.com/paritytech/parity/pull/6760)) diff --git a/docs/CHANGELOG-1.7.md b/docs/CHANGELOG-1.7.md index fc28e6a45..25ebcd82e 100644 --- a/docs/CHANGELOG-1.7.md +++ b/docs/CHANGELOG-1.7.md @@ -1,23 +1,26 @@ -### Parity [v1.7.8](https://github.com/paritytech/parity/releases/tag/v1.7.8) (2017-10-27) +### Parity [v1.7.9](https://github.com/paritytech/parity/releases/tag/v1.7.9) (2017-11-14) -- [stable] Refactor static context check in CREATE ([#6889](https://github.com/paritytech/parity/pull/6889)) -- Fix #6228: do not display eth price in cli for etc ([#6877](https://github.com/paritytech/parity/pull/6877)) -- Fix mining help ([#6885](https://github.com/paritytech/parity/pull/6885)) -- [stable] v1.7.8 ([#6890](https://github.com/paritytech/parity/pull/6890)) -- Refactor static context check in CREATE. ([#6886](https://github.com/paritytech/parity/pull/6886)) -- Cleanup some configuration options ([#6878](https://github.com/paritytech/parity/pull/6878)) -- Fix serialization of non-localized transactions ([#6868](https://github.com/paritytech/parity/pull/6868)) -- Updated NTP to version 0.3 ([#6854](https://github.com/paritytech/parity/pull/6854)) -- Align README with 1.8 and prepare CHANGELOG with 1.8.1 ([#6833](https://github.com/paritytech/parity/pull/6833)) -- Return error on timed unlock ([#6777](https://github.com/paritytech/parity/pull/6777)) -- Fix dapps tests in master ([#6866](https://github.com/paritytech/parity/pull/6866)) -- [Beta] Add ECIP1017 to Morden config (#6810) ([#6845](https://github.com/paritytech/parity/pull/6845)) +Parity 1.7.9 removes the ability to deploy built-in multi-signature wallets. + +The full list of included changes: + +- Bump to v1.7.9 ([#7047](https://github.com/paritytech/parity/pull/7047)) +- Disallow built-in multi-sig deploy (only watch) ([#7017](https://github.com/paritytech/parity/pull/7017)) + +### Parity [v1.7.8](https://github.com/paritytech/parity/releases/tag/v1.7.8) (2017-10-26) + +Parity 1.7.8 fixes a critical Byzantium consensus issue. Update is highly recommended. + +The full list of included changes: + +- Refactor static context check in CREATE ([#6889](https://github.com/paritytech/parity/pull/6889)) +- Bump to v1.7.8 ([#6890](https://github.com/paritytech/parity/pull/6890)) ## Parity [v1.7.7](https://github.com/paritytech/parity/releases/tag/v1.7.7) (2017-10-15) -Parity 1.7.7 Fixes an issue with auto-update system. Updating is recommended, but not required for Byzantium. +Parity 1.7.7 fixes an issue with auto-update system. Updating is recommended, but not required for Byzantium. -Full list of included changes: +The full list of included changes: - Fix auto-update ([#6769](https://github.com/paritytech/parity/pull/6759)) - Bump to v1.7.7 @@ -28,7 +31,7 @@ Full list of included changes: Parity 1.7.6 includes a critical consensus-relevant fix for the Byzantium hard-fork. Please upgrade your Ethereum client before block number `4_370_000`. -Full list of included changes: +The full list of included changes: - Fixed modexp gas calculation overflow ([#6746](https://github.com/paritytech/parity/pull/6746)) - Fixed modexp gas calculation overflow ([#6741](https://github.com/paritytech/parity/pull/6741)) @@ -40,7 +43,7 @@ Parity 1.7.5 includes a critical consensus-relevant fix for the Byzantium hard-f Parity 1.7.5 is the first stable release of the 1.7 branch. With this release the support for 1.6 releases ends. Please upgrade your stable nodes to 1.7.5. -Full list of included changes: +The full list of included changes: - Backport stable - Fixes Badges ([#6731](https://github.com/paritytech/parity/pull/6731)) - Fix badges not showing up ([#6730](https://github.com/paritytech/parity/pull/6730)) @@ -67,7 +70,7 @@ Full list of included changes: Parity 1.7.4 includes a critical consensus-relevant fix for the Byzantium hard-fork. Please upgrade your Ethereum client before block number `4_370_000`. -Full list of included changes: +The full list of included changes: - Backport ([#6715](https://github.com/paritytech/parity/pull/6715)) - Fix estimate gas if from is not provided. ([#6714](https://github.com/paritytech/parity/pull/6714)) @@ -95,7 +98,7 @@ Parity 1.7.3 enables the Byzantium fork for Ethereum main network on Block 4_370 - Revised timeout and batch size constants for bigger blocks. - Renamed RPC receipt `statusCode` field to `status`. -Full list of included changes: +The full list of included changes: - Backporting ([#6676](https://github.com/paritytech/parity/pull/6676)) - Fix wallet view ([#6597](https://github.com/paritytech/parity/pull/6597)) @@ -143,7 +146,7 @@ Parity 1.7.2 is a bug-fix release to improve performance and stability. Among ot - Tweaked warp-sync to quickly catch up with chains fallen back more than 10,000 blocks. - Fixes to the Chrome extension and macOS installer upgrades. -Full list of included changes: +The full list of included changes: - Fix output from eth_call. ([#6538](https://github.com/paritytech/parity/pull/6538)) - Ropsten fork ([#6532](https://github.com/paritytech/parity/pull/6532)) @@ -294,7 +297,7 @@ Parity 1.7.0 is a major release introducing several important features: - **PubSub API**. https://github.com/paritytech/parity/wiki/JSONRPC-Parity-Pub-Sub-module - **Signer apps for IOS and Android**. -Full list of included changes: +The full list of included changes: - Backports [#6163](https://github.com/paritytech/parity/pull/6163) - Light client improvements ([#6156](https://github.com/paritytech/parity/pull/6156)) From a98652bef646e865e5f0481b5a7407857681a40d Mon Sep 17 00:00:00 2001 From: GitLab Build Bot Date: Wed, 15 Nov 2017 10:50:45 +0000 Subject: [PATCH 27/31] [ci skip] js-precompiled 20171115-103846 --- Cargo.lock | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1c089df2..9051c58c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2227,7 +2227,7 @@ dependencies = [ [[package]] name = "parity-ui-precompiled" version = "1.9.0" -source = "git+https://github.com/paritytech/js-precompiled.git#31b526f7ec289801a96100e80f19c4cbe850276b" +source = "git+https://github.com/paritytech/js-precompiled.git#5b3e31509c369f558c8cb90f6f9918e50cdb2501" dependencies = [ "parity-dapps-glue 1.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/js/package-lock.json b/js/package-lock.json index 0c1c2ff8e..cde7c67f8 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "Parity", - "version": "1.9.9", + "version": "1.9.10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js/package.json b/js/package.json index 31c9ccc7b..873720452 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "Parity", - "version": "1.9.9", + "version": "1.9.10", "main": "src/index.parity.js", "jsnext:main": "src/index.parity.js", "author": "Parity Team ", From e16f6fb9d9ee44e1a670d3888ca68d246613c848 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 16 Nov 2017 19:34:23 +0300 Subject: [PATCH 28/31] SecretStore: servers set change session api (#6925) * SecretStore: first key versions flush * SecretStore: key versions in encryption session * SecretStore: flush key versions negotiation session * SecretStore: connected key version negotiation session to cluster * SecretStore: cluster sessions container refactoring * SecretStore: flush * SecretStore: flush key versions * SecretStore: flush * SecretStore: delegation proto * SecretStore: decryption_session_is_delegated_when_node_does_not_have_key_share * SecretStore: fixed version in decryption session * SecretStore: signing_session_is_delegated_when_node_does_not_have_key_share * SecretStore: started restoring admin sessions * SecretStore: restoring admin sessions * SecretStore: removed obsolete ShareRemove && ShareMove sessions * SecretStore: ShareAdd math tests only require old_t+1 nodes * SecretStore: ShareAdd revamp using new math backend * SecretStore: do not include isolated nodes into consensus_group * SecretStore: ServersSetChange + ShareAdd revamp * removed debug printlns * SecretStore: key version negotiation tests * SecretStore: removed debug/merge artifacts * SecretStore: fixed master node selection * SecretStore: cleanup + tests + fixes * SecretStore: uncommented tests * SecretStore: cleaning up * SecretStore: cleaning up + tests * SecretStore: cleaning up * SecretStore: cleaning up && tests * SecretStore: fixing TODOs * SecretStore: fixing TODOs + cleanup * SecretStore: fixing TODOs * SecretStore: nodes_add_to_the_node_with_obsolete_version * SecretStore: nodes_add_fails_when_not_enough_share_owners_are_connected * SecretStore: tests * SecretStore: signing && delegation tests * SecretStore: signing && decryption tests when some nodes are isolated * SecretStore: sessions_are_removed_when_initialization_fails * SecretStore: ceaning up * SecretStore: removed obsolete comments * SecretStore: signing_session_completes_if_node_does_not_have_a_share * SecretStore: initial ServersSetChange API * SecretStore: added secretstore_signServersSet RPC * SecretStore: ChangeServersSet parse tests * SecretStore: fixes after manual ServersSetChange tests * lost file * fixed network ports overlap in tests * lost files --- Cargo.lock | 1 + rpc/Cargo.toml | 1 + rpc/src/lib.rs | 1 + rpc/src/v1/helpers/secretstore.rs | 17 +++ rpc/src/v1/impls/secretstore.rs | 12 +- rpc/src/v1/tests/mocked/secretstore.rs | 34 +++++- rpc/src/v1/traits/secretstore.rs | 6 + secret_store/src/http_listener.rs | 113 ++++++++++++++---- secret_store/src/key_server.rs | 31 ++++- .../servers_set_change_session.rs | 15 ++- .../client_sessions/decryption_session.rs | 23 ++-- .../client_sessions/generation_session.rs | 2 +- .../client_sessions/signing_session.rs | 21 ++-- .../src/key_server_cluster/cluster.rs | 21 +++- .../key_server_cluster/cluster_sessions.rs | 9 +- .../src/key_server_cluster/message.rs | 4 +- secret_store/src/traits.rs | 13 +- 17 files changed, 268 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a370af35..4f7b0d510 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2145,6 +2145,7 @@ dependencies = [ "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 9fd178dd8..beb42b8d2 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -24,6 +24,7 @@ serde = "1.0" serde_derive = "1.0" serde_json = "1.0" time = "0.1" +tiny-keccak = "1.3" tokio-timer = "0.1" transient-hashmap = "0.4" itertools = "0.5" diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 3d782d419..113ac19ff 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -37,6 +37,7 @@ extern crate semver; extern crate serde; extern crate serde_json; extern crate time; +extern crate tiny_keccak; extern crate tokio_timer; extern crate transient_hashmap; diff --git a/rpc/src/v1/helpers/secretstore.rs b/rpc/src/v1/helpers/secretstore.rs index 39709e78e..4834611d8 100644 --- a/rpc/src/v1/helpers/secretstore.rs +++ b/rpc/src/v1/helpers/secretstore.rs @@ -14,12 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::collections::BTreeSet; use rand::{Rng, OsRng}; use ethkey::{Public, Secret, math}; use crypto; use bytes::Bytes; use jsonrpc_core::Error; use v1::helpers::errors; +use v1::types::{H256, H512}; +use tiny_keccak::Keccak; /// Initialization vector length. const INIT_VEC_LEN: usize = 16; @@ -61,11 +64,25 @@ pub fn decrypt_document(key: Bytes, mut encrypted_document: Bytes) -> Result, encrypted_document: Bytes) -> Result { let key = decrypt_with_shadow_coefficients(decrypted_secret, common_point, shadows)?; decrypt_document(key.to_vec(), encrypted_document) } +/// Calculate Keccak(ordered servers set) +pub fn ordered_servers_keccak(servers_set: BTreeSet) -> H256 { + let mut servers_set_keccak = Keccak::new_keccak256(); + for server in servers_set { + servers_set_keccak.update(&server.0); + } + + let mut servers_set_keccak_value = [0u8; 32]; + servers_set_keccak.finalize(&mut servers_set_keccak_value); + + servers_set_keccak_value.into() +} + fn into_document_key(key: Bytes) -> Result { // key is a previously distributely generated Public if key.len() != 64 { diff --git a/rpc/src/v1/impls/secretstore.rs b/rpc/src/v1/impls/secretstore.rs index 6ddb4a7a0..c34da62d4 100644 --- a/rpc/src/v1/impls/secretstore.rs +++ b/rpc/src/v1/impls/secretstore.rs @@ -16,6 +16,7 @@ //! SecretStore-specific rpc implementation. +use std::collections::BTreeSet; use std::sync::Arc; use crypto::DEFAULT_MAC; @@ -25,7 +26,7 @@ use ethcore::account_provider::AccountProvider; use jsonrpc_core::Result; use v1::helpers::errors; use v1::helpers::accounts::unwrap_provider; -use v1::helpers::secretstore::{encrypt_document, decrypt_document, decrypt_document_with_shadow}; +use v1::helpers::secretstore::{encrypt_document, decrypt_document, decrypt_document_with_shadow, ordered_servers_keccak}; use v1::traits::SecretStore; use v1::types::{H160, H512, Bytes}; @@ -82,4 +83,13 @@ impl SecretStore for SecretStoreClient { decrypt_document_with_shadow(decrypted_secret.into(), common_point.into(), shadows, data.0) .map(Into::into) } + + fn sign_servers_set(&self, address: H160, password: String, servers_set: BTreeSet) -> Result { + let servers_set_keccak_value = ordered_servers_keccak(servers_set); + let store = self.account_provider()?; + store + .sign(address.into(), Some(password), servers_set_keccak_value.into()) + .map(|s| Bytes::new((*s).to_vec())) + .map_err(|e| errors::account("Could not sign servers set.", e)) + } } diff --git a/rpc/src/v1/tests/mocked/secretstore.rs b/rpc/src/v1/tests/mocked/secretstore.rs index ed278ced8..b0b01cb65 100644 --- a/rpc/src/v1/tests/mocked/secretstore.rs +++ b/rpc/src/v1/tests/mocked/secretstore.rs @@ -17,12 +17,14 @@ use std::sync::Arc; use ethcore::account_provider::AccountProvider; +use ethkey::{KeyPair, Signature, verify_public}; use serde_json; use jsonrpc_core::{IoHandler, Success}; use v1::metadata::Metadata; use v1::SecretStoreClient; use v1::traits::secretstore::SecretStore; +use v1::helpers::secretstore::ordered_servers_keccak; struct Dependencies { pub accounts: Arc, @@ -51,7 +53,7 @@ fn rpc_secretstore_encrypt_and_decrypt() { let deps = Dependencies::new(); let io = deps.default_client(); - // insert new account && unlock it + // insert new account let secret = "c1f1cfe279a5c350d13795bce162941967340c8a228e6ba175489afc564a5bef".parse().unwrap(); deps.accounts.insert_account(secret, "password").unwrap(); @@ -81,7 +83,7 @@ fn rpc_secretstore_shadow_decrypt() { let deps = Dependencies::new(); let io = deps.default_client(); - // insert new account && unlock it + // insert new account let secret = "82758356bf46b42710d3946a8efa612b7bf5e125e4d49f28facf1139db4a46f4".parse().unwrap(); deps.accounts.insert_account(secret, "password").unwrap(); @@ -96,3 +98,31 @@ fn rpc_secretstore_shadow_decrypt() { let decryption_response = io.handle_request_sync(&decryption_request).unwrap(); assert_eq!(decryption_response, r#"{"jsonrpc":"2.0","result":"0xdeadbeef","id":1}"#); } + +#[test] +fn rpc_secretstore_sign_servers_set() { + let deps = Dependencies::new(); + let io = deps.default_client(); + + // insert new account + let secret = "82758356bf46b42710d3946a8efa612b7bf5e125e4d49f28facf1139db4a46f4".parse().unwrap(); + let key_pair = KeyPair::from_secret(secret).unwrap(); + deps.accounts.insert_account(key_pair.secret().clone(), "password").unwrap(); + + // execute signing request + let signing_request = r#"{"jsonrpc": "2.0", "method": "secretstore_signServersSet", "params":[ + "0x00dfE63B22312ab4329aD0d28CaD8Af987A01932", "password", + ["0x843645726384530ffb0c52f175278143b5a93959af7864460f5a4fec9afd1450cfb8aef63dec90657f43f55b13e0a73c7524d4e9a13c051b4e5f1e53f39ecd91", + "0x07230e34ebfe41337d3ed53b186b3861751f2401ee74b988bba55694e2a6f60c757677e194be2e53c3523cc8548694e636e6acb35c4e8fdc5e29d28679b9b2f3"] + ], "id": 1}"#; + let signing_response = io.handle_request_sync(&signing_request).unwrap(); + let signing_response = signing_response.replace(r#"{"jsonrpc":"2.0","result":"0x"#, ""); + let signing_response = signing_response.replace(r#"","id":1}"#, ""); + let signature: Signature = signing_response.parse().unwrap(); + + let servers_set_keccak = ordered_servers_keccak(vec![ + "843645726384530ffb0c52f175278143b5a93959af7864460f5a4fec9afd1450cfb8aef63dec90657f43f55b13e0a73c7524d4e9a13c051b4e5f1e53f39ecd91".parse().unwrap(), + "07230e34ebfe41337d3ed53b186b3861751f2401ee74b988bba55694e2a6f60c757677e194be2e53c3523cc8548694e636e6acb35c4e8fdc5e29d28679b9b2f3".parse().unwrap() + ].into_iter().collect()); + assert!(verify_public(key_pair.public(), &signature, &servers_set_keccak.into()).unwrap()); +} diff --git a/rpc/src/v1/traits/secretstore.rs b/rpc/src/v1/traits/secretstore.rs index e625cf331..f63bdce92 100644 --- a/rpc/src/v1/traits/secretstore.rs +++ b/rpc/src/v1/traits/secretstore.rs @@ -16,6 +16,7 @@ //! SecretStore-specific rpc interface. +use std::collections::BTreeSet; use jsonrpc_core::Result; use v1::types::{H160, H512, Bytes}; @@ -37,5 +38,10 @@ build_rpc_trait! { /// Arguments: `account`, `password`, `decrypted_secret`, `common_point`, `decrypt_shadows`, `data`. #[rpc(name = "secretstore_shadowDecrypt")] fn shadow_decrypt(&self, H160, String, H512, H512, Vec, Bytes) -> Result; + + /// Sign servers set for use in ServersSetChange session. + /// Arguments: `account`, `password`, `servers_set`. + #[rpc(name = "secretstore_signServersSet")] + fn sign_servers_set(&self, H160, String, BTreeSet) -> Result; } } diff --git a/secret_store/src/http_listener.rs b/secret_store/src/http_listener.rs index 883389365..b6e48f1c5 100644 --- a/secret_store/src/http_listener.rs +++ b/secret_store/src/http_listener.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::collections::BTreeSet; +use std::io::Read; use std::sync::Arc; use hyper::header; use hyper::uri::RequestUri; @@ -25,10 +27,10 @@ use serde::Serialize; use serde_json; use url::percent_encoding::percent_decode; -use traits::{ServerKeyGenerator, DocumentKeyServer, MessageSigner, KeyServer}; +use traits::{ServerKeyGenerator, AdminSessionsServer, DocumentKeyServer, MessageSigner, KeyServer}; use serialization::{SerializableEncryptedDocumentKeyShadow, SerializableBytes, SerializablePublic}; use types::all::{Error, Public, MessageHash, EncryptedMessageSignature, NodeAddress, RequestSignature, ServerKeyId, - EncryptedDocumentKey, EncryptedDocumentKeyShadow}; + EncryptedDocumentKey, EncryptedDocumentKeyShadow, NodeId}; /// Key server http-requests listener. Available requests: /// To generate server key: POST /shadow/{server_key_id}/{signature}/{threshold} @@ -37,6 +39,7 @@ use types::all::{Error, Public, MessageHash, EncryptedMessageSignature, NodeAddr /// To get document key: GET /{server_key_id}/{signature} /// To get document key shadow: GET /shadow/{server_key_id}/{signature} /// To sign message with server key: GET /{server_key_id}/{signature}/{message_hash} +/// To change servers set: POST /admin/servers_set_change/{old_signature}/{new_signature} + BODY: json array of hex-encoded nodes ids pub struct KeyServerHttpListener { http_server: Option, @@ -60,6 +63,8 @@ enum Request { GetDocumentKeyShadow(ServerKeyId, RequestSignature), /// Sign message. SignMessage(ServerKeyId, RequestSignature, MessageHash), + /// Change servers set. + ChangeServersSet(RequestSignature, RequestSignature, BTreeSet), } /// Cloneable http handler @@ -96,6 +101,12 @@ impl KeyServerHttpListener where T: KeyServer + 'static { impl KeyServer for KeyServerHttpListener where T: KeyServer + 'static {} +impl AdminSessionsServer for KeyServerHttpListener where T: KeyServer + 'static { + fn change_servers_set(&self, old_set_signature: RequestSignature, new_set_signature: RequestSignature, new_servers_set: BTreeSet) -> Result<(), Error> { + self.handler.key_server.change_servers_set(old_set_signature, new_set_signature, new_servers_set) + } +} + impl ServerKeyGenerator for KeyServerHttpListener where T: KeyServer + 'static { fn generate_key(&self, key_id: &ServerKeyId, signature: &RequestSignature, threshold: usize) -> Result { self.handler.key_server.generate_key(key_id, signature, threshold) @@ -134,17 +145,24 @@ impl Drop for KeyServerHttpListener where T: KeyServer + 'static { } impl HttpHandler for KeyServerHttpHandler where T: KeyServer + 'static { - fn handle(&self, req: HttpRequest, mut res: HttpResponse) { + fn handle(&self, mut req: HttpRequest, mut res: HttpResponse) { if req.headers.has::() { warn!(target: "secretstore", "Ignoring {}-request {} with Origin header", req.method, req.uri); *res.status_mut() = HttpStatusCode::NotFound; return; } + let mut req_body = Default::default(); + if let Err(error) = req.read_to_string(&mut req_body) { + warn!(target: "secretstore", "Error {} reading body of {}-request {}", error, req.method, req.uri); + *res.status_mut() = HttpStatusCode::BadRequest; + return; + } + let req_method = req.method.clone(); let req_uri = req.uri.clone(); match &req_uri { - &RequestUri::AbsolutePath(ref path) => match parse_request(&req_method, &path) { + &RequestUri::AbsolutePath(ref path) => match parse_request(&req_method, &path, &req_body) { Request::GenerateServerKey(document, signature, threshold) => { return_server_public_key(req, res, self.handler.key_server.generate_key(&document, &signature, threshold) .map_err(|err| { @@ -187,6 +205,13 @@ impl HttpHandler for KeyServerHttpHandler where T: KeyServer + 'static { err })); }, + Request::ChangeServersSet(old_set_signature, new_set_signature, new_servers_set) => { + return_empty(req, res, self.handler.key_server.change_servers_set(old_set_signature, new_set_signature, new_servers_set) + .map_err(|err| { + warn!(target: "secretstore", "ChangeServersSet request {} has failed with: {}", req_uri, err); + err + })); + }, Request::Invalid => { warn!(target: "secretstore", "Ignoring invalid {}-request {}", req_method, req_uri); *res.status_mut() = HttpStatusCode::BadRequest; @@ -261,7 +286,7 @@ fn return_error(mut res: HttpResponse, err: Error) { } } -fn parse_request(method: &HttpMethod, uri_path: &str) -> Request { +fn parse_request(method: &HttpMethod, uri_path: &str, body: &str) -> Request { let uri_path = match percent_decode(uri_path.as_bytes()).decode_utf8() { Ok(path) => path, Err(_) => return Request::Invalid, @@ -272,6 +297,10 @@ fn parse_request(method: &HttpMethod, uri_path: &str) -> Request { return Request::Invalid; } + if path[0] == "admin" { + return parse_admin_request(method, path, body); + } + let (is_shadow_request, args_offset) = if &path[0] == "shadow" { (true, 1) } else { (false, 0) }; let args_count = path.len() - args_offset; if args_count < 2 || path[args_offset].is_empty() || path[args_offset + 1].is_empty() { @@ -308,9 +337,35 @@ fn parse_request(method: &HttpMethod, uri_path: &str) -> Request { } } +fn parse_admin_request(method: &HttpMethod, path: Vec, body: &str) -> Request { + let args_count = path.len(); + if *method != HttpMethod::Post || args_count != 4 || path[1] != "servers_set_change" { + return Request::Invalid; + } + + let old_set_signature = match path[2].parse() { + Ok(signature) => signature, + _ => return Request::Invalid, + }; + + let new_set_signature = match path[3].parse() { + Ok(signature) => signature, + _ => return Request::Invalid, + }; + + let new_servers_set: BTreeSet = match serde_json::from_str(body) { + Ok(new_servers_set) => new_servers_set, + _ => return Request::Invalid, + }; + + Request::ChangeServersSet(old_set_signature, new_set_signature, + new_servers_set.into_iter().map(Into::into).collect()) +} + #[cfg(test)] mod tests { use hyper::method::Method as HttpMethod; + use ethkey::Public; use key_server::tests::DummyKeyServer; use types::all::NodeAddress; use super::{parse_request, Request, KeyServerHttpListener}; @@ -326,48 +381,66 @@ mod tests { #[test] fn parse_request_successful() { // POST /shadow/{server_key_id}/{signature}/{threshold} => generate server key - assert_eq!(parse_request(&HttpMethod::Post, "/shadow/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/2"), + assert_eq!(parse_request(&HttpMethod::Post, "/shadow/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/2", Default::default()), Request::GenerateServerKey("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap(), 2)); // POST /shadow/{server_key_id}/{signature}/{common_point}/{encrypted_key} => store encrypted document key - assert_eq!(parse_request(&HttpMethod::Post, "/shadow/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/b486d3840218837b035c66196ecb15e6b067ca20101e11bd5e626288ab6806ecc70b8307012626bd512bad1559112d11d21025cef48cc7a1d2f3976da08f36c8/1395568277679f7f583ab7c0992da35f26cde57149ee70e524e49bdae62db3e18eb96122501e7cbb798b784395d7bb5a499edead0706638ad056d886e56cf8fb"), + assert_eq!(parse_request(&HttpMethod::Post, "/shadow/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/b486d3840218837b035c66196ecb15e6b067ca20101e11bd5e626288ab6806ecc70b8307012626bd512bad1559112d11d21025cef48cc7a1d2f3976da08f36c8/1395568277679f7f583ab7c0992da35f26cde57149ee70e524e49bdae62db3e18eb96122501e7cbb798b784395d7bb5a499edead0706638ad056d886e56cf8fb", Default::default()), Request::StoreDocumentKey("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap(), "b486d3840218837b035c66196ecb15e6b067ca20101e11bd5e626288ab6806ecc70b8307012626bd512bad1559112d11d21025cef48cc7a1d2f3976da08f36c8".parse().unwrap(), "1395568277679f7f583ab7c0992da35f26cde57149ee70e524e49bdae62db3e18eb96122501e7cbb798b784395d7bb5a499edead0706638ad056d886e56cf8fb".parse().unwrap())); // POST /{server_key_id}/{signature}/{threshold} => generate server && document key - assert_eq!(parse_request(&HttpMethod::Post, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/2"), + assert_eq!(parse_request(&HttpMethod::Post, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/2", Default::default()), Request::GenerateDocumentKey("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap(), 2)); // GET /{server_key_id}/{signature} => get document key - assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01"), + assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01", Default::default()), Request::GetDocumentKey("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap())); - assert_eq!(parse_request(&HttpMethod::Get, "/%30000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01"), + assert_eq!(parse_request(&HttpMethod::Get, "/%30000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01", Default::default()), Request::GetDocumentKey("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap())); // GET /shadow/{server_key_id}/{signature} => get document key shadow - assert_eq!(parse_request(&HttpMethod::Get, "/shadow/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01"), + assert_eq!(parse_request(&HttpMethod::Get, "/shadow/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01", Default::default()), Request::GetDocumentKeyShadow("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap())); // GET /{server_key_id}/{signature}/{message_hash} => sign message with server key - assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/281b6bf43cb86d0dc7b98e1b7def4a80f3ce16d28d2308f934f116767306f06c"), + assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/281b6bf43cb86d0dc7b98e1b7def4a80f3ce16d28d2308f934f116767306f06c", Default::default()), Request::SignMessage("0000000000000000000000000000000000000000000000000000000000000001".into(), "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap(), "281b6bf43cb86d0dc7b98e1b7def4a80f3ce16d28d2308f934f116767306f06c".parse().unwrap())); + // POST /admin/servers_set_change/{old_set_signature}/{new_set_signature} + body + let node1: Public = "843645726384530ffb0c52f175278143b5a93959af7864460f5a4fec9afd1450cfb8aef63dec90657f43f55b13e0a73c7524d4e9a13c051b4e5f1e53f39ecd91".parse().unwrap(); + let node2: Public = "07230e34ebfe41337d3ed53b186b3861751f2401ee74b988bba55694e2a6f60c757677e194be2e53c3523cc8548694e636e6acb35c4e8fdc5e29d28679b9b2f3".parse().unwrap(); + let nodes = vec![node1, node2].into_iter().collect(); + assert_eq!(parse_request(&HttpMethod::Post, "/admin/servers_set_change/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/b199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01", + &r#"["0x843645726384530ffb0c52f175278143b5a93959af7864460f5a4fec9afd1450cfb8aef63dec90657f43f55b13e0a73c7524d4e9a13c051b4e5f1e53f39ecd91", + "0x07230e34ebfe41337d3ed53b186b3861751f2401ee74b988bba55694e2a6f60c757677e194be2e53c3523cc8548694e636e6acb35c4e8fdc5e29d28679b9b2f3"]"#), + Request::ChangeServersSet( + "a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap(), + "b199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01".parse().unwrap(), + nodes, + )); } #[test] fn parse_request_failed() { - assert_eq!(parse_request(&HttpMethod::Get, ""), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "/shadow"), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "///2"), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "/shadow///2"), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001"), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/"), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "/a/b"), Request::Invalid); - assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/0000000000000000000000000000000000000000000000000000000000000002/0000000000000000000000000000000000000000000000000000000000000002"), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "/shadow", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "///2", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "/shadow///2", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "/a/b", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Get, "/0000000000000000000000000000000000000000000000000000000000000001/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/0000000000000000000000000000000000000000000000000000000000000002/0000000000000000000000000000000000000000000000000000000000000002", Default::default()), Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Post, "/admin/servers_set_change/xxx/yyy", + &r#"["0x843645726384530ffb0c52f175278143b5a93959af7864460f5a4fec9afd1450cfb8aef63dec90657f43f55b13e0a73c7524d4e9a13c051b4e5f1e53f39ecd91", + "0x07230e34ebfe41337d3ed53b186b3861751f2401ee74b988bba55694e2a6f60c757677e194be2e53c3523cc8548694e636e6acb35c4e8fdc5e29d28679b9b2f3"]"#), + Request::Invalid); + assert_eq!(parse_request(&HttpMethod::Post, "/admin/servers_set_change/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01/a199fb39e11eefb61c78a4074a53c0d4424600a3e74aad4fb9d93a26c30d067e1d4d29936de0c73f19827394a1dd049480a0d581aee7ae7546968da7d3d1c2fd01", ""), + Request::Invalid); } } diff --git a/secret_store/src/key_server.rs b/secret_store/src/key_server.rs index ac6c45489..0d23b99c8 100644 --- a/secret_store/src/key_server.rs +++ b/secret_store/src/key_server.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::collections::BTreeSet; use std::thread; use std::sync::Arc; use std::sync::mpsc; @@ -26,9 +27,9 @@ use super::acl_storage::AclStorage; use super::key_storage::KeyStorage; use super::key_server_set::KeyServerSet; use key_server_cluster::{math, ClusterCore}; -use traits::{ServerKeyGenerator, DocumentKeyServer, MessageSigner, KeyServer, NodeKeyPair}; +use traits::{AdminSessionsServer, ServerKeyGenerator, DocumentKeyServer, MessageSigner, KeyServer, NodeKeyPair}; use types::all::{Error, Public, RequestSignature, ServerKeyId, EncryptedDocumentKey, EncryptedDocumentKeyShadow, - ClusterConfiguration, MessageHash, EncryptedMessageSignature}; + ClusterConfiguration, MessageHash, EncryptedMessageSignature, NodeId}; use key_server_cluster::{ClusterClient, ClusterConfiguration as NetClusterConfiguration}; /// Secret store key server implementation @@ -60,6 +61,14 @@ impl KeyServerImpl { impl KeyServer for KeyServerImpl {} +impl AdminSessionsServer for KeyServerImpl { + fn change_servers_set(&self, old_set_signature: RequestSignature, new_set_signature: RequestSignature, new_servers_set: BTreeSet) -> Result<(), Error> { + let servers_set_change_session = self.data.lock().cluster + .new_servers_set_change_session(None, new_servers_set, old_set_signature, new_set_signature)?; + servers_set_change_session.wait().map_err(Into::into) + } +} + impl ServerKeyGenerator for KeyServerImpl { fn generate_key(&self, key_id: &ServerKeyId, signature: &RequestSignature, threshold: usize) -> Result { // recover requestor' public key from signature @@ -153,7 +162,7 @@ impl KeyServerCore { allow_connecting_to_higher_nodes: config.allow_connecting_to_higher_nodes, acl_storage: acl_storage, key_storage: key_storage, - admin_public: None, + admin_public: config.admin_public.clone(), }; let (stop, stopped) = futures::oneshot(); @@ -191,6 +200,7 @@ impl Drop for KeyServerCore { #[cfg(test)] pub mod tests { + use std::collections::BTreeSet; use std::time; use std::sync::Arc; use std::net::SocketAddr; @@ -204,14 +214,20 @@ pub mod tests { use key_server_cluster::math; use bigint::hash::H256; use types::all::{Error, Public, ClusterConfiguration, NodeAddress, RequestSignature, ServerKeyId, - EncryptedDocumentKey, EncryptedDocumentKeyShadow, MessageHash, EncryptedMessageSignature}; - use traits::{ServerKeyGenerator, DocumentKeyServer, MessageSigner, KeyServer}; + EncryptedDocumentKey, EncryptedDocumentKeyShadow, MessageHash, EncryptedMessageSignature, NodeId}; + use traits::{AdminSessionsServer, ServerKeyGenerator, DocumentKeyServer, MessageSigner, KeyServer}; use super::KeyServerImpl; pub struct DummyKeyServer; impl KeyServer for DummyKeyServer {} + impl AdminSessionsServer for DummyKeyServer { + fn change_servers_set(&self, _old_set_signature: RequestSignature, _new_set_signature: RequestSignature, _new_servers_set: BTreeSet) -> Result<(), Error> { + unimplemented!() + } + } + impl ServerKeyGenerator for DummyKeyServer { fn generate_key(&self, _key_id: &ServerKeyId, _signature: &RequestSignature, _threshold: usize) -> Result { unimplemented!() @@ -444,4 +460,9 @@ pub mod tests { // check signature assert_eq!(math::verify_signature(&server_public, &(signature_c, signature_s), &message_hash), Ok(true)); } + + #[test] + fn servers_set_change_session_works_over_network() { + // TODO + } } diff --git a/secret_store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs b/secret_store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs index feb23c9ae..223caef21 100644 --- a/secret_store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs +++ b/secret_store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs @@ -412,7 +412,7 @@ impl SessionImpl { key_share: key_share, result_computer: Arc::new(LargestSupportResultComputer {}), transport: ServersSetChangeKeyVersionNegotiationTransport { - id: key_id, + id: self.core.meta.id.clone(), nonce: self.core.nonce, cluster: self.core.cluster.clone(), }, @@ -687,7 +687,7 @@ impl SessionImpl { /// Create share change session. fn create_share_change_session(core: &SessionCore, key_id: SessionId, master_node_id: NodeId, session_plan: ShareChangeSessionPlan) -> Result { ShareChangeSession::new(ShareChangeSessionParams { - session_id: key_id.clone(), + session_id: core.meta.id.clone(), nonce: core.nonce, meta: ShareChangeSessionMeta { id: key_id, @@ -726,7 +726,7 @@ impl SessionImpl { key_share: key_share, result_computer: Arc::new(LargestSupportResultComputer {}), // TODO: optimizations: could use modified Fast version transport: ServersSetChangeKeyVersionNegotiationTransport { - id: key_id, + id: core.meta.id.clone(), nonce: core.nonce, cluster: core.cluster.clone(), }, @@ -855,11 +855,20 @@ impl SessionImpl { /// Complete servers set change session. fn complete_session(core: &SessionCore, data: &mut SessionData) -> Result<(), Error> { debug_assert_eq!(core.meta.self_node_id, core.meta.master_node_id); + + // send completion notification core.cluster.broadcast(Message::ServersSetChange(ServersSetChangeMessage::ServersSetChangeCompleted(ServersSetChangeCompleted { session: core.meta.id.clone().into(), session_nonce: core.nonce, })))?; + // if we are on the set of nodes that are being removed from the cluster, let's clear database + if !data.new_nodes_set.as_ref() + .expect("new_nodes_set is filled during initialization; session is completed after initialization; qed") + .contains(&core.meta.self_node_id) { + core.key_storage.clear().map_err(|e| Error::KeyStorage(e.into()))?; + } + data.state = SessionState::Finished; data.result = Some(Ok(())); core.completed.notify_all(); diff --git a/secret_store/src/key_server_cluster/client_sessions/decryption_session.rs b/secret_store/src/key_server_cluster/client_sessions/decryption_session.rs index e907f6c13..087fc9245 100644 --- a/secret_store/src/key_server_cluster/client_sessions/decryption_session.rs +++ b/secret_store/src/key_server_cluster/client_sessions/decryption_session.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::collections::BTreeSet; use std::sync::Arc; use parking_lot::{Mutex, Condvar}; use bigint::hash::H256; @@ -243,14 +244,19 @@ impl SessionImpl { let mut data = self.data.lock(); let non_isolated_nodes = self.core.cluster.nodes(); - data.consensus_session.consensus_job_mut().transport_mut().version = Some(version.clone()); - data.version = Some(version.clone()); - data.is_shadow_decryption = Some(is_shadow_decryption); - data.consensus_session.initialize(key_version.id_numbers.keys() + let mut consensus_nodes: BTreeSet<_> = key_version.id_numbers.keys() .filter(|n| non_isolated_nodes.contains(*n)) .cloned() .chain(::std::iter::once(self.core.meta.self_node_id.clone())) - .collect())?; + .collect(); + if let Some(&DelegationStatus::DelegatedFrom(delegation_master, _)) = data.delegation_status.as_ref() { + consensus_nodes.remove(&delegation_master); + } + + data.consensus_session.consensus_job_mut().transport_mut().version = Some(version.clone()); + data.version = Some(version.clone()); + data.is_shadow_decryption = Some(is_shadow_decryption); + data.consensus_session.initialize(consensus_nodes)?; if data.consensus_session.state() == ConsensusSessionState::ConsensusEstablished { self.core.disseminate_jobs(&mut data.consensus_session, &version, is_shadow_decryption)?; @@ -502,7 +508,10 @@ impl ClusterSession for SessionImpl { } fn is_finished(&self) -> bool { - self.data.lock().result.is_some() + let data = self.data.lock(); + data.consensus_session.state() == ConsensusSessionState::Failed + || data.consensus_session.state() == ConsensusSessionState::Finished + || data.result.is_some() } fn on_node_timeout(&self, node: &NodeId) { @@ -1146,7 +1155,7 @@ mod tests { // now check that: // 1) 4 of 5 sessions are in Finished state - assert_eq!(sessions.iter().filter(|s| s.state() == ConsensusSessionState::Finished).count(), 5); + assert_eq!(sessions.iter().filter(|s| s.state() == ConsensusSessionState::Finished).count(), 4); // 2) 1 session has decrypted key value assert_eq!(sessions[1].decrypted_secret().unwrap().unwrap(), EncryptedDocumentKeyShadow { decrypted_secret: SECRET_PLAIN.into(), diff --git a/secret_store/src/key_server_cluster/client_sessions/generation_session.rs b/secret_store/src/key_server_cluster/client_sessions/generation_session.rs index b6926751b..5c21d5786 100644 --- a/secret_store/src/key_server_cluster/client_sessions/generation_session.rs +++ b/secret_store/src/key_server_cluster/client_sessions/generation_session.rs @@ -1322,7 +1322,7 @@ pub mod tests { let mut core = Core::new().unwrap(); // prepare cluster objects for each node - let clusters = make_clusters(&core, 6022, num_nodes); + let clusters = make_clusters(&core, 6031, num_nodes); run_clusters(&clusters); // establish connections diff --git a/secret_store/src/key_server_cluster/client_sessions/signing_session.rs b/secret_store/src/key_server_cluster/client_sessions/signing_session.rs index 6ca47580e..2f33160fa 100644 --- a/secret_store/src/key_server_cluster/client_sessions/signing_session.rs +++ b/secret_store/src/key_server_cluster/client_sessions/signing_session.rs @@ -250,14 +250,19 @@ impl SessionImpl { let mut data = self.data.lock(); let non_isolated_nodes = self.core.cluster.nodes(); - data.consensus_session.consensus_job_mut().transport_mut().version = Some(version.clone()); - data.version = Some(version.clone()); - data.message_hash = Some(message_hash); - data.consensus_session.initialize(key_version.id_numbers.keys() + let mut consensus_nodes: BTreeSet<_> = key_version.id_numbers.keys() .filter(|n| non_isolated_nodes.contains(*n)) .cloned() .chain(::std::iter::once(self.core.meta.self_node_id.clone())) - .collect())?; + .collect(); + if let Some(&DelegationStatus::DelegatedFrom(delegation_master, _)) = data.delegation_status.as_ref() { + consensus_nodes.remove(&delegation_master); + } + + data.consensus_session.consensus_job_mut().transport_mut().version = Some(version.clone()); + data.version = Some(version.clone()); + data.message_hash = Some(message_hash); + data.consensus_session.initialize(consensus_nodes)?; if data.consensus_session.state() == ConsensusSessionState::ConsensusEstablished { let generation_session = GenerationSession::new(GenerationSessionParams { @@ -355,7 +360,6 @@ impl SessionImpl { Ok(()) } - /// When consensus-related message is received. pub fn on_consensus_message(&self, sender: &NodeId, message: &SigningConsensusMessage) -> Result<(), Error> { debug_assert!(self.core.meta.id == *message.session); @@ -629,7 +633,10 @@ impl ClusterSession for SessionImpl { } fn is_finished(&self) -> bool { - self.data.lock().result.is_some() + let data = self.data.lock(); + data.consensus_session.state() == ConsensusSessionState::Failed + || data.consensus_session.state() == ConsensusSessionState::Finished + || data.result.is_some() } fn on_node_timeout(&self, node: &NodeId) { diff --git a/secret_store/src/key_server_cluster/cluster.rs b/secret_store/src/key_server_cluster/cluster.rs index 23df97cb3..0a975c275 100644 --- a/secret_store/src/key_server_cluster/cluster.rs +++ b/secret_store/src/key_server_cluster/cluster.rs @@ -31,7 +31,7 @@ use bigint::hash::H256; use key_server_cluster::{Error, NodeId, SessionId, AclStorage, KeyStorage, KeyServerSet, NodeKeyPair}; use key_server_cluster::cluster_sessions::{ClusterSession, ClusterSessions, GenerationSessionWrapper, EncryptionSessionWrapper, DecryptionSessionWrapper, SigningSessionWrapper, AdminSessionWrapper, KeyNegotiationSessionWrapper, SessionIdWithSubSession, - ClusterSessionsContainer, SERVERS_SET_CHANGE_SESSION_ID, create_cluster_view}; + ClusterSessionsContainer, SERVERS_SET_CHANGE_SESSION_ID, create_cluster_view, AdminSessionCreationData}; use key_server_cluster::cluster_sessions_creator::{ClusterSessionCreator, IntoSessionId}; use key_server_cluster::message::{self, Message, ClusterMessage}; use key_server_cluster::generation_session::{Session as GenerationSession}; @@ -519,7 +519,7 @@ impl ClusterCore { let creation_data = SC::creation_data_from_message(&message)?; let master = if is_initialization_message { sender.clone() } else { data.self_key_pair.public().clone() }; let cluster = create_cluster_view(data, requires_all_connections(&message))?; - sessions.insert(cluster, master, session_id.clone(), Some(message.session_nonce().ok_or(Error::InvalidMessage)?), message.is_exclusive_session_message(), creation_data) + sessions.insert(cluster, master, session_id, Some(message.session_nonce().ok_or(Error::InvalidMessage)?), message.is_exclusive_session_message(), creation_data) }, } } @@ -536,7 +536,7 @@ impl ClusterCore { Ok(session) => session, Err(error) => { // this is new session => it is not yet in container - warn!(target: "secretstore_net", "{}: {} session initialization error '{}' when requested for new session from node {}", + warn!(target: "secretstore_net", "{}: {} session read error '{}' when requested for session from node {}", data.self_key_pair.public(), S::type_name(), error, sender); if message.is_initialization_message() { let session_id = message.into_session_id().expect("session_id only fails for cluster messages; only session messages are passed to process_message; qed"); @@ -969,7 +969,7 @@ impl ClusterClient for ClusterClientImpl { }; let cluster = create_cluster_view(&self.data, true)?; - let session = self.data.sessions.admin_sessions.insert(cluster, self.data.self_key_pair.public().clone(), session_id, None, true, None)?; + let session = self.data.sessions.admin_sessions.insert(cluster, self.data.self_key_pair.public().clone(), session_id, None, true, Some(AdminSessionCreationData::ServersSetChange))?; let initialization_result = session.as_servers_set_change().expect("servers set change session is created; qed") .initialize(new_nodes_set, old_set_signature, new_set_signature); @@ -1294,15 +1294,26 @@ pub mod tests { assert!(session.joint_public_and_secret().unwrap().is_ok()); // now remove share from node2 + assert!((0..3).all(|i| clusters[i].data.sessions.generation_sessions.is_empty())); clusters[2].data.config.key_storage.remove(&Default::default()).unwrap(); // and try to sign message with generated key let signature = sign(Random.generate().unwrap().secret(), &Default::default()).unwrap(); let session0 = clusters[0].client().new_signing_session(Default::default(), signature, None, Default::default()).unwrap(); let session = clusters[0].data.sessions.signing_sessions.first().unwrap(); - loop_until(&mut core, time::Duration::from_millis(300), || session.is_finished()); + + loop_until(&mut core, time::Duration::from_millis(300), || session.is_finished() && (0..3).all(|i| + clusters[i].data.sessions.signing_sessions.is_empty())); session0.wait().unwrap(); + // and try to sign message with generated key using node that has no key share + let signature = sign(Random.generate().unwrap().secret(), &Default::default()).unwrap(); + let session2 = clusters[2].client().new_signing_session(Default::default(), signature, None, Default::default()).unwrap(); + let session = clusters[2].data.sessions.signing_sessions.first().unwrap(); + loop_until(&mut core, time::Duration::from_millis(300), || session.is_finished() && (0..3).all(|i| + clusters[i].data.sessions.signing_sessions.is_empty())); + session2.wait().unwrap(); + // now remove share from node1 clusters[1].data.config.key_storage.remove(&Default::default()).unwrap(); diff --git a/secret_store/src/key_server_cluster/cluster_sessions.rs b/secret_store/src/key_server_cluster/cluster_sessions.rs index ce98bd878..254e3ecc6 100644 --- a/secret_store/src/key_server_cluster/cluster_sessions.rs +++ b/secret_store/src/key_server_cluster/cluster_sessions.rs @@ -66,7 +66,7 @@ pub struct SessionIdWithSubSession { /// Generic cluster session. pub trait ClusterSession { /// Session identifier type. - type Id: Ord + Clone; + type Id: ::std::fmt::Debug + Ord + Clone; /// Session type name. fn type_name() -> &'static str; @@ -662,6 +662,13 @@ impl AdminSessionWrapper { cluster: cluster, }) } + + pub fn wait(&self) -> Result<(), Error> { + match *self.session { + AdminSession::ShareAdd(ref session) => session.wait(), + AdminSession::ServersSetChange(ref session) => session.wait(), + } + } } impl ShareAddSession for AdminSessionWrapper { diff --git a/secret_store/src/key_server_cluster/message.rs b/secret_store/src/key_server_cluster/message.rs index 43d27d1fd..357786725 100644 --- a/secret_store/src/key_server_cluster/message.rs +++ b/secret_store/src/key_server_cluster/message.rs @@ -1163,7 +1163,7 @@ impl fmt::Display for ConsensusMessageWithServersSet { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ConsensusMessageWithServersSet::InitializeConsensusSession(_) => write!(f, "InitializeConsensusSession"), - ConsensusMessageWithServersSet::ConfirmConsensusInitialization(_) => write!(f, "ConfirmConsensusInitialization"), + ConsensusMessageWithServersSet::ConfirmConsensusInitialization(ref msg) => write!(f, "ConfirmConsensusInitialization({})", msg.is_confirmed), } } } @@ -1172,7 +1172,7 @@ impl fmt::Display for ConsensusMessageOfShareAdd { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ConsensusMessageOfShareAdd::InitializeConsensusSession(_) => write!(f, "InitializeConsensusSession"), - ConsensusMessageOfShareAdd::ConfirmConsensusInitialization(_) => write!(f, "ConfirmConsensusInitialization"), + ConsensusMessageOfShareAdd::ConfirmConsensusInitialization(ref msg) => write!(f, "ConfirmConsensusInitialization({})", msg.is_confirmed), } } } diff --git a/secret_store/src/traits.rs b/secret_store/src/traits.rs index 7ee4c5cc1..0982f40e3 100644 --- a/secret_store/src/traits.rs +++ b/secret_store/src/traits.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::collections::BTreeSet; use ethkey::{KeyPair, Signature, Error as EthKeyError}; use bigint::hash::H256; use types::all::{Error, Public, ServerKeyId, MessageHash, EncryptedMessageSignature, RequestSignature, EncryptedDocumentKey, - EncryptedDocumentKeyShadow}; + EncryptedDocumentKeyShadow, NodeId}; /// Node key pair. pub trait NodeKeyPair: Send + Sync { @@ -81,7 +82,15 @@ pub trait MessageSigner: ServerKeyGenerator { fn sign_message(&self, key_id: &ServerKeyId, signature: &RequestSignature, message: MessageHash) -> Result; } +/// Administrative sessions server. +pub trait AdminSessionsServer { + /// Change servers set so that nodes in new_servers_set became owners of shares for all keys. + /// And old nodes (i.e. cluste nodes except new_servers_set) have clear databases. + /// WARNING: newly generated keys will be distributed among all cluster nodes. So this session + /// must be followed with cluster nodes change (either via contract, or config files). + fn change_servers_set(&self, old_set_signature: RequestSignature, new_set_signature: RequestSignature, new_servers_set: BTreeSet) -> Result<(), Error>; +} /// Key server. -pub trait KeyServer: DocumentKeyServer + MessageSigner + Send + Sync { +pub trait KeyServer: AdminSessionsServer + DocumentKeyServer + MessageSigner + Send + Sync { } From 6fabb56104fcf6a345f54273a696de81ac73c4b6 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 17 Nov 2017 17:12:12 +0100 Subject: [PATCH 29/31] fix tests on patricia-trie --- Cargo.lock | 5 ++++- stratum/Cargo.toml | 3 +-- stratum/src/lib.rs | 3 ++- util/patricia_trie/src/triedbmut.rs | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ac8bdd15..044bf2b03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -424,6 +424,9 @@ dependencies = [ name = "error-chain" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "eth-secp256k1" @@ -705,7 +708,6 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.2.1", "ethcore-logger 1.9.0", - "ethcore-util 1.9.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", @@ -2131,6 +2133,7 @@ dependencies = [ "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.9)", + "keccak-hash 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index eed15b4f0..d7245796e 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] [dependencies] ethcore-bigint = { path = "../util/bigint" } ethcore-logger = { path = "../logger" } -hash = { path = "../util/hash" } +keccak-hash = { path = "../util/hash" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.9" } @@ -21,4 +21,3 @@ tokio-core = "0.1" tokio-io = "0.1" parking_lot = "0.4" ethcore-logger = { path = "../logger" } -keccak-hash = { path = "../util/hash" } diff --git a/stratum/src/lib.rs b/stratum/src/lib.rs index 20bddf2f6..ebe90e8e4 100644 --- a/stratum/src/lib.rs +++ b/stratum/src/lib.rs @@ -19,11 +19,12 @@ extern crate jsonrpc_tcp_server; extern crate jsonrpc_core; extern crate jsonrpc_macros; -#[macro_use] extern crate log; extern crate ethcore_bigint as bigint; extern crate keccak_hash as hash; extern crate parking_lot; +#[macro_use] extern crate log; + #[cfg(test)] extern crate tokio_core; #[cfg(test)] extern crate tokio_io; #[cfg(test)] extern crate ethcore_logger; diff --git a/util/patricia_trie/src/triedbmut.rs b/util/patricia_trie/src/triedbmut.rs index 97c3c93e7..d0bef2181 100644 --- a/util/patricia_trie/src/triedbmut.rs +++ b/util/patricia_trie/src/triedbmut.rs @@ -262,12 +262,12 @@ impl<'a> Index<&'a StorageHandle> for NodeStorage { /// # Example /// ``` /// extern crate patricia_trie as trie; +/// extern crate keccak_hash; /// extern crate hashdb; /// extern crate memorydb; /// extern crate ethcore_bigint as bigint; -/// extern crate hash; /// -/// use hash::KECCAK_NULL_RLP; +/// use keccak_hash::KECCAK_NULL_RLP; /// use trie::*; /// use hashdb::*; /// use memorydb::*; From 5a20a826c4f22c8b577c49cfc86de3448294163f Mon Sep 17 00:00:00 2001 From: 5chdn <5chdn@users.noreply.github.com> Date: Mon, 20 Nov 2017 13:07:53 +0100 Subject: [PATCH 30/31] Improve Github Issue Template: IT CROWD approved version. --- .github/ISSUE_TEMPLATE.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f4b5311d5..3e526e5fa 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,9 +2,11 @@ _Before filing a new issue, please **provide the following information**._ > I'm running: > -> - **Parity version**: 0.0.0 -> - **Operating system**: Windows / MacOS / Linux -> - **And installed**: via installer / homebrew / binaries / from source +> - **Which Parity version?**: 0.0.0 +> - **Which operating system?**: Windows / MacOS / Linux +> - **How installed?**: via installer / homebrew / binaries / from source +> - **Are you fully synchronized?**: no / yes +> - **Did you try to restart the node?**: no / yes _Your issue description goes here below. Try to include **actual** vs. **expected behavior** and **steps to reproduce** the issue._ From 3d68051a1fa51d820dbddb5a18cbca51fa39b997 Mon Sep 17 00:00:00 2001 From: 5chdn <5chdn@users.noreply.github.com> Date: Mon, 20 Nov 2017 13:23:44 +0100 Subject: [PATCH 31/31] Remove seperator that causes issue descriptions to become headlines sometimes --- .github/ISSUE_TEMPLATE.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 3e526e5fa..506667ef9 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -9,6 +9,3 @@ _Before filing a new issue, please **provide the following information**._ > - **Did you try to restart the node?**: no / yes _Your issue description goes here below. Try to include **actual** vs. **expected behavior** and **steps to reproduce** the issue._ - ---- -