From 8ac5cad107c078347b336cdda78838691798826d Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Sat, 18 May 2019 02:05:00 +0200 Subject: [PATCH 001/113] feat(light client): fetch block body from remote (#2527) * feat(on_demand): block body request * fix(light block req): no justific + one block * fix(bad rebase) * feat(protocol): add messages for `remote_body` * fix(on demand body): remove needless `take()` * fix(network): remove messages for `on_demand_body` * fix(grumbles): use `hash` in `remote_body_requests` As long as we can't compute `ordered_trie_root(body)` just compare that request.header.hash() == response.header.hash() * fix(grumbles): `hdr.ext_root == trie_root(body)` * fix(grumbles): propogate `Err` in `fn body()` * fix(grumbles): Vec * fix(grumbles): util_fn for `not_impl` in tests * fix(on remote body): tests `fetch` and `on_demand` * docs(resolve todos) --- core/client/src/light/blockchain.rs | 18 ++- core/client/src/light/fetcher.rs | 132 +++++++++++++++++++-- core/network/src/message.rs | 2 +- core/network/src/on_demand.rs | 172 +++++++++++++++++++++++++++- core/network/src/protocol.rs | 23 +++- core/test-client/src/lib.rs | 8 ++ 6 files changed, 328 insertions(+), 27 deletions(-) diff --git a/core/client/src/light/blockchain.rs b/core/client/src/light/blockchain.rs index c38d50303e..d7fcd44232 100644 --- a/core/client/src/light/blockchain.rs +++ b/core/client/src/light/blockchain.rs @@ -30,7 +30,7 @@ use crate::blockchain::{Backend as BlockchainBackend, BlockStatus, Cache as Bloc HeaderBackend as BlockchainHeaderBackend, Info as BlockchainInfo, ProvideCache}; use crate::cht; use crate::error::{Error as ClientError, Result as ClientResult}; -use crate::light::fetcher::{Fetcher, RemoteHeaderRequest}; +use crate::light::fetcher::{Fetcher, RemoteBodyRequest, RemoteHeaderRequest}; /// Light client blockchain storage. pub trait Storage: AuxStore + BlockchainHeaderBackend { @@ -144,9 +144,19 @@ impl BlockchainHeaderBackend for Blockchain where Bloc } impl BlockchainBackend for Blockchain where Block: BlockT, S: Storage, F: Fetcher { - fn body(&self, _id: BlockId) -> ClientResult>> { - // TODO: #1445 fetch from remote node - Ok(None) + fn body(&self, id: BlockId) -> ClientResult>> { + let header = match self.header(id)? { + Some(header) => header, + None => return Ok(None), + }; + + self.fetcher().upgrade().ok_or(ClientError::NotAvailableOnLightClient)? + .remote_body(RemoteBodyRequest { + header, + retry_count: None, + }) + .into_future().wait() + .map(Some) } fn justification(&self, _id: BlockId) -> ClientResult> { diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index 1e6f0842fb..ff6d3c5c45 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -22,8 +22,9 @@ use std::marker::PhantomData; use futures::IntoFuture; use hash_db::{HashDB, Hasher}; +use parity_codec::Encode; use primitives::{ChangesTrieConfiguration, convert_hash}; -use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, NumberFor}; +use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor}; use state_machine::{CodeExecutor, ChangesTrieRootsStorage, ChangesTrieAnchorBlockId, TrieBackend, read_proof_check, key_changes_proof_check, create_proof_check_backend_storage, read_child_proof_check}; @@ -124,17 +125,28 @@ pub struct ChangesProof { pub roots_proof: Vec>, } +/// Remote block body request +#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)] +pub struct RemoteBodyRequest { + /// Header of the requested block body + pub header: Header, + /// Number of times to retry request. None means that default RETRY_COUNT is used. + pub retry_count: Option, +} + /// Light client data fetcher. Implementations of this trait must check if remote data /// is correct (see FetchedDataChecker) and return already checked data. pub trait Fetcher: Send + Sync { /// Remote header future. - type RemoteHeaderResult: IntoFuture; + type RemoteHeaderResult: IntoFuture; /// Remote storage read future. - type RemoteReadResult: IntoFuture>, Error=ClientError>; + type RemoteReadResult: IntoFuture>, Error = ClientError>; /// Remote call result future. - type RemoteCallResult: IntoFuture, Error=ClientError>; + type RemoteCallResult: IntoFuture, Error = ClientError>; /// Remote changes result future. - type RemoteChangesResult: IntoFuture, u32)>, Error=ClientError>; + type RemoteChangesResult: IntoFuture, u32)>, Error = ClientError>; + /// Remote block body result future. + type RemoteBodyResult: IntoFuture, Error = ClientError>; /// Fetch remote header. fn remote_header(&self, request: RemoteHeaderRequest) -> Self::RemoteHeaderResult; @@ -153,6 +165,8 @@ pub trait Fetcher: Send + Sync { /// Fetch remote changes ((block number, extrinsic index)) where given key has been changed /// at a given blocks range. fn remote_changes(&self, request: RemoteChangesRequest) -> Self::RemoteChangesResult; + /// Fetch remote block body + fn remote_body(&self, request: RemoteBodyRequest) -> Self::RemoteBodyResult; } /// Light client remote data checker. @@ -191,6 +205,12 @@ pub trait FetchChecker: Send + Sync { request: &RemoteChangesRequest, proof: ChangesProof ) -> ClientResult, u32)>>; + /// Check remote body proof. + fn check_body_proof( + &self, + request: &RemoteBodyRequest, + body: Vec + ) -> ClientResult>; } /// Remote data checker. @@ -396,6 +416,25 @@ impl FetchChecker for LightDataChecker ClientResult, u32)>> { self.check_changes_proof_with_cht_size(request, remote_proof, cht::SIZE) } + + fn check_body_proof( + &self, + request: &RemoteBodyRequest, + body: Vec + ) -> ClientResult> { + + // TODO: #2621 + let extrinsics_root = HashFor::::ordered_trie_root(body.iter().map(Encode::encode)); + if *request.header.extrinsics_root() == extrinsics_root { + Ok(body) + } else { + Err(format!("RemoteBodyRequest: invalid extrinsics root expected: {} but got {}", + *request.header.extrinsics_root(), + extrinsics_root, + ).into()) + } + + } } /// A view of BTreeMap as a changes trie roots storage. @@ -438,7 +477,7 @@ pub mod tests { use crate::error::Error as ClientError; use test_client::{ self, TestClient, blockchain::HeaderBackend, AccountKeyring, - runtime::{self, Hash, Block, Header} + runtime::{self, Hash, Block, Header, Extrinsic} }; use consensus::BlockOrigin; @@ -446,7 +485,7 @@ pub mod tests { use crate::light::fetcher::{Fetcher, FetchChecker, LightDataChecker, RemoteCallRequest, RemoteHeaderRequest}; use crate::light::blockchain::tests::{DummyStorage, DummyBlockchain}; - use primitives::{blake2_256, Blake2Hasher}; + use primitives::{blake2_256, Blake2Hasher, H256}; use primitives::storage::{StorageKey, well_known_keys}; use runtime_primitives::generic::BlockId; use state_machine::Backend; @@ -454,22 +493,30 @@ pub mod tests { pub type OkCallFetcher = Mutex>; + fn not_implemented_in_tests() -> FutureResult + where + E: std::convert::From<&'static str>, + { + err("Not implemented on test node".into()) + } + impl Fetcher for OkCallFetcher { type RemoteHeaderResult = FutureResult; type RemoteReadResult = FutureResult>, ClientError>; type RemoteCallResult = FutureResult, ClientError>; type RemoteChangesResult = FutureResult, u32)>, ClientError>; + type RemoteBodyResult = FutureResult, ClientError>; fn remote_header(&self, _request: RemoteHeaderRequest
) -> Self::RemoteHeaderResult { - err("Not implemented on test node".into()) + not_implemented_in_tests() } fn remote_read(&self, _request: RemoteReadRequest
) -> Self::RemoteReadResult { - err("Not implemented on test node".into()) + not_implemented_in_tests() } fn remote_read_child(&self, _request: RemoteReadChildRequest
) -> Self::RemoteReadResult { - err("Not implemented on test node".into()) + not_implemented_in_tests() } fn remote_call(&self, _request: RemoteCallRequest
) -> Self::RemoteCallResult { @@ -477,11 +524,21 @@ pub mod tests { } fn remote_changes(&self, _request: RemoteChangesRequest
) -> Self::RemoteChangesResult { - err("Not implemented on test node".into()) + not_implemented_in_tests() + } + + fn remote_body(&self, _request: RemoteBodyRequest
) -> Self::RemoteBodyResult { + not_implemented_in_tests() } } - type TestChecker = LightDataChecker, Blake2Hasher, Block, DummyStorage, OkCallFetcher>; + type TestChecker = LightDataChecker< + executor::NativeExecutor, + Blake2Hasher, + Block, + DummyStorage, + OkCallFetcher, + >; fn prepare_for_read_proof_check() -> (TestChecker, Header, Vec>, u32) { // prepare remote client @@ -537,6 +594,14 @@ pub mod tests { (local_checker, local_cht_root, remote_block_header, remote_header_proof) } + fn header_with_computed_extrinsics_root(extrinsics: Vec) -> Header { + let extrinsics_root = + trie::ordered_trie_root::(extrinsics.iter().map(Encode::encode)); + + // only care about `extrinsics_root` + Header::new(0, extrinsics_root, H256::zero(), H256::zero(), Default::default()) + } + #[test] fn storage_read_proof_is_generated_and_checked() { let (local_checker, remote_block_header, remote_read_proof, authorities_len) = prepare_for_read_proof_check(); @@ -776,4 +841,47 @@ pub mod tests { ); assert!(local_checker.check_changes_tries_proof(4, &remote_proof.roots, vec![]).is_err()); } + + #[test] + fn check_body_proof_faulty() { + let header = header_with_computed_extrinsics_root( + vec![Extrinsic::IncludeData(vec![1, 2, 3, 4])] + ); + let block = Block::new(header.clone(), Vec::new()); + + let local_checker = TestChecker::new( + Arc::new(DummyBlockchain::new(DummyStorage::new())), + test_client::LocalExecutor::new(None) + ); + + let body_request = RemoteBodyRequest { + header: header.clone(), + retry_count: None, + }; + + assert!( + local_checker.check_body_proof(&body_request, block.extrinsics).is_err(), + "vec![1, 2, 3, 4] != vec![]" + ); + } + + #[test] + fn check_body_proof_of_same_data_should_succeed() { + let extrinsics = vec![Extrinsic::IncludeData(vec![1, 2, 3, 4, 5, 6, 7, 8, 255])]; + + let header = header_with_computed_extrinsics_root(extrinsics.clone()); + let block = Block::new(header.clone(), extrinsics); + + let local_checker = TestChecker::new( + Arc::new(DummyBlockchain::new(DummyStorage::new())), + test_client::LocalExecutor::new(None) + ); + + let body_request = RemoteBodyRequest { + header: header.clone(), + retry_count: None, + }; + + assert!(local_checker.check_body_proof(&body_request, block.extrinsics).is_ok()); + } } diff --git a/core/network/src/message.rs b/core/network/src/message.rs index 3166703389..6a38c106b7 100644 --- a/core/network/src/message.rs +++ b/core/network/src/message.rs @@ -205,7 +205,7 @@ pub mod generic { FinalityProofRequest(FinalityProofRequest), /// Finality proof reponse. FinalityProofResponse(FinalityProofResponse), - /// Chain-specific message + /// Chain-specific message. #[codec(index = "255")] ChainSpecific(Vec), } diff --git a/core/network/src/on_demand.rs b/core/network/src/on_demand.rs index aea762eefc..ec4c178232 100644 --- a/core/network/src/on_demand.rs +++ b/core/network/src/on_demand.rs @@ -22,13 +22,12 @@ use std::time::{Instant, Duration}; use log::{trace, info}; use futures::{Async, Future, Poll}; use futures::sync::oneshot::{channel, Receiver, Sender as OneShotSender}; -use linked_hash_map::LinkedHashMap; -use linked_hash_map::Entry; +use linked_hash_map::{Entry, LinkedHashMap}; use parking_lot::Mutex; use client::error::Error as ClientError; use client::light::fetcher::{Fetcher, FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, ChangesProof, - RemoteReadChildRequest}; + RemoteReadChildRequest, RemoteBodyRequest}; use crate::message; use network_libp2p::PeerId; use crate::config::Roles; @@ -76,6 +75,16 @@ pub trait OnDemandService: Send + Sync { peer: PeerId, response: message::RemoteChangesResponse, Block::Hash> ); + + /// When body response is received from remote node. + fn on_remote_body_response( + &self, + peer: PeerId, + response: message::BlockResponse + ); + + /// Check whether a block response is an `on_demand` response + fn is_on_demand_response(&self, peer: &PeerId, request_id: message::RequestId) -> bool; } /// Trait used by the `OnDemand` service to communicate messages back to the network. @@ -139,6 +148,7 @@ struct Request { } enum RequestData { + RemoteBody(RemoteBodyRequest, OneShotSender, ClientError>>), RemoteHeader(RemoteHeaderRequest, OneShotSender>), RemoteRead(RemoteReadRequest, OneShotSender>, ClientError>>), RemoteReadChild( @@ -391,6 +401,41 @@ impl OnDemandService for OnDemand where data => Accept::Unexpected(data), }) } + + fn on_remote_body_response(&self, peer: PeerId, response: message::BlockResponse) { + self.accept_response("body", peer, response.id, |request| match request.data { + RequestData::RemoteBody(request, sender) => { + let mut bodies: Vec<_> = response + .blocks + .into_iter() + .filter_map(|b| b.body) + .collect(); + + // Number of bodies are hardcoded to 1 for valid `RemoteBodyResponses` + if bodies.len() != 1 { + return Accept::CheckFailed( + "RemoteBodyResponse: invalid number of blocks".into(), + RequestData::RemoteBody(request, sender), + ) + } + let body = bodies.remove(0); + + match self.checker.check_body_proof(&request, body) { + Ok(body) => { + let _ = sender.send(Ok(body)); + Accept::Ok + } + Err(error) => Accept::CheckFailed(error, RequestData::RemoteBody(request, sender)), + } + } + other => Accept::Unexpected(other), + }) + } + + fn is_on_demand_response(&self, peer: &PeerId, request_id: message::RequestId) -> bool { + let core = self.core.lock(); + core.is_pending_request(&peer, request_id) + } } impl Fetcher for OnDemand where @@ -401,6 +446,7 @@ impl Fetcher for OnDemand where type RemoteReadResult = RemoteResponse>>; type RemoteCallResult = RemoteResponse>; type RemoteChangesResult = RemoteResponse, u32)>>; + type RemoteBodyResult = RemoteResponse>; fn remote_header(&self, request: RemoteHeaderRequest) -> Self::RemoteHeaderResult { let (sender, receiver) = channel(); @@ -440,12 +486,22 @@ impl Fetcher for OnDemand where self.schedule_request(request.retry_count.clone(), RequestData::RemoteChanges(request, sender), RemoteResponse { receiver }) } + + fn remote_body(&self, request: RemoteBodyRequest) -> Self::RemoteBodyResult { + let (sender, receiver) = channel(); + self.schedule_request(request.retry_count.clone(), RequestData::RemoteBody(request, sender), + RemoteResponse { receiver }) + } } impl OnDemandCore where B: BlockT, B::Header: HeaderT, { + fn is_pending_request(&self, peer: &PeerId, request_id: message::RequestId) -> bool { + self.active_peers.get(&peer).map_or(false, |r| r.id == request_id) + } + pub fn add_peer(&mut self, peer: PeerId, best_number: NumberFor) { self.idle_peers.push_back(peer.clone()); self.best_blocks.insert(peer, best_number); @@ -570,6 +626,7 @@ impl Request { RequestData::RemoteReadChild(ref data, _) => *data.header.number(), RequestData::RemoteCall(ref data, _) => *data.header.number(), RequestData::RemoteChanges(ref data, _) => data.max_block.0, + RequestData::RemoteBody(ref data, _) => *data.header.number(), } } @@ -610,6 +667,16 @@ impl Request { max: data.max_block.1.clone(), key: data.key.clone(), }), + RequestData::RemoteBody(ref data, _) => { + message::generic::Message::BlockRequest(message::BlockRequest:: { + id: self.id, + fields: message::BlockAttributes::BODY, + from: message::FromBlock::Hash(data.header.hash()), + to: None, + direction: message::Direction::Ascending, + max: Some(1), + }) + } } } } @@ -623,6 +690,7 @@ impl RequestData { RequestData::RemoteRead(_, sender) => { let _ = sender.send(Err(error)); }, RequestData::RemoteReadChild(_, sender) => { let _ = sender.send(Err(error)); }, RequestData::RemoteChanges(_, sender) => { let _ = sender.send(Err(error)); }, + RequestData::RemoteBody(_, sender) => { let _ = sender.send(Err(error)); }, } } } @@ -637,12 +705,12 @@ pub mod tests { use client::{error::{Error as ClientError, Result as ClientResult}}; use client::light::fetcher::{Fetcher, FetchChecker, RemoteHeaderRequest, ChangesProof, RemoteCallRequest, RemoteReadRequest, - RemoteReadChildRequest, RemoteChangesRequest}; + RemoteReadChildRequest, RemoteChangesRequest, RemoteBodyRequest}; use crate::config::Roles; use crate::message; use network_libp2p::PeerId; use super::{REQUEST_TIMEOUT, OnDemand, OnDemandNetwork, OnDemandService}; - use test_client::runtime::{changes_trie_config, Block, Header}; + use test_client::runtime::{changes_trie_config, Block, Extrinsic, Header}; pub struct DummyExecutor; struct DummyFetchChecker { ok: bool } @@ -685,12 +753,27 @@ pub mod tests { } } - fn check_changes_proof(&self, _: &RemoteChangesRequest
, _: ChangesProof
) -> ClientResult, u32)>> { + fn check_changes_proof( + &self, + _: &RemoteChangesRequest
, + _: ChangesProof
+ ) -> ClientResult, u32)>> { match self.ok { true => Ok(vec![(100, 2)]), false => Err(ClientError::Backend("Test error".into())), } } + + fn check_body_proof( + &self, + _: &RemoteBodyRequest
, + body: Vec + ) -> ClientResult> { + match self.ok { + true => Ok(body), + false => Err(ClientError::Backend("Test error".into())), + } + } } fn dummy(ok: bool) -> (Arc, Arc>) { @@ -1166,4 +1249,81 @@ pub mod tests { assert!(on_demand.core.lock().idle_peers.iter().cloned().collect::>().is_empty()); assert_eq!(on_demand.core.lock().pending_requests.len(), 1); } + + #[test] + fn remote_body_with_one_block_body_should_succeed() { + let (_x, on_demand) = dummy(true); + let network_interface = Arc::new(DummyNetwork::default()); + let peer1 = PeerId::random(); + on_demand.set_network_interface(Box::new(network_interface.clone())); + + let header = dummy_header(); + on_demand.on_connect(peer1.clone(), Roles::FULL, 250); + + on_demand.remote_body(RemoteBodyRequest { + header: header.clone(), + retry_count: None, + }); + + assert!(on_demand.core.lock().pending_requests.is_empty()); + assert_eq!(on_demand.core.lock().active_peers.len(), 1); + + let block = message::BlockData:: { + hash: primitives::H256::random(), + header: None, + body: Some(Vec::new()), + message_queue: None, + receipt: None, + justification: None, + }; + + let response = message::generic::BlockResponse { + id: 0, + blocks: vec![block], + }; + + on_demand.on_remote_body_response(peer1.clone(), response); + + assert!(on_demand.core.lock().active_peers.is_empty()); + assert_eq!(on_demand.core.lock().idle_peers.len(), 1); + } + + #[test] + fn remote_body_with_three_bodies_should_fail() { + let (_x, on_demand) = dummy(true); + let network_interface = Arc::new(DummyNetwork::default()); + let peer1 = PeerId::random(); + on_demand.set_network_interface(Box::new(network_interface.clone())); + + let header = dummy_header(); + on_demand.on_connect(peer1.clone(), Roles::FULL, 250); + + on_demand.remote_body(RemoteBodyRequest { + header: header.clone(), + retry_count: None, + }); + + assert!(on_demand.core.lock().pending_requests.is_empty()); + assert_eq!(on_demand.core.lock().active_peers.len(), 1); + + let response = { + let blocks: Vec<_> = (0..3).map(|_| message::BlockData:: { + hash: primitives::H256::random(), + header: None, + body: Some(Vec::new()), + message_queue: None, + receipt: None, + justification: None, + }).collect(); + + message::generic::BlockResponse { + id: 0, + blocks, + } + }; + + on_demand.on_remote_body_response(peer1.clone(), response); + assert!(on_demand.core.lock().active_peers.is_empty()); + assert!(on_demand.core.lock().idle_peers.is_empty(), "peer should be disconnected after bad response"); + } } diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 33e376aab3..685b447df6 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -324,6 +324,10 @@ impl, H: ExHashT> Future for Protocol, H: ExHashT> Protocol { + fn is_on_demand_response(&self, who: &PeerId, response_id: message::RequestId) -> bool { + self.on_demand.as_ref().map_or(false, |od| od.is_on_demand_response(&who, response_id)) + } + fn handle_response( &mut self, who: PeerId, @@ -365,10 +369,15 @@ impl, H: ExHashT> Protocol { GenericMessage::Status(s) => self.on_status_message(who, s), GenericMessage::BlockRequest(r) => self.on_block_request(who, r), GenericMessage::BlockResponse(r) => { - if let Some(request) = self.handle_response(who.clone(), &r) { - let outcome = self.on_block_response(who.clone(), request, r); - self.update_peer_info(&who); - return outcome + // Note, this is safe because only `ordinary bodies` and `remote bodies` are received in this matter. + if self.is_on_demand_response(&who, r.id) { + self.on_remote_body_response(who, r); + } else { + if let Some(request) = self.handle_response(who.clone(), &r) { + let outcome = self.on_block_response(who.clone(), request, r); + self.update_peer_info(&who); + return outcome + } } }, GenericMessage::BlockAnnounce(announce) => { @@ -1202,6 +1211,12 @@ impl, H: ExHashT> Protocol { CustomMessageOutcome::None } } + + fn on_remote_body_response(&self, peer: PeerId, response: message::BlockResponse) { + self.on_demand + .as_ref() + .map(|od| od.on_remote_body_response(peer, response)); + } } /// Outcome of an incoming custom message. diff --git a/core/test-client/src/lib.rs b/core/test-client/src/lib.rs index dfbb1fbcec..770b3de323 100644 --- a/core/test-client/src/lib.rs +++ b/core/test-client/src/lib.rs @@ -288,6 +288,7 @@ impl client::light::fetcher::Fetcher for LightFetcher { type RemoteReadResult = FutureResult>, client::error::Error>; type RemoteCallResult = FutureResult, client::error::Error>; type RemoteChangesResult = FutureResult, u32)>, client::error::Error>; + type RemoteBodyResult = FutureResult, client::error::Error>; fn remote_header( &self, @@ -323,4 +324,11 @@ impl client::light::fetcher::Fetcher for LightFetcher { ) -> Self::RemoteChangesResult { unimplemented!("not (yet) used in tests") } + + fn remote_body( + &self, + _request: client::light::fetcher::RemoteBodyRequest, + ) -> Self::RemoteBodyResult { + unimplemented!("not (yet) used in tests") + } } -- GitLab From 89a9556e30404a2772b9e235c631179f0c5e8d78 Mon Sep 17 00:00:00 2001 From: ddorgan Date: Sat, 18 May 2019 21:50:38 +0100 Subject: [PATCH 002/113] Flaming fir deployment scripts (#2599) * Initial commit of flaming fir deployment scripts * Debug * Fix formatting * Correct wget syntax * Use 8 char commit id * 9 chars * Use the longer CI_BUILD_REF ref to slice from * Fix backtick error with flaming fir deploy script * Use the correct commit id length * Split out validator deploments * Fix syntax, missing : * Pass hostname as TARGET_HOST per validator * Correct syntax * Uncomment wget * Switch deploy -> kubernetes * Use full group name * Check awx log * Fix if syntax and ignore failed * Use correct JOB_ID and fix if syntax * Use correct variable * Print ansible awx log and status * Make awx status clearer * make variable names consistent * Do 15 second checkups on the job * Remove extra echo * Use artifacts/VERSION instead of gitlab variables * Use all of the VERSION info --- .gitlab-ci.yml | 21 ++++++++++++++------- scripts/flamingfir-deploy.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100755 scripts/flamingfir-deploy.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bcedb0c6e1..ff4172aa5e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,8 @@ stages: - test - build - publish - - deploy + - kubernetes + - flaming-fir image: parity/rust-builder:latest @@ -264,7 +265,7 @@ publish-s3-doc: --human-readable --summarize .deploy-template: &deploy - stage: deploy + stage: kubernetes when: manual retry: 1 image: parity/kubetools:latest @@ -332,7 +333,7 @@ deploy-ue1-tag: name: parity-prod-ue1 .validator-deploy: &validator-deploy - stage: publish + stage: flaming-fir dependencies: - build-linux-release image: parity/azure-ansible:v1 @@ -344,10 +345,16 @@ deploy-ue1-tag: validator1: <<: *validator-deploy script: - - ansible-playbook -i scripts/ansible/inventory.ini -u gitlab scripts/ansible/alexander.yml -l validator1 - + - ./scripts/flamingfir-deploy.sh flamingfir-validator1 validator2: <<: *validator-deploy script: - - ansible-playbook -i scripts/ansible/inventory.ini -u gitlab scripts/ansible/alexander.yml -l validator2 - + - ./scripts/flamingfir-deploy.sh flamingfir-validator2 +validator3: + <<: *validator-deploy + script: + - ./scripts/flamingfir-deploy.sh flamingfir-validator3 +validator4: + <<: *validator-deploy + script: + - ./scripts/flamingfir-deploy.sh flamingfir-validator4 diff --git a/scripts/flamingfir-deploy.sh b/scripts/flamingfir-deploy.sh new file mode 100755 index 0000000000..ffd3cab9d8 --- /dev/null +++ b/scripts/flamingfir-deploy.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +RETRY_COUNT=10 +RETRY_ATTEMPT=0 +SLEEP_TIME=15 +TARGET_HOST="$1" +COMMIT=$(cat artifacts/VERSION) +DOWNLOAD_URL="https://releases.parity.io/substrate/x86_64-debian:stretch/${COMMIT}/substrate" +POST_DATA='{"extra_vars":{"artifact_path":"'${DOWNLOAD_URL}'","target_host":"'${TARGET_HOST}'"}}' + +JOB_ID=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" --header "Content-type: application/json" --post-data "${POST_DATA}" https://ansible-awx.parity.io/api/v2/job_templates/32/launch/ | jq .job) + +echo "Launched job: $JOB_ID" + + +while [ ${RETRY_ATTEMPT} -le ${RETRY_COUNT} ] ; do + export RETRY_RESULT=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/ | jq .status) + RETRY_ATTEMPT=$(( $RETRY_ATTEMPT +1 )) + sleep $SLEEP_TIME + if [ $(echo $RETRY_RESULT | egrep -e successful -e failed) ] ; then + break + fi +done + +AWX_OUTPUT=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/stdout?format=txt_download) + +echo "AWX job log:" +echo "${AWX_OUTPUT}" + + +JOB_STATUS=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/ | jq .status ) + +echo "===================================" +echo -e "Ansible AWX Remote Job: ${JOB_ID} \x1B[31mStatus: ${JOB_STATUS}\x1B[0m" +echo "===================================" -- GitLab From c8c7cfd2b3606f63290ae6967794fceeb826b0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sun, 19 May 2019 19:02:09 +0200 Subject: [PATCH 003/113] Access child storage over RPC. (#2586) * Access child storage over RPC. * Address review grumbles. * Test happy case in child_storage rpc. * Remove stray printlns * Fix line widths. * Bump runtime again. * Fix genesis storage root calculation for light clients. * Don't pass values to full_storage_root child_delta. --- core/client/db/src/storage_cache.rs | 6 +- core/client/src/client.rs | 31 +++++++- core/client/src/light/backend.rs | 15 +++- core/rpc/src/state/mod.rs | 87 ++++++++++++++++++++++- core/rpc/src/state/tests.rs | 44 ++++++++++-- core/sr-primitives/src/lib.rs | 22 +++++- core/state-machine/src/backend.rs | 44 ++++++++++-- core/state-machine/src/proving_backend.rs | 6 +- core/state-machine/src/trie_backend.rs | 2 +- core/test-client/src/lib.rs | 14 +++- node-template/runtime/wasm/Cargo.lock | 1 + 11 files changed, 248 insertions(+), 24 deletions(-) diff --git a/core/client/db/src/storage_cache.rs b/core/client/db/src/storage_cache.rs index 439a749c85..bc0a179cf8 100644 --- a/core/client/db/src/storage_cache.rs +++ b/core/client/db/src/storage_cache.rs @@ -397,10 +397,14 @@ impl, B:Block> StateBackend for CachingState) -> Vec> { + fn keys(&self, prefix: &[u8]) -> Vec> { self.state.keys(prefix) } + fn child_keys(&self, child_key: &[u8], prefix: &[u8]) -> Vec> { + self.state.child_keys(child_key, prefix) + } + fn try_into_trie_backend(self) -> Option> { self.state.try_into_trie_backend() } diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 4091e23b5f..257f120d72 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -337,19 +337,46 @@ impl Client where self.import_lock.clone() } - /// Return storage entry keys in state in a block of given hash with given prefix. + /// Given a `BlockId` and a key prefix, return the matching child storage keys in that block. pub fn storage_keys(&self, id: &BlockId, key_prefix: &StorageKey) -> error::Result> { let keys = self.state_at(id)?.keys(&key_prefix.0).into_iter().map(StorageKey).collect(); Ok(keys) } - /// Return single storage entry of contract under given address in state in a block of given hash. + /// Given a `BlockId` and a key, return the value under the key in that block. pub fn storage(&self, id: &BlockId, key: &StorageKey) -> error::Result> { Ok(self.state_at(id)? .storage(&key.0).map_err(|e| error::Error::from_state(Box::new(e)))? .map(StorageData)) } + /// Given a `BlockId`, a key prefix, and a child storage key, return the matching child storage keys. + pub fn child_storage_keys( + &self, + id: &BlockId, + child_storage_key: &StorageKey, + key_prefix: &StorageKey + ) -> error::Result> { + let keys = self.state_at(id)? + .child_keys(&child_storage_key.0, &key_prefix.0) + .into_iter() + .map(StorageKey) + .collect(); + Ok(keys) + } + + /// Given a `BlockId`, a key and a child storage key, return the value under the key in that block. + pub fn child_storage( + &self, + id: &BlockId, + child_storage_key: &StorageKey, + key: &StorageKey + ) -> error::Result> { + Ok(self.state_at(id)? + .child_storage(&child_storage_key.0, &key.0).map_err(|e| error::Error::from_state(Box::new(e)))? + .map(StorageData)) + } + /// Get the code at a given block. pub fn code_at(&self, id: &BlockId) -> error::Result> { Ok(self.storage(id, &StorageKey(well_known_keys::CODE.to_vec()))? diff --git a/core/client/src/light/backend.rs b/core/client/src/light/backend.rs index 52cdb6a626..0579c8c8d4 100644 --- a/core/client/src/light/backend.rs +++ b/core/client/src/light/backend.rs @@ -278,11 +278,20 @@ where // this is only called when genesis block is imported => shouldn't be performance bottleneck let mut storage: HashMap>, StorageOverlay> = HashMap::new(); storage.insert(None, top); + + // create a list of children keys to re-compute roots for + let child_delta = children.keys() + .cloned() + .map(|storage_key| (storage_key, None)) + .collect::>(); + + // make sure to persist the child storage for (child_key, child_storage) in children { storage.insert(Some(child_key), child_storage); } + let storage_update: InMemoryState = storage.into(); - let (storage_root, _) = storage_update.storage_root(::std::iter::empty()); + let (storage_root, _) = storage_update.full_storage_root(::std::iter::empty(), child_delta); self.storage_update = Some(storage_update); Ok(storage_root) @@ -373,7 +382,7 @@ where Vec::new() } - fn keys(&self, _prefix: &Vec) -> Vec> { + fn keys(&self, _prefix: &[u8]) -> Vec> { // whole state is not available on light node Vec::new() } @@ -465,7 +474,7 @@ where } } - fn keys(&self, prefix: &Vec) -> Vec> { + fn keys(&self, prefix: &[u8]) -> Vec> { match *self { OnDemandOrGenesisState::OnDemand(ref state) => StateBackend::::keys(state, prefix), diff --git a/core/rpc/src/state/mod.rs b/core/rpc/src/state/mod.rs index 168c0bd692..4cb7a3fbd8 100644 --- a/core/rpc/src/state/mod.rs +++ b/core/rpc/src/state/mod.rs @@ -57,7 +57,7 @@ pub trait StateApi { /// Returns the keys with prefix, leave empty to get all the keys #[rpc(name = "state_getKeys")] - fn storage_keys(&self, key: StorageKey, hash: Option) -> Result>; + fn storage_keys(&self, prefix: StorageKey, hash: Option) -> Result>; /// Returns a storage entry at a specific block's state. #[rpc(name = "state_getStorage", alias("state_getStorageAt"))] @@ -71,6 +71,40 @@ pub trait StateApi { #[rpc(name = "state_getStorageSize", alias("state_getStorageSizeAt"))] fn storage_size(&self, key: StorageKey, hash: Option) -> Result>; + /// Returns the keys with prefix from a child storage, leave empty to get all the keys + #[rpc(name = "state_getChildKeys")] + fn child_storage_keys( + &self, + child_storage_key: StorageKey, + prefix: StorageKey, + hash: Option + ) -> Result>; + + /// Returns a child storage entry at a specific block's state. + #[rpc(name = "state_getChildStorage")] + fn child_storage( + &self, + child_storage_key: StorageKey, + key: StorageKey, hash: Option + ) -> Result>; + + /// Returns the hash of a child storage entry at a block's state. + #[rpc(name = "state_getChildStorageHash")] + fn child_storage_hash( + &self, + child_storage_key: StorageKey, + key: StorageKey, hash: Option + ) -> Result>; + + /// Returns the size of a child storage entry at a block's state. + #[rpc(name = "state_getChildStorageSize")] + fn child_storage_size( + &self, + child_storage_key: StorageKey, + key: StorageKey, + hash: Option + ) -> Result>; + /// Returns the runtime metadata as an opaque blob. #[rpc(name = "state_getMetadata")] fn metadata(&self, hash: Option) -> Result; @@ -84,7 +118,12 @@ pub trait StateApi { /// NOTE This first returned result contains the initial state of storage for all keys. /// Subsequent values in the vector represent changes to the previous state (diffs). #[rpc(name = "state_queryStorage")] - fn query_storage(&self, keys: Vec, block: Hash, hash: Option) -> Result>>; + fn query_storage( + &self, + keys: Vec, + block: Hash, + hash: Option + ) -> Result>>; /// New runtime version subscription #[pubsub( @@ -324,6 +363,50 @@ impl StateApi for State where Ok(self.storage(key, block)?.map(|x| x.0.len() as u64)) } + fn child_storage( + &self, + child_storage_key: StorageKey, + key: StorageKey, + block: Option + ) -> Result> { + let block = self.unwrap_or_best(block)?; + trace!(target: "rpc", "Querying child storage at {:?} for key {}", block, HexDisplay::from(&key.0)); + Ok(self.client.child_storage(&BlockId::Hash(block), &child_storage_key, &key)?) + } + + fn child_storage_keys( + &self, + child_storage_key: StorageKey, + key_prefix: StorageKey, + block: Option + ) -> Result> { + let block = self.unwrap_or_best(block)?; + trace!(target: "rpc", "Querying child storage keys at {:?}", block); + Ok(self.client.child_storage_keys(&BlockId::Hash(block), &child_storage_key, &key_prefix)?) + } + + fn child_storage_hash( + &self, + child_storage_key: StorageKey, + key: StorageKey, + block: Option + ) -> Result> { + use runtime_primitives::traits::{Hash, Header as HeaderT}; + Ok( + self.child_storage(child_storage_key, key, block)? + .map(|x| ::Hashing::hash(&x.0)) + ) + } + + fn child_storage_size( + &self, + child_storage_key: StorageKey, + key: StorageKey, + block: Option + ) -> Result> { + Ok(self.child_storage(child_storage_key, key, block)?.map(|x| x.0.len() as u64)) + } + fn metadata(&self, block: Option) -> Result { let block = self.unwrap_or_best(block)?; self.client.runtime_api().metadata(&BlockId::Hash(block)).map(Into::into).map_err(Into::into) diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 5321116c95..73a52fbc62 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -17,9 +17,10 @@ use super::*; use self::error::{Error, ErrorKind}; -use sr_io::blake2_256; use assert_matches::assert_matches; use consensus::BlockOrigin; +use primitives::storage::well_known_keys; +use sr_io::blake2_256; use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt}; #[test] @@ -28,11 +29,46 @@ fn should_return_storage() { let client = Arc::new(test_client::new()); let genesis_hash = client.genesis_hash(); let client = State::new(client, Subscriptions::new(core.executor())); + let key = StorageKey(b":code".to_vec()); + assert!( + client.storage(key.clone(), Some(genesis_hash).into()) + .map(|x| x.map(|x| x.0.len())).unwrap().unwrap() + > 195_000 + ); assert_matches!( - client.storage(StorageKey(vec![10]), Some(genesis_hash).into()), - Ok(None) - ) + client.storage_hash(key.clone(), Some(genesis_hash).into()).map(|x| x.is_some()), + Ok(true) + ); + assert!( + client.storage_size(key.clone(), None).unwrap().unwrap() + > 195_000 + ); +} + +#[test] +fn should_return_child_storage() { + let core = ::tokio::runtime::Runtime::new().unwrap(); + let client = Arc::new(test_client::new()); + let genesis_hash = client.genesis_hash(); + let client = State::new(client, Subscriptions::new(core.executor())); + let child_key = StorageKey(well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect()); + let key = StorageKey(b"key".to_vec()); + + + assert_matches!( + client.child_storage(child_key.clone(), key.clone(), Some(genesis_hash).into()), + Ok(Some(StorageData(ref d))) if d[0] == 42 && d.len() == 1 + ); + assert_matches!( + client.child_storage_hash(child_key.clone(), key.clone(), Some(genesis_hash).into()) + .map(|x| x.is_some()), + Ok(true) + ); + assert_matches!( + client.child_storage_size(child_key.clone(), key.clone(), None), + Ok(Some(1)) + ); } #[test] diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index 65a4f3d822..bdecfe8981 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -102,12 +102,32 @@ impl BuildStorage for StorageOverlay { fn build_storage(self) -> Result<(StorageOverlay, ChildrenStorageOverlay), String> { Ok((self, Default::default())) } - fn assimilate_storage(self, storage: &mut StorageOverlay, _child_storage: &mut ChildrenStorageOverlay) -> Result<(), String> { + fn assimilate_storage( + self, + storage: &mut StorageOverlay, + _child_storage: &mut ChildrenStorageOverlay + ) -> Result<(), String> { storage.extend(self); Ok(()) } } +#[cfg(feature = "std")] +impl BuildStorage for (StorageOverlay, ChildrenStorageOverlay) { + fn build_storage(self) -> Result<(StorageOverlay, ChildrenStorageOverlay), String> { + Ok(self) + } + fn assimilate_storage( + self, + storage: &mut StorageOverlay, + child_storage: &mut ChildrenStorageOverlay + )-> Result<(), String> { + storage.extend(self.0); + child_storage.extend(self.1); + Ok(()) + } +} + /// Consensus engine unique ID. pub type ConsensusEngineId = [u8; 4]; diff --git a/core/state-machine/src/backend.rs b/core/state-machine/src/backend.rs index 895a805e43..fd143a553e 100644 --- a/core/state-machine/src/backend.rs +++ b/core/state-machine/src/backend.rs @@ -88,7 +88,22 @@ pub trait Backend { fn pairs(&self) -> Vec<(Vec, Vec)>; /// Get all keys with given prefix - fn keys(&self, prefix: &Vec) -> Vec>; + fn keys(&self, prefix: &[u8]) -> Vec> { + let mut all = Vec::new(); + self.for_keys_with_prefix(prefix, |k| all.push(k.to_vec())); + all + } + + /// Get all keys of child storage with given prefix + fn child_keys(&self, child_storage_key: &[u8], prefix: &[u8]) -> Vec> { + let mut all = Vec::new(); + self.for_keys_in_child_storage(child_storage_key, |k| { + if k.starts_with(prefix) { + all.push(k.to_vec()); + } + }); + all + } /// Try convert into trie backend. fn try_into_trie_backend(self) -> Option>; @@ -286,7 +301,9 @@ impl Backend for InMemory { I: IntoIterator, Option>)>, ::Out: Ord, { - let existing_pairs = self.inner.get(&None).into_iter().flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone())))); + let existing_pairs = self.inner.get(&None) + .into_iter() + .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone())))); let transaction: Vec<_> = delta.into_iter().collect(); let root = trie_root::(existing_pairs.chain(transaction.iter().cloned()) @@ -307,7 +324,9 @@ impl Backend for InMemory { { let storage_key = storage_key.to_vec(); - let existing_pairs = self.inner.get(&Some(storage_key.clone())).into_iter().flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone())))); + let existing_pairs = self.inner.get(&Some(storage_key.clone())) + .into_iter() + .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone())))); let transaction: Vec<_> = delta.into_iter().collect(); let root = child_trie_root::( @@ -326,11 +345,24 @@ impl Backend for InMemory { } fn pairs(&self) -> Vec<(Vec, Vec)> { - self.inner.get(&None).into_iter().flat_map(|map| map.iter().map(|(k, v)| (k.clone(), v.clone()))).collect() + self.inner.get(&None) + .into_iter() + .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), v.clone()))) + .collect() } - fn keys(&self, prefix: &Vec) -> Vec> { - self.inner.get(&None).into_iter().flat_map(|map| map.keys().filter(|k| k.starts_with(prefix)).cloned()).collect() + fn keys(&self, prefix: &[u8]) -> Vec> { + self.inner.get(&None) + .into_iter() + .flat_map(|map| map.keys().filter(|k| k.starts_with(prefix)).cloned()) + .collect() + } + + fn child_keys(&self, storage_key: &[u8], prefix: &[u8]) -> Vec> { + self.inner.get(&Some(storage_key.to_vec())) + .into_iter() + .flat_map(|map| map.keys().filter(|k| k.starts_with(prefix)).cloned()) + .collect() } fn try_into_trie_backend( diff --git a/core/state-machine/src/proving_backend.rs b/core/state-machine/src/proving_backend.rs index fa7e94f78f..c23838bc21 100644 --- a/core/state-machine/src/proving_backend.rs +++ b/core/state-machine/src/proving_backend.rs @@ -162,10 +162,14 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.backend.pairs() } - fn keys(&self, prefix: &Vec) -> Vec> { + fn keys(&self, prefix: &[u8]) -> Vec> { self.backend.keys(prefix) } + fn child_keys(&self, child_storage_key: &[u8], prefix: &[u8]) -> Vec> { + self.backend.child_keys(child_storage_key, prefix) + } + fn storage_root(&self, delta: I) -> (H::Out, Self::Transaction) where I: IntoIterator, Option>)> { diff --git a/core/state-machine/src/trie_backend.rs b/core/state-machine/src/trie_backend.rs index 1ce915d5f5..00c0aca006 100644 --- a/core/state-machine/src/trie_backend.rs +++ b/core/state-machine/src/trie_backend.rs @@ -105,7 +105,7 @@ impl, H: Hasher> Backend for TrieBackend where } } - fn keys(&self, prefix: &Vec) -> Vec> { + fn keys(&self, prefix: &[u8]) -> Vec> { let mut read_overlay = S::Overlay::default(); let eph = Ephemeral::new(self.essence.backend_storage(), &mut read_overlay); diff --git a/core/test-client/src/lib.rs b/core/test-client/src/lib.rs index 770b3de323..5154fb0c1d 100644 --- a/core/test-client/src/lib.rs +++ b/core/test-client/src/lib.rs @@ -34,7 +34,8 @@ pub use keyring::{sr25519::Keyring as AuthorityKeyring, AccountKeyring}; use std::{sync::Arc, collections::HashMap}; use futures::future::FutureResult; use primitives::Blake2Hasher; -use runtime_primitives::StorageOverlay; +use primitives::storage::well_known_keys; +use runtime_primitives::{StorageOverlay, ChildrenStorageOverlay}; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor }; @@ -271,7 +272,7 @@ fn genesis_config(support_changes_trie: bool) -> GenesisConfig { fn genesis_storage( support_changes_trie: bool, extension: HashMap, Vec> -) -> StorageOverlay { +) -> (StorageOverlay, ChildrenStorageOverlay) { let mut storage = genesis_config(support_changes_trie).genesis_map(); storage.extend(extension.into_iter()); @@ -280,7 +281,14 @@ fn genesis_storage( ); let block: runtime::Block = client::genesis::construct_genesis_block(state_root); storage.extend(additional_storage_with_genesis(&block)); - storage + + let mut child_storage = ChildrenStorageOverlay::default(); + child_storage.insert( + well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect(), + vec![(b"key".to_vec(), vec![42_u8])].into_iter().collect() + ); + + (storage, child_storage) } impl client::light::fetcher::Fetcher for LightFetcher { diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index bd69f55c62..cfbf85fbf2 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -2359,6 +2359,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", -- GitLab From 3d775f552f00f7133aef1e6c20430552d19b19c6 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 20 May 2019 15:47:52 +0200 Subject: [PATCH 004/113] Update to libp2p 0.8 (#2607) * Update to libp2p 0.8 * Fix CLI tests * Zeroize --- Cargo.lock | 228 ++++++++++-------- core/cli/src/lib.rs | 4 +- core/consensus/common/Cargo.toml | 2 +- core/network-libp2p/Cargo.toml | 3 +- core/network-libp2p/src/config.rs | 17 +- .../src/custom_proto/handler.rs | 8 +- core/peerset/Cargo.toml | 2 +- 7 files changed, 157 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a2a3a4c2bd..c9149bd9d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1483,42 +1483,43 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-websocket 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1529,6 +1530,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1539,21 +1541,20 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core-derive" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1562,20 +1563,19 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-floodsub" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1583,7 +1583,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1594,13 +1594,13 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1608,14 +1608,14 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-kad" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1625,7 +1625,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1635,20 +1635,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mdns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1656,20 +1656,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mplex" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1679,14 +1679,16 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1697,41 +1699,42 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-plaintext" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1739,7 +1742,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1750,13 +1753,12 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1769,14 +1771,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1784,25 +1786,38 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-wasm-ext" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-websocket" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1812,11 +1827,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3022,15 +3037,6 @@ dependencies = [ "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "secp256k1" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "security-framework" version = "0.2.2" @@ -4108,7 +4114,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4301,7 +4307,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4317,6 +4323,7 @@ dependencies = [ "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4359,7 +4366,7 @@ name = "substrate-peerset" version = "2.0.0" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5107,7 +5114,7 @@ name = "twox-hash" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5356,6 +5363,18 @@ dependencies = [ "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasm-timer" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasmi" version = "0.4.5" @@ -5539,6 +5558,24 @@ name = "zeroize" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "zeroize" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zeroize_derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] "checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f" "checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" @@ -5708,24 +5745,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0231edab431064b30b7749484a39735eb36492cef4658c372c9059e58c3003aa" -"checksum libp2p-core 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdcbded83195ac0e560090fc5da9c1b7f980d1ec221f02d97432db4d36793eb7" -"checksum libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f765f103b680cbed910b02bfdbdcfce5b1142899c93e51acb960bf59b6f81b1" -"checksum libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b129d20cc8cbb6ce5da8361045649c024659173e246c5dfbf20ae06071c046a" -"checksum libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70d68816b8435d6788399416eb2f0a6974fb1d15c4be5c30141f87c8e81746df" -"checksum libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "718ca645a065fd70855ca6042a7df686c24cd21add750c37a82c811fbd1e5c43" -"checksum libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bbe27c623a6a720efd5d704347838972062f89149a9c3cd149748da60bdcd3e0" -"checksum libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9bc1a5d85f4812cae6367b49a432763fe28997bac7c530dc55b70ec18a78aa7" -"checksum libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe5a858342a1cc89464474f7edc4bae1da649b9c823a3e04d9fb494493601746" -"checksum libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc6b5185c50a52a12e7bbe2ee7799059e24de4e52ab25edbfd26c8ab8515d317" -"checksum libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7905c1431ad115bee83405770629a27d6f17153ad02ec9670a7347998ef20e22" -"checksum libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc17626763ded57da8fed73187c2d9f6ebb89d30838673c430315bf560c7e4db" -"checksum libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2409d08b809ab1a74269597f7da2829d117cc11b9ed3343af33fc20831619726" -"checksum libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258cdc6742945c8f6402997bbbf36733588e2db18e5a0014da6d46e3ccfb92cf" -"checksum libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b5691e2ba2720d42bd1e93d6b90239fa9235c1956ef6a5f1dd499a7ae2767be" -"checksum libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ab0b9ca050105fd94229c48911c0c84aef4d6b86a53d1b6df81d938354e47e" -"checksum libp2p-websocket 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81692c3141a9aefd84f4faffdc93985af3858ef82ed7fe8185e6b27437b36183" -"checksum libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6ff51a5b2056bacee1c9f2ed8455cdf3c5c619261ddb4efc783119130aaf52" +"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" +"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" +"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" +"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" +"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" +"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" +"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" +"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" +"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" +"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" +"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" +"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" +"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" +"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" +"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" +"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04451aa166aa2040293f44c1c27144b65500e4a2ebbb723dfe732f39436eccbd" +"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum librocksdb-sys 5.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7dfb546562f9b450237bb8df7a31961849ee9fb1186d9e356db1d7a6b7609ff2" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" @@ -5840,7 +5878,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scrypt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8570c5e2fa69cb29d492fd4e9974b6b5facb5a888e1c6da630d4a3cd7ebfef4a" -"checksum secp256k1 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaccd3a23619349e0878d9a241f34b1982343cdf67367058cd7d078d326b63e" "checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05" "checksum security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6696852716b589dff9e886ff83778bb635150168e83afa8ac6b8a78cb82abc" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -5957,6 +5994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" "checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" "checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" "checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" "checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" @@ -5977,3 +6015,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" "checksum yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9073f5dbc901abb0b2ec4f866e726fed2f54953bdf81f8a5fde7762b7cc3b3" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" +"checksum zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e68403b858b6af538b11614e62dfe9ab2facba9f13a0cafb974855cfb495ec95" +"checksum zeroize_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3f07490820219949839d0027b965ffdd659d75be9220c00798762e36c6cd281" diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 4bdaaee8e5..3fd3454e0e 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -836,7 +836,7 @@ mod tests { NodeKeyType::variants().into_iter().try_for_each(|t| { let node_key_type = NodeKeyType::from_str(t).unwrap(); let sk = match node_key_type { - NodeKeyType::Secp256k1 => secp256k1::SecretKey::generate().as_ref().to_vec(), + NodeKeyType::Secp256k1 => secp256k1::SecretKey::generate().to_bytes().to_vec(), NodeKeyType::Ed25519 => ed25519::SecretKey::generate().as_ref().to_vec() }; let params = NodeKeyParams { @@ -847,7 +847,7 @@ mod tests { node_key_config(params, &net_config_dir).and_then(|c| match c { NodeKeyConfig::Secp256k1(network::Secret::Input(ref ski)) if node_key_type == NodeKeyType::Secp256k1 && - &sk[..] == ski.as_ref() => Ok(()), + &sk[..] == ski.to_bytes() => Ok(()), NodeKeyConfig::Ed25519(network::Secret::Input(ref ski)) if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() => Ok(()), diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index 52a2c6a1c4..58ea5a1b0a 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] crossbeam-channel = "0.3.4" -libp2p = { version = "0.7.0", default-features = false } +libp2p = { version = "0.8.1", default-features = false } log = "0.4" primitives = { package = "substrate-primitives", path= "../../primitives" } inherents = { package = "substrate-inherents", path = "../../inherents" } diff --git a/core/network-libp2p/Cargo.toml b/core/network-libp2p/Cargo.toml index 8ee8caa06a..be631aa4b9 100644 --- a/core/network-libp2p/Cargo.toml +++ b/core/network-libp2p/Cargo.toml @@ -13,7 +13,7 @@ bytes = "0.4" error-chain = { version = "0.12", default-features = false } fnv = "1.0" futures = "0.1" -libp2p = { version = "0.7.0", default-features = false, features = ["secio-secp256k1", "libp2p-websocket"] } +libp2p = { version = "0.8.1", default-features = false, features = ["secp256k1", "libp2p-websocket"] } parking_lot = "0.7.1" lazy_static = "1.2" log = "0.4" @@ -26,6 +26,7 @@ tokio-io = "0.1" tokio-timer = "0.2" unsigned-varint = { version = "0.2.1", features = ["codec"] } void = "1.0" +zeroize = "0.6.0" slog = { version = "^2", features = ["nested-values"] } slog_derive = "0.1.1" diff --git a/core/network-libp2p/src/config.rs b/core/network-libp2p/src/config.rs index 9d74cd73e2..d845d132a8 100644 --- a/core/network-libp2p/src/config.rs +++ b/core/network-libp2p/src/config.rs @@ -20,6 +20,7 @@ use libp2p::identity::{Keypair, secp256k1, ed25519}; use libp2p::{Multiaddr, multiaddr::Protocol}; use std::error::Error; use std::{io::{self, Write}, iter, fs, net::Ipv4Addr, path::{Path, PathBuf}}; +use zeroize::Zeroize; /// Network service configuration. #[derive(Clone)] @@ -167,7 +168,8 @@ impl NodeKeyConfig { Secp256k1(Secret::File(f)) => get_secret(f, |mut b| secp256k1::SecretKey::from_bytes(&mut b), - secp256k1::SecretKey::generate) + secp256k1::SecretKey::generate, + |b| b.to_bytes().to_vec()) .map(secp256k1::Keypair::from) .map(Keypair::Secp256k1), @@ -180,7 +182,8 @@ impl NodeKeyConfig { Ed25519(Secret::File(f)) => get_secret(f, |mut b| ed25519::SecretKey::from_bytes(&mut b), - ed25519::SecretKey::generate) + ed25519::SecretKey::generate, + |b| b.as_ref().to_vec()) .map(ed25519::Keypair::from) .map(Keypair::Ed25519), } @@ -190,13 +193,13 @@ impl NodeKeyConfig { /// Load a secret key from a file, if it exists, or generate a /// new secret key and write it to that file. In either case, /// the secret key is returned. -fn get_secret(file: P, parse: F, generate: G) -> io::Result +fn get_secret(file: P, parse: F, generate: G, serialize: W) -> io::Result where P: AsRef, F: for<'r> FnOnce(&'r mut [u8]) -> Result, G: FnOnce() -> K, E: Error + Send + Sync + 'static, - K: AsRef<[u8]> + W: Fn(&K) -> Vec, { std::fs::read(&file) .and_then(|mut sk_bytes| @@ -206,7 +209,9 @@ where if e.kind() == io::ErrorKind::NotFound { file.as_ref().parent().map_or(Ok(()), fs::create_dir_all)?; let sk = generate(); - write_secret_file(file, sk.as_ref())?; + let mut sk_vec = serialize(&sk); + write_secret_file(file, &sk_vec)?; + sk_vec.zeroize(); Ok(sk) } else { Err(e) @@ -257,7 +262,7 @@ mod tests { fn secret_bytes(kp: &Keypair) -> Vec { match kp { Keypair::Ed25519(p) => p.secret().as_ref().iter().cloned().collect(), - Keypair::Secp256k1(p) => p.secret().as_ref().iter().cloned().collect(), + Keypair::Secp256k1(p) => p.secret().to_bytes().to_vec(), _ => panic!("Unexpected keypair.") } } diff --git a/core/network-libp2p/src/custom_proto/handler.rs b/core/network-libp2p/src/custom_proto/handler.rs index 2cfc1107a9..01644f6214 100644 --- a/core/network-libp2p/src/custom_proto/handler.rs +++ b/core/network-libp2p/src/custom_proto/handler.rs @@ -18,7 +18,7 @@ use crate::custom_proto::upgrade::{CustomMessage, RegisteredProtocol}; use crate::custom_proto::upgrade::{RegisteredProtocolEvent, RegisteredProtocolSubstream}; use futures::prelude::*; use libp2p::core::{ - PeerId, Endpoint, ProtocolsHandler, ProtocolsHandlerEvent, + ConnectedPoint, PeerId, Endpoint, ProtocolsHandler, ProtocolsHandlerEvent, protocols_handler::IntoProtocolsHandler, protocols_handler::KeepAlive, protocols_handler::ProtocolsHandlerUpgrErr, @@ -114,7 +114,11 @@ where { type Handler = CustomProtoHandler; - fn into_handler(self, remote_peer_id: &PeerId) -> Self::Handler { + fn inbound_protocol(&self) -> RegisteredProtocol { + self.protocol.clone() + } + + fn into_handler(self, remote_peer_id: &PeerId, _: &ConnectedPoint) -> Self::Handler { let clock = Clock::new(); CustomProtoHandler { protocol: self.protocol, diff --git a/core/peerset/Cargo.toml b/core/peerset/Cargo.toml index dfe6815480..d878485203 100644 --- a/core/peerset/Cargo.toml +++ b/core/peerset/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] futures = "0.1" -libp2p = { version = "0.7.0", default-features = false } +libp2p = { version = "0.8.1", default-features = false } linked-hash-map = "0.5" log = "0.4" lru-cache = "0.1.2" -- GitLab From c52d16441b5d9f0afbd44cedab0525b4e6566bbb Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 20 May 2019 23:14:02 +0200 Subject: [PATCH 005/113] Allow warnings (#2627) --- core/consensus/babe/src/lib.rs | 5 ++--- core/finality-grandpa/src/lib.rs | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 9c6ef69777..c621d510a4 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -533,7 +533,6 @@ impl SlotWorker for BabeWorker whe /// This digest item will always return `Some` when used with `as_babe_seal`. // // FIXME #1018 needs misbehavior types -#[forbid(warnings)] fn check_header( client: &Arc, slot_now: u64, @@ -585,7 +584,7 @@ fn check_header( format!("VRF verification failed") })? }; - + if check(&inout, threshold) { match check_equivocation(&client, slot_now, slot_num, header.clone(), signer.clone()) { Ok(Some(equivocation_proof)) => { @@ -1015,7 +1014,7 @@ mod tests { Default::default(), 0, ); - + let (inout, proof, _batchable_proof) = get_keypair(&pair).vrf_sign_n_check(transcript, |inout| check(inout, u64::MAX)).unwrap(); let pre_hash: H256 = header.hash(); let to_sign = (slot_num, pre_hash, proof.to_bytes()).encode(); diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 9d808bf4d5..f9f2016cc9 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -51,8 +51,6 @@ //! number (this is num(signal) + N). When finalizing a block, we either apply //! or prune any signaled changes based on whether the signaling block is //! included in the newly-finalized chain. -#![forbid(warnings)] -#![allow(deprecated)] // FIXME #2532: remove once the refactor is done https://github.com/paritytech/substrate/issues/2532 use futures::prelude::*; use log::{debug, info, warn}; -- GitLab From 0b522355cd9c6c48cb6ee628e67632bf4ed153a2 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 21 May 2019 14:56:58 +0300 Subject: [PATCH 006/113] fix panic in PSM when add_reserved_peer(same_peer) is called twice (#2640) --- core/peerset/src/peersstate.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/peerset/src/peersstate.rs b/core/peerset/src/peersstate.rs index c02b1daf62..a6a375b369 100644 --- a/core/peerset/src/peersstate.rs +++ b/core/peerset/src/peersstate.rs @@ -291,6 +291,10 @@ impl<'a> ConnectedPeer<'a> { /// Sets whether or not the node is reserved. pub fn set_reserved(&mut self, reserved: bool) { + if reserved == self.state.reserved { + return; + } + if reserved { self.state.reserved = true; match self.state.connection_state { @@ -595,4 +599,16 @@ mod tests { peer.set_reserved(true); peer.disconnect(); } + + #[test] + fn multiple_set_reserved_calls_doesnt_panic() { + let mut peers_state = PeersState::new(1, 1); + let id = PeerId::random(); + let mut peer = peers_state.peer(&id) + .into_unknown().unwrap().discover() + .force_outgoing(); + peer.set_reserved(true); + peer.set_reserved(true); + peer.disconnect(); + } } -- GitLab From 4794d9893ef58bb898a46354883e64c241af39fd Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 21 May 2019 14:07:01 +0200 Subject: [PATCH 007/113] Remove the NetworkChan (#2577) * Remove the NetworkChan from the API * Remove the NetworkChan altogether * Address review * Fix line widths * More line width fixes * Remove pub visibility from entire world * Fix tests --- Cargo.lock | 1 - core/consensus/aura/src/lib.rs | 4 + core/consensus/babe/src/lib.rs | 4 + core/finality-grandpa/src/tests.rs | 4 + core/network/Cargo.toml | 1 - core/network/src/protocol.rs | 265 ++++++++++++++++------------- core/network/src/service.rs | 181 +++++++------------- core/network/src/test/mod.rs | 197 ++++++++++++++------- 8 files changed, 360 insertions(+), 297 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9149bd9d7..106be37cdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4271,7 +4271,6 @@ name = "substrate-network" version = "2.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 2c545cec33..429666585d 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -964,6 +964,10 @@ mod tests { } } + fn uses_tokio(&self) -> bool { + true + } + fn peer(&self, i: usize) -> &Peer { &self.peers[i] } diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index c621d510a4..3c720db627 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -973,6 +973,10 @@ mod tests { }) } + fn uses_tokio(&self) -> bool { + true + } + fn peer(&self, i: usize) -> &Peer { trace!(target: "babe", "Retreiving a peer"); &self.peers[i] diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 98e4b6d85c..622eb7d470 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -159,6 +159,10 @@ impl TestNetFactory for GrandpaTestNet { } } + fn uses_tokio(&self) -> bool { + true + } + fn peer(&self, i: usize) -> &GrandpaPeer { &self.peers[i] } diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index ca898eea07..c3184ab47d 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -9,7 +9,6 @@ edition = "2018" [lib] [dependencies] -crossbeam-channel = "0.3.6" log = "0.4" parking_lot = "0.7.1" error-chain = "0.12" diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 685b447df6..62c5f508db 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -30,7 +30,7 @@ use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessage use crate::on_demand::OnDemandService; use crate::specialization::NetworkSpecialization; use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; -use crate::service::{NetworkChan, NetworkMsg, TransactionPool, ExHashT}; +use crate::service::{TransactionPool, ExHashT}; use crate::config::{ProtocolConfig, Roles}; use parking_lot::RwLock; use rustc_hex::ToHex; @@ -76,7 +76,6 @@ const RPC_FAILED_REPUTATION_CHANGE: i32 = -(1 << 12); // Lock must always be taken in order declared here. pub struct Protocol, H: ExHashT> { - network_chan: NetworkChan, /// Interval at which we call `tick`. tick_timeout: tokio::timer::Interval, /// Interval at which we call `propagate_extrinsics`. @@ -148,6 +147,20 @@ pub struct PeerInfo { pub best_number: ::Number, } +/// Context passed as input to the methods of `protocol.rs` and that is used to communicate back +/// with the network. +pub trait NetworkOut { + /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or + /// irresponsible or appeared lazy. + fn report_peer(&mut self, who: PeerId, reputation: i32); + + /// Force disconnecting from a peer. + fn disconnect_peer(&mut self, who: PeerId); + + /// Send a message to a peer. + fn send_message(&mut self, who: PeerId, message: Message); +} + /// Context for a network-specific handler. pub trait Context { /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or @@ -166,29 +179,29 @@ pub trait Context { /// Protocol context. struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> { - network_chan: &'a NetworkChan, + network_out: &'a mut dyn NetworkOut, context_data: &'a mut ContextData, } impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> { - fn new(context_data: &'a mut ContextData, network_chan: &'a NetworkChan) -> Self { - ProtocolContext { network_chan, context_data } + fn new(context_data: &'a mut ContextData, network_out: &'a mut dyn NetworkOut) -> Self { + ProtocolContext { network_out, context_data } } } impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, H> { fn report_peer(&mut self, who: PeerId, reputation: i32) { - self.network_chan.send(NetworkMsg::ReportPeer(who, reputation)) + self.network_out.report_peer(who, reputation) } fn disconnect_peer(&mut self, who: PeerId) { - self.network_chan.send(NetworkMsg::DisconnectPeer(who)) + self.network_out.disconnect_peer(who) } fn send_consensus(&mut self, who: PeerId, consensus: ConsensusMessage) { send_message( &mut self.context_data.peers, - &self.network_chan, + self.network_out, who, GenericMessage::Consensus(consensus) ) @@ -197,7 +210,7 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, fn send_chain_specific(&mut self, who: PeerId, message: Vec) { send_message( &mut self.context_data.peers, - &self.network_chan, + self.network_out, who, GenericMessage::ChainSpecific(message) ) @@ -206,11 +219,11 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SyncContext for ProtocolContext<'a, B, H> { fn report_peer(&mut self, who: PeerId, reputation: i32) { - self.network_chan.send(NetworkMsg::ReportPeer(who, reputation)) + self.network_out.report_peer(who, reputation) } fn disconnect_peer(&mut self, who: PeerId) { - self.network_chan.send(NetworkMsg::DisconnectPeer(who)) + self.network_out.disconnect_peer(who) } fn peer_info(&self, who: &PeerId) -> Option> { @@ -224,7 +237,7 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SyncContext for ProtocolContext<'a, fn send_finality_proof_request(&mut self, who: PeerId, request: FinalityProofRequestMessage) { send_message( &mut self.context_data.peers, - &self.network_chan, + self.network_out, who, GenericMessage::FinalityProofRequest(request) ) @@ -233,7 +246,7 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SyncContext for ProtocolContext<'a, fn send_block_request(&mut self, who: PeerId, request: BlockRequestMessage) { send_message( &mut self.context_data.peers, - &self.network_chan, + self.network_out, who, GenericMessage::BlockRequest(request) ) @@ -252,7 +265,6 @@ impl, H: ExHashT> Protocol { /// Create a new instance. pub fn new( connected_peers: Arc>>>, - network_chan: NetworkChan, config: ProtocolConfig, chain: Arc>, finality_proof_provider: Option>>, @@ -263,7 +275,6 @@ impl, H: ExHashT> Protocol { let info = chain.info()?; let sync = ChainSync::new(config.roles, &info); Ok(Protocol { - network_chan, tick_timeout: tokio::timer::Interval::new_interval(TICK_TIMEOUT), propagate_timeout: tokio::timer::Interval::new_interval(PROPAGATE_TIMEOUT), config: config, @@ -304,32 +315,26 @@ impl, H: ExHashT> Protocol { pub fn is_offline(&self) -> bool { self.sync.status().is_offline() } -} - -impl, H: ExHashT> Future for Protocol { - type Item = (); - type Error = void::Void; - fn poll(&mut self) -> Poll { + pub fn poll(&mut self, network_out: &mut dyn NetworkOut) -> Poll { while let Ok(Async::Ready(_)) = self.tick_timeout.poll() { - self.tick(); + self.tick(network_out); } while let Ok(Async::Ready(_)) = self.propagate_timeout.poll() { - self.propagate_extrinsics(); + self.propagate_extrinsics(network_out); } Ok(Async::NotReady) } -} -impl, H: ExHashT> Protocol { fn is_on_demand_response(&self, who: &PeerId, response_id: message::RequestId) -> bool { self.on_demand.as_ref().map_or(false, |od| od.is_on_demand_response(&who, response_id)) } fn handle_response( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, response: &message::BlockResponse ) -> Option> { @@ -344,8 +349,8 @@ impl, H: ExHashT> Protocol { return request.map(|(_, r)| r) } trace!(target: "sync", "Unexpected response packet from {} ({})", who, response.id); - self.network_chan.send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); - self.network_chan.send(NetworkMsg::DisconnectPeer(who)); + network_out.report_peer(who.clone(), i32::min_value()); + network_out.disconnect_peer(who); } None } @@ -364,48 +369,54 @@ impl, H: ExHashT> Protocol { } } - pub fn on_custom_message(&mut self, who: PeerId, message: Message) -> CustomMessageOutcome { + pub fn on_custom_message( + &mut self, + network_out: &mut dyn NetworkOut, + who: PeerId, + message: Message + ) -> CustomMessageOutcome { match message { - GenericMessage::Status(s) => self.on_status_message(who, s), - GenericMessage::BlockRequest(r) => self.on_block_request(who, r), + GenericMessage::Status(s) => self.on_status_message(network_out, who, s), + GenericMessage::BlockRequest(r) => self.on_block_request(network_out, who, r), GenericMessage::BlockResponse(r) => { // Note, this is safe because only `ordinary bodies` and `remote bodies` are received in this matter. if self.is_on_demand_response(&who, r.id) { self.on_remote_body_response(who, r); } else { - if let Some(request) = self.handle_response(who.clone(), &r) { - let outcome = self.on_block_response(who.clone(), request, r); + if let Some(request) = self.handle_response(network_out, who.clone(), &r) { + let outcome = self.on_block_response(network_out, who.clone(), request, r); self.update_peer_info(&who); return outcome } } }, GenericMessage::BlockAnnounce(announce) => { - self.on_block_announce(who.clone(), announce); + self.on_block_announce(network_out, who.clone(), announce); self.update_peer_info(&who); }, - GenericMessage::Transactions(m) => self.on_extrinsics(who, m), - GenericMessage::RemoteCallRequest(request) => self.on_remote_call_request(who, request), + GenericMessage::Transactions(m) => self.on_extrinsics(network_out, who, m), + GenericMessage::RemoteCallRequest(request) => self.on_remote_call_request(network_out, who, request), GenericMessage::RemoteCallResponse(response) => self.on_remote_call_response(who, response), - GenericMessage::RemoteReadRequest(request) => self.on_remote_read_request(who, request), + GenericMessage::RemoteReadRequest(request) => self.on_remote_read_request(network_out, who, request), GenericMessage::RemoteReadResponse(response) => self.on_remote_read_response(who, response), - GenericMessage::RemoteHeaderRequest(request) => self.on_remote_header_request(who, request), + GenericMessage::RemoteHeaderRequest(request) => self.on_remote_header_request(network_out, who, request), GenericMessage::RemoteHeaderResponse(response) => self.on_remote_header_response(who, response), - GenericMessage::RemoteChangesRequest(request) => self.on_remote_changes_request(who, request), + GenericMessage::RemoteChangesRequest(request) => self.on_remote_changes_request(network_out, who, request), GenericMessage::RemoteChangesResponse(response) => self.on_remote_changes_response(who, response), - GenericMessage::FinalityProofRequest(request) => self.on_finality_proof_request(who, request), - GenericMessage::FinalityProofResponse(response) => return self.on_finality_proof_response(who, response), + GenericMessage::FinalityProofRequest(request) => self.on_finality_proof_request(network_out, who, request), + GenericMessage::FinalityProofResponse(response) => + return self.on_finality_proof_response(network_out, who, response), GenericMessage::Consensus(msg) => { if self.context_data.peers.get(&who).map_or(false, |peer| peer.info.protocol_version > 2) { self.consensus_gossip.on_incoming( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), who, msg, ); } } other => self.specialization.on_message( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), who, &mut Some(other), ), @@ -414,36 +425,43 @@ impl, H: ExHashT> Protocol { CustomMessageOutcome::None } - fn send_message(&mut self, who: PeerId, message: Message) { + fn send_message(&mut self, network_out: &mut dyn NetworkOut, who: PeerId, message: Message) { send_message::( &mut self.context_data.peers, - &self.network_chan, + network_out, who, message, ); } /// Locks `self` and returns a context plus the `ConsensusGossip` struct. - pub fn consensus_gossip_lock<'a>(&'a mut self) -> (impl Context + 'a, &'a mut ConsensusGossip) { - let context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + pub fn consensus_gossip_lock<'a>( + &'a mut self, + network_out: &'a mut dyn NetworkOut + ) -> (impl Context + 'a, &'a mut ConsensusGossip) { + let context = ProtocolContext::new(&mut self.context_data, network_out); (context, &mut self.consensus_gossip) } /// Locks `self` and returns a context plus the network specialization. - pub fn specialization_lock<'a>(&'a mut self) -> (impl Context + 'a, &'a mut S) { - let context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + pub fn specialization_lock<'a>( + &'a mut self, + network_out: &'a mut dyn NetworkOut + ) -> (impl Context + 'a, &'a mut S) { + let context = ProtocolContext::new(&mut self.context_data, network_out); (context, &mut self.specialization) } /// Gossip a consensus message to the network. pub fn gossip_consensus_message( &mut self, + network_out: &mut dyn NetworkOut, topic: B::Hash, engine_id: ConsensusEngineId, message: Vec, recipient: GossipMessageRecipient, ) { - let mut context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + let mut context = ProtocolContext::new(&mut self.context_data, network_out); let message = ConsensusMessage { data: message, engine_id }; match recipient { GossipMessageRecipient::BroadcastToAll => @@ -451,19 +469,19 @@ impl, H: ExHashT> Protocol { GossipMessageRecipient::BroadcastNew => self.consensus_gossip.multicast(&mut context, topic, message, false), GossipMessageRecipient::Peer(who) => - self.send_message(who, GenericMessage::Consensus(message)), + self.send_message(network_out, who, GenericMessage::Consensus(message)), } } /// Called when a new peer is connected - pub fn on_peer_connected(&mut self, who: PeerId, debug_info: String) { + pub fn on_peer_connected(&mut self, network_out: &mut dyn NetworkOut, who: PeerId, debug_info: String) { trace!(target: "sync", "Connecting {}: {}", who, debug_info); self.handshaking_peers.insert(who.clone(), HandshakingPeer { timestamp: time::Instant::now() }); - self.send_status(who); + self.send_status(network_out, who); } /// Called by peer when it is disconnecting - pub fn on_peer_disconnected(&mut self, peer: PeerId, debug_info: String) { + pub fn on_peer_disconnected(&mut self, network_out: &mut dyn NetworkOut, peer: PeerId, debug_info: String) { trace!(target: "sync", "Disconnecting {}: {}", peer, debug_info); // lock all the the peer lists so that add/remove peer events are in order let removed = { @@ -472,7 +490,7 @@ impl, H: ExHashT> Protocol { self.context_data.peers.remove(&peer) }; if let Some(peer_data) = removed { - let mut context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + let mut context = ProtocolContext::new(&mut self.context_data, network_out); if peer_data.info.protocol_version > 2 { self.consensus_gossip.peer_disconnected(&mut context, peer.clone()); } @@ -484,8 +502,8 @@ impl, H: ExHashT> Protocol { /// Called as a back-pressure mechanism if the networking detects that the peer cannot process /// our messaging rate fast enough. - pub fn on_clogged_peer(&self, who: PeerId, _msg: Option>) { - self.network_chan.send(NetworkMsg::ReportPeer(who.clone(), CLOGGED_PEER_REPUTATION_CHANGE)); + pub fn on_clogged_peer(&self, network_out: &mut dyn NetworkOut, who: PeerId, _msg: Option>) { + network_out.report_peer(who.clone(), CLOGGED_PEER_REPUTATION_CHANGE); // Print some diagnostics. if let Some(peer) = self.context_data.peers.get(&who) { @@ -498,13 +516,7 @@ impl, H: ExHashT> Protocol { } } - /// Puts the `Synchronized` message on `network_chan`. - #[cfg(any(test, feature = "test-helpers"))] - pub fn synchronize(&self) { - self.network_chan.send(NetworkMsg::Synchronized); - } - - fn on_block_request(&mut self, peer: PeerId, request: message::BlockRequest) { + fn on_block_request(&mut self, network_out: &mut dyn NetworkOut, peer: PeerId, request: message::BlockRequest) { trace!(target: "sync", "BlockRequest {} from {}: from {:?} to {:?} max {:?}", request.id, peer, @@ -515,8 +527,8 @@ impl, H: ExHashT> Protocol { // sending block requests to the node that is unable to serve it is considered a bad behavior if !self.config.roles.is_full() { trace!(target: "sync", "Peer {} is trying to sync from the light node", peer); - self.network_chan.send(NetworkMsg::DisconnectPeer(peer.clone())); - self.network_chan.send(NetworkMsg::ReportPeer(peer, i32::min_value())); + network_out.disconnect_peer(peer.clone()); + network_out.report_peer(peer, i32::min_value()); return; } @@ -574,11 +586,12 @@ impl, H: ExHashT> Protocol { blocks: blocks, }; trace!(target: "sync", "Sending BlockResponse with {} blocks", response.blocks.len()); - self.send_message(peer, GenericMessage::BlockResponse(response)) + self.send_message(network_out, peer, GenericMessage::BlockResponse(response)) } fn on_block_response( &mut self, + network_out: &mut dyn NetworkOut, peer: PeerId, request: message::BlockRequest, response: message::BlockResponse, @@ -602,7 +615,7 @@ impl, H: ExHashT> Protocol { // justifications are imported asynchronously (#1482) if request.fields == message::BlockAttributes::JUSTIFICATION { let outcome = self.sync.on_block_justification_data( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), peer, request, response, @@ -616,7 +629,7 @@ impl, H: ExHashT> Protocol { } else { let outcome = self.sync.on_block_data( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), peer, request, response @@ -632,16 +645,16 @@ impl, H: ExHashT> Protocol { /// Perform time based maintenance. /// /// > **Note**: This method normally doesn't have to be called except for testing purposes. - pub fn tick(&mut self) { - self.consensus_gossip.tick(&mut ProtocolContext::new(&mut self.context_data, &self.network_chan)); - self.maintain_peers(); - self.sync.tick(&mut ProtocolContext::new(&mut self.context_data, &self.network_chan)); + pub fn tick(&mut self, network_out: &mut dyn NetworkOut) { + self.consensus_gossip.tick(&mut ProtocolContext::new(&mut self.context_data, network_out)); + self.maintain_peers(network_out); + self.sync.tick(&mut ProtocolContext::new(&mut self.context_data, network_out)); self.on_demand .as_ref() .map(|s| s.maintain_peers()); } - fn maintain_peers(&mut self) { + fn maintain_peers(&mut self, network_out: &mut dyn NetworkOut) { let tick = time::Instant::now(); let mut aborting = Vec::new(); { @@ -662,20 +675,20 @@ impl, H: ExHashT> Protocol { } } - self.specialization.maintain_peers(&mut ProtocolContext::new(&mut self.context_data, &self.network_chan)); + self.specialization.maintain_peers(&mut ProtocolContext::new(&mut self.context_data, network_out)); for p in aborting { - let _ = self.network_chan.send(NetworkMsg::DisconnectPeer(p.clone())); - let _ = self.network_chan.send(NetworkMsg::ReportPeer(p, TIMEOUT_REPUTATION_CHANGE)); + network_out.disconnect_peer(p.clone()); + network_out.report_peer(p, TIMEOUT_REPUTATION_CHANGE); } } /// Called by peer to report status - fn on_status_message(&mut self, who: PeerId, status: message::Status) { + fn on_status_message(&mut self, network_out: &mut dyn NetworkOut, who: PeerId, status: message::Status) { trace!(target: "sync", "New peer {} {:?}", who, status); let protocol_version = { if self.context_data.peers.contains_key(&who) { debug!("Unexpected status packet from {}", who); - self.network_chan.send(NetworkMsg::ReportPeer(who, UNEXPECTED_STATUS_REPUTATION_CHANGE)); + network_out.report_peer(who, UNEXPECTED_STATUS_REPUTATION_CHANGE); return; } if status.genesis_hash != self.genesis_hash { @@ -684,14 +697,14 @@ impl, H: ExHashT> Protocol { "Peer is on different chain (our genesis: {} theirs: {})", self.genesis_hash, status.genesis_hash ); - self.network_chan.send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); - self.network_chan.send(NetworkMsg::DisconnectPeer(who)); + network_out.report_peer(who.clone(), i32::min_value()); + network_out.disconnect_peer(who); return; } if status.version < MIN_VERSION && CURRENT_VERSION < status.min_supported_version { trace!(target: "protocol", "Peer {:?} using unsupported protocol version {}", who, status.version); - self.network_chan.send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); - self.network_chan.send(NetworkMsg::DisconnectPeer(who)); + network_out.report_peer(who.clone(), i32::min_value()); + network_out.disconnect_peer(who); return; } if self.config.roles.is_light() { @@ -708,10 +721,8 @@ impl, H: ExHashT> Protocol { .unwrap_or(0); if blocks_difference > LIGHT_MAXIMAL_BLOCKS_DIFFERENCE { debug!(target: "sync", "Peer {} is far behind us and will unable to serve light requests", who); - self.network_chan.send( - NetworkMsg::ReportPeer(who.clone(), PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE) - ); - self.network_chan.send(NetworkMsg::DisconnectPeer(who)); + network_out.report_peer(who.clone(), PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE); + network_out.disconnect_peer(who); return; } } @@ -751,7 +762,7 @@ impl, H: ExHashT> Protocol { status.version }; - let mut context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + let mut context = ProtocolContext::new(&mut self.context_data, network_out); self.on_demand .as_ref() .map(|s| s.on_connect(who.clone(), status.roles, status.best_number)); @@ -763,7 +774,12 @@ impl, H: ExHashT> Protocol { } /// Called when peer sends us new extrinsics - fn on_extrinsics(&mut self, who: PeerId, extrinsics: message::Transactions) { + fn on_extrinsics( + &mut self, + network_out: &mut dyn NetworkOut, + who: PeerId, + extrinsics: message::Transactions + ) { // Accept extrinsics only when fully synced if self.sync.status().state != SyncState::Idle { trace!(target: "sync", "{} Ignoring extrinsics while syncing", who); @@ -773,7 +789,7 @@ impl, H: ExHashT> Protocol { if let Some(ref mut peer) = self.context_data.peers.get_mut(&who) { for t in extrinsics { if let Some(hash) = self.transaction_pool.import(&t) { - self.network_chan.send(NetworkMsg::ReportPeer(who.clone(), NEW_EXTRINSIC_REPUTATION_CHANGE)); + network_out.report_peer(who.clone(), NEW_EXTRINSIC_REPUTATION_CHANGE); peer.known_extrinsics.insert(hash); } else { trace!(target: "sync", "Extrinsic rejected"); @@ -783,7 +799,7 @@ impl, H: ExHashT> Protocol { } /// Call when we must propagate ready extrinsics to peers. - pub fn propagate_extrinsics(&mut self) { + pub fn propagate_extrinsics(&mut self, network_out: &mut dyn NetworkOut) { debug!(target: "sync", "Propagating extrinsics"); // Accept transactions only when fully synced @@ -808,7 +824,7 @@ impl, H: ExHashT> Protocol { .push(who.to_base58()); } trace!(target: "sync", "Sending {} transactions to {}", to_send.len(), who); - self.network_chan.send(NetworkMsg::Outgoing(who.clone(), GenericMessage::Transactions(to_send))) + network_out.send_message(who.clone(), GenericMessage::Transactions(to_send)) } } self.transaction_pool.on_broadcasted(propagated_to); @@ -818,7 +834,7 @@ impl, H: ExHashT> Protocol { /// /// In chain-based consensus, we often need to make sure non-best forks are /// at least temporarily synced. - pub fn announce_block(&mut self, hash: B::Hash) { + pub fn announce_block(&mut self, network_out: &mut dyn NetworkOut, hash: B::Hash) { let header = match self.context_data.chain.header(&BlockId::Hash(hash)) { Ok(Some(header)) => header, Ok(None) => { @@ -837,12 +853,12 @@ impl, H: ExHashT> Protocol { for (who, ref mut peer) in self.context_data.peers.iter_mut() { trace!(target: "sync", "Reannouncing block {:?} to {}", hash, who); peer.known_blocks.insert(hash); - self.network_chan.send(NetworkMsg::Outgoing(who.clone(), message.clone())) + network_out.send_message(who.clone(), message.clone()) } } /// Send Status message - fn send_status(&mut self, who: PeerId) { + fn send_status(&mut self, network_out: &mut dyn NetworkOut, who: PeerId) { if let Ok(info) = self.context_data.chain.info() { let status = message::generic::Status { version: CURRENT_VERSION, @@ -853,11 +869,16 @@ impl, H: ExHashT> Protocol { best_hash: info.chain.best_hash, chain_status: self.specialization.status(), }; - self.send_message(who, GenericMessage::Status(status)) + self.send_message(network_out, who, GenericMessage::Status(status)) } } - fn on_block_announce(&mut self, who: PeerId, announce: message::BlockAnnounce) { + fn on_block_announce( + &mut self, + network_out: &mut dyn NetworkOut, + who: PeerId, + announce: message::BlockAnnounce + ) { let header = announce.header; let hash = header.hash(); { @@ -869,7 +890,7 @@ impl, H: ExHashT> Protocol { .as_ref() .map(|s| s.on_block_announce(who.clone(), *header.number())); self.sync.on_block_announce( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), who.clone(), hash, &header, @@ -878,10 +899,10 @@ impl, H: ExHashT> Protocol { /// Call this when a block has been imported in the import queue and we should announce it on /// the network. - pub fn on_block_imported(&mut self, hash: B::Hash, header: &B::Header) { + pub fn on_block_imported(&mut self, network_out: &mut dyn NetworkOut, hash: B::Hash, header: &B::Header) { self.sync.update_chain_info(header); self.specialization.on_block_imported( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), hash.clone(), header, ); @@ -898,23 +919,24 @@ impl, H: ExHashT> Protocol { for (who, ref mut peer) in self.context_data.peers.iter_mut() { if peer.known_blocks.insert(hash.clone()) { trace!(target: "sync", "Announcing block {:?} to {}", hash, who); - self.network_chan.send(NetworkMsg::Outgoing(who.clone(), message.clone())) + network_out.send_message(who.clone(), message.clone()) } } } /// Call this when a block has been finalized. The sync layer may have some additional /// requesting to perform. - pub fn on_block_finalized(&mut self, hash: B::Hash, header: &B::Header) { + pub fn on_block_finalized(&mut self, network_out: &mut dyn NetworkOut, hash: B::Hash, header: &B::Header) { self.sync.on_block_finalized( &hash, *header.number(), - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), ); } fn on_remote_call_request( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, request: message::RemoteCallRequest, ) { @@ -938,12 +960,13 @@ impl, H: ExHashT> Protocol { request.block, error ); - self.network_chan.send(NetworkMsg::ReportPeer(who.clone(), RPC_FAILED_REPUTATION_CHANGE)); + network_out.report_peer(who.clone(), RPC_FAILED_REPUTATION_CHANGE); Default::default() } }; self.send_message( + network_out, who, GenericMessage::RemoteCallResponse(message::RemoteCallResponse { id: request.id, @@ -956,9 +979,9 @@ impl, H: ExHashT> Protocol { /// /// Uses `protocol` to queue a new justification request and tries to dispatch all pending /// requests. - pub fn request_justification(&mut self, hash: &B::Hash, number: NumberFor) { + pub fn request_justification(&mut self, network_out: &mut dyn NetworkOut, hash: &B::Hash, number: NumberFor) { let mut context = - ProtocolContext::new(&mut self.context_data, &self.network_chan); + ProtocolContext::new(&mut self.context_data, network_out); self.sync.request_justification(&hash, number, &mut context); } @@ -970,16 +993,21 @@ impl, H: ExHashT> Protocol { /// A batch of blocks have been processed, with or without errors. /// Call this when a batch of blocks have been processed by the import queue, with or without /// errors. - pub fn blocks_processed(&mut self, processed_blocks: Vec, has_error: bool) { + pub fn blocks_processed( + &mut self, + network_out: &mut dyn NetworkOut, + processed_blocks: Vec, + has_error: bool + ) { self.sync.blocks_processed(processed_blocks, has_error); let mut context = - ProtocolContext::new(&mut self.context_data, &self.network_chan); + ProtocolContext::new(&mut self.context_data, network_out); self.sync.maintain_sync(&mut context); } /// Restart the sync process. - pub fn restart(&mut self) { - let mut context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + pub fn restart(&mut self, network_out: &mut dyn NetworkOut) { + let mut context = ProtocolContext::new(&mut self.context_data, network_out); self.sync.restart(&mut context); } @@ -1001,8 +1029,8 @@ impl, H: ExHashT> Protocol { /// Request a finality proof for the given block. /// /// Queues a new finality proof request and tries to dispatch all pending requests. - pub fn request_finality_proof(&mut self, hash: &B::Hash, number: NumberFor) { - let mut context = ProtocolContext::new(&mut self.context_data, &self.network_chan); + pub fn request_finality_proof(&mut self, network_out: &mut dyn NetworkOut, hash: &B::Hash, number: NumberFor) { + let mut context = ProtocolContext::new(&mut self.context_data, network_out); self.sync.request_finality_proof(&hash, number, &mut context); } @@ -1023,6 +1051,7 @@ impl, H: ExHashT> Protocol { fn on_remote_read_request( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, request: message::RemoteReadRequest, ) { @@ -1042,6 +1071,7 @@ impl, H: ExHashT> Protocol { } }; self.send_message( + network_out, who, GenericMessage::RemoteReadResponse(message::RemoteReadResponse { id: request.id, @@ -1058,6 +1088,7 @@ impl, H: ExHashT> Protocol { fn on_remote_header_request( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, request: message::RemoteHeaderRequest>, ) { @@ -1076,6 +1107,7 @@ impl, H: ExHashT> Protocol { } }; self.send_message( + network_out, who, GenericMessage::RemoteHeaderResponse(message::RemoteHeaderResponse { id: request.id, @@ -1098,6 +1130,7 @@ impl, H: ExHashT> Protocol { fn on_remote_changes_request( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, request: message::RemoteChangesRequest, ) { @@ -1135,6 +1168,7 @@ impl, H: ExHashT> Protocol { } }; self.send_message( + network_out, who, GenericMessage::RemoteChangesResponse(message::RemoteChangesResponse { id: request.id, @@ -1163,6 +1197,7 @@ impl, H: ExHashT> Protocol { fn on_finality_proof_request( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, request: message::FinalityProofRequest, ) { @@ -1184,6 +1219,7 @@ impl, H: ExHashT> Protocol { }, }; self.send_message( + network_out, who, GenericMessage::FinalityProofResponse(message::FinalityProofResponse { id: 0, @@ -1195,12 +1231,13 @@ impl, H: ExHashT> Protocol { fn on_finality_proof_response( &mut self, + network_out: &mut dyn NetworkOut, who: PeerId, response: message::FinalityProofResponse, ) -> CustomMessageOutcome { trace!(target: "sync", "Finality proof response from {} for {}", who, response.block); let outcome = self.sync.on_block_finality_proof_data( - &mut ProtocolContext::new(&mut self.context_data, &self.network_chan), + &mut ProtocolContext::new(&mut self.context_data, network_out), who, response, ); @@ -1230,7 +1267,7 @@ pub enum CustomMessageOutcome { fn send_message( peers: &mut HashMap>, - network_chan: &NetworkChan, + network_out: &mut dyn NetworkOut, who: PeerId, mut message: Message, ) { @@ -1245,5 +1282,5 @@ fn send_message( peer.block_request = Some((time::Instant::now(), r.clone())); } } - network_chan.send(NetworkMsg::Outgoing(who, message)); + network_out.send_message(who, message); } diff --git a/core/network/src/service.rs b/core/network/src/service.rs index e63ce4037f..1a966fc933 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -31,13 +31,12 @@ use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use crate::message::Message; -use crate::protocol::{self, Context, CustomMessageOutcome, Protocol, ConnectedPeer, ProtocolStatus, PeerInfo}; +use crate::protocol::{self, Context, CustomMessageOutcome, Protocol, ConnectedPeer}; +use crate::protocol::{ProtocolStatus, PeerInfo, NetworkOut}; use crate::config::Params; use crate::error::Error; use crate::specialization::NetworkSpecialization; -use crossbeam_channel::{self as channel, Receiver, Sender, TryRecvError}; -use tokio::prelude::task::AtomicTask; use tokio::runtime::Builder as RuntimeBuilder; /// Interval at which we send status updates on the SyncProvider status stream. @@ -86,7 +85,7 @@ pub struct NetworkLink> { /// The protocol sender pub(crate) protocol_sender: mpsc::UnboundedSender>, /// The network sender - pub(crate) network_sender: NetworkChan, + pub(crate) network_sender: mpsc::UnboundedSender>, } impl> Link for NetworkLink { @@ -102,8 +101,8 @@ impl> Link for NetworkLink { let _ = self.protocol_sender.unbounded_send(ProtocolMsg::JustificationImportResult(hash.clone(), number, success)); if !success { info!("Invalid justification provided by {} for #{}", who, hash); - let _ = self.network_sender.send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); - let _ = self.network_sender.send(NetworkMsg::DisconnectPeer(who.clone())); + let _ = self.network_sender.unbounded_send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); + let _ = self.network_sender.unbounded_send(NetworkMsg::DisconnectPeer(who.clone())); } } @@ -135,13 +134,13 @@ impl> Link for NetworkLink { )); if !success { info!("Invalid finality proof provided by {} for #{}", who, request_block.0); - let _ = self.network_sender.send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); - let _ = self.network_sender.send(NetworkMsg::DisconnectPeer(who.clone())); + let _ = self.network_sender.unbounded_send(NetworkMsg::ReportPeer(who.clone(), i32::min_value())); + let _ = self.network_sender.unbounded_send(NetworkMsg::DisconnectPeer(who.clone())); } } fn report_peer(&self, who: PeerId, reputation_change: i32) { - self.network_sender.send(NetworkMsg::ReportPeer(who, reputation_change)); + let _ = self.network_sender.unbounded_send(NetworkMsg::ReportPeer(who, reputation_change)); } fn restart(&self) { @@ -178,7 +177,7 @@ pub struct Service> { /// Peers whom we are connected with. peers: Arc>>>, /// Channel for networking messages processed by the background thread. - network_chan: NetworkChan, + network_chan: mpsc::UnboundedSender>, /// Network service network: Arc>>>, /// Peerset manager (PSM); manages the reputation of nodes and indicates the network which @@ -199,7 +198,7 @@ impl> Service { protocol_id: ProtocolId, import_queue: Box>, ) -> Result>, Error> { - let (network_chan, network_port) = network_channel(); + let (network_chan, network_port) = mpsc::unbounded(); let (protocol_sender, protocol_rx) = mpsc::unbounded(); let status_sinks = Arc::new(Mutex::new(Vec::new())); // Start in off-line mode, since we're not connected to any nodes yet. @@ -208,7 +207,6 @@ impl> Service { let peers: Arc>>> = Arc::new(Default::default()); let protocol = Protocol::new( peers.clone(), - network_chan.clone(), params.config, params.chain, params.finality_proof_provider, @@ -322,14 +320,14 @@ impl> Service { /// /// This method is extremely poor in terms of API and should be eventually removed. pub fn disconnect_peer(&self, who: PeerId) { - let _ = self.network_chan.send(NetworkMsg::DisconnectPeer(who)); + let _ = self.network_chan.unbounded_send(NetworkMsg::DisconnectPeer(who)); } /// Send a message to the given peer. Has no effect if we're not connected to this peer. /// /// This method is extremely poor in terms of API and should be eventually removed. pub fn send_request(&self, who: PeerId, message: Message) { - let _ = self.network_chan.send(NetworkMsg::Outgoing(who, message)); + let _ = self.network_chan.unbounded_send(NetworkMsg::Outgoing(who, message)); } /// Execute a closure with the chain-specific network specialization. @@ -433,81 +431,6 @@ impl> ManageNetwork for Service } } - -/// Create a NetworkPort/Chan pair. -pub fn network_channel() -> (NetworkChan, NetworkPort) { - let (network_sender, network_receiver) = channel::unbounded(); - let task_notify = Arc::new(AtomicTask::new()); - let network_port = NetworkPort::new(network_receiver, task_notify.clone()); - let network_chan = NetworkChan::new(network_sender, task_notify); - (network_chan, network_port) -} - - -/// A sender of NetworkMsg that notifies a task when a message has been sent. -#[derive(Clone)] -pub struct NetworkChan { - sender: Sender>, - task_notify: Arc, -} - -impl NetworkChan { - /// Create a new network chan. - pub fn new(sender: Sender>, task_notify: Arc) -> Self { - NetworkChan { - sender, - task_notify, - } - } - - /// Send a messaging, to be handled on a stream. Notify the task handling the stream. - pub fn send(&self, msg: NetworkMsg) { - let _ = self.sender.send(msg); - self.task_notify.notify(); - } -} - -impl Drop for NetworkChan { - /// Notifying the task when a sender is dropped(when all are dropped, the stream is finished). - fn drop(&mut self) { - self.task_notify.notify(); - } -} - - -/// A receiver of NetworkMsg that makes the protocol-id available with each message. -pub struct NetworkPort { - receiver: Receiver>, - task_notify: Arc, -} - -impl NetworkPort { - /// Create a new network port for a given protocol-id. - pub fn new(receiver: Receiver>, task_notify: Arc) -> Self { - Self { - receiver, - task_notify, - } - } - - /// Receive a message, if any is currently-enqueued. - /// Register the current tokio task for notification when a new message is available. - pub fn take_one_message(&self) -> Result>, ()> { - self.task_notify.register(); - match self.receiver.try_recv() { - Ok(msg) => Ok(Some(msg)), - Err(TryRecvError::Empty) => Ok(None), - Err(TryRecvError::Disconnected) => Err(()), - } - } - - /// Get a reference to the underlying crossbeam receiver. - #[cfg(any(test, feature = "test-helpers"))] - pub fn receiver(&self) -> &Receiver> { - &self.receiver - } -} - /// Messages to be handled by NetworkService. #[derive(Debug)] pub enum NetworkMsg { @@ -592,7 +515,7 @@ fn start_thread, H: ExHashT>( is_major_syncing: Arc, protocol: Protocol, import_queue: Box>, - network_port: NetworkPort, + network_port: mpsc::UnboundedReceiver>, protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, config: NetworkConfiguration, @@ -645,11 +568,25 @@ fn run_thread, H: ExHashT>( mut protocol: Protocol, network_service: Arc>>>, import_queue: Box>, - network_port: NetworkPort, + mut network_port: mpsc::UnboundedReceiver>, mut protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, peerset: PeersetHandle, ) -> impl Future { + // Implementation of `protocol::NetworkOut` using the available local variables. + struct Ctxt<'a, B: BlockT>(&'a mut NetworkService>, &'a PeersetHandle); + impl<'a, B: BlockT> NetworkOut for Ctxt<'a, B> { + fn report_peer(&mut self, who: PeerId, reputation: i32) { + self.1.report_peer(who, reputation) + } + fn disconnect_peer(&mut self, who: PeerId) { + self.0.drop_node(&who) + } + fn send_message(&mut self, who: PeerId, message: Message) { + self.0.send_custom_message(&who, message) + } + } + // Interval at which we send status updates on the `status_sinks`. let mut status_interval = tokio::timer::Interval::new_interval(STATUS_INTERVAL); @@ -659,25 +596,26 @@ fn run_thread, H: ExHashT>( status_sinks.lock().retain(|sink| sink.unbounded_send(status.clone()).is_ok()); } - match protocol.poll() { - Ok(Async::Ready(())) => return Ok(Async::Ready(())), + match protocol.poll(&mut Ctxt(&mut network_service.lock(), &peerset)) { + Ok(Async::Ready(v)) => void::unreachable(v), Ok(Async::NotReady) => {} Err(err) => void::unreachable(err), } loop { - match network_port.take_one_message() { - Ok(None) => break, - Ok(Some(NetworkMsg::Outgoing(who, outgoing_message))) => + match network_port.poll() { + Ok(Async::NotReady) => break, + Ok(Async::Ready(Some(NetworkMsg::Outgoing(who, outgoing_message)))) => network_service.lock().send_custom_message(&who, outgoing_message), - Ok(Some(NetworkMsg::ReportPeer(who, reputation))) => + Ok(Async::Ready(Some(NetworkMsg::ReportPeer(who, reputation)))) => peerset.report_peer(who, reputation), - Ok(Some(NetworkMsg::DisconnectPeer(who))) => + Ok(Async::Ready(Some(NetworkMsg::DisconnectPeer(who)))) => network_service.lock().drop_node(&who), + #[cfg(any(test, feature = "test-helpers"))] - Ok(Some(NetworkMsg::Synchronized)) => {} + Ok(Async::Ready(Some(NetworkMsg::Synchronized))) => {} - Err(_) => return Ok(Async::Ready(())), + Ok(Async::Ready(None)) | Err(_) => return Ok(Async::Ready(())), } } @@ -688,71 +626,78 @@ fn run_thread, H: ExHashT>( Ok(Async::NotReady) => break, }; + let mut network_service = network_service.lock(); + let mut network_out = Ctxt(&mut network_service, &peerset); + match msg { ProtocolMsg::BlockImported(hash, header) => - protocol.on_block_imported(hash, &header), + protocol.on_block_imported(&mut network_out, hash, &header), ProtocolMsg::BlockFinalized(hash, header) => - protocol.on_block_finalized(hash, &header), + protocol.on_block_finalized(&mut network_out, hash, &header), ProtocolMsg::ExecuteWithSpec(task) => { - let (mut context, spec) = protocol.specialization_lock(); + let (mut context, spec) = protocol.specialization_lock(&mut network_out); task.call_box(spec, &mut context); }, ProtocolMsg::ExecuteWithGossip(task) => { - let (mut context, gossip) = protocol.consensus_gossip_lock(); + let (mut context, gossip) = protocol.consensus_gossip_lock(&mut network_out); task.call_box(gossip, &mut context); } ProtocolMsg::GossipConsensusMessage(topic, engine_id, message, recipient) => - protocol.gossip_consensus_message(topic, engine_id, message, recipient), + protocol.gossip_consensus_message(&mut network_out, topic, engine_id, message, recipient), ProtocolMsg::BlocksProcessed(hashes, has_error) => - protocol.blocks_processed(hashes, has_error), + protocol.blocks_processed(&mut network_out, hashes, has_error), ProtocolMsg::RestartSync => - protocol.restart(), + protocol.restart(&mut network_out), ProtocolMsg::AnnounceBlock(hash) => - protocol.announce_block(hash), + protocol.announce_block(&mut network_out, hash), ProtocolMsg::BlockImportedSync(hash, number) => protocol.block_imported(&hash, number), ProtocolMsg::ClearJustificationRequests => protocol.clear_justification_requests(), ProtocolMsg::RequestJustification(hash, number) => - protocol.request_justification(&hash, number), + protocol.request_justification(&mut network_out, &hash, number), ProtocolMsg::JustificationImportResult(hash, number, success) => protocol.justification_import_result(hash, number, success), ProtocolMsg::SetFinalityProofRequestBuilder(builder) => protocol.set_finality_proof_request_builder(builder), ProtocolMsg::RequestFinalityProof(hash, number) => - protocol.request_finality_proof(&hash, number), + protocol.request_finality_proof(&mut network_out, &hash, number), ProtocolMsg::FinalityProofImportResult(requested_block, finalziation_result) => protocol.finality_proof_import_result(requested_block, finalziation_result), - ProtocolMsg::PropagateExtrinsics => protocol.propagate_extrinsics(), + ProtocolMsg::PropagateExtrinsics => protocol.propagate_extrinsics(&mut network_out), #[cfg(any(test, feature = "test-helpers"))] - ProtocolMsg::Tick => protocol.tick(), + ProtocolMsg::Tick => protocol.tick(&mut network_out), #[cfg(any(test, feature = "test-helpers"))] - ProtocolMsg::Synchronize => protocol.synchronize(), + ProtocolMsg::Synchronize => {}, } } loop { - let outcome = match network_service.lock().poll() { + let mut network_service = network_service.lock(); + let poll_value = network_service.poll(); + let mut network_out = Ctxt(&mut network_service, &peerset); + + let outcome = match poll_value { Ok(Async::NotReady) => break, Ok(Async::Ready(Some(NetworkServiceEvent::OpenedCustomProtocol { peer_id, version, debug_info, .. }))) => { debug_assert!( version <= protocol::CURRENT_VERSION as u8 && version >= protocol::MIN_VERSION as u8 ); - protocol.on_peer_connected(peer_id, debug_info); + protocol.on_peer_connected(&mut network_out, peer_id, debug_info); CustomMessageOutcome::None } Ok(Async::Ready(Some(NetworkServiceEvent::ClosedCustomProtocol { peer_id, debug_info, .. }))) => { - protocol.on_peer_disconnected(peer_id, debug_info); + protocol.on_peer_disconnected(&mut network_out, peer_id, debug_info); CustomMessageOutcome::None }, Ok(Async::Ready(Some(NetworkServiceEvent::CustomMessage { peer_id, message, .. }))) => - protocol.on_custom_message(peer_id, message), + protocol.on_custom_message(&mut network_out, peer_id, message), Ok(Async::Ready(Some(NetworkServiceEvent::Clogged { peer_id, messages, .. }))) => { debug!(target: "sync", "{} clogging messages:", messages.len()); for msg in messages.into_iter().take(5) { debug!(target: "sync", "{:?}", msg); - protocol.on_clogged_peer(peer_id.clone(), Some(msg)); + protocol.on_clogged_peer(&mut network_out, peer_id.clone(), Some(msg)); } CustomMessageOutcome::None } diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 44e0eafd91..82d54d40b0 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -26,7 +26,8 @@ use std::sync::Arc; use log::trace; use crate::chain::FinalityProofProvider; -use client::{self, ClientInfo, BlockchainEvents, FinalityNotifications, in_mem::Backend as InMemoryBackend, error::Result as ClientResult}; +use client::{self, ClientInfo, BlockchainEvents, FinalityNotifications}; +use client::{in_mem::Backend as InMemoryBackend, error::Result as ClientResult}; use client::block_builder::BlockBuilder; use client::backend::AuxStore; use crate::config::{ProtocolConfig, Roles}; @@ -38,17 +39,16 @@ use consensus::import_queue::{ use consensus::{Error as ConsensusError, ErrorKind as ConsensusErrorKind}; use consensus::{BlockOrigin, ForkChoiceStrategy, ImportBlock, JustificationImport}; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient, TopicNotification}; -use crossbeam_channel::RecvError; use futures::{prelude::*, sync::{mpsc, oneshot}}; use crate::message::Message; use network_libp2p::PeerId; use parking_lot::{Mutex, RwLock}; use primitives::{H256, sr25519::Public as AuthorityId, Blake2Hasher}; -use crate::protocol::{ConnectedPeer, Context, Protocol, ProtocolStatus, CustomMessageOutcome}; +use crate::protocol::{ConnectedPeer, Context, Protocol, ProtocolStatus, CustomMessageOutcome, NetworkOut}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{AuthorityIdFor, Block as BlockT, Digest, DigestItem, Header, NumberFor}; use runtime_primitives::{Justification, ConsensusEngineId}; -use crate::service::{network_channel, NetworkChan, NetworkLink, NetworkMsg, NetworkPort, ProtocolMsg, TransactionPool}; +use crate::service::{NetworkLink, NetworkMsg, ProtocolMsg, TransactionPool}; use crate::specialization::NetworkSpecialization; use test_client::{self, AccountKeyring}; @@ -115,8 +115,10 @@ impl NetworkSpecialization for DummySpecialization { } } -pub type PeersFullClient = client::Client; -pub type PeersLightClient = client::Client; +pub type PeersFullClient = + client::Client; +pub type PeersLightClient = + client::Client; #[derive(Clone)] pub enum PeersClient { @@ -181,7 +183,12 @@ impl PeersClient { } } - pub fn finalize_block(&self, id: BlockId, justification: Option, notify: bool) -> ClientResult<()> { + pub fn finalize_block( + &self, + id: BlockId, + justification: Option, + notify: bool + ) -> ClientResult<()> { match *self { PeersClient::Full(ref client) => client.finalize_block(id, justification, notify), PeersClient::Light(ref client) => client.finalize_block(id, justification, notify), @@ -201,7 +208,7 @@ impl> TestLink { fn new( protocol_sender: mpsc::UnboundedSender>, _network_to_protocol_sender: mpsc::UnboundedSender>, - network_sender: NetworkChan + network_sender: mpsc::UnboundedSender> ) -> TestLink { TestLink { #[cfg(any(test, feature = "test-helpers"))] @@ -267,12 +274,12 @@ impl> Link for TestLink { } pub struct Peer> { - pub peers: Arc>>>, - pub peer_id: PeerId, + peers: Arc>>>, + peer_id: PeerId, client: PeersClient, net_proto_channel: ProtocolChannel, protocol_status: Arc>>, - pub import_queue: Box>, + import_queue: Box>, pub data: D, best_hash: Mutex>, finalized_hash: Mutex>, @@ -292,24 +299,28 @@ pub enum FromNetworkMsg { } struct ProtocolChannel> { + /// If true, we expect a tokio executor to be available. If false, we spawn our own. + use_tokio: bool, buffered_messages: Mutex>>, network_to_protocol_sender: mpsc::UnboundedSender>, client_to_protocol_sender: mpsc::UnboundedSender>, - protocol_to_network_receiver: NetworkPort, + protocol_to_network_receiver: Mutex>>, } impl> ProtocolChannel { /// Create new buffered network port. pub fn new( + use_tokio: bool, network_to_protocol_sender: mpsc::UnboundedSender>, client_to_protocol_sender: mpsc::UnboundedSender>, - protocol_to_network_receiver: NetworkPort, + protocol_to_network_receiver: mpsc::UnboundedReceiver>, ) -> Self { ProtocolChannel { + use_tokio, buffered_messages: Mutex::new(VecDeque::new()), network_to_protocol_sender, client_to_protocol_sender, - protocol_to_network_receiver, + protocol_to_network_receiver: Mutex::new(protocol_to_network_receiver), } } @@ -330,13 +341,23 @@ impl> ProtocolChannel { } /// Wait until synchronization response is generated by the protocol. - pub fn wait_sync(&self) -> Result<(), RecvError> { - loop { - match self.protocol_to_network_receiver.receiver().recv() { - Ok(NetworkMsg::Synchronized) => return Ok(()), - Err(error) => return Err(error), - Ok(msg) => self.buffered_messages.lock().push_back(msg), + pub fn wait_sync(&self) -> Result<(), ()> { + let fut = futures::future::poll_fn(|| { + loop { + let mut protocol_to_network_receiver = self.protocol_to_network_receiver.lock(); + match protocol_to_network_receiver.poll() { + Ok(Async::Ready(Some(NetworkMsg::Synchronized))) => return Ok(Async::Ready(())), + Ok(Async::Ready(None)) | Err(_) => return Err(()), + Ok(Async::NotReady) => return Ok(Async::NotReady), + Ok(Async::Ready(Some(msg))) => self.buffered_messages.lock().push_back(msg), + } } + }); + + if self.use_tokio { + fut.wait() + } else { + tokio::runtime::current_thread::block_on_all(fut) } } @@ -359,8 +380,13 @@ impl> ProtocolChannel { /// Whether this peer is done syncing (has no messages to send). fn is_done(&self) -> bool { - self.buffered_messages.lock().is_empty() - && self.protocol_to_network_receiver.receiver().is_empty() + let mut buffered_messages = self.buffered_messages.lock(); + if let Some(msg) = self.channel_message() { + buffered_messages.push_back(msg); + false + } else { + buffered_messages.is_empty() + } } /// Return oldest buffered message if it exists. @@ -377,7 +403,20 @@ impl> ProtocolChannel { /// Receive message from the channel. fn channel_message(&self) -> Option> { - self.protocol_to_network_receiver.receiver().try_recv().ok() + let fut = futures::future::poll_fn(|| -> Result<_, ()> { + Ok(Async::Ready(match self.protocol_to_network_receiver.lock().poll() { + Ok(Async::Ready(Some(m))) => Some(m), + Ok(Async::NotReady) => None, + Err(_) => None, + Ok(Async::Ready(None)) => None, + })) + }); + + if self.use_tokio { + fut.wait() + } else { + tokio::runtime::current_thread::block_on_all(fut) + }.ok().and_then(|a| a) } } @@ -387,13 +426,15 @@ impl> Peer { peers: Arc>>>, client: PeersClient, import_queue: Box>, + use_tokio: bool, network_to_protocol_sender: mpsc::UnboundedSender>, protocol_sender: mpsc::UnboundedSender>, - network_sender: NetworkChan, - network_port: NetworkPort, + network_sender: mpsc::UnboundedSender>, + network_port: mpsc::UnboundedReceiver>, data: D, ) -> Self { let net_proto_channel = ProtocolChannel::new( + use_tokio, network_to_protocol_sender.clone(), protocol_sender.clone(), network_port, @@ -417,7 +458,7 @@ impl> Peer { } } /// Called after blockchain has been populated to updated current state. - pub fn start(&self) { + fn start(&self) { // Update the sync state to the latest chain state. let info = self.client.info().expect("In-mem client does not fail"); let header = self @@ -428,7 +469,7 @@ impl> Peer { self.net_proto_channel.send_from_client(ProtocolMsg::BlockImported(info.chain.best_hash, header)); } - pub fn on_block_imported( + fn on_block_imported( &self, hash: ::Hash, header: &::Header, @@ -438,18 +479,18 @@ impl> Peer { /// SyncOracle: are we connected to any peer? #[cfg(test)] - pub fn is_offline(&self) -> bool { + fn is_offline(&self) -> bool { self.protocol_status.read().sync.is_offline() } /// SyncOracle: are we in the process of catching-up with the chain? #[cfg(test)] - pub fn is_major_syncing(&self) -> bool { + fn is_major_syncing(&self) -> bool { self.protocol_status.read().sync.is_major_syncing() } /// Get protocol status. - pub fn protocol_status(&self) -> ProtocolStatus { + fn protocol_status(&self) -> ProtocolStatus { self.protocol_status.read().clone() } @@ -507,7 +548,7 @@ impl> Peer { } /// Send block finalization notifications. - pub fn send_finality_notifications(&self) { + fn send_finality_notifications(&self) { let info = self.client.info().expect("In-mem client does not fail"); let mut finalized_hash = self.finalized_hash.lock(); @@ -543,10 +584,6 @@ impl> Peer { ); } - pub fn consensus_gossip_collect_garbage_for_topic(&self, _topic: ::Hash) { - self.with_gossip(move |gossip, _| gossip.collect_garbage()) - } - /// access the underlying consensus gossip handler pub fn consensus_gossip_messages_for( &self, @@ -569,7 +606,7 @@ impl> Peer { } /// Announce a block to peers. - pub fn announce_block(&self, block: Hash) { + fn announce_block(&self, block: Hash) { self.net_proto_channel.send_from_client(ProtocolMsg::AnnounceBlock(block)); } @@ -589,9 +626,13 @@ impl> Peer { /// Add blocks to the peer -- edit the block before adding. The chain will /// start at the given block iD. - pub fn generate_blocks_at(&self, at: BlockId, count: usize, origin: BlockOrigin, mut edit_block: F) -> H256 - where F: FnMut(BlockBuilder) -> Block - { + fn generate_blocks_at( + &self, + at: BlockId, + count: usize, + origin: BlockOrigin, + mut edit_block: F + ) -> H256 where F: FnMut(BlockBuilder) -> Block { let full_client = self.client.as_full().expect("blocks could only be generated by full clients"); let mut at = full_client.header(&at).unwrap().unwrap().hash(); for _ in 0..count { @@ -633,7 +674,7 @@ impl> Peer { /// Push blocks to the peer (simplified: with or without a TX) starting from /// given hash. - pub fn push_blocks_at(&self, at: BlockId, count: usize, with_tx: bool) -> H256 { + fn push_blocks_at(&self, at: BlockId, count: usize, with_tx: bool) -> H256 { let mut nonce = 0; if with_tx { self.generate_blocks_at(at, count, BlockOrigin::File, |mut builder| { @@ -728,6 +769,11 @@ pub trait TestNetFactory: Sized { ProtocolConfig::default() } + /// Must return true if the testnet is going to be used from within a tokio context. + fn uses_tokio(&self) -> bool { + false + } + /// Create new test network with this many peers. fn new(n: usize) -> Self { trace!(target: "test_network", "Creating test network"); @@ -747,26 +793,41 @@ pub trait TestNetFactory: Sized { protocol_status: Arc>>, import_queue: Box>, mut protocol: Protocol, + network_sender: mpsc::UnboundedSender>, mut network_to_protocol_rx: mpsc::UnboundedReceiver>, mut protocol_rx: mpsc::UnboundedReceiver>, peer: Arc>, ) { std::thread::spawn(move || { + // Implementation of `protocol::NetworkOut` using the available local variables. + struct Ctxt<'a, B: BlockT>(&'a mpsc::UnboundedSender>); + impl<'a, B: BlockT> NetworkOut for Ctxt<'a, B> { + fn report_peer(&mut self, who: PeerId, reputation: i32) { + let _ = self.0.unbounded_send(NetworkMsg::ReportPeer(who, reputation)); + } + fn disconnect_peer(&mut self, who: PeerId) { + let _ = self.0.unbounded_send(NetworkMsg::DisconnectPeer(who)); + } + fn send_message(&mut self, who: PeerId, message: Message) { + let _ = self.0.unbounded_send(NetworkMsg::Outgoing(who, message)); + } + } + tokio::runtime::current_thread::run(futures::future::poll_fn(move || { while let Async::Ready(msg) = network_to_protocol_rx.poll().unwrap() { let outcome = match msg { Some(FromNetworkMsg::PeerConnected(peer_id, debug_msg)) => { - protocol.on_peer_connected(peer_id, debug_msg); + protocol.on_peer_connected(&mut Ctxt(&network_sender), peer_id, debug_msg); CustomMessageOutcome::None }, Some(FromNetworkMsg::PeerDisconnected(peer_id, debug_msg)) => { - protocol.on_peer_disconnected(peer_id, debug_msg); + protocol.on_peer_disconnected(&mut Ctxt(&network_sender), peer_id, debug_msg); CustomMessageOutcome::None }, Some(FromNetworkMsg::CustomMessage(peer_id, message)) => - protocol.on_custom_message(peer_id, message), + protocol.on_custom_message(&mut Ctxt(&network_sender), peer_id, message), Some(FromNetworkMsg::Synchronize) => { - protocol.synchronize(); + let _ = network_sender.unbounded_send(NetworkMsg::Synchronized); CustomMessageOutcome::None }, None => return Ok(Async::Ready(())), @@ -792,51 +853,59 @@ pub trait TestNetFactory: Sized { match msg { ProtocolMsg::BlockImported(hash, header) => - protocol.on_block_imported(hash, &header), + protocol.on_block_imported(&mut Ctxt(&network_sender), hash, &header), ProtocolMsg::BlockFinalized(hash, header) => - protocol.on_block_finalized(hash, &header), + protocol.on_block_finalized(&mut Ctxt(&network_sender), hash, &header), ProtocolMsg::ExecuteWithSpec(task) => { - let (mut context, spec) = protocol.specialization_lock(); + let mut ctxt = Ctxt(&network_sender); + let (mut context, spec) = protocol.specialization_lock(&mut ctxt); task.call_box(spec, &mut context); }, ProtocolMsg::ExecuteWithGossip(task) => { - let (mut context, gossip) = protocol.consensus_gossip_lock(); + let mut ctxt = Ctxt(&network_sender); + let (mut context, gossip) = protocol.consensus_gossip_lock(&mut ctxt); task.call_box(gossip, &mut context); } ProtocolMsg::GossipConsensusMessage(topic, engine_id, message, recipient) => - protocol.gossip_consensus_message(topic, engine_id, message, recipient), + protocol.gossip_consensus_message( + &mut Ctxt(&network_sender), + topic, + engine_id, + message, + recipient + ), ProtocolMsg::BlocksProcessed(hashes, has_error) => - protocol.blocks_processed(hashes, has_error), + protocol.blocks_processed(&mut Ctxt(&network_sender), hashes, has_error), ProtocolMsg::RestartSync => - protocol.restart(), + protocol.restart(&mut Ctxt(&network_sender)), ProtocolMsg::AnnounceBlock(hash) => - protocol.announce_block(hash), + protocol.announce_block(&mut Ctxt(&network_sender), hash), ProtocolMsg::BlockImportedSync(hash, number) => protocol.block_imported(&hash, number), ProtocolMsg::ClearJustificationRequests => protocol.clear_justification_requests(), ProtocolMsg::RequestJustification(hash, number) => - protocol.request_justification(&hash, number), + protocol.request_justification(&mut Ctxt(&network_sender), &hash, number), ProtocolMsg::JustificationImportResult(hash, number, success) => protocol.justification_import_result(hash, number, success), ProtocolMsg::SetFinalityProofRequestBuilder(builder) => protocol.set_finality_proof_request_builder(builder), ProtocolMsg::RequestFinalityProof(hash, number) => - protocol.request_finality_proof(&hash, number), + protocol.request_finality_proof(&mut Ctxt(&network_sender), &hash, number), ProtocolMsg::FinalityProofImportResult(requested_block, finalziation_result) => protocol.finality_proof_import_result(requested_block, finalziation_result), - ProtocolMsg::PropagateExtrinsics => protocol.propagate_extrinsics(), + ProtocolMsg::PropagateExtrinsics => protocol.propagate_extrinsics(&mut Ctxt(&network_sender)), #[cfg(any(test, feature = "test-helpers"))] - ProtocolMsg::Tick => protocol.tick(), + ProtocolMsg::Tick => protocol.tick(&mut Ctxt(&network_sender)), #[cfg(any(test, feature = "test-helpers"))] ProtocolMsg::Synchronize => { trace!(target: "sync", "handle_client_msg: received Synchronize msg"); - protocol.synchronize(); + let _ = network_sender.unbounded_send(NetworkMsg::Synchronized); } } } - if let Async::Ready(_) = protocol.poll().unwrap() { + if let Async::Ready(_) = protocol.poll(&mut Ctxt(&network_sender)).unwrap() { return Ok(Async::Ready(())) } @@ -865,7 +934,7 @@ pub trait TestNetFactory: Sized { let verifier = self.make_verifier(PeersClient::Full(client.clone()), config); let (block_import, justification_import, finality_proof_import, finality_proof_request_builder, data) = self.make_block_import(PeersClient::Full(client.clone())); - let (network_sender, network_port) = network_channel(); + let (network_sender, network_port) = mpsc::unbounded(); let import_queue = Box::new(BasicQueue::new( verifier, @@ -882,7 +951,6 @@ pub trait TestNetFactory: Sized { let protocol = Protocol::new( peers.clone(), - network_sender.clone(), config.clone(), client.clone(), self.make_finality_proof_provider(PeersClient::Full(client.clone())), @@ -896,6 +964,7 @@ pub trait TestNetFactory: Sized { protocol_status.clone(), import_queue.clone(), protocol, + network_sender.clone(), network_to_protocol_rx, protocol_rx, Arc::new(Peer::new( @@ -903,6 +972,7 @@ pub trait TestNetFactory: Sized { peers, PeersClient::Full(client), import_queue, + self.uses_tokio(), network_to_protocol_sender, protocol_sender, network_sender, @@ -922,7 +992,7 @@ pub trait TestNetFactory: Sized { let verifier = self.make_verifier(PeersClient::Light(client.clone()), &config); let (block_import, justification_import, finality_proof_import, finality_proof_request_builder, data) = self.make_block_import(PeersClient::Light(client.clone())); - let (network_sender, network_port) = network_channel(); + let (network_sender, network_port) = mpsc::unbounded(); let import_queue = Box::new(BasicQueue::new( verifier, @@ -939,7 +1009,6 @@ pub trait TestNetFactory: Sized { let protocol = Protocol::new( peers.clone(), - network_sender.clone(), config, client.clone(), self.make_finality_proof_provider(PeersClient::Light(client.clone())), @@ -953,6 +1022,7 @@ pub trait TestNetFactory: Sized { protocol_status.clone(), import_queue.clone(), protocol, + network_sender.clone(), network_to_protocol_rx, protocol_rx, Arc::new(Peer::new( @@ -960,6 +1030,7 @@ pub trait TestNetFactory: Sized { peers, PeersClient::Light(client), import_queue, + self.uses_tokio(), network_to_protocol_sender, protocol_sender, network_sender, @@ -1187,7 +1258,7 @@ impl TestNetFactory for JustificationTestNet { self.0.peers() } - fn mut_peers>>)>(&mut self, closure: F ) { + fn mut_peers>>)>(&mut self, closure: F) { self.0.mut_peers(closure) } -- GitLab From 95017b7f7c3aab5489a1161819ebde2aa4934767 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Tue, 21 May 2019 17:07:30 +0200 Subject: [PATCH 008/113] Reserve function name (#2609) * reserve function name * bumpd impl version * Revert "bumpd impl version" This reverts commit 03a23e308312d857bdfd3c90ff564b4b11347530. * add test * update test * update lock * Fix test on stable --- Cargo.lock | 1 + srml/support/src/dispatch.rs | 36 ++++++++++++++ srml/support/src/lib.rs | 2 +- srml/support/src/unsigned.rs | 1 + srml/support/test/Cargo.toml | 5 +- srml/support/test/src/lib.rs | 6 +++ .../tests/reserved_keyword/on_initialize.rs | 33 +++++++++++++ .../reserved_keyword/on_initialize.stderr | 47 +++++++++++++++++++ 8 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 srml/support/test/tests/reserved_keyword/on_initialize.rs create mode 100644 srml/support/test/tests/reserved_keyword/on_initialize.stderr diff --git a/Cargo.lock b/Cargo.lock index 106be37cdc..e0c683f24c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3699,6 +3699,7 @@ dependencies = [ "srml-support 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", + "trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/srml/support/src/dispatch.rs b/srml/support/src/dispatch.rs index d5fabd341c..aa6282c773 100644 --- a/srml/support/src/dispatch.rs +++ b/srml/support/src/dispatch.rs @@ -874,6 +874,10 @@ macro_rules! decl_module { { $( $on_finalize:tt )* } { $( $offchain:tt )* } ) => { + $crate::__check_reserved_fn_name! { + $($fn_name)* + } + // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] @@ -1201,6 +1205,38 @@ macro_rules! __function_to_metadata { } } +#[macro_export] +#[doc(hidden)] +macro_rules! __check_reserved_fn_name { + (deposit_event $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error deposit_event); + }; + (on_initialize $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error on_initialize); + }; + (on_initialise $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error on_initialise); + }; + (on_finalize $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error on_finalize); + }; + (on_finalise $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error on_finalise); + }; + (offchain_worker $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!(@compile_error offchain_worker); + }; + ($t:ident $( $rest:ident )*) => { + $crate::__check_reserved_fn_name!($( $rest )*); + }; + () => {}; + (@compile_error $ident:ident) => { + compile_error!(concat!("Invalid call fn name: `", stringify!($ident), + "`, name is reserved and doesn't match expected signature, please refer to `decl_module!`", + " documentation to see the appropriate usage, or rename it to an unreserved keyword.")); + }; +} + #[cfg(test)] // Do not complain about unused `dispatch` and `dispatch_aux`. #[allow(dead_code)] diff --git a/srml/support/src/lib.rs b/srml/support/src/lib.rs index cdaec09632..4f749d4c89 100644 --- a/srml/support/src/lib.rs +++ b/srml/support/src/lib.rs @@ -381,7 +381,7 @@ mod tests { let key2 = 18u32; DoubleMap::insert(key1, key2, vec![1]); - DoubleMap::append(key1, key2, &[2, 3]); + DoubleMap::append(key1, key2, &[2, 3]).unwrap(); assert_eq!(DoubleMap::get(key1, key2), vec![1, 2, 3]); }); } diff --git a/srml/support/src/unsigned.rs b/srml/support/src/unsigned.rs index dcdf4b2683..8ea613461a 100644 --- a/srml/support/src/unsigned.rs +++ b/srml/support/src/unsigned.rs @@ -84,6 +84,7 @@ mod test_empty_call { pub enum Call { } + #[allow(unused)] pub struct Runtime; impl_outer_validate_unsigned! { diff --git a/srml/support/test/Cargo.toml b/srml/support/test/Cargo.toml index 29cc927ff7..44a3b8d884 100644 --- a/srml/support/test/Cargo.toml +++ b/srml/support/test/Cargo.toml @@ -4,13 +4,14 @@ version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" -[dev-dependencies] +[dependencies] serde = { version = "1.0", default-features = false, features = ["derive"] } parity-codec = { version = "3.3", default-features = false, features = ["derive"] } runtime_io = { package = "sr-io", path = "../../../core/sr-io", default-features = false } -srml-support = { path = "../", default-features = false } +srml-support = { version = "2", path = "../", default-features = false } inherents = { package = "substrate-inherents", path = "../../../core/inherents", default-features = false } primitives = { package = "substrate-primitives", path = "../../../core/primitives", default-features = false } +trybuild = "1" [features] default = ["std"] diff --git a/srml/support/test/src/lib.rs b/srml/support/test/src/lib.rs index 7b23662e68..a7a869cf87 100644 --- a/srml/support/test/src/lib.rs +++ b/srml/support/test/src/lib.rs @@ -16,3 +16,9 @@ //! Test crate for srml_support. Allow to make use of `srml_support::decl_storage`. //! See tests directory. + +#[test] +fn reserved_keyword() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/reserved_keyword/*.rs"); +} diff --git a/srml/support/test/tests/reserved_keyword/on_initialize.rs b/srml/support/test/tests/reserved_keyword/on_initialize.rs new file mode 100644 index 0000000000..c63153241c --- /dev/null +++ b/srml/support/test/tests/reserved_keyword/on_initialize.rs @@ -0,0 +1,33 @@ +macro_rules! reserved { + ($($reserved:ident)*) => { + $( + mod $reserved { + pub use srml_support::dispatch::Result; + + pub trait Trait { + type Origin; + type BlockNumber: Into; + } + + pub mod system { + use srml_support::dispatch::Result; + + pub fn ensure_root(_: R) -> Result { + Ok(()) + } + } + + srml_support::decl_module! { + pub struct Module for enum Call where origin: T::Origin { + fn $reserved() -> Result { unreachable!() } + } + } + } + )* + } +} + +reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + +fn main() { +} diff --git a/srml/support/test/tests/reserved_keyword/on_initialize.stderr b/srml/support/test/tests/reserved_keyword/on_initialize.stderr new file mode 100644 index 0000000000..7a37eb66c3 --- /dev/null +++ b/srml/support/test/tests/reserved_keyword/on_initialize.stderr @@ -0,0 +1,47 @@ +error: Invalid call fn name: `on_finalize`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword. + --> $DIR/on_initialize.rs:30:1 + | +30 | reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: Invalid call fn name: `on_initialize`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword. + --> $DIR/on_initialize.rs:30:1 + | +30 | reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: Invalid call fn name: `on_finalise`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword. + --> $DIR/on_initialize.rs:30:1 + | +30 | reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: Invalid call fn name: `on_initialise`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword. + --> $DIR/on_initialize.rs:30:1 + | +30 | reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: Invalid call fn name: `offchain_worker`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword. + --> $DIR/on_initialize.rs:30:1 + | +30 | reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: Invalid call fn name: `deposit_event`, name is reserved and doesn't match expected signature, please refer to `decl_module!` documentation to see the appropriate usage, or rename it to an unreserved keyword. + --> $DIR/on_initialize.rs:30:1 + | +30 | reserved!(on_finalize on_initialize on_finalise on_initialise offchain_worker deposit_event); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -- GitLab From d6eba14a55be26e1a4e24a882ff574aa0190aff6 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 21 May 2019 13:08:55 -0400 Subject: [PATCH 009/113] Update build script to create a table for the runtime (#2643) This enables use of the sanbox needed for running smart contracts on Substrate See: https://github.com/paritytech/substrate/issues/2570 --- node-template/runtime/wasm/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/runtime/wasm/build.sh b/node-template/runtime/wasm/build.sh index 0be6e7a11c..f5761cbb1e 100755 --- a/node-template/runtime/wasm/build.sh +++ b/node-template/runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -$CARGO_CMD build --target=wasm32-unknown-unknown --release +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release for i in node_template_runtime_wasm do wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm -- GitLab From 5e47bbae2cc6f1dab8cda7bbb07544e749b0da15 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Wed, 22 May 2019 09:18:18 +0200 Subject: [PATCH 010/113] docs: Rephrase EnumerableStorageMap comment in Rustdocs (#2647) --- srml/support/src/storage/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srml/support/src/storage/mod.rs b/srml/support/src/storage/mod.rs index 426e480f0c..a2747da78b 100644 --- a/srml/support/src/storage/mod.rs +++ b/srml/support/src/storage/mod.rs @@ -332,8 +332,8 @@ impl StorageMap for U where U: hashed::generator::S /// A storage map that can be enumerated. /// -/// Note that type is primarily useful for off-chain computations. -/// Runtime implementors should avoid enumerating storage entries. +/// Primarily useful for off-chain computations. +/// Runtime implementors should avoid enumerating storage entries on-chain. pub trait EnumerableStorageMap: StorageMap { /// Return current head element. fn head() -> Option; -- GitLab From 5cb4ac17840b5c8178039e446f14d47dd8babe0b Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 22 May 2019 08:45:28 +0100 Subject: [PATCH 011/113] Revert "Allow warnings (#2627)" (#2648) This reverts commit c52d16441b5d9f0afbd44cedab0525b4e6566bbb. --- core/consensus/babe/src/lib.rs | 5 +++-- core/finality-grandpa/src/lib.rs | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 3c720db627..c3d73b6e49 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -533,6 +533,7 @@ impl SlotWorker for BabeWorker whe /// This digest item will always return `Some` when used with `as_babe_seal`. // // FIXME #1018 needs misbehavior types +#[forbid(warnings)] fn check_header( client: &Arc, slot_now: u64, @@ -584,7 +585,7 @@ fn check_header( format!("VRF verification failed") })? }; - + if check(&inout, threshold) { match check_equivocation(&client, slot_now, slot_num, header.clone(), signer.clone()) { Ok(Some(equivocation_proof)) => { @@ -1018,7 +1019,7 @@ mod tests { Default::default(), 0, ); - + let (inout, proof, _batchable_proof) = get_keypair(&pair).vrf_sign_n_check(transcript, |inout| check(inout, u64::MAX)).unwrap(); let pre_hash: H256 = header.hash(); let to_sign = (slot_num, pre_hash, proof.to_bytes()).encode(); diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index f9f2016cc9..9d808bf4d5 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -51,6 +51,8 @@ //! number (this is num(signal) + N). When finalizing a block, we either apply //! or prune any signaled changes based on whether the signaling block is //! included in the newly-finalized chain. +#![forbid(warnings)] +#![allow(deprecated)] // FIXME #2532: remove once the refactor is done https://github.com/paritytech/substrate/issues/2532 use futures::prelude::*; use log::{debug, info, warn}; -- GitLab From 47ff2c6e02b25c049d924d4068eac05de00a2139 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 22 May 2019 18:01:36 +0200 Subject: [PATCH 012/113] propagate round messages after verification (#2660) --- core/finality-grandpa/src/communication/gossip.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/finality-grandpa/src/communication/gossip.rs b/core/finality-grandpa/src/communication/gossip.rs index fd9d30e951..79f98e5bdb 100644 --- a/core/finality-grandpa/src/communication/gossip.rs +++ b/core/finality-grandpa/src/communication/gossip.rs @@ -690,6 +690,7 @@ impl network_gossip::Validator for GossipValidator match action { Action::Keep(topic, cb) => { self.report(who.clone(), cb); + context.broadcast_message(topic, data.to_vec(), false); network_gossip::ValidationResult::ProcessAndKeep(topic) } Action::ProcessAndDiscard(topic, cb) => { -- GitLab From 1e3fd718a22d2e538fdf58a9a244c37e68ae8453 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 22 May 2019 23:11:38 +0100 Subject: [PATCH 013/113] Remove `As` (#2602) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Start to remove the `As` bound on `SimpleArtithmetic` This just introduces standard numeric bounds, assuming a minimum of `u32`. Also included is a saturating from/into trait allowing ergonomic infallible conversion when you don't care if it saturates. * Remove As from Balances trait * Remove As from Aura module * Remove As from Babe module * Expunge `As` from contract * Council module * Democracy * Finality tracker * Grandpa * First bit of indices * indices * Line lengths * session * system * Staking * Square up all other uses of As. * RHD update * Fix build/test * Remove As trait * line widths * Remove final As ref * Update srml/staking/src/lib.rs Co-Authored-By: Bastian Köcher * Update core/client/src/cht.rs Co-Authored-By: Bastian Köcher * Update core/client/db/src/light.rs Co-Authored-By: Bastian Köcher * Apply suggestions from code review Co-Authored-By: Bastian Köcher * whitespace * Apply suggestions from code review Co-Authored-By: Bastian Köcher Co-Authored-By: André Silva * Bring back u32 check for number on CLI --- Cargo.lock | 1 + core/cli/src/informant.rs | 6 +- core/cli/src/lib.rs | 5 +- core/cli/src/params.rs | 6 +- core/client/db/src/cache/list_cache.rs | 12 +- core/client/db/src/cache/mod.rs | 6 +- core/client/db/src/lib.rs | 37 ++-- core/client/db/src/light.rs | 14 +- core/client/db/src/utils.rs | 36 ++-- core/client/src/cht.rs | 34 ++-- core/client/src/client.rs | 96 ++++++---- core/client/src/in_mem.rs | 14 +- core/client/src/light/call_executor.rs | 4 +- core/client/src/light/fetcher.rs | 26 +-- core/consensus/common/Cargo.toml | 1 + core/consensus/common/src/evaluation.rs | 15 +- core/consensus/rhd/src/lib.rs | 7 +- core/finality-grandpa/src/environment.rs | 4 +- core/finality-grandpa/src/lib.rs | 2 +- core/network/src/blocks.rs | 12 +- core/network/src/protocol.rs | 15 +- core/network/src/sync.rs | 61 ++++--- core/rpc/src/chain/number.rs | 21 ++- core/rpc/src/state/mod.rs | 11 +- core/service/src/chain_ops.rs | 14 +- core/service/src/lib.rs | 7 +- core/service/test/src/lib.rs | 11 +- .../unchecked_mortal_compact_extrinsic.rs | 7 +- .../src/generic/unchecked_mortal_extrinsic.rs | 9 +- core/sr-primitives/src/lib.rs | 58 +++--- core/sr-primitives/src/traits.rs | 170 +++++++++++++----- core/state-machine/src/changes_trie/prune.rs | 3 +- core/test-runtime/wasm/Cargo.lock | 1 + core/transaction-pool/graph/src/pool.rs | 8 +- node-template/runtime/wasm/Cargo.lock | 1 + node/runtime/src/lib.rs | 4 +- node/runtime/wasm/Cargo.lock | 1 + srml/aura/src/lib.rs | 28 ++- srml/babe/src/lib.rs | 10 +- srml/balances/src/lib.rs | 27 +-- srml/contract/src/account_db.rs | 4 +- srml/contract/src/gas.rs | 9 +- srml/contract/src/lib.rs | 52 +++--- srml/contract/src/rent.rs | 9 +- srml/contract/src/tests.rs | 18 +- srml/contract/src/wasm/code_cache.rs | 9 +- srml/contract/src/wasm/env_def/macros.rs | 6 +- srml/contract/src/wasm/prepare.rs | 8 +- srml/contract/src/wasm/runtime.rs | 21 ++- srml/council/src/seats.rs | 14 +- srml/council/src/voting.rs | 8 +- srml/democracy/src/lib.rs | 18 +- srml/finality-tracker/src/lib.rs | 16 +- srml/grandpa/src/lib.rs | 4 +- srml/indices/src/address.rs | 54 +++--- srml/indices/src/lib.rs | 69 ++++--- srml/session/src/lib.rs | 6 +- srml/staking/src/lib.rs | 23 ++- srml/system/src/lib.rs | 9 +- srml/timestamp/src/lib.rs | 22 +-- 60 files changed, 694 insertions(+), 490 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0c683f24c..9944db924b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4119,6 +4119,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-std 2.0.0", "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", diff --git a/core/cli/src/informant.rs b/core/cli/src/informant.rs index 0d100c1963..dd0237b7f8 100644 --- a/core/cli/src/informant.rs +++ b/core/cli/src/informant.rs @@ -29,7 +29,7 @@ use substrate_telemetry::{telemetry, SUBSTRATE_INFO}; use log::{info, warn}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Header, As}; +use runtime_primitives::traits::{Header, SaturatedConversion}; /// Spawn informant on the event loop pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExecutor) where @@ -47,7 +47,7 @@ pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExe let display_notifications = network.status().for_each(move |sync_status| { if let Ok(info) = client.info() { - let best_number: u64 = info.chain.best_number.as_(); + let best_number = info.chain.best_number.saturated_into::(); let best_hash = info.chain.best_hash; let num_peers = sync_status.num_peers; let speed = move || speed(best_number, last_number, last_update); @@ -59,7 +59,7 @@ pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExe }; last_number = Some(best_number); let txpool_status = txpool.status(); - let finalized_number: u64 = info.chain.finalized_number.as_(); + let finalized_number: u64 = info.chain.finalized_number.saturated_into::(); let bandwidth_download = network.average_download_per_sec(); let bandwidth_upload = network.average_upload_per_sec(); info!( diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 3fd3454e0e..3aa567de66 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -26,7 +26,6 @@ pub mod error; pub mod informant; use client::ExecutionStrategies; -use runtime_primitives::traits::As; use service::{ ServiceFactory, FactoryFullConfiguration, RuntimeGenesis, FactoryGenesis, PruningMode, ChainSpec, @@ -627,7 +626,7 @@ where }; service::chain_ops::export_blocks::( - config, exit.into_exit(), file, As::sa(from), to.map(As::sa), json + config, exit.into_exit(), file, from.into(), to.map(Into::into), json ).map_err(Into::into) } @@ -663,7 +662,7 @@ where { let config = create_config_with_db_path::(spec_factory, &cli.shared_params, version)?; let blocks = cli.num; - Ok(service::chain_ops::revert_chain::(config, As::sa(blocks))?) + Ok(service::chain_ops::revert_chain::(config, blocks.into())?) } fn purge_chain( diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index 503d8fca32..ab473a304b 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -533,11 +533,11 @@ pub struct ExportBlocksCmd { /// Specify starting block number. 1 by default. #[structopt(long = "from", value_name = "BLOCK")] - pub from: Option, + pub from: Option, /// Specify last block number. Best block by default. #[structopt(long = "to", value_name = "BLOCK")] - pub to: Option, + pub to: Option, /// Use JSON output rather than binary. #[structopt(long = "json")] @@ -573,7 +573,7 @@ impl_get_log_filter!(ImportBlocksCmd); pub struct RevertCmd { /// Number of blocks to revert. #[structopt(default_value = "256")] - pub num: u64, + pub num: u32, #[allow(missing_docs)] #[structopt(flatten)] diff --git a/core/client/db/src/cache/list_cache.rs b/core/client/db/src/cache/list_cache.rs index 4d7b4e2e51..3c74ac2d1f 100644 --- a/core/client/db/src/cache/list_cache.rs +++ b/core/client/db/src/cache/list_cache.rs @@ -44,7 +44,9 @@ use std::collections::BTreeSet; use log::warn; use client::error::{Error as ClientError, Result as ClientResult}; -use runtime_primitives::traits::{Block as BlockT, NumberFor, As, Zero}; +use runtime_primitives::traits::{ + Block as BlockT, NumberFor, Zero, Bounded, SaturatedConversion, CheckedSub +}; use crate::cache::{CacheItemT, ComplexBlockId, EntryType}; use crate::cache::list_entry::{Entry, StorageEntry}; @@ -135,7 +137,7 @@ impl> ListCache // BUT since we're not guaranteeing to provide correct values for forks // behind the finalized block, check if the block is finalized first - if !chain::is_finalized_block(&self.storage, at, As::sa(::std::u64::MAX))? { + if !chain::is_finalized_block(&self.storage, at, Bounded::max_value())? { return Ok(None); } @@ -349,9 +351,9 @@ impl> ListCache ) { let mut do_pruning = || -> ClientResult<()> { // calculate last ancient block number - let ancient_block = match block.number.as_().checked_sub(self.prune_depth.as_()) { - Some(number) => match self.storage.read_id(As::sa(number))? { - Some(hash) => ComplexBlockId::new(hash, As::sa(number)), + let ancient_block = match block.number.checked_sub(&self.prune_depth) { + Some(number) => match self.storage.read_id(number)? { + Some(hash) => ComplexBlockId::new(hash, number), None => return Ok(()), }, None => return Ok(()), diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index e4e23a5ca1..d8ffaea723 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -25,7 +25,7 @@ use client::blockchain::Cache as BlockchainCache; use client::error::Result as ClientResult; use parity_codec::{Encode, Decode}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As, Zero}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; use consensus_common::well_known_cache_keys::Id as CacheKeyId; use crate::utils::{self, COLUMN_META, db_err}; @@ -36,7 +36,7 @@ mod list_entry; mod list_storage; /// Minimal post-finalization age age of finalized blocks before they'll pruned. -const PRUNE_DEPTH: u64 = 1024; +const PRUNE_DEPTH: u32 = 1024; /// The type of entry that is inserted to the cache. #[derive(Clone, Copy, Debug, PartialEq)] @@ -166,7 +166,7 @@ fn get_cache_helper<'a, Block: BlockT>( cache, }, ), - As::sa(PRUNE_DEPTH), + PRUNE_DEPTH.into(), best_finalized_block.clone(), ) }) diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index a7d7935278..0e65e17f8d 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -46,7 +46,10 @@ use parking_lot::{Mutex, RwLock}; use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash}; use primitives::storage::well_known_keys; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem}; +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, NumberFor, Zero, One, Digest, DigestItem, + SaturatedConversion, UniqueSaturatedFrom, UniqueSaturatedInto +}; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; use executor::RuntimeInfo; @@ -446,7 +449,7 @@ impl DbChangesTrieStorage { min_blocks_to_keep, &state_machine::ChangesTrieAnchorBlockId { hash: convert_hash(&block_hash), - number: block_num.as_(), + number: block_num.saturated_into::(), }, |node| tx.delete(columns::CHANGES_TRIE, node.as_ref())); } @@ -477,19 +480,19 @@ impl state_machine::ChangesTrieRootsStorage for DbC } // we need to get hash of the block to resolve changes trie root - let block_id = if block <= self.meta.read().finalized_number.as_() { + let block_id = if block <= self.meta.read().finalized_number.saturated_into::() { // if block is finalized, we could just read canonical hash - BlockId::Number(As::sa(block)) + BlockId::Number(block.saturated_into()) } else { // the block is not finalized let mut current_num = anchor.number; let mut current_hash: Block::Hash = convert_hash(&anchor.hash); let maybe_anchor_header: Block::Header = utils::require_header::( - &*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Number(As::sa(current_num)) + &*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Number(current_num.saturated_into()) ).map_err(|e| e.to_string())?; if maybe_anchor_header.hash() == current_hash { // if anchor is canonicalized, then the block is also canonicalized - BlockId::Number(As::sa(block)) + BlockId::Number(block.saturated_into()) } else { // else (block is not finalized + anchor is not canonicalized): // => we should find the required block hash by traversing @@ -770,7 +773,7 @@ impl> Backend { ) -> Result<(), client::error::Error> { - let number_u64 = number.as_(); + let number_u64 = number.saturated_into::(); if number_u64 > self.canonicalization_delay { let new_canonical = number_u64 - self.canonicalization_delay; @@ -781,7 +784,7 @@ impl> Backend { let hash = if new_canonical == number_u64 { hash } else { - ::client::blockchain::HeaderBackend::hash(&self.blockchain, As::sa(new_canonical))? + ::client::blockchain::HeaderBackend::hash(&self.blockchain, new_canonical.saturated_into())? .expect("existence of block with number `new_canonical` \ implies existence of blocks with all numbers before it; qed") }; @@ -865,7 +868,7 @@ impl> Backend { changeset.deleted.push(key); } } - let number_u64 = number.as_(); + let number_u64 = number.saturated_into::(); let commit = self.storage.state_db.insert_block(&hash, number_u64, &pending_block.header.parent_hash(), changeset) .map_err(|e: state_db::Error| client::error::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(&mut transaction, commit); @@ -978,7 +981,7 @@ impl> Backend { { let f_num = f_header.number().clone(); - if self.storage.state_db.best_canonical().map(|c| f_num.as_() > c).unwrap_or(true) { + if self.storage.state_db.best_canonical().map(|c| f_num.saturated_into::() > c).unwrap_or(true) { let parent_hash = f_header.parent_hash().clone(); let lookup_key = utils::number_and_hash_to_lookup_key(f_num, f_hash.clone()); @@ -1126,9 +1129,9 @@ impl client::backend::Backend for Backend whe let revertible = best - finalized; let n = if revertible < n { revertible } else { n }; - for c in 0 .. n.as_() { - if best == As::sa(0) { - return Ok(As::sa(c)) + for c in 0 .. n.saturated_into::() { + if best.is_zero() { + return Ok(c.saturated_into::>()) } let mut transaction = DBTransaction::new(); match self.storage.state_db.revert_one() { @@ -1138,7 +1141,7 @@ impl client::backend::Backend for Backend whe || client::error::Error::UnknownBlock( format!("Error reverting to {}. Block hash not found.", best)))?; - best -= As::sa(1); // prev block + best -= One::one(); // prev block let hash = self.blockchain.hash(best)?.ok_or_else( || client::error::Error::UnknownBlock( format!("Error reverting to {}. Block hash not found.", best)))?; @@ -1150,7 +1153,7 @@ impl client::backend::Backend for Backend whe self.blockchain.update_meta(hash, best, true, false); self.blockchain.leaves.write().revert(removed.hash().clone(), removed.number().clone(), removed.parent_hash().clone()); } - None => return Ok(As::sa(c)) + None => return Ok(c.saturated_into::>()) } } Ok(n) @@ -1182,7 +1185,7 @@ impl client::backend::Backend for Backend whe match self.blockchain.header(block) { Ok(Some(ref hdr)) => { let hash = hdr.hash(); - if !self.storage.state_db.is_pruned(&hash, hdr.number().as_()) { + if !self.storage.state_db.is_pruned(&hash, (*hdr.number()).saturated_into::()) { let root = H256::from_slice(hdr.state_root().as_ref()); let state = DbState::new(self.storage.clone(), root); Ok(CachingState::new(state, self.shared_cache.clone(), Some(hash))) @@ -1196,7 +1199,7 @@ impl client::backend::Backend for Backend whe } fn have_state_at(&self, hash: &Block::Hash, number: NumberFor) -> bool { - !self.storage.state_db.is_pruned(hash, number.as_()) + !self.storage.state_db.is_pruned(hash, number.saturated_into::()) } fn destroy_state(&self, mut state: Self::State) -> Result<(), client::error::Error> { diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index 39817140c6..02525455ba 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -17,6 +17,7 @@ //! RocksDB-based light client blockchain storage. use std::{sync::Arc, collections::HashMap}; +use std::convert::TryInto; use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; @@ -32,7 +33,8 @@ use parity_codec::{Decode, Encode}; use primitives::Blake2Hasher; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, - Zero, One, As, NumberFor, Digest, DigestItem}; + Zero, One, SaturatedConversion, NumberFor, Digest, DigestItem +}; use consensus_common::well_known_cache_keys; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType}; use crate::utils::{self, meta_keys, Meta, db_err, open_database, @@ -271,8 +273,8 @@ impl LightStorage { let new_cht_start: NumberFor = cht::start_number(cht::SIZE, new_cht_number); let new_header_cht_root = cht::compute_root::( - cht::SIZE, new_cht_number, (new_cht_start.as_()..) - .map(|num| self.hash(As::sa(num))) + cht::SIZE, new_cht_number, (new_cht_start.saturated_into::()..) + .map(|num| self.hash(num.saturated_into())) )?; transaction.put( columns::CHT, @@ -283,8 +285,8 @@ impl LightStorage { // if the header includes changes trie root, let's build a changes tries roots CHT if header.digest().log(DigestItem::as_changes_trie_root).is_some() { let new_changes_trie_cht_root = cht::compute_root::( - cht::SIZE, new_cht_number, (new_cht_start.as_()..) - .map(|num| self.changes_trie_root(BlockId::Number(As::sa(num)))) + cht::SIZE, new_cht_number, (new_cht_start.saturated_into::()..) + .map(|num| self.changes_trie_root(BlockId::Number(num.saturated_into()))) )?; transaction.put( columns::CHT, @@ -530,7 +532,7 @@ impl LightBlockchainStorage for LightStorage } /// Build the key for inserting header-CHT at given block. -fn cht_key>(cht_type: u8, block: N) -> [u8; 5] { +fn cht_key>(cht_type: u8, block: N) -> [u8; 5] { let mut key = [cht_type; 5]; key[1..].copy_from_slice(&utils::number_index_key(block)); key diff --git a/core/client/db/src/utils.rs b/core/client/db/src/utils.rs index b51faae6de..eec476f40e 100644 --- a/core/client/db/src/utils.rs +++ b/core/client/db/src/utils.rs @@ -19,6 +19,7 @@ use std::sync::Arc; use std::io; +use std::convert::TryInto; use kvdb::{KeyValueDB, DBTransaction}; use kvdb_rocksdb::{Database, DatabaseConfig}; @@ -28,7 +29,10 @@ use client; use parity_codec::Decode; use trie::DBValue; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, Zero}; +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, Zero, UniqueSaturatedFrom, + UniqueSaturatedInto, SaturatedConversion, CheckedConversion +}; use crate::DatabaseSettings; /// Number of columns in the db. Must be the same for both full && light dbs. @@ -78,10 +82,8 @@ pub type NumberIndexKey = [u8; 4]; /// /// In the current database schema, this kind of key is only used for /// lookups into an index, NOT for storing header data or others. -pub fn number_index_key(n: N) -> NumberIndexKey where N: As { - let n: u64 = n.as_(); - assert!(n & 0xffffffff00000000 == 0); - +pub fn number_index_key>(n: N) -> NumberIndexKey { + let n = n.checked_into::().unwrap(); [ (n >> 24) as u8, ((n >> 16) & 0xff) as u8, @@ -93,7 +95,7 @@ pub fn number_index_key(n: N) -> NumberIndexKey where N: As { /// Convert number and hash into long lookup key for blocks that are /// not in the canonical chain. pub fn number_and_hash_to_lookup_key(number: N, hash: H) -> Vec where - N: As, + N: TryInto, H: AsRef<[u8]> { let mut lookup_key = number_index_key(number).to_vec(); @@ -103,18 +105,20 @@ pub fn number_and_hash_to_lookup_key(number: N, hash: H) -> Vec where /// Convert block lookup key into block number. /// all block lookup keys start with the block number. -pub fn lookup_key_to_number(key: &[u8]) -> client::error::Result where N: As { +pub fn lookup_key_to_number(key: &[u8]) -> client::error::Result where + N: From +{ if key.len() < 4 { return Err(client::error::Error::Backend("Invalid block key".into())); } - Ok((key[0] as u64) << 24 - | (key[1] as u64) << 16 - | (key[2] as u64) << 8 - | (key[3] as u64)).map(As::sa) + Ok((key[0] as u32) << 24 + | (key[1] as u32) << 16 + | (key[2] as u32) << 8 + | (key[3] as u32)).map(Into::into) } /// Delete number to hash mapping in DB transaction. -pub fn remove_number_to_key_mapping>( +pub fn remove_number_to_key_mapping>( transaction: &mut DBTransaction, key_lookup_col: Option, number: N, @@ -123,7 +127,7 @@ pub fn remove_number_to_key_mapping>( } /// Remove key mappings. -pub fn remove_key_mappings, H: AsRef<[u8]>>( +pub fn remove_key_mappings, H: AsRef<[u8]>>( transaction: &mut DBTransaction, key_lookup_col: Option, number: N, @@ -135,7 +139,7 @@ pub fn remove_key_mappings, H: AsRef<[u8]>>( /// Place a number mapping into the database. This maps number to current perceived /// block hash at that position. -pub fn insert_number_to_key_mapping + Clone, H: AsRef<[u8]>>( +pub fn insert_number_to_key_mapping + Clone, H: AsRef<[u8]>>( transaction: &mut DBTransaction, key_lookup_col: Option, number: N, @@ -149,7 +153,7 @@ pub fn insert_number_to_key_mapping + Clone, H: AsRef<[u8]>>( } /// Insert a hash to key mapping in the database. -pub fn insert_hash_to_key_mapping, H: AsRef<[u8]> + Clone>( +pub fn insert_hash_to_key_mapping, H: AsRef<[u8]> + Clone>( transaction: &mut DBTransaction, key_lookup_col: Option, number: N, @@ -171,7 +175,7 @@ pub fn block_id_to_lookup_key( id: BlockId ) -> Result>, client::error::Error> where Block: BlockT, - ::runtime_primitives::traits::NumberFor: As, + ::runtime_primitives::traits::NumberFor: UniqueSaturatedFrom + UniqueSaturatedInto, { let res = match id { BlockId::Number(n) => db.get( diff --git a/core/client/src/cht.rs b/core/client/src/cht.rs index 8002f52b6f..42b4654d34 100644 --- a/core/client/src/cht.rs +++ b/core/client/src/cht.rs @@ -29,7 +29,12 @@ use hash_db; use trie; use primitives::{H256, convert_hash}; -use runtime_primitives::traits::{As, Header as HeaderT, SimpleArithmetic, One}; +// We're using saturatedconversion in order to go back and forth to `u64`. this is stupid. +// instead we should just make the CHT generic over the block number. +use runtime_primitives::traits::{ + Header as HeaderT, SimpleArithmetic, One, SaturatedConversion, + UniqueSaturatedInto +}; use state_machine::backend::InMemory as InMemoryState; use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend}; @@ -183,7 +188,7 @@ pub fn for_each_cht_group( let mut current_cht_num = None; let mut current_cht_blocks = Vec::new(); for block in blocks { - let new_cht_num = match block_to_cht_number(cht_size, block.as_()) { + let new_cht_num = match block_to_cht_number(cht_size, block.saturated_into()) { Some(new_cht_num) => new_cht_num, None => return Err(ClientError::Backend(format!( "Cannot compute CHT root for the block #{}", block)).into() @@ -198,7 +203,7 @@ pub fn for_each_cht_group( functor_param = functor( functor_param, - As::sa(current_cht_num), + current_cht_num.saturated_into(), ::std::mem::replace(&mut current_cht_blocks, Vec::new()), )?; } @@ -210,7 +215,7 @@ pub fn for_each_cht_group( if let Some(current_cht_num) = current_cht_num { functor( functor_param, - As::sa(current_cht_num), + current_cht_num.saturated_into(), ::std::mem::replace(&mut current_cht_blocks, Vec::new()), )?; } @@ -233,7 +238,10 @@ fn build_pairs( let mut hash_number = start_num; for hash in hashes.into_iter().take(cht_size as usize) { let hash = hash?.ok_or_else(|| ClientError::from( - ClientError::MissingHashRequiredForCHT(cht_num.as_(), hash_number.as_()) + ClientError::MissingHashRequiredForCHT( + cht_num.saturated_into::(), + hash_number.saturated_into::() + ) ))?; pairs.push(( encode_cht_key(hash_number).to_vec(), @@ -245,7 +253,10 @@ fn build_pairs( if pairs.len() as u64 == cht_size { Ok(pairs) } else { - Err(ClientError::MissingHashRequiredForCHT(cht_num.as_(), hash_number.as_())) + Err(ClientError::MissingHashRequiredForCHT( + cht_num.saturated_into::(), + hash_number.saturated_into::() + )) } } @@ -256,12 +267,12 @@ fn build_pairs( /// This is because the genesis hash is assumed to be known /// and including it would be redundant. pub fn start_number(cht_size: u64, cht_num: N) -> N { - (cht_num * As::sa(cht_size)) + N::one() + (cht_num * cht_size.saturated_into()) + N::one() } /// Get the ending block of a given CHT. pub fn end_number(cht_size: u64, cht_num: N) -> N { - (cht_num + N::one()) * As::sa(cht_size) + (cht_num + N::one()) * cht_size.saturated_into() } /// Convert a block number to a CHT number. @@ -270,13 +281,14 @@ pub fn block_to_cht_number(cht_size: u64, block_num: N) -> if block_num == N::zero() { None } else { - Some((block_num - N::one()) / As::sa(cht_size)) + Some((block_num - N::one()) / cht_size.saturated_into()) } } /// Convert header number into CHT key. -pub fn encode_cht_key>(number: N) -> Vec { - let number: u64 = number.as_(); +pub fn encode_cht_key>(number: N) -> Vec { + // why not just use Encode? + let number: u64 = number.saturated_into(); vec![ (number >> 56) as u8, ((number >> 48) & 0xff) as u8, diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 257f120d72..5b849e1352 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -35,8 +35,9 @@ use consensus::{ SelectChain, self, }; use runtime_primitives::traits::{ - Block as BlockT, Header as HeaderT, Zero, As, NumberFor, CurrentHeight, - BlockNumberToHash, ApiRef, ProvideRuntimeApi, Digest, DigestItem + Block as BlockT, Header as HeaderT, Zero, NumberFor, CurrentHeight, + BlockNumberToHash, ApiRef, ProvideRuntimeApi, Digest, DigestItem, + SaturatedConversion, One }; use runtime_primitives::BuildStorage; use crate::runtime_api::{ @@ -82,7 +83,11 @@ pub type ImportNotifications = mpsc::UnboundedReceiver = mpsc::UnboundedReceiver>; -type StorageUpdate = <<>::BlockImportOperation as BlockImportOperation>::State as state_machine::Backend>::Transaction; +type StorageUpdate = < + < + >::BlockImportOperation + as BlockImportOperation + >::State as state_machine::Backend>::Transaction; type ChangesUpdate = trie::MemoryDB; /// Execution strategies settings. @@ -146,13 +151,17 @@ pub trait BlockchainEvents { /// Get storage changes event stream. /// /// Passing `None` as `filter_keys` subscribes to all storage changes. - fn storage_changes_notification_stream(&self, filter_keys: Option<&[StorageKey]>) -> error::Result>; + fn storage_changes_notification_stream(&self, + filter_keys: Option<&[StorageKey]> + ) -> error::Result>; } /// Fetch block body by ID. pub trait BlockBody { /// Get block body by ID. Returns `None` if the body is not stored. - fn block_body(&self, id: &BlockId) -> error::Result::Extrinsic>>>; + fn block_body(&self, + id: &BlockId + ) -> error::Result::Extrinsic>>>; } /// Client info @@ -242,11 +251,15 @@ impl PrePostHeader { pub fn new_in_mem( executor: E, genesis_storage: S, -) -> error::Result, LocalCallExecutor, E>, Block, RA>> - where - E: CodeExecutor + RuntimeInfo, - S: BuildStorage, - Block: BlockT, +) -> error::Result, + LocalCallExecutor, E>, + Block, + RA +>> where + E: CodeExecutor + RuntimeInfo, + S: BuildStorage, + Block: BlockT, { new_with_backend(Arc::new(in_mem::Backend::new()), executor, genesis_storage) } @@ -286,7 +299,10 @@ impl Client where backend.begin_state_operation(&mut op, BlockId::Hash(Default::default()))?; let state_root = op.reset_storage(genesis_storage, children_genesis_storage)?; let genesis_block = genesis::construct_genesis_block::(state_root.into()); - info!("Initializing Genesis block/state (state: {}, header-hash: {})", genesis_block.header().state_root(), genesis_block.header().hash()); + info!("Initializing Genesis block/state (state: {}, header-hash: {})", + genesis_block.header().state_root(), + genesis_block.header().hash() + ); op.set_block_data( genesis_block.deconstruct().0, Some(vec![]), @@ -380,7 +396,8 @@ impl Client where /// Get the code at a given block. pub fn code_at(&self, id: &BlockId) -> error::Result> { Ok(self.storage(id, &StorageKey(well_known_keys::CODE.to_vec()))? - .expect("None is returned if there's no value stored for the given key; ':code' key is always defined; qed").0) + .expect("None is returned if there's no value stored for the given key;\ + ':code' key is always defined; qed").0) } /// Get the RuntimeVersion at a given block. @@ -419,7 +436,11 @@ impl Client where /// AND returning execution proof. /// /// No changes are made. - pub fn execution_proof(&self, id: &BlockId, method: &str, call_data: &[u8]) -> error::Result<(Vec, Vec>)> { + pub fn execution_proof(&self, + id: &BlockId, + method: &str, + call_data: &[u8] + ) -> error::Result<(Vec, Vec>)> { let state = self.state_at(id)?; let header = self.prepare_environment_block(id)?; prove_execution(state, header, &self.executor, method, call_data) @@ -431,18 +452,23 @@ impl Client where } /// Get block hash by number. - pub fn block_hash(&self, block_number: <::Header as HeaderT>::Number) -> error::Result> { + pub fn block_hash(&self, + block_number: <::Header as HeaderT>::Number + ) -> error::Result> { self.backend.blockchain().hash(block_number) } /// Reads given header and generates CHT-based header proof for CHT of given size. - pub fn header_proof_with_cht_size(&self, id: &BlockId, cht_size: u64) -> error::Result<(Block::Header, Vec>)> { + pub fn header_proof_with_cht_size(&self, + id: &BlockId, + cht_size: u64 + ) -> error::Result<(Block::Header, Vec>)> { let proof_error = || error::Error::Backend(format!("Failed to generate header proof for {:?}", id)); let header = self.backend.blockchain().expect_header(*id)?; let block_num = *header.number(); let cht_num = cht::block_to_cht_number(cht_size, block_num).ok_or_else(proof_error)?; let cht_start = cht::start_number(cht_size, cht_num); - let headers = (cht_start.as_()..).map(|num| self.block_hash(As::sa(num))); + let headers = (cht_start.saturated_into()..).map(|num| self.block_hash(num.saturated_into())); let proof = cht::build_proof::(cht_size, cht_num, ::std::iter::once(block_num), headers)?; Ok((header, proof)) } @@ -460,14 +486,14 @@ impl Client where Some((config, storage)) => (config, storage), None => return Ok(None), }; - let first = first.as_(); - let last_num = self.backend.blockchain().expect_block_number_from_id(&last)?.as_(); + let first = first.saturated_into::(); + let last_num = self.backend.blockchain().expect_block_number_from_id(&last)?.saturated_into::(); if first > last_num { return Err(error::Error::ChangesTrieAccessFailed("Invalid changes trie range".into())); } let finalized_number = self.backend.blockchain().info()?.finalized_number; - let oldest = storage.oldest_changes_trie_block(&config, finalized_number.as_()); - let first = As::sa(::std::cmp::max(first, oldest)); + let oldest = storage.oldest_changes_trie_block(&config, finalized_number.saturated_into::()); + let first = ::std::cmp::max(first, oldest).saturated_into::>(); Ok(Some((first, last))) } @@ -480,20 +506,20 @@ impl Client where key: &StorageKey ) -> error::Result, u32)>> { let (config, storage) = self.require_changes_trie()?; - let last_number = self.backend.blockchain().expect_block_number_from_id(&last)?.as_(); + let last_number = self.backend.blockchain().expect_block_number_from_id(&last)?.saturated_into::(); let last_hash = self.backend.blockchain().expect_block_hash_from_id(&last)?; key_changes::<_, Blake2Hasher>( &config, &*storage, - first.as_(), + first.saturated_into::(), &ChangesTrieAnchorBlockId { hash: convert_hash(&last_hash), number: last_number, }, - self.backend.blockchain().info()?.best_number.as_(), + self.backend.blockchain().info()?.best_number.saturated_into::(), &key.0) - .and_then(|r| r.map(|r| r.map(|(block, tx)| (As::sa(block), tx))).collect::>()) + .and_then(|r| r.map(|r| r.map(|(block, tx)| (block.saturated_into(), tx))).collect::>()) .map_err(|err| error::Error::ChangesTrieAccessFailed(err)) } @@ -543,7 +569,7 @@ impl Client where if block < self.min { if let Some(ref root) = root { self.required_roots_proofs.lock().insert( - As::sa(block), + block.saturated_into(), root.clone() ); } @@ -563,7 +589,7 @@ impl Client where let recording_storage = AccessedRootsRecorder:: { storage, - min: min_number.as_(), + min: min_number.saturated_into::(), required_roots_proofs: Mutex::new(BTreeMap::new()), }; @@ -573,8 +599,12 @@ impl Client where ); // fetch key changes proof - let first_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(first))?.as_(); - let last_number = self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(last))?.as_(); + let first_number = self.backend.blockchain() + .expect_block_number_from_id(&BlockId::Hash(first))? + .saturated_into::(); + let last_number = self.backend.blockchain() + .expect_block_number_from_id(&BlockId::Hash(last))? + .saturated_into::(); let key_changes_proof = key_changes_proof::<_, Blake2Hasher>( &config, &recording_storage, @@ -583,7 +613,7 @@ impl Client where hash: convert_hash(&last), number: last_number, }, - max_number.as_(), + max_number.saturated_into::(), &key.0 ) .map_err(|err| error::Error::from(error::Error::ChangesTrieAccessFailed(err)))?; @@ -628,7 +658,7 @@ impl Client where blocks: Vec> ) -> error::Result>> { let cht_start = cht::start_number(cht_size, cht_num); - let roots = (cht_start.as_()..).map(|num| self.header(&BlockId::Number(As::sa(num))) + let roots = (cht_start.saturated_into()..).map(|num| self.header(&BlockId::Number(num.saturated_into())) .map(|block| block.and_then(|block| block.digest().log(DigestItem::as_changes_trie_root).cloned()))); let proof = cht::build_proof::(cht_size, cht_num, blocks, roots)?; Ok(proof) @@ -777,7 +807,7 @@ impl Client where }; let hash = import_headers.post().hash(); - let height: u64 = import_headers.post().number().as_(); + let height = (*import_headers.post().number()).saturated_into::(); *self.importing_block.write() = Some(hash); @@ -1201,7 +1231,7 @@ impl Client where let mut ancestor = load_header(ancestor_hash)?; let mut uncles = Vec::new(); - for _generation in 0..max_generation.as_() { + for _generation in 0..max_generation.saturated_into() { let children = self.backend.blockchain().children(ancestor_hash)?; uncles.extend(children.into_iter().filter(|h| h != ¤t_hash)); current_hash = ancestor_hash; @@ -1224,7 +1254,7 @@ impl Client where /// Prepare in-memory header that is used in execution environment. fn prepare_environment_block(&self, parent: &BlockId) -> error::Result { Ok(<::Header as HeaderT>::new( - self.backend.blockchain().expect_block_number_from_id(parent)? + As::sa(1), + self.backend.blockchain().expect_block_number_from_id(parent)? + One::one(), Default::default(), Default::default(), self.backend.blockchain().expect_block_hash_from_id(&parent)?, diff --git a/core/client/src/in_mem.rs b/core/client/src/in_mem.rs index 0050cb9110..558643e887 100644 --- a/core/client/src/in_mem.rs +++ b/core/client/src/in_mem.rs @@ -21,8 +21,10 @@ use std::sync::Arc; use parking_lot::RwLock; use primitives::{ChangesTrieConfiguration, storage::well_known_keys}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, - NumberFor, As, Digest, DigestItem}; +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, Zero, + NumberFor, SaturatedConversion, Digest, DigestItem +}; use runtime_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay}; use state_machine::backend::{Backend as StateBackend, InMemory}; use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId}; @@ -619,7 +621,11 @@ where if let Some(changes_trie_root) = changes_trie_root { if let Some(changes_trie_update) = operation.changes_trie_update { let changes_trie_root: H::Out = changes_trie_root.into(); - self.changes_trie_storage.0.insert(header.number().as_(), changes_trie_root, changes_trie_update); + self.changes_trie_storage.0.insert( + (*header.number()).saturated_into::(), + changes_trie_root, + changes_trie_update + ); } } @@ -668,7 +674,7 @@ where } fn revert(&self, _n: NumberFor) -> error::Result> { - Ok(As::sa(0)) + Ok(Zero::zero()) } } diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index 8f90aaf54e..a45a166674 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -26,7 +26,7 @@ use futures::{IntoFuture, Future}; use parity_codec::{Encode, Decode}; use primitives::{H256, Blake2Hasher, convert_hash, NativeOrEncoded, OffchainExt}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT}; +use runtime_primitives::traits::{One, Block as BlockT, Header as HeaderT}; use state_machine::{ self, Backend as StateBackend, CodeExecutor, OverlayedChanges, ExecutionStrategy, create_proof_check_backend, @@ -444,7 +444,7 @@ pub fn check_execution_proof( let mut changes = OverlayedChanges::default(); let trie_backend = create_proof_check_backend(root, remote_proof)?; let next_block =
::new( - *request.header.number() + As::sa(1), + *request.header.number() + One::one(), Default::default(), Default::default(), request.header.hash(), diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index ff6d3c5c45..29fd6f4c39 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -24,7 +24,10 @@ use futures::IntoFuture; use hash_db::{HashDB, Hasher}; use parity_codec::Encode; use primitives::{ChangesTrieConfiguration, convert_hash}; -use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor}; +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor, + UniqueSaturatedInto, UniqueSaturatedFrom, SaturatedConversion +}; use state_machine::{CodeExecutor, ChangesTrieRootsStorage, ChangesTrieAnchorBlockId, TrieBackend, read_proof_check, key_changes_proof_check, create_proof_check_backend_storage, read_child_proof_check}; @@ -288,14 +291,16 @@ impl, F> LightDataChecker(), &ChangesTrieAnchorBlockId { hash: convert_hash(&request.last_block.1), - number: request.last_block.0.as_(), + number: request.last_block.0.saturated_into::(), }, - remote_max_block.as_(), + remote_max_block.saturated_into::(), &request.key) - .map(|pairs| pairs.into_iter().map(|(b, x)| (As::sa(b), x)).collect()) + .map(|pairs| pairs.into_iter().map(|(b, x)| + (b.saturated_into::>(), x) + ).collect()) .map_err(|err| ClientError::ChangesTrieAccessFailed(err)) } @@ -438,7 +443,7 @@ impl FetchChecker for LightDataChecker as a changes trie roots storage. -struct RootsStorage<'a, Number: As, Hash: 'a> { +struct RootsStorage<'a, Number: UniqueSaturatedInto + UniqueSaturatedFrom, Hash: 'a> { roots: (Number, &'a [Hash]), prev_roots: BTreeMap, } @@ -446,15 +451,16 @@ struct RootsStorage<'a, Number: As, Hash: 'a> { impl<'a, H, Number, Hash> ChangesTrieRootsStorage for RootsStorage<'a, Number, Hash> where H: Hasher, - Number: Send + Sync + Eq + ::std::cmp::Ord + Copy + As, + Number: Send + Sync + Eq + ::std::cmp::Ord + Copy + UniqueSaturatedInto + + UniqueSaturatedFrom, Hash: 'a + Send + Sync + Clone + AsRef<[u8]>, { fn root(&self, _anchor: &ChangesTrieAnchorBlockId, block: u64) -> Result, String> { // we can't ask for roots from parallel forks here => ignore anchor - let root = if block < self.roots.0.as_() { - self.prev_roots.get(&As::sa(block)).cloned() + let root = if block < self.roots.0.saturated_into::() { + self.prev_roots.get(&Number::unique_saturated_from(block)).cloned() } else { - block.checked_sub(self.roots.0.as_()) + block.checked_sub(self.roots.0.saturated_into::()) .and_then(|index| self.roots.1.get(index as usize)) .cloned() }; diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index 58ea5a1b0a..4031830108 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -13,6 +13,7 @@ primitives = { package = "substrate-primitives", path= "../../primitives" } inherents = { package = "substrate-inherents", path = "../../inherents" } error-chain = "0.12" futures = "0.1" +rstd = { package = "sr-std", path = "../../sr-std" } runtime_version = { package = "sr-version", path = "../../sr-version" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } tokio-timer = "0.2" diff --git a/core/consensus/common/src/evaluation.rs b/core/consensus/common/src/evaluation.rs index 48016b1e94..7f1f527042 100644 --- a/core/consensus/common/src/evaluation.rs +++ b/core/consensus/common/src/evaluation.rs @@ -19,11 +19,13 @@ use super::MAX_BLOCK_SIZE; use parity_codec::Encode; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion}; use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, impl_extract_backtrace, impl_error_chain_kind, bail}; -type BlockNumber = u64; +// This is just a best effort to encode the number. None indicated that it's too big to encode +// in a u128. +type BlockNumber = Option; error_chain! { errors { @@ -37,7 +39,7 @@ error_chain! { } WrongNumber(expected: BlockNumber, got: BlockNumber) { description("Proposal had wrong number."), - display("Proposal had wrong number. Expected {}, got {}", expected, got), + display("Proposal had wrong number. Expected {:?}, got {:?}", expected, got), } ProposalTooLarge(size: usize) { description("Proposal exceeded the maximum size."), @@ -72,8 +74,11 @@ pub fn evaluate_initial( )); } - if parent_number.as_() + 1 != proposal.header().number().as_() { - bail!(ErrorKind::WrongNumber(parent_number.as_() + 1, proposal.header().number().as_())); + if parent_number + One::one() != *proposal.header().number() { + bail!(ErrorKind::WrongNumber( + parent_number.checked_into::().map(|x| x + 1), + (*proposal.header().number()).checked_into::() + )); } Ok(()) diff --git a/core/consensus/rhd/src/lib.rs b/core/consensus/rhd/src/lib.rs index 0afe10ffce..ca4b9120eb 100644 --- a/core/consensus/rhd/src/lib.rs +++ b/core/consensus/rhd/src/lib.rs @@ -45,7 +45,10 @@ use client::{Client as SubstrateClient, CallExecutor}; use client::runtime_api::{Core, BlockBuilder as BlockBuilderAPI, OldTxQueue, BlockBuilderError}; use runtime_primitives::generic::{BlockId, Era, ImportResult, ImportBlock, BlockOrigin}; use runtime_primitives::traits::{Block, Header}; -use runtime_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, As, BlockNumberToHash}; +use runtime_primitives::traits::{ + Block as BlockT, Hash as HashT, Header as HeaderT, + BlockNumberToHash, SaturatedConversion +}; use runtime_primitives::Justification; use primitives::{AuthorityId, ed25519, Blake2Hasher, ed25519::LocalizedSignature}; use srml_system::Trait as SystemT; @@ -1246,7 +1249,7 @@ impl LocalProposer<::Block> for Proposer where for (target, misbehavior) in misbehavior { let report = MisbehaviorReport { parent_hash: self.parent_hash.into(), - parent_number: self.parent_number.as_(), + parent_number: self.parent_number.saturated_into::(), target, misbehavior: match misbehavior { GenericMisbehavior::ProposeOutOfTurn(_, _, _) => continue, diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index cec64b254c..564b7630c4 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -34,7 +34,7 @@ use grandpa::{ }; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ - As, Block as BlockT, Header as HeaderT, NumberFor, One, Zero, BlockNumberToHash, + Block as BlockT, Header as HeaderT, NumberFor, One, Zero, BlockNumberToHash, }; use substrate_primitives::{Blake2Hasher, ed25519, H256, Pair}; use substrate_telemetry::{telemetry, CONSENSUS_INFO}; @@ -669,7 +669,7 @@ where &*self.inner, &self.authority_set, &self.consensus_changes, - Some(As::sa(self.config.justification_period)), + Some(self.config.justification_period.into()), hash, number, (round, commit).into(), diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 9d808bf4d5..53dd9d2a57 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -157,7 +157,7 @@ pub struct Config { /// Justification generation period (in blocks). GRANDPA will try to generate justifications /// at least every justification_period blocks. There are some other events which might cause /// justification generation. - pub justification_period: u64, + pub justification_period: u32, /// The local signing key. pub local_key: Option>, /// Some local identifier of the voter. diff --git a/core/network/src/blocks.rs b/core/network/src/blocks.rs index 60c6886f09..d693afba17 100644 --- a/core/network/src/blocks.rs +++ b/core/network/src/blocks.rs @@ -21,7 +21,7 @@ use std::collections::{HashMap, BTreeMap}; use std::collections::hash_map::Entry; use log::trace; use network_libp2p::PeerId; -use runtime_primitives::traits::{Block as BlockT, NumberFor, As}; +use runtime_primitives::traits::{Block as BlockT, NumberFor, One}; use crate::message; const MAX_PARALLEL_DOWNLOADS: u32 = 1; @@ -48,7 +48,7 @@ impl BlockRangeState { pub fn len(&self) -> NumberFor { match *self { BlockRangeState::Downloading { len, .. } => len, - BlockRangeState::Complete(ref blocks) => As::sa(blocks.len() as u64), + BlockRangeState::Complete(ref blocks) => (blocks.len() as u32).into(), } } } @@ -102,8 +102,8 @@ impl BlockCollection { /// Returns a set of block hashes that require a header download. The returned set is marked as being downloaded. pub fn needed_blocks(&mut self, who: PeerId, count: usize, peer_best: NumberFor, common: NumberFor) -> Option>> { // First block number that we need to download - let first_different = common + As::sa(1); - let count = As::sa(count as u64); + let first_different = common + >::one(); + let count = (count as u32).into(); let (mut range, downloading) = { let mut downloading_iter = self.blocks.iter().peekable(); let mut prev: Option<(&NumberFor, &BlockRangeState)> = None; @@ -132,7 +132,7 @@ impl BlockCollection { trace!(target: "sync", "Out of range for peer {} ({} vs {})", who, range.start, peer_best); return None; } - range.end = cmp::min(peer_best + As::sa(1), range.end); + range.end = cmp::min(peer_best + One::one(), range.end); self.peer_requests.insert(who, range.start); self.blocks.insert(range.start, BlockRangeState::Downloading { len: range.end - range.start, downloading: downloading + 1 }); if range.end <= range.start { @@ -150,7 +150,7 @@ impl BlockCollection { for (start, range_data) in &mut self.blocks { match range_data { &mut BlockRangeState::Complete(ref mut blocks) if *start <= prev => { - prev = *start + As::sa(blocks.len() as u64); + prev = *start + (blocks.len() as u32).into(); let mut blocks = mem::replace(blocks, Vec::new()); drained.append(&mut blocks); ranges.push(*start); diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 62c5f508db..cd7a14bdbb 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -19,7 +19,10 @@ use network_libp2p::PeerId; use primitives::storage::StorageKey; use consensus::{import_queue::IncomingBlock, import_queue::Origin, BlockOrigin}; use runtime_primitives::{generic::BlockId, ConsensusEngineId, Justification}; -use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, NumberFor, Zero}; +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, NumberFor, One, Zero, + CheckedSub, SaturatedConversion +}; use consensus::import_queue::SharedFinalityProofRequestBuilder; use crate::message::{ self, BlockRequest as BlockRequestMessage, @@ -572,9 +575,9 @@ impl, H: ExHashT> Protocol { }; blocks.push(block_data); match request.direction { - message::Direction::Ascending => id = BlockId::Number(number + As::sa(1)), + message::Direction::Ascending => id = BlockId::Number(number + One::one()), message::Direction::Descending => { - if number == As::sa(0) { + if number.is_zero() { break; } id = BlockId::Hash(parent_hash) @@ -716,9 +719,9 @@ impl, H: ExHashT> Protocol { .and_then(|info| info.best_queued_number) .unwrap_or_else(|| Zero::zero()); let blocks_difference = self_best_block - .as_() - .checked_sub(status.best_number.as_()) - .unwrap_or(0); + .checked_sub(&status.best_number) + .unwrap_or_else(Zero::zero) + .saturated_into::(); if blocks_difference > LIGHT_MAXIMAL_BLOCKS_DIFFERENCE { debug!(target: "sync", "Peer {} is far behind us and will unable to serve light requests", who); network_out.report_peer(who.clone(), PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE); diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index 7358672231..fdd36a024d 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -40,7 +40,10 @@ use consensus::{BlockOrigin, import_queue::{IncomingBlock, SharedFinalityProofRe use client::error::Error as ClientError; use crate::blocks::BlockCollection; use crate::sync::extra_requests::ExtraRequestsAggregator; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, CheckedSub}; +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, NumberFor, Zero, One, + CheckedSub, SaturatedConversion +}; use runtime_primitives::{Justification, generic::BlockId}; use crate::message; use crate::config::Roles; @@ -204,7 +207,7 @@ impl ChainSync { fn state(&self, best_seen: &Option>) -> SyncState { match best_seen { - &Some(n) if n > self.best_queued_number && n - self.best_queued_number > As::sa(5) => SyncState::Downloading, + &Some(n) if n > self.best_queued_number && n - self.best_queued_number > 5.into() => SyncState::Downloading, _ => SyncState::Idle, } } @@ -251,7 +254,7 @@ impl ChainSync { protocol.report_peer(who.clone(), i32::min_value()); protocol.disconnect_peer(who); }, - (Ok(BlockStatus::Unknown), b) if b == As::sa(0) => { + (Ok(BlockStatus::Unknown), b) if b.is_zero() => { info!("New peer with unknown genesis hash {} ({}).", info.best_hash, info.best_number); protocol.report_peer(who.clone(), i32::min_value()); protocol.disconnect_peer(who); @@ -269,28 +272,32 @@ impl ChainSync { } (Ok(BlockStatus::Unknown), _) => { let our_best = self.best_queued_number; - if our_best > As::sa(0) { - let common_best = ::std::cmp::min(our_best, info.best_number); - debug!(target:"sync", "New peer with unknown best hash {} ({}), searching for common ancestor.", info.best_hash, info.best_number); + if our_best.is_zero() { + // We are at genesis, just start downloading + debug!(target:"sync", "New peer with best hash {} ({}).", info.best_hash, info.best_number); self.peers.insert(who.clone(), PeerSync { - common_number: As::sa(0), + common_number: Zero::zero(), best_hash: info.best_hash, best_number: info.best_number, - state: PeerSyncState::AncestorSearch(common_best, AncestorSearchState::ExponentialBackoff(As::sa(1))), + state: PeerSyncState::Available, recently_announced: Default::default(), }); - Self::request_ancestry(protocol, who, common_best) + self.download_new(protocol, who) } else { - // We are at genesis, just start downloading - debug!(target:"sync", "New peer with best hash {} ({}).", info.best_hash, info.best_number); + let common_best = ::std::cmp::min(our_best, info.best_number); + debug!(target:"sync", + "New peer with unknown best hash {} ({}), searching for common ancestor.", + info.best_hash, + info.best_number + ); self.peers.insert(who.clone(), PeerSync { - common_number: As::sa(0), + common_number: Zero::zero(), best_hash: info.best_hash, best_number: info.best_number, - state: PeerSyncState::Available, + state: PeerSyncState::AncestorSearch(common_best, AncestorSearchState::ExponentialBackoff(One::one())), recently_announced: Default::default(), }); - self.download_new(protocol, who) + Self::request_ancestry(protocol, who, common_best) } }, (Ok(BlockStatus::Queued), _) | (Ok(BlockStatus::InChainWithState), _) | (Ok(BlockStatus::InChainPruned), _) => { @@ -312,20 +319,22 @@ impl ChainSync { curr_block_num: NumberFor, block_hash_match: bool, ) -> Option<(AncestorSearchState, NumberFor)> { + let two = >::one() + >::one(); match state { AncestorSearchState::ExponentialBackoff(next_distance_to_tip) => { - if block_hash_match && next_distance_to_tip == As::sa(1) { + if block_hash_match && next_distance_to_tip == One::one() { // We found the ancestor in the first step so there is no need to execute binary search. return None; } if block_hash_match { let left = curr_block_num; - let right = left + next_distance_to_tip / As::sa(2); - let middle = left + (right - left) / As::sa(2); + let right = left + next_distance_to_tip / two; + let middle = left + (right - left) / two; Some((AncestorSearchState::BinarySearch(left, right), middle)) } else { - let next_block_num = curr_block_num.checked_sub(&next_distance_to_tip).unwrap_or(As::sa(0)); - let next_distance_to_tip = next_distance_to_tip * As::sa(2); + let next_block_num = curr_block_num.checked_sub(&next_distance_to_tip) + .unwrap_or_else(Zero::zero); + let next_distance_to_tip = next_distance_to_tip * two; Some((AncestorSearchState::ExponentialBackoff(next_distance_to_tip), next_block_num)) } }, @@ -339,7 +348,7 @@ impl ChainSync { right = curr_block_num; } assert!(right >= left); - let middle = left + (right - left) / As::sa(2); + let middle = left + (right - left) / two; Some((AncestorSearchState::BinarySearch(left, right), middle)) }, } @@ -372,7 +381,7 @@ impl ChainSync { peer.state = PeerSyncState::Available; self.blocks.insert(start_block, blocks, who); self.blocks - .drain(self.best_queued_number + As::sa(1)) + .drain(self.best_queued_number + One::one()) .into_iter() .map(|block_data| { IncomingBlock { @@ -418,7 +427,7 @@ impl ChainSync { if block_hash_match && peer.common_number < num { peer.common_number = num; } - if !block_hash_match && num == As::sa(0) { + if !block_hash_match && num.is_zero() { trace!(target:"sync", "Ancestry search: genesis mismatch for peer {}", who); protocol.report_peer(who.clone(), GENESIS_MISMATCH_REPUTATION_CHANGE); protocol.disconnect_peer(who); @@ -675,7 +684,7 @@ impl ChainSync { pub(crate) fn on_block_announce(&mut self, protocol: &mut Context, who: PeerId, hash: B::Hash, header: &B::Header) { let number = *header.number(); debug!(target: "sync", "Received block announcement with number {:?}", number); - if number <= As::sa(0) { + if number.is_zero() { warn!(target: "sync", "Ignored invalid block announcement from {}: {}", who, hash); return; } @@ -699,7 +708,7 @@ impl ChainSync { return; } if header.parent_hash() == &self.best_queued_hash || known_parent { - peer.common_number = number - As::sa(1); + peer.common_number = number - One::one(); } else if known { peer.common_number = number } @@ -769,7 +778,7 @@ impl ChainSync { Err(e) => { debug!(target:"sync", "Error reading blockchain: {:?}", e); self.best_queued_hash = self.genesis_hash; - self.best_queued_number = As::sa(0); + self.best_queued_number = Zero::zero(); } } let ids: Vec = self.peers.drain().map(|(id, _)| id).collect(); @@ -839,7 +848,7 @@ impl ChainSync { from: message::FromBlock::Number(range.start), to: None, direction: message::Direction::Ascending, - max: Some((range.end - range.start).as_() as u32), + max: Some((range.end - range.start).saturated_into::()), }; peer.state = PeerSyncState::DownloadingNew(range.start); protocol.send_block_request(who, request); diff --git a/core/rpc/src/chain/number.rs b/core/rpc/src/chain/number.rs index 2e5af190ea..7983ac6c78 100644 --- a/core/rpc/src/chain/number.rs +++ b/core/rpc/src/chain/number.rs @@ -15,6 +15,7 @@ // along with Substrate. If not, see . use serde::Deserialize; +use std::{convert::TryFrom, fmt::Debug}; use primitives::U256; use runtime_primitives::traits; @@ -34,30 +35,28 @@ pub enum NumberOrHex { Hex(U256), } -impl> NumberOrHex { +impl + From + Debug + PartialOrd> NumberOrHex { /// Attempts to convert into concrete block number. /// /// Fails in case hex number is too big. pub fn to_number(self) -> Result { - let num: u64 = match self { - NumberOrHex::Number(n) => n.as_(), + let num = match self { + NumberOrHex::Number(n) => n, NumberOrHex::Hex(h) => { - // FIXME #1377 this only supports `u64` since `BlockNumber` - // is `As` we could possibly go with `u128`. let l = h.low_u64(); if U256::from(l) != h { - return Err(format!("`{}` does not fit into the block number type.", h)); + return Err(format!("`{}` does not fit into u64 type; unsupported for now.", h)) } else { - l + Number::try_from(l) + .map_err(|_| format!("`{}` does not fit into block number type.", h))? } }, }; // FIXME <2329>: Database seems to limit the block number to u32 for no reason - if num > u32::max_value() as u64 { - Err(format!("`{}` > u32::max_value(), the max block number is u32.", num)) - } else { - Ok(traits::As::sa(num)) + if num > Number::from(u32::max_value()) { + return Err(format!("`{:?}` > u32::max_value(), the max block number is u32.", num)) } + Ok(num) } } diff --git a/core/rpc/src/state/mod.rs b/core/rpc/src/state/mod.rs index 4cb7a3fbd8..0f87faa7a7 100644 --- a/core/rpc/src/state/mod.rs +++ b/core/rpc/src/state/mod.rs @@ -33,7 +33,10 @@ use primitives::storage::{self, StorageKey, StorageData, StorageChangeSet}; use crate::rpc::Result as RpcResult; use crate::rpc::futures::{stream, Future, Sink, Stream}; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header, ProvideRuntimeApi, As, NumberFor}; +use runtime_primitives::traits::{ + Block as BlockT, Header, ProvideRuntimeApi, NumberFor, + SaturatedConversion +}; use runtime_version::RuntimeVersion; use state_machine::{self, ExecutionStrategy}; @@ -229,7 +232,7 @@ impl State where }; // check if we can filter blocks-with-changes from some (sub)range using changes tries let changes_trie_range = self.client.max_key_changes_range(from_number, BlockId::Hash(to.hash()))?; - let filtered_range_begin = changes_trie_range.map(|(begin, _)| (begin - from_number).as_() as usize); + let filtered_range_begin = changes_trie_range.map(|(begin, _)| (begin - from_number).saturated_into::()); let (unfiltered_range, filtered_range) = split_range(blocks.len(), filtered_range_begin); Ok(QueryStorageRange { hashes: blocks, @@ -281,7 +284,7 @@ impl State where ) -> Result<()> { let (begin, end) = match range.filtered_range { Some(ref filtered_range) => ( - range.first_number + As::sa(filtered_range.start as u64), + range.first_number + filtered_range.start.saturated_into(), BlockId::Hash(range.hashes[filtered_range.end - 1].clone()) ), None => return Ok(()), @@ -293,7 +296,7 @@ impl State where if last_block == Some(block) { continue; } - let block_hash = range.hashes[(block - range.first_number).as_() as usize].clone(); + let block_hash = range.hashes[(block - range.first_number).saturated_into::()].clone(); let id = BlockId::Hash(block_hash); let value_at_block = self.client.storage(&id, key)?; changes_map.entry(block) diff --git a/core/service/src/chain_ops.rs b/core/service/src/chain_ops.rs index 9f39e8088e..4df3b06cdf 100644 --- a/core/service/src/chain_ops.rs +++ b/core/service/src/chain_ops.rs @@ -21,7 +21,7 @@ use futures::Future; use log::{info, warn}; use runtime_primitives::generic::{SignedBlock, BlockId}; -use runtime_primitives::traits::{As, Block, Header, NumberFor}; +use runtime_primitives::traits::{SaturatedConversion, Zero, One, Block, Header, NumberFor}; use consensus_common::import_queue::{ImportQueue, IncomingBlock, Link}; use network::message; @@ -50,7 +50,7 @@ pub fn export_blocks( let mut block = from; let last = match to { - Some(v) if v == As::sa(0) => As::sa(1), + Some(v) if v.is_zero() => One::one(), Some(v) => v, None => client.info()?.chain.best_number, }; @@ -66,8 +66,8 @@ pub fn export_blocks( }); info!("Exporting blocks from #{} to #{}", block, last); if !json { - let last_: u64 = last.as_(); - let block_: u64 = block.as_(); + let last_: u64 = last.saturated_into::(); + let block_: u64 = block.saturated_into::(); let len: u64 = last_ - block_ + 1; output.write(&len.encode())?; } @@ -87,13 +87,13 @@ pub fn export_blocks( }, None => break, } - if block.as_() % 10000 == 0 { + if (block % 10000.into()).is_zero() { info!("#{}", block); } if block == last { break; } - block += As::sa(1); + block += One::one(); } Ok(()) } @@ -202,7 +202,7 @@ pub fn revert_chain( let reverted = client.revert(blocks)?; let info = client.info()?.chain; - if reverted.as_() == 0 { + if reverted.is_zero() { info!("There aren't any non-finalized blocks to revert."); } else { info!("Reverted {} blocks. Best: #{} ({})", reverted, info.best_number, info.best_hash); diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 2ed9348e52..98a77b68b4 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -40,7 +40,7 @@ use log::{info, warn, debug}; use parity_codec::{Encode, Decode}; use primitives::Pair; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Header, As}; +use runtime_primitives::traits::{Header, SaturatedConversion}; use substrate_executor::NativeExecutor; use tel::{telemetry, SUBSTRATE_INFO}; @@ -162,7 +162,10 @@ impl Service { let version = config.full_version(); info!("Highest known block at #{}", chain_info.best_number); - telemetry!(SUBSTRATE_INFO; "node.start"; "height" => chain_info.best_number.as_(), "best" => ?chain_info.best_hash); + telemetry!(SUBSTRATE_INFO; "node.start"; + "height" => chain_info.best_number.saturated_into::(), + "best" => ?chain_info.best_hash + ); let network_protocol = ::build_network_protocol(&config)?; let transaction_pool = Arc::new( diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index b0ed0c0fc1..a0f37709bd 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -36,7 +36,6 @@ use service::{ }; use network::{multiaddr, Multiaddr, SyncProvider, ManageNetwork}; use network::config::{NetworkConfiguration, NodeKeyConfig, Secret, NonReservedPeerMode}; -use sr_primitives::traits::As; use sr_primitives::generic::BlockId; use consensus::{ImportBlock, BlockImport}; @@ -229,7 +228,7 @@ where E: Fn(&F::FullService) -> FactoryExtrinsic, { const NUM_NODES: u32 = 10; - const NUM_BLOCKS: usize = 512; + const NUM_BLOCKS: u32 = 512; let temp = TempDir::new("substrate-sync-test").expect("Error creating test dir"); let mut network = TestNet::::new(&temp, spec.clone(), NUM_NODES, 0, vec![], 30500); info!("Checking block sync"); @@ -249,7 +248,7 @@ where service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| - service.client().info().unwrap().chain.best_number == As::sa(NUM_BLOCKS as u64) + service.client().info().unwrap().chain.best_number == NUM_BLOCKS.into() ); info!("Checking extrinsic propagation"); let first_service = network.full_nodes[0].1.clone(); @@ -265,7 +264,7 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) F: ServiceFactory, { const NUM_NODES: u32 = 20; - const NUM_BLOCKS: u64 = 200; + const NUM_BLOCKS: u32 = 200; let temp = TempDir::new("substrate-conensus-test").expect("Error creating test dir"); let mut network = TestNet::::new(&temp, spec.clone(), NUM_NODES / 2, 0, authorities, 30600); info!("Checking consensus"); @@ -277,7 +276,7 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| { - service.client().info().unwrap().chain.finalized_number >= As::sa(NUM_BLOCKS / 2) + service.client().info().unwrap().chain.finalized_number >= (NUM_BLOCKS / 2).into() }); info!("Adding more peers"); network.insert_nodes(&temp, NUM_NODES / 2, 0, vec![]); @@ -285,6 +284,6 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| - service.client().info().unwrap().chain.finalized_number >= As::sa(NUM_BLOCKS) + service.client().info().unwrap().chain.finalized_number >= NUM_BLOCKS.into() ); } diff --git a/core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs b/core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs index ea9dad2a50..36e17fc277 100644 --- a/core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs +++ b/core/sr-primitives/src/generic/unchecked_mortal_compact_extrinsic.rs @@ -22,8 +22,8 @@ use std::fmt; use rstd::prelude::*; use runtime_io::blake2_256; use crate::codec::{Decode, Encode, Input, Compact}; -use crate::traits::{self, Member, SimpleArithmetic, MaybeDisplay, CurrentHeight, BlockNumberToHash, Lookup, - Checkable, Extrinsic}; +use crate::traits::{self, Member, SimpleArithmetic, MaybeDisplay, CurrentHeight, BlockNumberToHash, + Lookup, Checkable, Extrinsic, SaturatedConversion}; use super::{CheckedExtrinsic, Era}; const TRANSACTION_VERSION: u8 = 1; @@ -84,7 +84,8 @@ where fn check(self, context: &Context) -> Result { Ok(match self.signature { Some((signed, signature, index, era)) => { - let h = context.block_number_to_hash(BlockNumber::sa(era.birth(context.current_height().as_()))) + let current_u64 = context.current_height().saturated_into::(); + let h = context.block_number_to_hash(era.birth(current_u64).saturated_into()) .ok_or("transaction birth block ancient")?; let signed = context.lookup(signed)?; let raw_payload = (index, self.function, era, h); diff --git a/core/sr-primitives/src/generic/unchecked_mortal_extrinsic.rs b/core/sr-primitives/src/generic/unchecked_mortal_extrinsic.rs index a91f4461ff..7f92b20edd 100644 --- a/core/sr-primitives/src/generic/unchecked_mortal_extrinsic.rs +++ b/core/sr-primitives/src/generic/unchecked_mortal_extrinsic.rs @@ -22,8 +22,10 @@ use std::fmt; use rstd::prelude::*; use runtime_io::blake2_256; use crate::codec::{Decode, Encode, Input}; -use crate::traits::{self, Member, SimpleArithmetic, MaybeDisplay, CurrentHeight, BlockNumberToHash, Lookup, - Checkable, Extrinsic}; +use crate::traits::{ + self, Member, SimpleArithmetic, MaybeDisplay, CurrentHeight, BlockNumberToHash, + Lookup, Checkable, Extrinsic, SaturatedConversion +}; use super::{CheckedExtrinsic, Era}; const TRANSACTION_VERSION: u8 = 1; @@ -83,7 +85,8 @@ where fn check(self, context: &Context) -> Result { Ok(match self.signature { Some((signed, signature, index, era)) => { - let h = context.block_number_to_hash(BlockNumber::sa(era.birth(context.current_height().as_()))) + let current_u64 = context.current_height().saturated_into::(); + let h = context.block_number_to_hash(era.birth(current_u64).saturated_into()) .ok_or("transaction birth block ancient")?; let signed = context.lookup(signed)?; let raw_payload = (index, self.function, era, h); diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index bdecfe8981..05938a6a82 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -29,8 +29,7 @@ pub use serde; #[cfg(feature = "std")] pub use runtime_io::{StorageOverlay, ChildrenStorageOverlay}; -use rstd::prelude::*; -use rstd::ops; +use rstd::{prelude::*, ops}; use substrate_primitives::{crypto, ed25519, sr25519, hash::{H256, H512}}; use codec::{Encode, Decode}; @@ -38,6 +37,8 @@ use codec::{Encode, Decode}; pub mod testing; pub mod traits; +use traits::{SaturatedConversion, UniqueSaturatedInto}; + pub mod generic; pub mod transaction_validity; @@ -159,27 +160,30 @@ impl Permill { impl ops::Mul for Permill where - N: Clone + traits::As + ops::Rem + ops::Div - + ops::Mul + ops::Add, + N: Clone + From + UniqueSaturatedInto + ops::Rem + + ops::Div + ops::Mul + ops::Add, { type Output = N; fn mul(self, b: N) -> Self::Output { - let million = >::sa(1_000_000); - let part = >::sa(self.0 as u64); + let million: N = 1_000_000.into(); + let part: N = self.0.into(); let rem_multiplied_divided = { let rem = b.clone().rem(million.clone()); - // `rem` is inferior to one million, thus it fits into u64 - let rem_u64: u64 = rem.as_(); + // `rem` is inferior to one million, thus it fits into u32 + let rem_u32 = rem.saturated_into::(); - // `self` and `rem` are inferior to one million, thus the product fits into u64 - let rem_multiplied_u64 = rem_u64 * self.0 as u64; + // `self` and `rem` are inferior to one million, thus the product is less than 10^12 + // and fits into u64 + let rem_multiplied_u64 = rem_u32 as u64 * self.0 as u64; - let rem_multiplied_divided_u64 = rem_multiplied_u64 / 1_000_000; + // `rem_multiplied_u64` is less than 10^12 therefore divided by a million it fits into + // u32 + let rem_multiplied_divided_u32 = (rem_multiplied_u64 / 1_000_000) as u32; // `rem_multiplied_divided` is inferior to b, thus it can be converted back to N type - traits::As::sa(rem_multiplied_divided_u64) + rem_multiplied_divided_u32.into() }; (b / million) * part + rem_multiplied_divided @@ -248,27 +252,30 @@ impl Perbill { impl ops::Mul for Perbill where - N: Clone + traits::As + ops::Rem + ops::Div - + ops::Mul + ops::Add + N: Clone + From + UniqueSaturatedInto + ops::Rem + + ops::Div + ops::Mul + ops::Add, { type Output = N; fn mul(self, b: N) -> Self::Output { - let billion = >::sa(1_000_000_000); - let part = >::sa(self.0 as u64); + let billion: N = 1_000_000_000.into(); + let part: N = self.0.into(); let rem_multiplied_divided = { let rem = b.clone().rem(billion.clone()); - // `rem` is inferior to one billion, thus it fits into u64 - let rem_u64: u64 = rem.as_(); + // `rem` is inferior to one billion, thus it fits into u32 + let rem_u32 = rem.saturated_into::(); - // `self` and `rem` are inferior to one billion, thus the product fits into u64 - let rem_multiplied_u64 = rem_u64 * self.0 as u64; + // `self` and `rem` are inferior to one billion, thus the product is less than 10^18 + // and fits into u64 + let rem_multiplied_u64 = rem_u32 as u64 * self.0 as u64; - let rem_multiplied_divided_u64 = rem_multiplied_u64 / 1_000_000_000; + // `rem_multiplied_u64` is less than 10^18 therefore divided by a billion it fits into + // u32 + let rem_multiplied_divided_u32 = (rem_multiplied_u64 / 1_000_000_000) as u32; // `rem_multiplied_divided` is inferior to b, thus it can be converted back to N type - traits::As::sa(rem_multiplied_divided_u64) + rem_multiplied_divided_u32.into() }; (b / billion) * part + rem_multiplied_divided @@ -918,13 +925,8 @@ mod tests { } #[test] - #[should_panic] fn per_things_operate_in_output_type() { - use super::Perbill; - - assert_eq!(Perbill::one() * 255_u64, 255); - // panics - assert_ne!(Perbill::one() * 255_u8, 255); + assert_eq!(super::Perbill::one() * 255_u64, 255); } #[test] diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index 92c8026340..8906bbf074 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -17,7 +17,7 @@ //! Primitives for the runtime modules. use rstd::prelude::*; -use rstd::{self, result, marker::PhantomData}; +use rstd::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}}; use runtime_io; #[cfg(feature = "std")] use std::fmt::{Debug, Display}; #[cfg(feature = "std")] use serde::{Serialize, Deserialize, de::DeserializeOwned}; @@ -27,7 +27,7 @@ use crate::transaction_validity::TransactionValidity; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ Zero, One, Bounded, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, - CheckedShl, CheckedShr, Saturating + CheckedShl, CheckedShr }; use rstd::ops::{ Add, Sub, Mul, Div, Rem, AddAssign, SubAssign, MulAssign, DivAssign, @@ -157,71 +157,143 @@ impl Convert for Identity { fn convert(a: T) -> T { a } } -/// Simple trait similar to `Into`, except that it can be used to convert numerics between each -/// other. -pub trait As { - /// Convert forward (ala `Into::into`). - fn as_(self) -> T; - /// Convert backward (ala `From::from`). - fn sa(_: T) -> Self; -} - -macro_rules! impl_numerics { - ( $( $t:ty ),* ) => { - $( - impl_numerics!($t: u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize,); - )* - }; - ( $f:ty : $t:ty, $( $rest:ty, )* ) => { - impl As<$t> for $f { - fn as_(self) -> $t { self as $t } - fn sa(t: $t) -> Self { t as Self } - } - impl_numerics!($f: $( $rest, )*); - }; - ( $f:ty : ) => {} -} - -impl_numerics!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); - /// A meta trait for arithmetic. +/// +/// Arithmetic types do all the usual stuff you'd expect numbers to do. They are guaranteed to +/// be able to represent at least `u32` values without loss, hence the trait implies `From` +/// and smaller ints. All other conversions are fallible. pub trait SimpleArithmetic: - Zero + One + IntegerSquareRoot + As + + Zero + One + IntegerSquareRoot + + From + From + From + TryInto + TryInto + TryInto + + TryFrom + TryInto + TryFrom + TryInto + TryFrom + TryInto + + UniqueSaturatedInto + UniqueSaturatedInto + UniqueSaturatedInto + + UniqueSaturatedFrom + UniqueSaturatedInto + UniqueSaturatedFrom + UniqueSaturatedInto + Add + AddAssign + Sub + SubAssign + Mul + MulAssign + Div + DivAssign + Rem + RemAssign + Shl + Shr + - CheckedShl + - CheckedShr + - CheckedAdd + - CheckedSub + - CheckedMul + - CheckedDiv + - Saturating + - PartialOrd + Ord + Bounded + - HasCompact + CheckedShl + CheckedShr + CheckedAdd + CheckedSub + CheckedMul + CheckedDiv + + Saturating + PartialOrd + Ord + Bounded + + HasCompact + Sized {} impl + + Zero + One + IntegerSquareRoot + + From + From + From + TryInto + TryInto + TryInto + + TryFrom + TryInto + TryFrom + TryInto + TryFrom + TryInto + + UniqueSaturatedInto + UniqueSaturatedInto + UniqueSaturatedInto + + UniqueSaturatedFrom + UniqueSaturatedInto + UniqueSaturatedFrom + + UniqueSaturatedInto + UniqueSaturatedFrom + UniqueSaturatedInto + Add + AddAssign + Sub + SubAssign + Mul + MulAssign + Div + DivAssign + Rem + RemAssign + Shl + Shr + - CheckedShl + - CheckedShr + - CheckedAdd + - CheckedSub + - CheckedMul + - CheckedDiv + - Saturating + - PartialOrd + Ord + Bounded + - HasCompact + CheckedShl + CheckedShr + CheckedAdd + CheckedSub + CheckedMul + CheckedDiv + + Saturating + PartialOrd + Ord + Bounded + + HasCompact + Sized > SimpleArithmetic for T {} +/// Just like `From` except that if the source value is too big to fit into the destination type +/// then it'll saturate the destination. +pub trait UniqueSaturatedFrom: Sized { + /// Convert from a value of `T` into an equivalent instance of `Self`. + fn unique_saturated_from(t: T) -> Self; +} + +/// Just like `Into` except that if the source value is too big to fit into the destination type +/// then it'll saturate the destination. +pub trait UniqueSaturatedInto: Sized { + /// Consume self to return an equivalent value of `T`. + fn unique_saturated_into(self) -> T; +} + +impl + Bounded + Sized> UniqueSaturatedFrom for S { + fn unique_saturated_from(t: T) -> Self { + S::try_from(t).unwrap_or_else(|_| Bounded::max_value()) + } +} + +impl + Sized> UniqueSaturatedInto for S { + fn unique_saturated_into(self) -> T { + self.try_into().unwrap_or_else(|_| Bounded::max_value()) + } +} + +/// Simple trait to use checked mul and max value to give a saturated mul operation over +/// supported types. +pub trait Saturating { + /// Saturated addition - if the product can't fit in the type then just use max-value. + fn saturating_add(self, o: Self) -> Self; + + /// Saturated subtraction - if the product can't fit in the type then just use max-value. + fn saturating_sub(self, o: Self) -> Self; + + /// Saturated multiply - if the product can't fit in the type then just use max-value. + fn saturating_mul(self, o: Self) -> Self; +} + +impl Saturating for T { + fn saturating_add(self, o: Self) -> Self { + ::saturating_add(self, o) + } + fn saturating_sub(self, o: Self) -> Self { + ::saturating_sub(self, o) + } + fn saturating_mul(self, o: Self) -> Self { + self.checked_mul(&o).unwrap_or_else(Bounded::max_value) + } +} + +/// Convenience type to work around the highly unergonomic syntax needed +/// to invoke the functions of overloaded generic traits, in this case +/// `SaturatedFrom` and `SaturatedInto`. +pub trait SaturatedConversion { + /// Convert from a value of `T` into an equivalent instance of `Self`. + /// + /// This just uses `UniqueSaturatedFrom` internally but with this + /// variant you can provide the destination type using turbofish syntax + /// in case Rust happens not to assume the correct type. + fn saturated_from(t: T) -> Self where Self: UniqueSaturatedFrom { + >::unique_saturated_from(t) + } + + /// Consume self to return an equivalent value of `T`. + /// + /// This just uses `UniqueSaturatedInto` internally but with this + /// variant you can provide the destination type using turbofish syntax + /// in case Rust happens not to assume the correct type. + fn saturated_into(self) -> T where Self: UniqueSaturatedInto { + >::unique_saturated_into(self) + } +} +impl SaturatedConversion for T {} + +/// Convenience type to work around the highly unergonomic syntax needed +/// to invoke the functions of overloaded generic traits, in this case +/// `TryFrom` and `TryInto`. +pub trait CheckedConversion { + /// Convert from a value of `T` into an equivalent instance of `Option`. + /// + /// This just uses `TryFrom` internally but with this + /// variant you can provide the destination type using turbofish syntax + /// in case Rust happens not to assume the correct type. + fn checked_from(t: T) -> Option where Self: TryFrom { + >::try_from(t).ok() + } + /// Consume self to return `Some` equivalent value of `Option`. + /// + /// This just uses `TryInto` internally but with this + /// variant you can provide the destination type using turbofish syntax + /// in case Rust happens not to assume the correct type. + fn checked_into(self) -> Option where Self: TryInto { + >::try_into(self).ok() + } +} +impl CheckedConversion for T {} + /// Trait for things that can be clear (have no bits set). For numeric types, essentially the same /// as `Zero`. pub trait Clear { diff --git a/core/state-machine/src/changes_trie/prune.rs b/core/state-machine/src/changes_trie/prune.rs index bbe5bb573b..09e53315a5 100644 --- a/core/state-machine/src/changes_trie/prune.rs +++ b/core/state-machine/src/changes_trie/prune.rs @@ -51,8 +51,7 @@ pub fn prune, H: Hasher, F: FnMut(H::Out)>( min_blocks_to_keep: u64, current_block: &AnchorBlockId, mut remove_trie_node: F, -) -{ +) { // select range for pruning let (first, last) = match pruning_range(config, min_blocks_to_keep, current_block.number) { Some((first, last)) => (first, last), diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index 2a8f1942a3..df89cba455 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -2453,6 +2453,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-std 2.0.0", "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 121e3ddf00..78d06eabb5 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -34,7 +34,7 @@ use futures::sync::mpsc; use parking_lot::{Mutex, RwLock}; use sr_primitives::{ generic::BlockId, - traits::{self, As}, + traits::{self, SaturatedConversion}, transaction_validity::{TransactionValidity, TransactionTag as Tag}, }; @@ -138,7 +138,9 @@ impl Pool { priority, requires, provides, - valid_till: block_number.as_().saturating_add(longevity), + valid_till: block_number + .saturated_into::() + .saturating_add(longevity), }) }, TransactionValidity::Invalid(e) => { @@ -337,7 +339,7 @@ impl Pool { pub fn clear_stale(&self, at: &BlockId) -> Result<(), B::Error> { let block_number = self.api.block_id_to_number(at)? .ok_or_else(|| error::ErrorKind::Msg(format!("Invalid block id: {:?}", at)).into())? - .as_(); + .saturated_into::(); let now = time::Instant::now(); let to_remove = { self.ready() diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index cfbf85fbf2..e458c165c0 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -2596,6 +2596,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-std 2.0.0", "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index e74db4629d..a285a246cc 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 80, - impl_version: 82, + spec_version: 81, + impl_version: 81, apis: RUNTIME_API_VERSIONS, }; diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index cee874bf50..50037f709e 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -2731,6 +2731,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-std 2.0.0", "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index e5eb3674cd..646ad972d0 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -53,7 +53,7 @@ pub use timestamp; use rstd::{result, prelude::*}; use srml_support::storage::StorageValue; use srml_support::{decl_storage, decl_module}; -use primitives::traits::{As, Zero}; +use primitives::traits::{SaturatedConversion, Saturating, Zero, One}; use timestamp::OnTimestampSet; #[cfg(feature = "std")] use timestamp::TimestampInherentData; @@ -154,7 +154,7 @@ pub trait Trait: timestamp::Trait { decl_storage! { trait Store for Module as Aura { /// The last timestamp. - LastTimestamp get(last) build(|_| T::Moment::sa(0)): T::Moment; + LastTimestamp get(last) build(|_| 0.into()): T::Moment; } } @@ -192,43 +192,41 @@ impl AuraReport { impl Module { /// Determine the Aura slot-duration based on the Timestamp module configuration. - pub fn slot_duration() -> u64 { + pub fn slot_duration() -> T::Moment { // we double the minimum block-period so each author can always propose within // the majority of its slot. - >::minimum_period().as_().saturating_mul(2) + >::minimum_period().saturating_mul(2.into()) } fn on_timestamp_set(now: T::Moment, slot_duration: T::Moment) { let last = Self::last(); ::LastTimestamp::put(now.clone()); - if last == T::Moment::zero() { + if last.is_zero() { return; } - assert!(slot_duration > T::Moment::zero(), "Aura slot duration cannot be zero."); + assert!(!slot_duration.is_zero(), "Aura slot duration cannot be zero."); let last_slot = last / slot_duration.clone(); - let first_skipped = last_slot.clone() + T::Moment::sa(1); + let first_skipped = last_slot.clone() + One::one(); let cur_slot = now / slot_duration; assert!(last_slot < cur_slot, "Only one block may be authored per slot."); if cur_slot == first_skipped { return } - let slot_to_usize = |slot: T::Moment| { slot.as_() as usize }; - - let skipped_slots = cur_slot - last_slot - T::Moment::sa(1); + let skipped_slots = cur_slot - last_slot - One::one(); H::handle_report(AuraReport { - start_slot: slot_to_usize(first_skipped), - skipped: slot_to_usize(skipped_slots), + start_slot: first_skipped.saturated_into::(), + skipped: skipped_slots.saturated_into::(), }) } } impl OnTimestampSet for Module { fn on_timestamp_set(moment: T::Moment) { - Self::on_timestamp_set::(moment, T::Moment::sa(Self::slot_duration())) + Self::on_timestamp_set::(moment, Self::slot_duration()) } } @@ -265,9 +263,9 @@ impl ProvideInherent for Module { _ => return Ok(()), }; - let timestamp_based_slot = timestamp.as_() / Self::slot_duration(); + let timestamp_based_slot = timestamp / Self::slot_duration(); - let seal_slot = data.aura_inherent_data()?; + let seal_slot = data.aura_inherent_data()?.saturated_into(); if timestamp_based_slot == seal_slot { Ok(()) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index e9b5426221..3e36481151 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -22,8 +22,8 @@ pub use timestamp; use rstd::{result, prelude::*}; use srml_support::{decl_storage, decl_module}; -use primitives::traits::As; use timestamp::{OnTimestampSet, Trait}; +use primitives::traits::{SaturatedConversion, Saturating}; #[cfg(feature = "std")] use timestamp::TimestampInherentData; use parity_codec::Decode; @@ -116,10 +116,10 @@ decl_module! { impl Module { /// Determine the BABE slot duration based on the Timestamp module configuration. - pub fn slot_duration() -> u64 { + pub fn slot_duration() -> T::Moment { // we double the minimum block-period so each author can always propose within // the majority of their slot. - >::minimum_period().as_().saturating_mul(2) + >::minimum_period().saturating_mul(2.into()) } } @@ -142,10 +142,8 @@ impl ProvideInherent for Module { _ => return Ok(()), }; - let timestamp_based_slot = timestamp.as_() / Self::slot_duration(); - + let timestamp_based_slot = (timestamp / Self::slot_duration()).saturated_into::(); let seal_slot = data.babe_inherent_data()?; - if timestamp_based_slot == seal_slot { Ok(()) } else { diff --git a/srml/balances/src/lib.rs b/srml/balances/src/lib.rs index 90f774dbf3..9fe93a9d4a 100644 --- a/srml/balances/src/lib.rs +++ b/srml/balances/src/lib.rs @@ -155,7 +155,7 @@ use srml_support::traits::{ }; use srml_support::dispatch::Result; use primitives::traits::{ - Zero, SimpleArithmetic, As, StaticLookup, Member, CheckedAdd, CheckedSub, + Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug, Saturating }; use system::{IsDeadAccount, OnNewAccount, ensure_signed}; @@ -167,7 +167,8 @@ pub use self::imbalances::{PositiveImbalance, NegativeImbalance}; pub trait Subtrait: system::Trait { /// The balance of an account. - type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + MaybeSerializeDebug; + type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + + MaybeSerializeDebug + From; /// A function that is invoked when the free-balance has fallen below the existential deposit and /// has been reduced to zero. @@ -181,7 +182,8 @@ pub trait Subtrait: system::Trait { pub trait Trait: system::Trait { /// The balance of an account. - type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + MaybeSerializeDebug; + type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + + MaybeSerializeDebug + From; /// A function that is invoked when the free-balance has fallen below the existential deposit and /// has been reduced to zero. @@ -236,10 +238,12 @@ pub struct VestingSchedule { pub per_block: Balance, } -impl> VestingSchedule { +impl VestingSchedule { /// Amount locked at block `n`. - pub fn locked_at>(&self, n: BlockNumber) -> Balance { - if let Some(x) = Balance::sa(n.as_()).checked_mul(&self.per_block) { + pub fn locked_at(&self, n: BlockNumber) -> Balance + where Balance: From + { + if let Some(x) = Balance::from(n).checked_mul(&self.per_block) { self.offset.max(x) - x } else { Zero::zero() @@ -276,10 +280,8 @@ decl_storage! { /// Information regarding the vesting of a given account. pub Vesting get(vesting) build(|config: &GenesisConfig| { config.vesting.iter().filter_map(|&(ref who, begin, length)| { - let begin: u64 = begin.as_(); - let length: u64 = length.as_(); - let begin: T::Balance = As::sa(begin); - let length: T::Balance = As::sa(length); + let begin = >::from(begin); + let length = >::from(length); config.balances.iter() .find(|&&(ref w, _)| w == who) @@ -380,7 +382,8 @@ impl, I: Instance> Module { /// Get the amount that is currently being vested and cannot be transferred out of this account. pub fn vesting_balance(who: &T::AccountId) -> T::Balance { if let Some(v) = Self::vesting(who) { - Self::free_balance(who).min(v.locked_at(>::block_number())) + Self::free_balance(who) + .min(v.locked_at::(>::block_number())) } else { Zero::zero() } @@ -1013,7 +1016,7 @@ where impl, I: Instance> MakePayment for Module { fn make_payment(transactor: &T::AccountId, encoded_len: usize) -> Result { - let encoded_len = >::sa(encoded_len as u64); + let encoded_len = T::Balance::from(encoded_len as u32); let transaction_fee = Self::transaction_base_fee() + Self::transaction_byte_fee() * encoded_len; let imbalance = Self::withdraw( transactor, diff --git a/srml/contract/src/account_db.rs b/srml/contract/src/account_db.rs index df63ccc479..21f2972893 100644 --- a/srml/contract/src/account_db.rs +++ b/srml/contract/src/account_db.rs @@ -140,10 +140,10 @@ impl AccountDb for DirectAccountDb { for (k, v) in changed.storage.into_iter() { if let Some(value) = child::get_raw(&new_info.trie_id[..], &blake2_256(&k)) { - new_info.storage_size -= value.len() as u64; + new_info.storage_size -= value.len() as u32; } if let Some(value) = v { - new_info.storage_size += value.len() as u64; + new_info.storage_size += value.len() as u32; child::put_raw(&new_info.trie_id[..], &blake2_256(&k), &value[..]); } else { child::kill(&new_info.trie_id[..], &blake2_256(&k)); diff --git a/srml/contract/src/gas.rs b/srml/contract/src/gas.rs index f42b0919f3..1ea5196344 100644 --- a/srml/contract/src/gas.rs +++ b/srml/contract/src/gas.rs @@ -16,7 +16,7 @@ use crate::{GasSpent, Module, Trait, BalanceOf, NegativeImbalanceOf}; use runtime_primitives::BLOCK_FULL; -use runtime_primitives::traits::{As, CheckedMul, CheckedSub, Zero}; +use runtime_primitives::traits::{CheckedMul, CheckedSub, Zero, SaturatedConversion}; use srml_support::{StorageValue, traits::{OnUnbalanced, ExistenceRequirement, WithdrawReason, Currency, Imbalance}}; #[cfg(test)] @@ -212,7 +212,7 @@ pub fn buy_gas( // Buy the specified amount of gas. let gas_price = >::gas_price(); - let cost = >>::as_(gas_limit.clone()) + let cost = gas_limit.clone().into() .checked_mul(&gas_price) .ok_or("overflow multiplying gas limit by price")?; @@ -248,7 +248,7 @@ pub fn refund_unused_gas( >::mutate(|block_gas_spent| *block_gas_spent += gas_spent); // Refund gas left by the price it was bought at. - let refund = >>::as_(gas_left) * gas_meter.gas_price; + let refund = gas_left.into() * gas_meter.gas_price; let refund_imbalance = T::Currency::deposit_creating(transactor, refund); if let Ok(imbalance) = imbalance.offset(refund_imbalance) { T::GasPayment::on_unbalanced(imbalance); @@ -258,8 +258,7 @@ pub fn refund_unused_gas( /// A little handy utility for converting a value in balance units into approximate value in gas units /// at the given gas price. pub fn approx_gas_for_balance(gas_price: BalanceOf, balance: BalanceOf) -> T::Gas { - let amount_in_gas: BalanceOf = balance / gas_price; - >>::sa(amount_in_gas) + (balance / gas_price).saturated_into::() } /// A simple utility macro that helps to match against a diff --git a/srml/contract/src/lib.rs b/srml/contract/src/lib.rs index 0cd3b0a325..b9412b3619 100644 --- a/srml/contract/src/lib.rs +++ b/srml/contract/src/lib.rs @@ -94,10 +94,9 @@ use crate::account_db::{AccountDb, DirectAccountDb}; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use substrate_primitives::crypto::UncheckedFrom; -use rstd::prelude::*; -use rstd::marker::PhantomData; +use rstd::{prelude::*, marker::PhantomData, convert::TryFrom}; use parity_codec::{Codec, Encode, Decode}; -use runtime_primitives::traits::{Hash, As, SimpleArithmetic, Bounded, StaticLookup, Zero}; +use runtime_primitives::traits::{Hash, SimpleArithmetic, Bounded, StaticLookup, Zero}; use srml_support::dispatch::{Result, Dispatchable}; use srml_support::{Parameter, StorageMap, StorageValue, decl_module, decl_event, decl_storage, storage::child}; use srml_support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency}; @@ -188,7 +187,7 @@ pub struct RawAliveContractInfo { /// Unique ID for the subtree encoded as a bytes vector. pub trie_id: TrieId, /// The size of stored value in octet. - pub storage_size: u64, + pub storage_size: u32, /// The code associated with a given account. pub code_hash: CodeHash, pub rent_allowance: Balance, @@ -199,7 +198,7 @@ pub struct RawAliveContractInfo { pub struct TombstoneContractInfo(T::Hash); impl TombstoneContractInfo { - fn new(storage_root: Vec, storage_size: u64, code_hash: CodeHash) -> Self { + fn new(storage_root: Vec, storage_size: u32, code_hash: CodeHash) -> Self { let mut buf = Vec::new(); storage_root.using_encoded(|encoded| buf.extend_from_slice(encoded)); storage_size.using_encoded(|encoded| buf.extend_from_slice(encoded)); @@ -252,7 +251,8 @@ where } pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -pub type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; +pub type NegativeImbalanceOf = + <::Currency as Currency<::AccountId>>::NegativeImbalance; pub trait Trait: timestamp::Trait { type Currency: Currency; @@ -263,8 +263,8 @@ pub trait Trait: timestamp::Trait { /// The overarching event type. type Event: From> + Into<::Event>; - // `As` is needed for wasm-utils - type Gas: Parameter + Default + Codec + SimpleArithmetic + Bounded + Copy + As> + As + As; + type Gas: Parameter + Default + Codec + SimpleArithmetic + Bounded + Copy + + Into> + TryFrom>; /// A function type to get the contract address given the creator. type DetermineContractAddress: ContractAddressFor, Self::AccountId>; @@ -310,10 +310,10 @@ where pub struct DefaultDispatchFeeComputor(PhantomData); impl ComputeDispatchFee> for DefaultDispatchFeeComputor { fn compute_dispatch_fee(call: &T::Call) -> BalanceOf { - let encoded_len = call.using_encoded(|encoded| encoded.len()); + let encoded_len = call.using_encoded(|encoded| encoded.len() as u32); let base_fee = >::transaction_base_fee(); let byte_fee = >::transaction_byte_fee(); - base_fee + byte_fee * as As>::sa(encoded_len as u64) + base_fee + byte_fee * encoded_len.into() } } @@ -553,7 +553,7 @@ decl_storage! { TombstoneDeposit get(tombstone_deposit) config(): BalanceOf; /// Size of a contract at the time of creation. This is a simple way to ensure /// that empty contracts eventually gets deleted. - StorageSizeOffset get(storage_size_offset) config(): u64; + StorageSizeOffset get(storage_size_offset) config(): u32; /// Price of a byte of storage per one block interval. Should be greater than 0. RentByteFee get(rent_byte_price) config(): BalanceOf; /// The amount of funds a contract should deposit in order to offset @@ -576,17 +576,17 @@ decl_storage! { /// The fee to be paid for making a transaction; the per-byte portion. TransactionByteFee get(transaction_byte_fee) config(): BalanceOf; /// The fee required to create a contract instance. - ContractFee get(contract_fee) config(): BalanceOf = BalanceOf::::sa(21); + ContractFee get(contract_fee) config(): BalanceOf = 21.into(); /// The base fee charged for calling into a contract. - CallBaseFee get(call_base_fee) config(): T::Gas = T::Gas::sa(135); + CallBaseFee get(call_base_fee) config(): T::Gas = 135.into(); /// The base fee charged for creating a contract. - CreateBaseFee get(create_base_fee) config(): T::Gas = T::Gas::sa(175); + CreateBaseFee get(create_base_fee) config(): T::Gas = 175.into(); /// The price of one unit of gas. - GasPrice get(gas_price) config(): BalanceOf = BalanceOf::::sa(1); + GasPrice get(gas_price) config(): BalanceOf = 1.into(); /// The maximum nesting level of a call/create stack. MaxDepth get(max_depth) config(): u32 = 100; /// The maximum amount of gas that could be expended per block. - BlockGasLimit get(block_gas_limit) config(): T::Gas = T::Gas::sa(10_000_000); + BlockGasLimit get(block_gas_limit) config(): T::Gas = 10_000_000.into(); /// Gas spent so far in this block. GasSpent get(gas_spent): T::Gas; /// Current cost schedule for contracts. @@ -692,19 +692,19 @@ pub struct Schedule { pub enable_println: bool, } -impl> Default for Schedule { +impl> Default for Schedule { fn default() -> Schedule { Schedule { version: 0, - put_code_per_byte_cost: Gas::sa(1), - grow_mem_cost: Gas::sa(1), - regular_op_cost: Gas::sa(1), - return_data_per_byte_cost: Gas::sa(1), - event_data_per_byte_cost: Gas::sa(1), - event_per_topic_cost: Gas::sa(1), - event_base_cost: Gas::sa(1), - sandbox_data_read_cost: Gas::sa(1), - sandbox_data_write_cost: Gas::sa(1), + put_code_per_byte_cost: 1.into(), + grow_mem_cost: 1.into(), + regular_op_cost: 1.into(), + return_data_per_byte_cost: 1.into(), + event_data_per_byte_cost: 1.into(), + event_per_topic_cost: 1.into(), + event_base_cost: 1.into(), + sandbox_data_read_cost: 1.into(), + sandbox_data_write_cost: 1.into(), max_event_topics: 4, max_stack_height: 64 * 1024, max_memory_pages: 16, diff --git a/srml/contract/src/rent.rs b/srml/contract/src/rent.rs index 5466e2553d..aacbb4ab7f 100644 --- a/srml/contract/src/rent.rs +++ b/srml/contract/src/rent.rs @@ -15,7 +15,8 @@ // along with Substrate. If not, see . use crate::{BalanceOf, ContractInfo, ContractInfoOf, Module, TombstoneContractInfo, Trait}; -use runtime_primitives::traits::{As, Bounded, CheckedDiv, CheckedMul, Saturating, Zero}; +use runtime_primitives::traits::{Bounded, CheckedDiv, CheckedMul, Saturating, Zero, + SaturatedConversion}; use srml_support::traits::{Currency, ExistenceRequirement, Imbalance, WithdrawReason}; use srml_support::StorageMap; @@ -75,10 +76,10 @@ fn try_evict_or_and_pay_rent( let fee_per_block = { let free_storage = balance .checked_div(&>::rent_deposit_offset()) - .unwrap_or(>::sa(0)); + .unwrap_or_else(Zero::zero); let effective_storage_size = - >::sa(contract.storage_size).saturating_sub(free_storage); + >::from(contract.storage_size).saturating_sub(free_storage); effective_storage_size .checked_mul(&>::rent_byte_price()) @@ -95,7 +96,7 @@ fn try_evict_or_and_pay_rent( let subsistence_threshold = T::Currency::minimum_balance() + >::tombstone_deposit(); let dues = fee_per_block - .checked_mul(&>::sa(blocks_passed.as_())) + .checked_mul(&blocks_passed.saturated_into::().into()) .unwrap_or(>::max_value()); let dues_limited = dues.min(contract.rent_allowance); diff --git a/srml/contract/src/tests.rs b/srml/contract/src/tests.rs index 4eed6777b4..a14819850e 100644 --- a/srml/contract/src/tests.rs +++ b/srml/contract/src/tests.rs @@ -21,8 +21,8 @@ use crate::account_db::{AccountDb, DirectAccountDb, OverlayAccountDb}; use crate::{ - BalanceOf, ComputeDispatchFee, ContractAddressFor, ContractInfo, ContractInfoOf, GenesisConfig, Module, - RawAliveContractInfo, RawEvent, Trait, TrieId, TrieIdFromParentCounter, TrieIdGenerator, + BalanceOf, ComputeDispatchFee, ContractAddressFor, ContractInfo, ContractInfoOf, GenesisConfig, + Module, RawAliveContractInfo, RawEvent, Trait, TrieId, TrieIdFromParentCounter, TrieIdGenerator, }; use assert_matches::assert_matches; use hex_literal::*; @@ -30,7 +30,7 @@ use parity_codec::{Decode, Encode, KeyedVec}; use runtime_io; use runtime_io::with_externalities; use runtime_primitives::testing::{Digest, DigestItem, Header, UintAuthorityId, H256}; -use runtime_primitives::traits::{As, BlakeTwo256, IdentityLookup}; +use runtime_primitives::traits::{BlakeTwo256, IdentityLookup}; use runtime_primitives::BuildStorage; use srml_support::{ assert_ok, impl_outer_dispatch, impl_outer_event, impl_outer_origin, storage::child, @@ -689,7 +689,7 @@ fn storage_size() { Origin::signed(ALICE), 30_000, 100_000, HASH_SET_RENT.into(), - ::Balance::sa(1_000u64).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.storage_size, Contract::storage_size_offset() + 4); @@ -719,7 +719,7 @@ fn deduct_blocks() { Origin::signed(ALICE), 30_000, 100_000, HASH_SET_RENT.into(), - ::Balance::sa(1_000u64).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Check creation @@ -812,7 +812,7 @@ fn claim_surcharge(blocks: u64, trigger_call: impl Fn() -> bool, removes: bool) Origin::signed(ALICE), 100, 100_000, HASH_SET_RENT.into(), - ::Balance::sa(1_000u64).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Advance blocks @@ -848,7 +848,7 @@ fn removals(trigger_call: impl Fn() -> bool) { Origin::signed(ALICE), 100, 100_000, HASH_SET_RENT.into(), - ::Balance::sa(1_000u64).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Trigger rent must have no effect @@ -882,7 +882,7 @@ fn removals(trigger_call: impl Fn() -> bool) { Origin::signed(ALICE), 1_000, 100_000, HASH_SET_RENT.into(), - ::Balance::sa(100u64).encode() // rent allowance + ::Balance::from(100u32).encode() // rent allowance )); // Trigger rent must have no effect @@ -916,7 +916,7 @@ fn removals(trigger_call: impl Fn() -> bool) { Origin::signed(ALICE), 50+Balances::minimum_balance(), 100_000, HASH_SET_RENT.into(), - ::Balance::sa(1_000u64).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Trigger rent must have no effect diff --git a/srml/contract/src/wasm/code_cache.rs b/srml/contract/src/wasm/code_cache.rs index 0c71fe8cb5..da92272c38 100644 --- a/srml/contract/src/wasm/code_cache.rs +++ b/srml/contract/src/wasm/code_cache.rs @@ -29,7 +29,7 @@ use crate::gas::{GasMeter, Token}; use crate::wasm::{prepare, runtime::Env, PrefabWasmModule}; use crate::{CodeHash, CodeStorage, PristineCode, Schedule, Trait}; use rstd::prelude::*; -use runtime_primitives::traits::{As, CheckedMul, Hash, Bounded}; +use runtime_primitives::traits::{CheckedMul, Hash, Bounded}; use srml_support::StorageMap; /// Gas metering token that used for charging storing code into the code storage. @@ -37,16 +37,15 @@ use srml_support::StorageMap; /// Specifies the code length in bytes. #[cfg_attr(test, derive(Debug, PartialEq, Eq))] #[derive(Copy, Clone)] -pub struct PutCodeToken(u64); +pub struct PutCodeToken(u32); impl Token for PutCodeToken { type Metadata = Schedule; fn calculate_amount(&self, metadata: &Schedule) -> T::Gas { - let code_len_in_gas = >::sa(self.0); metadata .put_code_per_byte_cost - .checked_mul(&code_len_in_gas) + .checked_mul(&self.0.into()) .unwrap_or_else(|| Bounded::max_value()) } } @@ -63,7 +62,7 @@ pub fn save( // The first time instrumentation is on the user. However, consequent reinstrumentation // due to the schedule changes is on governance system. if gas_meter - .charge(schedule, PutCodeToken(original_code.len() as u64)) + .charge(schedule, PutCodeToken(original_code.len() as u32)) .is_out_of_gas() { return Err("there is not enough gas for storing the code"); diff --git a/srml/contract/src/wasm/env_def/macros.rs b/srml/contract/src/wasm/env_def/macros.rs index bfb42d19d0..32d02f5abe 100644 --- a/srml/contract/src/wasm/env_def/macros.rs +++ b/srml/contract/src/wasm/env_def/macros.rs @@ -195,7 +195,7 @@ macro_rules! define_env { mod tests { use parity_wasm::elements::FunctionType; use parity_wasm::elements::ValueType; - use runtime_primitives::traits::{As, Zero}; + use runtime_primitives::traits::Zero; use sandbox::{self, ReturnValue, TypedValue}; use crate::wasm::tests::MockExt; use crate::wasm::Runtime; @@ -256,7 +256,7 @@ mod tests { #[test] fn macro_define_func() { define_func!( ext_gas (_ctx, amount: u32) => { - let amount = <::Gas as As>::sa(amount); + let amount = ::Gas::from(amount); if !amount.is_zero() { Ok(()) } else { @@ -308,7 +308,7 @@ mod tests { define_env!(Env, , ext_gas( _ctx, amount: u32 ) => { - let amount = <::Gas as As>::sa(amount); + let amount = ::Gas::from(amount); if !amount.is_zero() { Ok(()) } else { diff --git a/srml/contract/src/wasm/prepare.rs b/srml/contract/src/wasm/prepare.rs index 94a38ef588..d780cc1a28 100644 --- a/srml/contract/src/wasm/prepare.rs +++ b/srml/contract/src/wasm/prepare.rs @@ -26,7 +26,7 @@ use parity_wasm::elements::{self, Internal, External, MemoryType, Type}; use pwasm_utils; use pwasm_utils::rules; use rstd::prelude::*; -use runtime_primitives::traits::As; +use runtime_primitives::traits::{UniqueSaturatedInto, SaturatedConversion}; struct ContractModule<'a, Gas: 'a> { /// A deserialized module. The module is valid (this is Guaranteed by `new` method). @@ -38,7 +38,7 @@ struct ContractModule<'a, Gas: 'a> { schedule: &'a Schedule, } -impl<'a, Gas: 'a + As + Clone> ContractModule<'a, Gas> { +impl<'a, Gas: 'a + From + UniqueSaturatedInto + Clone> ContractModule<'a, Gas> { /// Creates a new instance of `ContractModule`. /// /// Returns `Err` if the `original_code` couldn't be decoded or @@ -85,10 +85,10 @@ impl<'a, Gas: 'a + As + Clone> ContractModule<'a, Gas> { fn inject_gas_metering(&mut self) -> Result<(), &'static str> { let gas_rules = rules::Set::new( - self.schedule.regular_op_cost.clone().as_(), + self.schedule.regular_op_cost.clone().saturated_into(), Default::default(), ) - .with_grow_cost(self.schedule.grow_mem_cost.clone().as_()) + .with_grow_cost(self.schedule.grow_mem_cost.clone().saturated_into()) .with_forbidden_floats(); let module = self diff --git a/srml/contract/src/wasm/runtime.rs b/srml/contract/src/wasm/runtime.rs index 6327d8f2ce..b6f857269e 100644 --- a/srml/contract/src/wasm/runtime.rs +++ b/srml/contract/src/wasm/runtime.rs @@ -27,7 +27,7 @@ use system; use rstd::prelude::*; use rstd::mem; use parity_codec::{Decode, Encode}; -use runtime_primitives::traits::{As, CheckedMul, CheckedAdd, Bounded}; +use runtime_primitives::traits::{CheckedMul, CheckedAdd, Bounded, SaturatedConversion}; /// Enumerates all possible *special* trap conditions. /// @@ -122,24 +122,24 @@ impl Token for RuntimeToken { fn calculate_amount(&self, metadata: &Schedule) -> T::Gas { use self::RuntimeToken::*; let value = match *self { - Explicit(amount) => Some(>::sa(amount)), + Explicit(amount) => Some(amount.into()), ReadMemory(byte_count) => metadata .sandbox_data_read_cost - .checked_mul(&>::sa(byte_count)), + .checked_mul(&byte_count.into()), WriteMemory(byte_count) => metadata .sandbox_data_write_cost - .checked_mul(&>::sa(byte_count)), + .checked_mul(&byte_count.into()), ReturnData(byte_count) => metadata .return_data_per_byte_cost - .checked_mul(&>::sa(byte_count)), + .checked_mul(&byte_count.into()), DepositEvent(topic_count, data_byte_count) => { let data_cost = metadata .event_data_per_byte_cost - .checked_mul(&>::sa(data_byte_count)); + .checked_mul(&data_byte_count.into()); let topics_cost = metadata .event_per_topic_cost - .checked_mul(&>::sa(topic_count)); + .checked_mul(&topic_count.into()); data_cost .and_then(|data_cost| { @@ -340,7 +340,7 @@ define_env!(Env, , let nested_gas_limit = if gas == 0 { ctx.gas_meter.gas_left() } else { - <::Gas as As>::sa(gas) + gas.saturated_into() }; let ext = &mut ctx.ext; let call_outcome = ctx.gas_meter.with_nested(nested_gas_limit, |nested_meter| { @@ -413,7 +413,7 @@ define_env!(Env, , let nested_gas_limit = if gas == 0 { ctx.gas_meter.gas_left() } else { - <::Gas as As>::sa(gas) + gas.saturated_into() }; let ext = &mut ctx.ext; let instantiate_outcome = ctx.gas_meter.with_nested(nested_gas_limit, |nested_meter| { @@ -535,8 +535,7 @@ define_env!(Env, , // Load the latest block timestamp into the scratch buffer ext_now(ctx) => { - let now: u64 = As::as_(ctx.ext.now().clone()); - ctx.scratch_buf = now.encode(); + ctx.scratch_buf = ctx.ext.now().encode(); Ok(()) }, diff --git a/srml/council/src/seats.rs b/srml/council/src/seats.rs index 9ace6227da..fb93157981 100644 --- a/srml/council/src/seats.rs +++ b/srml/council/src/seats.rs @@ -17,7 +17,7 @@ //! Council system: Handles the voting in and maintenance of council members. use rstd::prelude::*; -use primitives::traits::{Zero, One, As, StaticLookup}; +use primitives::traits::{Zero, One, StaticLookup}; use runtime_io::print; use srml_support::{ StorageValue, StorageMap, dispatch::Result, decl_storage, decl_event, ensure, @@ -230,7 +230,7 @@ decl_module! { let (_, _, expiring) = Self::next_finalize().ok_or("cannot present outside of presentation period")?; let stakes = Self::snapshoted_stakes(); let voters = Self::voters(); - let bad_presentation_punishment = Self::present_slash_per_voter() * BalanceOf::::sa(voters.len() as u64); + let bad_presentation_punishment = Self::present_slash_per_voter() * BalanceOf::::from(voters.len() as u32); ensure!(T::Currency::can_slash(&who, bad_presentation_punishment), "presenter must have sufficient slashable funds"); let mut leaderboard = Self::leaderboard().ok_or("leaderboard must exist while present phase active")?; @@ -313,22 +313,22 @@ decl_storage! { // parameters /// How much should be locked up in order to submit one's candidacy. - pub CandidacyBond get(candidacy_bond) config(): BalanceOf = BalanceOf::::sa(9); + pub CandidacyBond get(candidacy_bond) config(): BalanceOf = 9.into(); /// How much should be locked up in order to be able to submit votes. pub VotingBond get(voting_bond) config(voter_bond): BalanceOf; /// The punishment, per voter, if you provide an invalid presentation. - pub PresentSlashPerVoter get(present_slash_per_voter) config(): BalanceOf = BalanceOf::::sa(1); + pub PresentSlashPerVoter get(present_slash_per_voter) config(): BalanceOf = 1.into(); /// How many runners-up should have their approvals persist until the next vote. pub CarryCount get(carry_count) config(): u32 = 2; /// How long to give each top candidate to present themselves after the vote ends. - pub PresentationDuration get(presentation_duration) config(): T::BlockNumber = T::BlockNumber::sa(1000); + pub PresentationDuration get(presentation_duration) config(): T::BlockNumber = 1000.into(); /// How many vote indexes need to go by after a target voter's last vote before they can be reaped if their /// approvals are moot. pub InactiveGracePeriod get(inactivity_grace_period) config(inactive_grace_period): VoteIndex = 1; /// How often (in blocks) to check for new votes. - pub VotingPeriod get(voting_period) config(approval_voting_period): T::BlockNumber = T::BlockNumber::sa(1000); + pub VotingPeriod get(voting_period) config(approval_voting_period): T::BlockNumber = 1000.into(); /// How long each position is active for. - pub TermDuration get(term_duration) config(): T::BlockNumber = T::BlockNumber::sa(5); + pub TermDuration get(term_duration) config(): T::BlockNumber = 5.into(); /// Number of accounts that should be sitting on the council. pub DesiredSeats get(desired_seats) config(): u32; diff --git a/srml/council/src/voting.rs b/srml/council/src/voting.rs index 22b4b9639c..0137cd6d2f 100644 --- a/srml/council/src/voting.rs +++ b/srml/council/src/voting.rs @@ -18,7 +18,7 @@ use rstd::prelude::*; use rstd::borrow::Borrow; -use primitives::traits::{Hash, As, Zero}; +use primitives::traits::{Hash, Zero}; use runtime_io::print; use srml_support::dispatch::Result; use srml_support::{StorageValue, StorageMap, IsSubType, decl_module, decl_storage, decl_event, ensure}; @@ -113,10 +113,10 @@ decl_module! { decl_storage! { trait Store for Module as CouncilVoting { - pub CooloffPeriod get(cooloff_period) config(): T::BlockNumber = T::BlockNumber::sa(1000); - pub VotingPeriod get(voting_period) config(): T::BlockNumber = T::BlockNumber::sa(3); + pub CooloffPeriod get(cooloff_period) config(): T::BlockNumber = 1000.into(); + pub VotingPeriod get(voting_period) config(): T::BlockNumber = 3.into(); /// Number of blocks by which to delay enactment of successful, non-unanimous-council-instigated referendum proposals. - pub EnactDelayPeriod get(enact_delay_period) config(): T::BlockNumber = T::BlockNumber::sa(0); + pub EnactDelayPeriod get(enact_delay_period) config(): T::BlockNumber = 0.into(); pub Proposals get(proposals) build(|_| vec![]): Vec<(T::BlockNumber, T::Hash)>; // ordered by expiry. pub ProposalOf get(proposal_of): map T::Hash => Option; pub ProposalVoters get(proposal_voters): map T::Hash => Vec; diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index b72a3add2e..c2a9b849f6 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -20,7 +20,7 @@ use rstd::prelude::*; use rstd::result; -use primitives::traits::{Zero, As, Bounded}; +use primitives::traits::{Zero, Bounded}; use parity_codec::{Encode, Decode}; use srml_support::{StorageValue, StorageMap, Parameter, Dispatchable, IsSubType, EnumerableStorageMap}; use srml_support::{decl_module, decl_storage, decl_event, ensure}; @@ -196,7 +196,7 @@ decl_module! { // Indefinite lock is reduced to the maximum voting lock that could be possible. let lock_period = Self::public_delay(); let now = >::block_number(); - let locked_until = now + lock_period * T::BlockNumber::sa(d.1 as u64); + let locked_until = now + lock_period * (d.1 as u32).into(); T::Currency::set_lock(DEMOCRACY_ID, &who, Bounded::max_value(), locked_until, WithdrawReason::Transfer.into()); Self::deposit_event(RawEvent::Undelegated(who)); } @@ -234,7 +234,7 @@ decl_storage! { /// Those who have locked a deposit. pub DepositOf get(deposit_of): map PropIndex => Option<(BalanceOf, Vec)>; /// How often (in blocks) new public referenda are launched. - pub LaunchPeriod get(launch_period) config(): T::BlockNumber = T::BlockNumber::sa(1000); + pub LaunchPeriod get(launch_period) config(): T::BlockNumber = 1000.into(); /// The minimum amount to be used as a deposit for a public referendum proposal. pub MinimumDeposit get(minimum_deposit) config(): BalanceOf; /// The delay before enactment for all public referenda. @@ -243,7 +243,7 @@ decl_storage! { pub MaxLockPeriods get(max_lock_periods) config(): LockPeriods; /// How often (in blocks) to check for new votes. - pub VotingPeriod get(voting_period) config(): T::BlockNumber = T::BlockNumber::sa(1000); + pub VotingPeriod get(voting_period) config(): T::BlockNumber = 1000.into(); /// The next free referendum index, aka the number of referenda started so far. pub ReferendumCount get(referendum_count) build(|_| 0 as ReferendumIndex): ReferendumIndex; @@ -290,7 +290,7 @@ impl Module { /// Get the amount locked in support of `proposal`; `None` if proposal isn't a valid proposal /// index. pub fn locked_for(proposal: PropIndex) -> Option> { - Self::deposit_of(proposal).map(|(d, l)| d * BalanceOf::::sa(l.len() as u64)) + Self::deposit_of(proposal).map(|(d, l)| d * (l.len() as u32).into()) } /// Return true if `ref_index` is an on-going referendum. @@ -325,9 +325,9 @@ impl Module { )) .map(|(bal, vote)| if vote.is_aye() { - (bal * BalanceOf::::sa(vote.multiplier() as u64), Zero::zero(), bal) + (bal * (vote.multiplier() as u32).into(), Zero::zero(), bal) } else { - (Zero::zero(), bal * BalanceOf::::sa(vote.multiplier() as u64), bal) + (Zero::zero(), bal * (vote.multiplier() as u32).into(), bal) } ).fold((Zero::zero(), Zero::zero(), Zero::zero()), |(a, b, c), (d, e, f)| (a + d, b + e, c + f)); let (del_approve, del_against, del_capital) = Self::tally_delegation(ref_index); @@ -361,7 +361,7 @@ impl Module { .fold((Zero::zero(), Zero::zero()), |(votes_acc, balance_acc), (delegator, (_delegate, periods))| { let lock_periods = if min_lock_periods <= periods { min_lock_periods } else { periods }; let balance = T::Currency::total_balance(&delegator); - let votes = T::Currency::total_balance(&delegator) * BalanceOf::::sa(lock_periods as u64); + let votes = T::Currency::total_balance(&delegator) * (lock_periods as u32).into(); let (del_votes, del_balance) = Self::delegated_votes(ref_index, delegator, lock_periods, recursion_limit - 1); (votes_acc + votes + del_votes, balance_acc + balance + del_balance) }) @@ -469,7 +469,7 @@ impl Module { { // now plus: the base lock period multiplied by the number of periods this voter offered to // lock should they win... - let locked_until = now + lock_period * T::BlockNumber::sa((vote.multiplier()) as u64); + let locked_until = now + lock_period * (vote.multiplier() as u32).into(); // ...extend their bondage until at least then. T::Currency::extend_lock(DEMOCRACY_ID, &a, Bounded::max_value(), locked_until, WithdrawReason::Transfer.into()); } diff --git a/srml/finality-tracker/src/lib.rs b/srml/finality-tracker/src/lib.rs index 91beefa66b..2276ad3155 100644 --- a/srml/finality-tracker/src/lib.rs +++ b/srml/finality-tracker/src/lib.rs @@ -26,7 +26,7 @@ use inherents::{ InherentData, MakeFatalError, }; use srml_support::StorageValue; -use primitives::traits::{As, One, Zero}; +use primitives::traits::{One, Zero, SaturatedConversion}; use rstd::{prelude::*, result, cmp, vec}; use parity_codec::Decode; use srml_system::{ensure_none, Trait as SystemTrait}; @@ -34,8 +34,8 @@ use srml_system::{ensure_none, Trait as SystemTrait}; #[cfg(feature = "std")] use parity_codec::Encode; -const DEFAULT_WINDOW_SIZE: u64 = 101; -const DEFAULT_DELAY: u64 = 1000; +const DEFAULT_WINDOW_SIZE: u32 = 101; +const DEFAULT_DELAY: u32 = 1000; /// The identifier for the `finalnum` inherent. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"finalnum"; @@ -100,9 +100,9 @@ decl_storage! { /// The median. Median get(median) build(|_| T::BlockNumber::zero()): T::BlockNumber; /// The number of recent samples to keep from this chain. Default is n-100 - pub WindowSize get(window_size) config(window_size): T::BlockNumber = T::BlockNumber::sa(DEFAULT_WINDOW_SIZE); + pub WindowSize get(window_size) config(window_size): T::BlockNumber = DEFAULT_WINDOW_SIZE.into(); /// The delay after which point things become suspicious. - pub ReportLatency get(report_latency) config(report_latency): T::BlockNumber = T::BlockNumber::sa(DEFAULT_DELAY); + pub ReportLatency get(report_latency) config(report_latency): T::BlockNumber = DEFAULT_DELAY.into(); /// Final hint to apply in the block. `None` means "same as parent". Update: Option; @@ -154,7 +154,7 @@ impl Module { // the sample size has just been shrunk. { // take into account the item we haven't pushed yet. - let to_prune = (recent.len() + 1).saturating_sub(window_size.as_() as usize); + let to_prune = (recent.len() + 1).saturating_sub(window_size.saturated_into::()); for drained in recent.drain(..to_prune) { let idx = ordered.binary_search(&drained) @@ -188,13 +188,13 @@ impl Module { } }; - let our_window_size = recent.len(); + let our_window_size = recent.len() as u32; ::RecentHints::put(recent); ::OrderedHints::put(ordered); ::Median::put(median); - if T::BlockNumber::sa(our_window_size as u64) == window_size { + if T::BlockNumber::from(our_window_size) == window_size { let now = srml_system::Module::::block_number(); let latency = Self::report_latency(); diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index e9886eddb1..5425ace8bb 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -275,8 +275,6 @@ impl Module { in_blocks: T::BlockNumber, forced: Option, ) -> Result { - use primitives::traits::As; - if Self::pending_change().is_none() { let scheduled_at = system::ChainContext::::default().current_height(); @@ -287,7 +285,7 @@ impl Module { // only allow the next forced change when twice the window has passed since // this one. - >::put(scheduled_at + in_blocks * T::BlockNumber::sa(2)); + >::put(scheduled_at + in_blocks * 2.into()); } >::put(StoredPendingChange { diff --git a/srml/indices/src/address.rs b/srml/indices/src/address.rs index c7709e3bec..123b8bca89 100644 --- a/srml/indices/src/address.rs +++ b/srml/indices/src/address.rs @@ -18,7 +18,8 @@ #[cfg(feature = "std")] use std::fmt; -use crate::{Member, Decode, Encode, As, Input, Output}; +use rstd::convert::TryInto; +use crate::{Member, Decode, Encode, Input, Output}; /// An indices-aware address, which can be either a direct `AccountId` or /// an index. @@ -59,14 +60,20 @@ fn need_more_than(a: T, b: T) -> Option { impl Decode for Address where AccountId: Member + Decode, - AccountIndex: Member + Decode + PartialOrd + Ord + As + As + As + Copy, + AccountIndex: Member + Decode + PartialOrd + Ord + From + Copy, { fn decode(input: &mut I) -> Option { Some(match input.read_byte()? { - x @ 0x00...0xef => Address::Index(As::sa(x)), - 0xfc => Address::Index(As::sa(need_more_than(0xef, u16::decode(input)?)?)), - 0xfd => Address::Index(As::sa(need_more_than(0xffff, u32::decode(input)?)?)), - 0xfe => Address::Index(need_more_than(As::sa(0xffffffffu32), Decode::decode(input)?)?), + x @ 0x00...0xef => Address::Index(AccountIndex::from(x as u32)), + 0xfc => Address::Index(AccountIndex::from( + need_more_than(0xef, u16::decode(input)?)? as u32 + )), + 0xfd => Address::Index(AccountIndex::from( + need_more_than(0xffff, u32::decode(input)?)? + )), + 0xfe => Address::Index( + need_more_than(0xffffffffu32.into(), Decode::decode(input)?)? + ), 0xff => Address::Id(Decode::decode(input)?), _ => return None, }) @@ -75,7 +82,7 @@ impl Decode for Address where impl Encode for Address where AccountId: Member + Encode, - AccountIndex: Member + Encode + PartialOrd + Ord + As + As + As + Copy, + AccountIndex: Member + Encode + PartialOrd + Ord + Copy + From + TryInto, { fn encode_to(&self, dest: &mut T) { match *self { @@ -83,19 +90,26 @@ impl Encode for Address where dest.push_byte(255); dest.push(i); } - Address::Index(i) if i > As::sa(0xffffffffu32) => { - dest.push_byte(254); - dest.push(&i); - } - Address::Index(i) if i > As::sa(0xffffu32) => { - dest.push_byte(253); - dest.push(&As::::as_(i)); - } - Address::Index(i) if i >= As::sa(0xf0u32) => { - dest.push_byte(252); - dest.push(&As::::as_(i)); - } - Address::Index(i) => dest.push_byte(As::::as_(i)), + Address::Index(i) => { + let maybe_u32: Result = i.try_into(); + if let Ok(x) = maybe_u32 { + if x > 0xffff { + dest.push_byte(253); + dest.push(&x); + } + else if x >= 0xf0 { + dest.push_byte(252); + dest.push(&(x as u16)); + } + else { + dest.push_byte(x as u8); + } + + } else { + dest.push_byte(254); + dest.push(&i); + } + }, } } } diff --git a/srml/indices/src/lib.rs b/srml/indices/src/lib.rs index 4a6010f800..509e5c1133 100644 --- a/srml/indices/src/lib.rs +++ b/srml/indices/src/lib.rs @@ -19,10 +19,10 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{prelude::*, result, marker::PhantomData}; +use rstd::{prelude::*, result, marker::PhantomData, convert::TryInto}; use parity_codec::{Encode, Decode, Codec, Input, Output}; use srml_support::{StorageValue, StorageMap, Parameter, decl_module, decl_event, decl_storage}; -use primitives::traits::{One, SimpleArithmetic, As, StaticLookup, Member}; +use primitives::traits::{One, SimpleArithmetic, StaticLookup, Member}; use system::{IsDeadAccount, OnNewAccount}; use self::address::Address as RawAddress; @@ -33,13 +33,13 @@ pub mod address; mod tests; /// Number of account IDs stored per enum set. -const ENUM_SET_SIZE: usize = 64; +const ENUM_SET_SIZE: u32 = 64; pub type Address = RawAddress<::AccountId, ::AccountIndex>; /// Turn an Id into an Index, or None for the purpose of getting /// a hint at a possibly desired index. -pub trait ResolveHint> { +pub trait ResolveHint { /// Turn an Id into an Index, or None for the purpose of getting /// a hint at a possibly desired index. fn resolve_hint(who: &AccountId) -> Option; @@ -47,9 +47,11 @@ pub trait ResolveHint> { /// Simple encode-based resolve hint implemenntation. pub struct SimpleResolveHint(PhantomData<(AccountId, AccountIndex)>); -impl> ResolveHint for SimpleResolveHint { +impl> + ResolveHint for SimpleResolveHint +{ fn resolve_hint(who: &AccountId) -> Option { - Some(AccountIndex::sa(who.using_encoded(|e| e[0] as usize + e[1] as usize * 256))) + Some(AccountIndex::from(who.using_encoded(|e| e[0] as u32 + e[1] as u32 * 256))) } } @@ -57,7 +59,7 @@ impl> ResolveHint + As + As + As + As + Copy; + type AccountIndex: Parameter + Member + Codec + Default + SimpleArithmetic + Copy; /// Whether an account is dead or not. type IsDeadAccount: IsDeadAccount; @@ -92,15 +94,18 @@ decl_storage! { trait Store for Module as Indices { /// The next free enumeration set. pub NextEnumSet get(next_enum_set) build(|config: &GenesisConfig| { - T::AccountIndex::sa(config.ids.len() / ENUM_SET_SIZE) + (config.ids.len() as u32 / ENUM_SET_SIZE).into() }): T::AccountIndex; /// The enumeration sets. pub EnumSet get(enum_set) build(|config: &GenesisConfig| { - (0..(config.ids.len() + ENUM_SET_SIZE - 1) / ENUM_SET_SIZE) + (0..((config.ids.len() as u32) + ENUM_SET_SIZE - 1) / ENUM_SET_SIZE) .map(|i| ( - T::AccountIndex::sa(i), - config.ids[i * ENUM_SET_SIZE..config.ids.len().min((i + 1) * ENUM_SET_SIZE)].to_owned(), + i.into(), + config.ids[ + (i * ENUM_SET_SIZE) as usize.. + config.ids.len().min(((i + 1) * ENUM_SET_SIZE) as usize) + ].to_owned(), )) .collect::>() }): map T::AccountIndex => Vec; @@ -117,7 +122,7 @@ impl Module { pub fn lookup_index(index: T::AccountIndex) -> Option { let enum_set_size = Self::enum_set_size(); let set = Self::enum_set(index / enum_set_size); - let i: usize = (index % enum_set_size).as_(); + let i: usize = (index % enum_set_size).try_into().ok()?; set.get(i).cloned() } @@ -125,12 +130,18 @@ impl Module { pub fn can_reclaim(try_index: T::AccountIndex) -> bool { let enum_set_size = Self::enum_set_size(); let try_set = Self::enum_set(try_index / enum_set_size); - let i = (try_index % enum_set_size).as_(); - i < try_set.len() && T::IsDeadAccount::is_dead_account(&try_set[i]) + let maybe_usize: Result = (try_index % enum_set_size).try_into(); + if let Ok(i) = maybe_usize { + i < try_set.len() && T::IsDeadAccount::is_dead_account(&try_set[i]) + } else { + false + } } /// Lookup an address to get an Id, if there's one there. - pub fn lookup_address(a: address::Address) -> Option { + pub fn lookup_address( + a: address::Address + ) -> Option { match a { address::Address::Id(i) => Some(i), address::Address::Index(i) => Self::lookup_index(i), @@ -140,7 +151,7 @@ impl Module { // PUBLIC MUTABLES (DANGEROUS) fn enum_set_size() -> T::AccountIndex { - T::AccountIndex::sa(ENUM_SET_SIZE) + ENUM_SET_SIZE.into() } } @@ -153,36 +164,38 @@ impl OnNewAccount for Module { // then check to see if this account id identifies a dead account index. let set_index = try_index / enum_set_size; let mut try_set = Self::enum_set(set_index); - let item_index = (try_index % enum_set_size).as_(); - if item_index < try_set.len() { - if T::IsDeadAccount::is_dead_account(&try_set[item_index]) { - // yup - this index refers to a dead account. can be reused. - try_set[item_index] = who.clone(); - >::insert(set_index, try_set); - - return + if let Ok(item_index) = (try_index % enum_set_size).try_into() { + if item_index < try_set.len() { + if T::IsDeadAccount::is_dead_account(&try_set[item_index]) { + // yup - this index refers to a dead account. can be reused. + try_set[item_index] = who.clone(); + >::insert(set_index, try_set); + + return + } } } } // insert normally as a back up let mut set_index = next_set_index; - // defensive only: this loop should never iterate since we keep NextEnumSet up to date later. + // defensive only: this loop should never iterate since we keep NextEnumSet up to date + // later. let mut set = loop { let set = Self::enum_set(set_index); - if set.len() < ENUM_SET_SIZE { + if set.len() < ENUM_SET_SIZE as usize { break set; } set_index += One::one(); }; - let index = T::AccountIndex::sa(set_index.as_() * ENUM_SET_SIZE + set.len()); + let index = set_index * enum_set_size + T::AccountIndex::from(set.len() as u32); // update set. set.push(who.clone()); // keep NextEnumSet up to date - if set.len() == ENUM_SET_SIZE { + if set.len() == ENUM_SET_SIZE as usize { >::put(set_index + One::one()); } diff --git a/srml/session/src/lib.rs b/srml/session/src/lib.rs index 255bb4f647..d13795e4bb 100644 --- a/srml/session/src/lib.rs +++ b/srml/session/src/lib.rs @@ -116,7 +116,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::prelude::*; -use primitives::traits::{As, Zero, One, Convert}; +use primitives::traits::{Zero, One, Convert}; use srml_support::{StorageValue, StorageMap, for_each_tuple, decl_module, decl_event, decl_storage}; use srml_support::{dispatch::Result, traits::OnFreeBalanceZero}; use system::ensure_signed; @@ -200,9 +200,9 @@ decl_storage! { /// The current set of validators. pub Validators get(validators) config(): Vec; /// Current length of the session. - pub SessionLength get(length) config(session_length): T::BlockNumber = T::BlockNumber::sa(1000); + pub SessionLength get(length) config(session_length): T::BlockNumber = 1000.into(); /// Current index of the session. - pub CurrentIndex get(current_index) build(|_| T::BlockNumber::sa(0)): T::BlockNumber; + pub CurrentIndex get(current_index) build(|_| 0.into()): T::BlockNumber; /// Timestamp when current session started. pub CurrentStart get(current_start) build(|_| T::Moment::zero()): T::Moment; diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 93bd941092..1901752666 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -247,7 +247,10 @@ use srml_support::traits::{ }; use session::OnSessionChange; use primitives::Perbill; -use primitives::traits::{Convert, Zero, One, As, StaticLookup, CheckedSub, CheckedShl, Saturating, Bounded}; +use primitives::traits::{ + Convert, Zero, One, StaticLookup, CheckedSub, CheckedShl, Saturating, + Bounded, SaturatedConversion +}; #[cfg(feature = "std")] use primitives::{Serialize, Deserialize}; use system::ensure_signed; @@ -396,7 +399,7 @@ type NegativeImbalanceOf = <::Currency as Currency< = (::AccountId, ExtendedBalance); type Assignment = (::AccountId, ExtendedBalance, BalanceOf); -type ExpoMap = BTreeMap::<::AccountId, Exposure<::AccountId, BalanceOf>>; +type ExpoMap = BTreeMap<::AccountId, Exposure<::AccountId, BalanceOf>>; pub trait Trait: system::Trait + session::Trait { /// The staking balance. @@ -432,7 +435,7 @@ decl_storage! { /// Minimum number of staking participants before emergency conditions are imposed. pub MinimumValidatorCount get(minimum_validator_count) config(): u32 = DEFAULT_MINIMUM_VALIDATOR_COUNT; /// The length of a staking era in sessions. - pub SessionsPerEra get(sessions_per_era) config(): T::BlockNumber = T::BlockNumber::sa(1000); + pub SessionsPerEra get(sessions_per_era) config(): T::BlockNumber = 1000.into(); /// Maximum reward, per validator, that is provided per acceptable session. pub SessionReward get(session_reward) config(): Perbill = Perbill::from_parts(60); /// Slash, per validator that is taken for the first time they are found to be offline. @@ -440,7 +443,7 @@ decl_storage! { /// Number of instances of offline reports before slashing begins for validators. pub OfflineSlashGrace get(offline_slash_grace) config(): u32; /// The length of the bonding duration in eras. - pub BondingDuration get(bonding_duration) config(): T::BlockNumber = T::BlockNumber::sa(12); + pub BondingDuration get(bonding_duration) config(): T::BlockNumber = 12.into(); /// Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize /// and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets. @@ -867,8 +870,12 @@ impl Module { if ideal_elapsed.is_zero() { return Self::current_session_reward(); } - let per65536: u64 = (T::Moment::sa(65536u64) * ideal_elapsed.clone() / actual_elapsed.max(ideal_elapsed)).as_(); - Self::current_session_reward() * >::sa(per65536) / >::sa(65536u64) + // Assumes we have 16-bits free at the top of T::Moment. Holds true for moment as seconds + // in a u64 for the forseeable future, but more correct would be to handle overflows + // explicitly. + let per65536 = T::Moment::from(65536) * ideal_elapsed.clone() / actual_elapsed.max(ideal_elapsed); + let per65536: BalanceOf = per65536.saturated_into::().into(); + Self::current_session_reward() * per65536 / 65536.into() } /// Session has just changed. We need to determine whether we pay a reward, slash and/or @@ -901,8 +908,8 @@ impl Module { Self::reward_validator(v, reward); } Self::deposit_event(RawEvent::Reward(reward)); - let len = validators.len() as u64; // validators length can never overflow u64 - let len = BalanceOf::::sa(len); + let len = validators.len() as u32; // validators length can never overflow u64 + let len: BalanceOf = len.into(); let total_minted = reward * len; let total_rewarded_stake = Self::slot_stake() * len; T::OnRewardMinted::on_dilution(total_minted, total_rewarded_stake); diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index b009785011..9018b109e8 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -77,8 +77,8 @@ use rstd::prelude::*; #[cfg(any(feature = "std", test))] use rstd::map; use primitives::traits::{self, CheckEqual, SimpleArithmetic, SimpleBitOps, One, Bounded, Lookup, - Hash, Member, MaybeDisplay, EnsureOrigin, Digest as DigestT, As, CurrentHeight, BlockNumberToHash, - MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup + Hash, Member, MaybeDisplay, EnsureOrigin, Digest as DigestT, CurrentHeight, BlockNumberToHash, + MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup, SaturatedConversion }; #[cfg(any(feature = "std", test))] use primitives::traits::Zero; @@ -311,7 +311,7 @@ decl_storage! { /// ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash. RandomMaterial get(random_material): (i8, Vec); /// The current block number being processed. Set by `execute_block`. - Number get(block_number) build(|_| T::BlockNumber::sa(1u64)): T::BlockNumber; + Number get(block_number) build(|_| 1.into()): T::BlockNumber; /// Hash of the previous block. ParentHash get(parent_hash) build(|_| hash69()): T::Hash; /// Extrinsics root of the current block, also part of the block header. @@ -493,7 +493,8 @@ impl Module { let mut digest = >::take(); let extrinsics_root = >::take(); let storage_root = T::Hashing::storage_root(); - let storage_changes_root = T::Hashing::storage_changes_root(parent_hash, number.as_() - 1); + let number_u64 = number.saturated_into::(); + let storage_changes_root = T::Hashing::storage_changes_root(parent_hash, number_u64 - 1); // we can't compute changes trie root earlier && put it to the Digest // because it will include all currently existing temporaries. diff --git a/srml/timestamp/src/lib.rs b/srml/timestamp/src/lib.rs index bc998a8539..24750215d1 100644 --- a/srml/timestamp/src/lib.rs +++ b/srml/timestamp/src/lib.rs @@ -87,6 +87,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +use rstd::{result, ops::{Mul, Div}, cmp}; use parity_codec::Encode; #[cfg(feature = "std")] use parity_codec::Decode; @@ -94,9 +95,8 @@ use parity_codec::Decode; use inherents::ProvideInherentData; use srml_support::{StorageValue, Parameter, decl_storage, decl_module}; use srml_support::for_each_tuple; -use runtime_primitives::traits::{As, SimpleArithmetic, Zero}; +use runtime_primitives::traits::{SimpleArithmetic, Zero, SaturatedConversion}; use system::ensure_none; -use rstd::{result, ops::{Mul, Div}, cmp}; use inherents::{RuntimeString, InherentIdentifier, ProvideInherent, IsFatalError, InherentData}; /// The identifier for the `timestamp` inherent. @@ -252,7 +252,7 @@ decl_module! { decl_storage! { trait Store for Module as Timestamp { /// Current time for the current block. - pub Now get(now) build(|_| T::Moment::sa(0)): T::Moment; + pub Now get(now) build(|_| 0.into()): T::Moment; /// Old storage item provided for compatibility. Remove after all networks upgraded. // TODO: #2133 @@ -262,7 +262,7 @@ decl_storage! { /// that the block production apparatus provides. Your chosen consensus system will generally /// work with this to determine a sensible block time. e.g. For Aura, it will be double this /// period on default settings. - pub MinimumPeriod get(minimum_period) config(): T::Moment = T::Moment::sa(3); + pub MinimumPeriod get(minimum_period) config(): T::Moment = 3.into(); /// Did the timestamp get updated in this block? DidUpdate: bool; @@ -297,23 +297,25 @@ impl ProvideInherent for Module { const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; fn create_inherent(data: &InherentData) -> Option { - let data = extract_inherent_data(data).expect("Gets and decodes timestamp inherent data"); + let data: T::Moment = extract_inherent_data(data) + .expect("Gets and decodes timestamp inherent data") + .saturated_into(); - let next_time = cmp::max(As::sa(data), Self::now() + >::get()); + let next_time = cmp::max(data, Self::now() + >::get()); Some(Call::set(next_time.into())) } fn check_inherent(call: &Self::Call, data: &InherentData) -> result::Result<(), Self::Error> { const MAX_TIMESTAMP_DRIFT: u64 = 60; - let t = match call { - Call::set(ref t) => t.clone(), + let t: u64 = match call { + Call::set(ref t) => t.clone().saturated_into::(), _ => return Ok(()), - }.as_(); + }; let data = extract_inherent_data(data).map_err(|e| InherentError::Other(e))?; - let minimum = (Self::now() + >::get()).as_(); + let minimum = (Self::now() + >::get()).saturated_into::(); if t > data + MAX_TIMESTAMP_DRIFT { Err(InherentError::Other("Timestamp too far in future to accept".into())) } else if t < minimum { -- GitLab From fec0e46bbf16f6f140d9221c43957114db7c094a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 23 May 2019 10:44:36 +0200 Subject: [PATCH 014/113] Remove TaskExecutor from the API of the informant (#2642) * Remove TaskExecutor from the API of the informant * Fix node-template --- core/cli/src/informant.rs | 11 +++++++++-- node-template/src/cli.rs | 4 ++-- node/cli/src/lib.rs | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/cli/src/informant.rs b/core/cli/src/informant.rs index dd0237b7f8..5c60229fab 100644 --- a/core/cli/src/informant.rs +++ b/core/cli/src/informant.rs @@ -32,9 +32,16 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Header, SaturatedConversion}; /// Spawn informant on the event loop +#[deprecated(note = "Please use informant::build instead, and then create the task manually")] pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExecutor) where C: Components, { + handle.spawn(exit.until(build(service)).map(|_| ())); +} + +/// Creates an informant in the form of a `Future` that must be polled regularly. +pub fn build(service: &Service) -> impl Future +where C: Components { let network = service.network(); let client = service.client(); let txpool = service.transaction_pool(); @@ -156,8 +163,8 @@ pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExe Ok(()) }); - let informant_work = display_notifications.join3(display_block_import, display_txpool_import); - handle.spawn(exit.until(informant_work).map(|_| ())); + display_notifications.join3(display_block_import, display_txpool_import) + .map(|((), (), ())| ()) } fn speed(best_number: u64, last_number: Option, last_update: time::Instant) -> String { diff --git a/node-template/src/cli.rs b/node-template/src/cli.rs index f41674631e..cd148f3462 100644 --- a/node-template/src/cli.rs +++ b/node-template/src/cli.rs @@ -61,8 +61,8 @@ fn run_until_exit( { let (exit_send, exit) = exit_future::signal(); - let executor = runtime.executor(); - informant::start(&service, exit.clone(), executor.clone()); + let informant = informant::build(&service); + runtime.executor().spawn(exit.until(informant).map(|_| ())); let _ = runtime.block_on(e.into_exit()); exit_send.fire(); diff --git a/node/cli/src/lib.rs b/node/cli/src/lib.rs index cbb0628a91..886c6eef77 100644 --- a/node/cli/src/lib.rs +++ b/node/cli/src/lib.rs @@ -118,8 +118,8 @@ fn run_until_exit( { let (exit_send, exit) = exit_future::signal(); - let executor = runtime.executor(); - cli::informant::start(&service, exit.clone(), executor.clone()); + let informant = cli::informant::build(&service); + runtime.executor().spawn(exit.until(informant).map(|_| ())); let _ = runtime.block_on(e.into_exit()); exit_send.fire(); -- GitLab From 25558a732fe59c9c71c9b91ecfdf54691fa9e0e7 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 23 May 2019 11:06:38 +0200 Subject: [PATCH 015/113] Make info! string less ambiguous (#2661) --- core/network-libp2p/src/behaviour.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/network-libp2p/src/behaviour.rs b/core/network-libp2p/src/behaviour.rs index b0eb1a66eb..a180a34064 100644 --- a/core/network-libp2p/src/behaviour.rs +++ b/core/network-libp2p/src/behaviour.rs @@ -355,7 +355,7 @@ where fn inject_new_external_addr(&mut self, addr: &Multiaddr) { let new_addr = addr.clone() .with(Protocol::P2p(self.local_peer_id.clone().into())); - info!(target: "sub-libp2p", "Discovered external node address: {}", new_addr); + info!(target: "sub-libp2p", "Discovered new external address for our node: {}", new_addr); } fn inject_expired_listen_addr(&mut self, addr: &Multiaddr) { -- GitLab From da947ac95def499c2d731b3a3dfe3f8662477d10 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Thu, 23 May 2019 11:08:20 +0200 Subject: [PATCH 016/113] get rid of refcell, use &mut storage (#2659) --- srml/support/procedural/src/storage/impls.rs | 32 +++++------ .../procedural/src/storage/transformation.rs | 11 ++-- srml/support/src/storage/hashed/generator.rs | 44 +++++++-------- srml/support/src/storage/mod.rs | 54 +++++++++---------- srml/support/src/storage/storage_items.rs | 42 +++++++-------- .../support/src/storage/unhashed/generator.rs | 50 ++++++++--------- 6 files changed, 114 insertions(+), 119 deletions(-) diff --git a/srml/support/procedural/src/storage/impls.rs b/srml/support/procedural/src/storage/impls.rs index 39d16edd91..720ed21c24 100644 --- a/srml/support/procedural/src/storage/impls.rs +++ b/srml/support/procedural/src/storage/impls.rs @@ -116,13 +116,13 @@ impl<'a, I: Iterator> Impls<'a, I> { } /// Take a value from storage, removing it afterwards. - fn take>(storage: &S) -> Self::Query { + fn take>(storage: &mut S) -> Self::Query { storage.take(>::key()) .#option_simple_1(|| #fielddefault) } /// Mutate the value under a key. - fn mutate R, S: #scrate::HashedStorage<#scrate::Twox128>>(f: F, storage: &S) -> R { + fn mutate R, S: #scrate::HashedStorage<#scrate::Twox128>>(f: F, storage: &mut S) -> R { let mut val = >::get(storage); let ret = f(&mut val); @@ -212,13 +212,13 @@ impl<'a, I: Iterator> Impls<'a, I> { } /// Take the value, reading and removing it. - fn take>(key: &#kty, storage: &S) -> Self::Query { + fn take>(key: &#kty, storage: &mut S) -> Self::Query { let key = #as_map::key_for(key); storage.take(&key[..]).#option_simple_1(|| #fielddefault) } /// Mutate the value under a key - fn mutate R, S: #scrate::HashedStorage<#scrate::#hasher>>(key: &#kty, f: F, storage: &S) -> R { + fn mutate R, S: #scrate::HashedStorage<#scrate::#hasher>>(key: &#kty, f: F, storage: &mut S) -> R { let mut val = #as_map::get(key, storage); let ret = f(&mut val); @@ -349,7 +349,7 @@ impl<'a, I: Iterator> Impls<'a, I> { /// /// Takes care of updating previous and next elements points /// as well as updates head if the element is first or last. - fn remove_linkage>(linkage: Linkage<#kty>, storage: &S); + fn remove_linkage>(linkage: Linkage<#kty>, storage: &mut S); /// Read the contained data and it's linkage. fn read_with_linkage>(storage: &S, key: &[u8]) -> Option<(#value_type, Linkage<#kty>)>; @@ -358,7 +358,7 @@ impl<'a, I: Iterator> Impls<'a, I> { /// /// Takes care of updating head and previous head's pointer. fn new_head_linkage>( - storage: &S, + storage: &mut S, key: &#kty, ) -> Linkage<#kty>; @@ -368,7 +368,7 @@ impl<'a, I: Iterator> Impls<'a, I> { /// Overwrite current head pointer. /// /// If `None` is given head is removed from storage. - fn write_head>(storage: &S, head: Option<&#kty>); + fn write_head>(storage: &mut S, head: Option<&#kty>); } } }; @@ -380,7 +380,7 @@ impl<'a, I: Iterator> Impls<'a, I> { impl<#traitinstance: #traittype, #instance #bound_instantiable> self::#inner_module::Utils<#traitinstance, #instance> for #name<#traitinstance, #instance> { fn remove_linkage>( linkage: self::#inner_module::Linkage<#kty>, - storage: &S, + storage: &mut S, ) { use self::#inner_module::Utils; @@ -415,7 +415,7 @@ impl<'a, I: Iterator> Impls<'a, I> { } fn new_head_linkage>( - storage: &S, + storage: &mut S, key: &#kty, ) -> self::#inner_module::Linkage<#kty> { use self::#inner_module::Utils; @@ -450,7 +450,7 @@ impl<'a, I: Iterator> Impls<'a, I> { storage.get(#final_head_key) } - fn write_head>(storage: &S, head: Option<&#kty>) { + fn write_head>(storage: &mut S, head: Option<&#kty>) { match head { Some(head) => storage.put(#final_head_key, head), None => storage.kill(#final_head_key), @@ -489,7 +489,7 @@ impl<'a, I: Iterator> Impls<'a, I> { } /// Take the value, reading and removing it. - fn take>(key: &#kty, storage: &S) -> Self::Query { + fn take>(key: &#kty, storage: &mut S) -> Self::Query { use self::#inner_module::Utils; let res: Option<(#value_type, self::#inner_module::Linkage<#kty>)> = storage.take(&*#as_map::key_for(key)); @@ -503,12 +503,12 @@ impl<'a, I: Iterator> Impls<'a, I> { } /// Remove the value under a key. - fn remove>(key: &#kty, storage: &S) { + fn remove>(key: &#kty, storage: &mut S) { #as_map::take(key, storage); } /// Store a value to be associated with the given key from the map. - fn insert>(key: &#kty, val: &#typ, storage: &S) { + fn insert>(key: &#kty, val: &#typ, storage: &mut S) { use self::#inner_module::Utils; let key_for = &*#as_map::key_for(key); @@ -522,7 +522,7 @@ impl<'a, I: Iterator> Impls<'a, I> { } /// Mutate the value under a key - fn mutate R, S: #scrate::HashedStorage<#scrate::#hasher>>(key: &#kty, f: F, storage: &S) -> R { + fn mutate R, S: #scrate::HashedStorage<#scrate::#hasher>>(key: &#kty, f: F, storage: &mut S) -> R { use self::#inner_module::Utils; let key_for = &*#as_map::key_for(key); @@ -643,12 +643,12 @@ impl<'a, I: Iterator> Impls<'a, I> { storage.get(&key).#option_simple_1(|| #fielddefault) } - fn take(key1: &#k1ty, key2: &#k2ty, storage: &S) -> Self::Query { + fn take(key1: &#k1ty, key2: &#k2ty, storage: &mut S) -> Self::Query { let key = #as_double_map::key_for(key1, key2); storage.take(&key).#option_simple_1(|| #fielddefault) } - fn mutate R, S: #scrate::UnhashedStorage>(key1: &#k1ty, key2: &#k2ty, f: F, storage: &S) -> R { + fn mutate R, S: #scrate::UnhashedStorage>(key1: &#k1ty, key2: &#k2ty, f: F, storage: &mut S) -> R { let mut val = #as_double_map::get(key1, key2, storage); let ret = f(&mut val); diff --git a/srml/support/procedural/src/storage/transformation.rs b/srml/support/procedural/src/storage/transformation.rs index 146210eb0c..933faa6ff9 100644 --- a/srml/support/procedural/src/storage/transformation.rs +++ b/srml/support/procedural/src/storage/transformation.rs @@ -295,7 +295,7 @@ fn decl_store_extra_genesis( use #scrate::codec::{Encode, Decode}; let v = (#builder)(&self); - <#name<#traitinstance, #instance> as #scrate::storage::hashed::generator::StorageValue<#typ>>::put(&v, &storage); + <#name<#traitinstance, #instance> as #scrate::storage::hashed::generator::StorageValue<#typ>>::put(&v, storage); }} }, DeclStorageTypeInfosKind::Map { key_type, .. } => { @@ -305,7 +305,7 @@ fn decl_store_extra_genesis( let data = (#builder)(&self); for (k, v) in data.into_iter() { - <#name<#traitinstance, #instance> as #scrate::storage::hashed::generator::StorageMap<#key_type, #typ>>::insert(&k, &v, &storage); + <#name<#traitinstance, #instance> as #scrate::storage::hashed::generator::StorageMap<#key_type, #typ>>::insert(&k, &v, storage); } }} }, @@ -316,7 +316,7 @@ fn decl_store_extra_genesis( let data = (#builder)(&self); for (k1, k2, v) in data.into_iter() { - <#name<#traitinstance, #instance> as #scrate::storage::unhashed::generator::StorageDoubleMap<#key1_type, #key2_type, #typ>>::insert(&k1, &k2, &v, &storage); + <#name<#traitinstance, #instance> as #scrate::storage::unhashed::generator::StorageDoubleMap<#key1_type, #key2_type, #typ>>::insert(&k1, &k2, &v, storage); } }} }, @@ -451,12 +451,11 @@ fn decl_store_extra_genesis( #[cfg(feature = "std")] impl#fparam_impl #scrate::runtime_primitives::BuildStorage for GenesisConfig#sparam { fn assimilate_storage(self, r: &mut #scrate::runtime_primitives::StorageOverlay, c: &mut #scrate::runtime_primitives::ChildrenStorageOverlay) -> ::std::result::Result<(), String> { - use #scrate::rstd::cell::RefCell; - let storage = RefCell::new(r); + let storage = r; #builders - let r = storage.into_inner(); + let r = storage; #scall(r, c, &self); diff --git a/srml/support/src/storage/hashed/generator.rs b/srml/support/src/storage/hashed/generator.rs index 12600a9eaf..fb876a2adb 100644 --- a/srml/support/src/storage/hashed/generator.rs +++ b/srml/support/src/storage/hashed/generator.rs @@ -103,25 +103,25 @@ pub trait HashedStorage { } /// Put a value in under a key. - fn put(&self, key: &[u8], val: &T); + fn put(&mut self, key: &[u8], val: &T); /// Remove the bytes of a key from storage. - fn kill(&self, key: &[u8]); + fn kill(&mut self, key: &[u8]); /// Take a value from storage, deleting it after reading. - fn take(&self, key: &[u8]) -> Option { + fn take(&mut self, key: &[u8]) -> Option { let value = self.get(key); self.kill(key); value } /// Take a value from storage, deleting it after reading. - fn take_or_panic(&self, key: &[u8]) -> T { + fn take_or_panic(&mut self, key: &[u8]) -> T { self.take(key).expect("Required values must be in storage") } /// Take a value from storage, deleting it after reading. - fn take_or_default(&self, key: &[u8]) -> T { + fn take_or_default(&mut self, key: &[u8]) -> T { self.take(key).unwrap_or_default() } @@ -129,12 +129,12 @@ pub trait HashedStorage { fn get_raw(&self, key: &[u8]) -> Option>; /// Put a raw byte slice into storage. - fn put_raw(&self, key: &[u8], value: &[u8]); + fn put_raw(&mut self, key: &[u8], value: &[u8]); } // We use a construct like this during when genesis storage is being built. #[cfg(feature = "std")] -impl HashedStorage for std::cell::RefCell<&mut sr_primitives::StorageOverlay> { +impl HashedStorage for sr_primitives::StorageOverlay { fn exists(&self, key: &[u8]) -> bool { UnhashedStorage::exists(self, &H::hash(key).as_ref()) } @@ -143,11 +143,11 @@ impl HashedStorage for std::cell::RefCell<&mut sr_primitive UnhashedStorage::get(self, &H::hash(key).as_ref()) } - fn put(&self, key: &[u8], val: &T) { + fn put(&mut self, key: &[u8], val: &T) { UnhashedStorage::put(self, &H::hash(key).as_ref(), val) } - fn kill(&self, key: &[u8]) { + fn kill(&mut self, key: &[u8]) { UnhashedStorage::kill(self, &H::hash(key).as_ref()) } @@ -155,7 +155,7 @@ impl HashedStorage for std::cell::RefCell<&mut sr_primitive UnhashedStorage::get_raw(self, &H::hash(key).as_ref()) } - fn put_raw(&self, key: &[u8], value: &[u8]) { + fn put_raw(&mut self, key: &[u8], value: &[u8]) { UnhashedStorage::put_raw(self, &H::hash(key).as_ref(), value) } } @@ -177,18 +177,18 @@ pub trait StorageValue { fn get>(storage: &S) -> Self::Query; /// Take a value from storage, removing it afterwards. - fn take>(storage: &S) -> Self::Query; + fn take>(storage: &mut S) -> Self::Query; /// Store a value under this key into the provided storage instance. - fn put>(val: &T, storage: &S) { + fn put>(val: &T, storage: &mut S) { storage.put(Self::key(), val) } /// Mutate this value - fn mutate R, S: HashedStorage>(f: F, storage: &S) -> R; + fn mutate R, S: HashedStorage>(f: F, storage: &mut S) -> R; /// Clear the storage value. - fn kill>(storage: &S) { + fn kill>(storage: &mut S) { storage.kill(Self::key()) } @@ -196,7 +196,7 @@ pub trait StorageValue { /// /// `T` is required to implement `codec::EncodeAppend`. fn append, I: codec::Encode>( - items: &[I], storage: &S + items: &[I], storage: &mut S ) -> Result<(), &'static str> where T: codec::EncodeAppend { let new_val = ::append( storage.get_raw(Self::key()).unwrap_or_default(), @@ -222,10 +222,10 @@ pub trait StorageList { fn items>(storage: &S) -> Vec; /// Set the current set of items. - fn set_items>(items: &[T], storage: &S); + fn set_items>(items: &[T], storage: &mut S); /// Set the item at the given index. - fn set_item>(index: u32, item: &T, storage: &S); + fn set_item>(index: u32, item: &T, storage: &mut S); /// Load the value at given index. Returns `None` if the index is out-of-bounds. fn get>(index: u32, storage: &S) -> Option; @@ -234,7 +234,7 @@ pub trait StorageList { fn len>(storage: &S) -> u32; /// Clear the list. - fn clear>(storage: &S); + fn clear>(storage: &mut S); } /// A strongly-typed map in storage. @@ -259,20 +259,20 @@ pub trait StorageMap { fn get>(key: &K, storage: &S) -> Self::Query; /// Take the value under a key. - fn take>(key: &K, storage: &S) -> Self::Query; + fn take>(key: &K, storage: &mut S) -> Self::Query; /// Store a value to be associated with the given key from the map. - fn insert>(key: &K, val: &V, storage: &S) { + fn insert>(key: &K, val: &V, storage: &mut S) { storage.put(&Self::key_for(key)[..], val); } /// Remove the value under a key. - fn remove>(key: &K, storage: &S) { + fn remove>(key: &K, storage: &mut S) { storage.kill(&Self::key_for(key)[..]); } /// Mutate the value under a key. - fn mutate R, S: HashedStorage>(key: &K, f: F, storage: &S) -> R; + fn mutate R, S: HashedStorage>(key: &K, f: F, storage: &mut S) -> R; } /// A `StorageMap` with enumerable entries. diff --git a/srml/support/src/storage/mod.rs b/srml/support/src/storage/mod.rs index a2747da78b..635572c991 100644 --- a/srml/support/src/storage/mod.rs +++ b/srml/support/src/storage/mod.rs @@ -70,17 +70,17 @@ impl HashedStorage for RuntimeStorage { } /// Put a value in under a key. - fn put(&self, key: &[u8], val: &T) { + fn put(&mut self, key: &[u8], val: &T) { hashed::put(&H::hash, key, val) } /// Remove the bytes of a key from storage. - fn kill(&self, key: &[u8]) { + fn kill(&mut self, key: &[u8]) { hashed::kill(&H::hash, key) } /// Take a value from storage, deleting it after reading. - fn take(&self, key: &[u8]) -> Option { + fn take(&mut self, key: &[u8]) -> Option { hashed::take(&H::hash, key) } @@ -88,7 +88,7 @@ impl HashedStorage for RuntimeStorage { hashed::get_raw(&H::hash, key) } - fn put_raw(&self, key: &[u8], value: &[u8]) { + fn put_raw(&mut self, key: &[u8], value: &[u8]) { hashed::put_raw(&H::hash, key, value) } } @@ -104,22 +104,22 @@ impl UnhashedStorage for RuntimeStorage { } /// Put a value in under a key. - fn put(&self, key: &[u8], val: &T) { + fn put(&mut self, key: &[u8], val: &T) { unhashed::put(key, val) } /// Remove the bytes of a key from storage. - fn kill(&self, key: &[u8]) { + fn kill(&mut self, key: &[u8]) { unhashed::kill(key) } /// Remove the bytes of a key from storage. - fn kill_prefix(&self, prefix: &[u8]) { + fn kill_prefix(&mut self, prefix: &[u8]) { unhashed::kill_prefix(prefix) } /// Take a value from storage, deleting it after reading. - fn take(&self, key: &[u8]) -> Option { + fn take(&mut self, key: &[u8]) -> Option { unhashed::take(key) } @@ -127,7 +127,7 @@ impl UnhashedStorage for RuntimeStorage { unhashed::get_raw(key) } - fn put_raw(&self, key: &[u8], value: &[u8]) { + fn put_raw(&mut self, key: &[u8], value: &[u8]) { unhashed::put_raw(key, value) } } @@ -178,21 +178,21 @@ impl StorageValue for U where U: hashed::generator::StorageValue U::get(&RuntimeStorage) } fn put>(val: Arg) { - U::put(val.borrow(), &RuntimeStorage) + U::put(val.borrow(), &mut RuntimeStorage) } fn mutate R>(f: F) -> R { - U::mutate(f, &RuntimeStorage) + U::mutate(f, &mut RuntimeStorage) } fn kill() { - U::kill(&RuntimeStorage) + U::kill(&mut RuntimeStorage) } fn take() -> Self::Query { - U::take(&RuntimeStorage) + U::take(&mut RuntimeStorage) } fn append(items: &[I]) -> Result<(), &'static str> where T: EncodeAppend { - U::append(items, &RuntimeStorage) + U::append(items, &mut RuntimeStorage) } } @@ -244,11 +244,11 @@ impl StorageList for U where U: hashed::generator::StorageList>(index: u32, val: Arg) { - U::set_item(index, val.borrow(), &RuntimeStorage) + U::set_item(index, val.borrow(), &mut RuntimeStorage) } fn get(index: u32) -> Option { @@ -260,7 +260,7 @@ impl StorageList for U where U: hashed::generator::StorageList StorageMap for U where U: hashed::generator::S } fn insert, ValArg: Borrow>(key: KeyArg, val: ValArg) { - U::insert(key.borrow(), val.borrow(), &RuntimeStorage) + U::insert(key.borrow(), val.borrow(), &mut RuntimeStorage) } fn remove>(key: KeyArg) { - U::remove(key.borrow(), &RuntimeStorage) + U::remove(key.borrow(), &mut RuntimeStorage) } fn mutate, R, F: FnOnce(&mut Self::Query) -> R>(key: KeyArg, f: F) -> R { - U::mutate(key.borrow(), f, &RuntimeStorage) + U::mutate(key.borrow(), f, &mut RuntimeStorage) } fn take>(key: KeyArg) -> Self::Query { - U::take(key.borrow(), &RuntimeStorage) + U::take(key.borrow(), &mut RuntimeStorage) } } @@ -444,19 +444,19 @@ where } fn take, KArg2: Borrow>(k1: KArg1, k2: KArg2) -> Self::Query { - U::take(k1.borrow(), k2.borrow(), &RuntimeStorage) + U::take(k1.borrow(), k2.borrow(), &mut RuntimeStorage) } fn insert, KArg2: Borrow, VArg: Borrow>(k1: KArg1, k2: KArg2, val: VArg) { - U::insert(k1.borrow(), k2.borrow(), val.borrow(), &RuntimeStorage) + U::insert(k1.borrow(), k2.borrow(), val.borrow(), &mut RuntimeStorage) } fn remove, KArg2: Borrow>(k1: KArg1, k2: KArg2) { - U::remove(k1.borrow(), k2.borrow(), &RuntimeStorage) + U::remove(k1.borrow(), k2.borrow(), &mut RuntimeStorage) } fn remove_prefix>(k1: KArg1) { - U::remove_prefix(k1.borrow(), &RuntimeStorage) + U::remove_prefix(k1.borrow(), &mut RuntimeStorage) } fn mutate(k1: KArg1, k2: KArg2, f: F) -> R @@ -465,7 +465,7 @@ where KArg2: Borrow, F: FnOnce(&mut Self::Query) -> R { - U::mutate(k1.borrow(), k2.borrow(), f, &RuntimeStorage) + U::mutate(k1.borrow(), k2.borrow(), f, &mut RuntimeStorage) } fn append( @@ -479,7 +479,7 @@ where I: codec::Encode, V: EncodeAppend, { - U::append(k1.borrow(), k2.borrow(), items, &RuntimeStorage) + U::append(k1.borrow(), k2.borrow(), items, &mut RuntimeStorage) } } diff --git a/srml/support/src/storage/storage_items.rs b/srml/support/src/storage/storage_items.rs index 720cac64c5..802965fc27 100644 --- a/srml/support/src/storage/storage_items.rs +++ b/srml/support/src/storage/storage_items.rs @@ -197,12 +197,12 @@ macro_rules! __storage_items_internal { } /// Take a value from storage, removing it afterwards. - fn take>(storage: &S) -> Self::Query { + fn take>(storage: &mut S) -> Self::Query { storage.$taker($key) } /// Mutate this value. - fn mutate R, S: $crate::HashedStorage<$crate::Twox128>>(f: F, storage: &S) -> R { + fn mutate R, S: $crate::HashedStorage<$crate::Twox128>>(f: F, storage: &mut S) -> R { let mut val = >::get(storage); let ret = f(&mut val); @@ -256,13 +256,13 @@ macro_rules! __storage_items_internal { } /// Take the value, reading and removing it. - fn take>(key: &$kty, storage: &S) -> Self::Query { + fn take>(key: &$kty, storage: &mut S) -> Self::Query { let key = <$name as $crate::storage::hashed::generator::StorageMap<$kty, $ty>>::key_for(key); storage.$taker(&key[..]) } /// Mutate the value under a key. - fn mutate R, S: $crate::HashedStorage>(key: &$kty, f: F, storage: &S) -> R { + fn mutate R, S: $crate::HashedStorage>(key: &$kty, f: F, storage: &mut S) -> R { let mut val = >::take(key, storage); let ret = f(&mut val); @@ -287,13 +287,13 @@ macro_rules! __storage_items_internal { $($vis)* struct $name; impl $name { - fn clear_item>(index: u32, storage: &S) { + fn clear_item>(index: u32, storage: &mut S) { if index < <$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage) { storage.kill(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::key_for(index)); } } - fn set_len>(count: u32, storage: &S) { + fn set_len>(count: u32, storage: &mut S) { (count..<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage)).for_each(|i| $name::clear_item(i, storage)); storage.put(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len_key(), &count); } @@ -327,14 +327,14 @@ macro_rules! __storage_items_internal { } /// Set the current set of items. - fn set_items>(items: &[$ty], storage: &S) { + fn set_items>(items: &[$ty], storage: &mut S) { $name::set_len(items.len() as u32, storage); items.iter() .enumerate() .for_each(|(i, item)| <$name as $crate::storage::hashed::generator::StorageList<$ty>>::set_item(i as u32, item, storage)); } - fn set_item>(index: u32, item: &$ty, storage: &S) { + fn set_item>(index: u32, item: &$ty, storage: &mut S) { if index < <$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage) { storage.put(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::key_for(index)[..], item); } @@ -351,7 +351,7 @@ macro_rules! __storage_items_internal { } /// Clear the list. - fn clear>(storage: &S) { + fn clear>(storage: &mut S) { for i in 0..<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage) { $name::clear_item(i, storage); } @@ -383,7 +383,6 @@ macro_rules! __handle_wrap_internal { #[allow(dead_code)] mod tests { use std::collections::HashMap; - use std::cell::RefCell; use super::*; use crate::metadata::*; use crate::metadata::StorageHasher; @@ -398,43 +397,40 @@ mod tests { #[test] fn value() { - let mut overlay = HashMap::new(); - let storage = RefCell::new(&mut overlay); + let mut storage = HashMap::new(); assert!(Value::get(&storage).is_none()); - Value::put(&100_000, &storage); + Value::put(&100_000, &mut storage); assert_eq!(Value::get(&storage), Some(100_000)); - Value::kill(&storage); + Value::kill(&mut storage); assert!(Value::get(&storage).is_none()); } #[test] fn list() { - let mut overlay = HashMap::new(); - let storage = RefCell::new(&mut overlay); + let mut storage = HashMap::new(); assert_eq!(List::len(&storage), 0); assert!(List::items(&storage).is_empty()); - List::set_items(&[0, 2, 4, 6, 8], &storage); + List::set_items(&[0, 2, 4, 6, 8], &mut storage); assert_eq!(List::items(&storage), &[0, 2, 4, 6, 8]); assert_eq!(List::len(&storage), 5); - List::set_item(2, &10, &storage); + List::set_item(2, &10, &mut storage); assert_eq!(List::items(&storage), &[0, 2, 10, 6, 8]); assert_eq!(List::len(&storage), 5); - List::clear(&storage); + List::clear(&mut storage); assert_eq!(List::len(&storage), 0); assert!(List::items(&storage).is_empty()); } #[test] fn map() { - let mut overlay = HashMap::new(); - let storage = RefCell::new(&mut overlay); + let mut storage = HashMap::new(); assert!(Map::get(&5, &storage).is_none()); - Map::insert(&5, &[1; 32], &storage); + Map::insert(&5, &[1; 32], &mut storage); assert_eq!(Map::get(&5, &storage), Some([1; 32])); - assert_eq!(Map::take(&5, &storage), Some([1; 32])); + assert_eq!(Map::take(&5, &mut storage), Some([1; 32])); assert!(Map::get(&5, &storage).is_none()); assert!(Map::get(&999, &storage).is_none()); } diff --git a/srml/support/src/storage/unhashed/generator.rs b/srml/support/src/storage/unhashed/generator.rs index 7e9e5a2199..e6bbb5905f 100644 --- a/srml/support/src/storage/unhashed/generator.rs +++ b/srml/support/src/storage/unhashed/generator.rs @@ -34,66 +34,66 @@ pub trait UnhashedStorage { fn get_or_default(&self, key: &[u8]) -> T { self.get(key).unwrap_or_default() } /// Put a value in under a key. - fn put(&self, key: &[u8], val: &T); + fn put(&mut self, key: &[u8], val: &T); /// Remove the bytes of a key from storage. - fn kill(&self, key: &[u8]); + fn kill(&mut self, key: &[u8]); /// Remove the bytes of a key from storage. - fn kill_prefix(&self, prefix: &[u8]); + fn kill_prefix(&mut self, prefix: &[u8]); /// Take a value from storage, deleting it after reading. - fn take(&self, key: &[u8]) -> Option { + fn take(&mut self, key: &[u8]) -> Option { let value = self.get(key); self.kill(key); value } /// Take a value from storage, deleting it after reading. - fn take_or_panic(&self, key: &[u8]) -> T { self.take(key).expect("Required values must be in storage") } + fn take_or_panic(&mut self, key: &[u8]) -> T { self.take(key).expect("Required values must be in storage") } /// Take a value from storage, deleting it after reading. - fn take_or_default(&self, key: &[u8]) -> T { self.take(key).unwrap_or_default() } + fn take_or_default(&mut self, key: &[u8]) -> T { self.take(key).unwrap_or_default() } /// Get a Vec of bytes from storage. fn get_raw(&self, key: &[u8]) -> Option>; /// Put a raw byte slice into storage. - fn put_raw(&self, key: &[u8], value: &[u8]); + fn put_raw(&mut self, key: &[u8], value: &[u8]); } // We use a construct like this during when genesis storage is being built. #[cfg(feature = "std")] -impl UnhashedStorage for std::cell::RefCell<&mut sr_primitives::StorageOverlay> { +impl UnhashedStorage for sr_primitives::StorageOverlay { fn exists(&self, key: &[u8]) -> bool { - self.borrow().contains_key(key) + self.contains_key(key) } fn get(&self, key: &[u8]) -> Option { - self.borrow().get(key) + self.get(key) .map(|x| codec::Decode::decode(&mut x.as_slice()).expect("Unable to decode expected type.")) } - fn put(&self, key: &[u8], val: &T) { - self.borrow_mut().insert(key.to_vec(), codec::Encode::encode(val)); + fn put(&mut self, key: &[u8], val: &T) { + self.insert(key.to_vec(), codec::Encode::encode(val)); } - fn kill(&self, key: &[u8]) { - self.borrow_mut().remove(key); + fn kill(&mut self, key: &[u8]) { + self.remove(key); } - fn kill_prefix(&self, prefix: &[u8]) { - self.borrow_mut().retain(|key, _| { + fn kill_prefix(&mut self, prefix: &[u8]) { + self.retain(|key, _| { !key.starts_with(prefix) }) } fn get_raw(&self, key: &[u8]) -> Option> { - self.borrow().get(key).cloned() + self.get(key).cloned() } - fn put_raw(&self, key: &[u8], value: &[u8]) { - self.borrow_mut().insert(key.to_vec(), value.to_vec()); + fn put_raw(&mut self, key: &[u8], value: &[u8]) { + self.insert(key.to_vec(), value.to_vec()); } } @@ -131,32 +131,32 @@ pub trait StorageDoubleMap fn get(k1: &K1, k2: &K2, storage: &S) -> Self::Query; /// Take the value under a key. - fn take(k1: &K1, k2: &K2, storage: &S) -> Self::Query; + fn take(k1: &K1, k2: &K2, storage: &mut S) -> Self::Query; /// Store a value to be associated with the given key from the map. - fn insert(k1: &K1, k2: &K2, val: &V, storage: &S) { + fn insert(k1: &K1, k2: &K2, val: &V, storage: &mut S) { storage.put(&Self::key_for(k1, k2), val); } /// Remove the value under a key. - fn remove(k1: &K1, k2: &K2, storage: &S) { + fn remove(k1: &K1, k2: &K2, storage: &mut S) { storage.kill(&Self::key_for(k1, k2)); } /// Removes all entries that shares the `k1` as the first key. - fn remove_prefix(k1: &K1, storage: &S) { + fn remove_prefix(k1: &K1, storage: &mut S) { storage.kill_prefix(&Self::prefix_for(k1)); } /// Mutate the value under a key. - fn mutate R, S: UnhashedStorage>(k1: &K1, k2: &K2, f: F, storage: &S) -> R; + fn mutate R, S: UnhashedStorage>(k1: &K1, k2: &K2, f: F, storage: &mut S) -> R; /// Append the given items to the value under the key specified. fn append( k1: &K1, k2: &K2, items: &[I], - storage: &S, + storage: &mut S, ) -> Result<(), &'static str> where I: codec::Encode, -- GitLab From eb6d30af2a86606b2bcaa3d86c7651f67752199f Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 23 May 2019 11:28:35 +0200 Subject: [PATCH 017/113] Remove dependency on parity-crypto (#2655) --- .gitlab-ci.yml | 2 + Cargo.lock | 147 ++------------------------------------- core/keystore/Cargo.toml | 1 - core/keystore/src/lib.rs | 2 - 4 files changed, 8 insertions(+), 144 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff4172aa5e..abab05f74e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -104,6 +104,8 @@ check-web-wasm: - time cargo web build -p sr-primitives - time cargo web build -p sr-std - time cargo web build -p substrate-consensus-common + - time cargo web build -p substrate-keyring + - time cargo web build -p substrate-keystore - time cargo web build -p substrate-executor - time cargo web build -p substrate-network-libp2p - time cargo web build -p substrate-panic-handler diff --git a/Cargo.lock b/Cargo.lock index 9944db924b..f8f8588edf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,16 +8,6 @@ dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "aes" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "aes-ctr" version = "0.3.0" @@ -257,15 +247,6 @@ dependencies = [ "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "block-buffer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "block-buffer" version = "0.7.3" @@ -285,15 +266,6 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "block-modes" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "block-padding" version = "0.1.4" @@ -629,15 +601,6 @@ dependencies = [ "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crypto-mac" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crypto-mac" version = "0.7.0" @@ -711,7 +674,7 @@ dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -743,14 +706,6 @@ dependencies = [ "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "digest" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "digest" version = "0.8.0" @@ -983,14 +938,6 @@ dependencies = [ "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "generic-array" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "generic-array" version = "0.12.0" @@ -1150,15 +1097,6 @@ dependencies = [ "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hmac" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crypto-mac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hmac" version = "0.7.0" @@ -2383,23 +2321,6 @@ dependencies = [ "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parity-crypto" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "block-modes 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "scrypt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parity-multiaddr" version = "0.4.0" @@ -2535,16 +2456,6 @@ dependencies = [ "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "pbkdf2" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crypto-mac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pbkdf2" version = "0.3.0" @@ -2911,16 +2822,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ripemd160" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rocksdb" version = "0.11.0" @@ -3017,7 +2918,7 @@ dependencies = [ "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3025,18 +2926,6 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "scrypt" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pbkdf2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "security-framework" version = "0.2.2" @@ -3132,17 +3021,6 @@ dependencies = [ "generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sha2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "sha2" version = "0.8.0" @@ -3249,7 +3127,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4260,11 +4138,10 @@ version = "2.0.0" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4663,7 +4540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -5579,7 +5456,6 @@ dependencies = [ [metadata] "checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f" -"checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" @@ -5607,10 +5483,8 @@ dependencies = [ "checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" -"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -"checksum block-modes 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "31aa8410095e39fdb732909fb5730a48d5bd7c2e3cd76bd1b07b3dbea130c529" "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" "checksum bstr 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6c8203ca06c502958719dae5f653a79e0cc6ba808ed02beffbf27d09610f2143" @@ -5649,7 +5523,6 @@ dependencies = [ "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" "checksum crypto-mac 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "779015233ac67d65098614aec748ac1c756ab6677fa2e14cf8b37c08dfed1198" -"checksum crypto-mac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7afa06d05a046c7a47c3a849907ec303504608c927f4e85f7bfff22b7180d971" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum csv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9044e25afb0924b5a5fc5511689b0918629e85d68ea591e5e87fbf1e85ea1b3b" "checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65" @@ -5662,7 +5535,6 @@ dependencies = [ "checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" -"checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" @@ -5692,7 +5564,6 @@ dependencies = [ "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" "checksum generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fceb69994e330afed50c93524be68c42fa898c2d9fd4ee8da03bd7363acd26f2" -"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" @@ -5711,7 +5582,6 @@ dependencies = [ "checksum hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" "checksum hex-literal-impl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06095d08c7c05760f11a071b3e1d4c5b723761c01bd8d7201c30a9536668a612" "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" -"checksum hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "733e1b3ac906631ca01ebb577e9bb0f5e37a454032b9036b5eaea4013ed6f99a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" @@ -5808,7 +5678,6 @@ dependencies = [ "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-crypto 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1b9c063d87e1507cb3807493c8d21859ef23b5414b39f81c53f0ba267d64c1" "checksum parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a130a727008cfcd1068a28439fe939897ccad28664422aeca65b384d6de6d0" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" @@ -5821,7 +5690,6 @@ dependencies = [ "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" -"checksum pbkdf2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0c09cddfbfc98de7f76931acf44460972edb4023eb14d0c6d4018800e552d8e0" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" @@ -5864,7 +5732,6 @@ dependencies = [ "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rhododendron 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9381ed76c1ec4e8994f1f7d2c6d7e33eed3ff7176e16fece09c2e993fc4a5a" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" "checksum rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e" "checksum rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c34fa7bcae7fca3c8471e8417088bbc3ad9af8066b0ecf4f3c0d98a0d772716e" "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" @@ -5878,7 +5745,6 @@ dependencies = [ "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum scrypt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8570c5e2fa69cb29d492fd4e9974b6b5facb5a888e1c6da630d4a3cd7ebfef4a" "checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05" "checksum security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6696852716b589dff9e886ff83778bb635150168e83afa8ac6b8a78cb82abc" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -5890,7 +5756,6 @@ dependencies = [ "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a" -"checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34a5e54083ce2b934bf059fdf38e7330a154177e029ab6c4e18638f2f624053a" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" @@ -5920,7 +5785,7 @@ dependencies = [ "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" "checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" +"checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" "checksum syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)" = "846620ec526c1599c070eff393bfeeeb88a93afa2513fc3b49f1fea84cf7b0ed" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum sysinfo 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a0cb7899e248ed0baa6ef6f8406352523c2f99bc7c4b1800f4cd6d5dde99eb" diff --git a/core/keystore/Cargo.toml b/core/keystore/Cargo.toml index 4c4a89157b..99f0ebedd2 100644 --- a/core/keystore/Cargo.toml +++ b/core/keystore/Cargo.toml @@ -6,7 +6,6 @@ edition = "2018" [dependencies] substrate-primitives = { path = "../primitives" } -crypto = { package = "parity-crypto", version = "0.3", default-features = false } error-chain = "0.12" hex = "0.3" rand = "0.6" diff --git a/core/keystore/src/lib.rs b/core/keystore/src/lib.rs index ff737535f9..9e6d4ec83c 100644 --- a/core/keystore/src/lib.rs +++ b/core/keystore/src/lib.rs @@ -30,8 +30,6 @@ use error_chain::{bail, error_chain, error_chain_processing, impl_error_chain_pr use substrate_primitives::{ed25519::{Pair, Public}, Pair as PairT}; -pub use crypto::KEY_ITERATIONS; - error_chain! { foreign_links { Io(io::Error); -- GitLab From c5c65b000c40548a6fd288a98322c3ba199e4a34 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 23 May 2019 11:28:49 +0200 Subject: [PATCH 018/113] fix(bump protobuf): fix vulnerability (#2654) --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8f8588edf..1ebeaad998 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1474,7 +1474,7 @@ dependencies = [ "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1522,7 +1522,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1542,7 +1542,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1568,7 +1568,7 @@ dependencies = [ "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1626,7 +1626,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1693,7 +1693,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2553,7 +2553,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -5702,7 +5702,7 @@ dependencies = [ "checksum proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6a9bed9ebc40cf53e3a76d7486c54d05002eae6485b2711ab9104476fb2eb8bc" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" "checksum proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)" = "ba92c84f814b3f9a44c5cfca7d2ad77fa10710867d2bbb1b3d175ab5f47daa12" -"checksum protobuf 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc7badf647ae2fa27ba51c218e347386c88cc604fcfe71f2aba0ad017f3f2b75" +"checksum protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3959be8d6250192f80ef056c0a4aaaeaff8a25e904e6e7a0f5285cb1a061835f" "checksum pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "efb0dcbddbb600f47a7098d33762a00552c671992171637f5bb310b37fe1f0e4" "checksum quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb6ccf8db7bbcb9c2eae558db5ab4f3da1c2a87e4e597ed394726bc8ea6ca1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -- GitLab From 445e0f65e9173491431d7d0c4a77cd4575a72192 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Thu, 23 May 2019 11:34:00 +0200 Subject: [PATCH 019/113] docs: Update Support SRML to link to StorageDoubleMap in Rustdocs (#2646) * docs: Update Support SRML to link to StorageDoubleMap in Rustdocs * review-fix: Add missing backticks. Add trait text for consistency. Fix typo * review-fix: Move trait text out of link --- srml/support/procedural/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/srml/support/procedural/src/lib.rs b/srml/support/procedural/src/lib.rs index f98baa7ed5..abd7e90951 100644 --- a/srml/support/procedural/src/lib.rs +++ b/srml/support/procedural/src/lib.rs @@ -47,10 +47,11 @@ use proc_macro::TokenStream; /// /// Basic storage consists of a name and a type; supported types are: /// -/// * Value: `Foo: type`: Implements [StorageValue](../srml_support/storage/trait.StorageValue.html). -/// * Map: `Foo: map hasher($hash) type => type`: Implements [StorageMap](../srml_support/storage/trait.StorageMap.html) +/// * Value: `Foo: type`: Implements the [`StorageValue`](../srml_support/storage/trait.StorageValue.html) trait. +/// * Map: `Foo: map hasher($hash) type => type`: Implements the +/// [`StorageMap`](../srml_support/storage/trait.StorageMap.html) trait /// with `$hash` representing a choice of hashing algorithms available in the -/// [`Hashable` trait](../srml_support/trait.Hashable.html). +/// [`Hashable`](../srml_support/trait.Hashable.html) trait. /// /// `hasher($hash)` is optional and its default is `blake2_256`. /// @@ -59,11 +60,12 @@ use proc_macro::TokenStream; /// `blake2_256` must be used. Otherwise, other values in storage can be compromised. /// /// * Linked map: `Foo: linked_map hasher($hash) type => type`: Same as `Map` but also implements -/// [EnumarableStorageMap](../srml_support/storage/trait.EnumerableStorageMap.html). +/// the [`EnumerableStorageMap`](../srml_support/storage/trait.EnumerableStorageMap.html) trait. /// -/// * Double map: `Foo: double_map hasher($hash) u32, $hash2(u32) => u32`: Implements `StorageDoubleMap` with +/// * Double map: `Foo: double_map hasher($hash) u32, $hash2(u32) => u32`: Implements the +/// [`StorageDoubleMap`](../srml_support/storage/trait.StorageDoubleMap.html) trait with /// `$hash` and `$hash2` representing choices of hashing algorithms available in the -/// [`Hashable` trait](../srml_support/trait.Hashable.html). +/// [`Hashable`](../srml_support/trait.Hashable.html) trait. /// /// `hasher($hash)` is optional and its default is `blake2_256`. /// -- GitLab From 69dd3b1b1646497360777880d3dfbcdd91a15fc4 Mon Sep 17 00:00:00 2001 From: Sergei Pepyakin Date: Thu, 23 May 2019 11:34:17 +0200 Subject: [PATCH 020/113] srml-contract: update ext_random(_seed) (#2635) * Initial implementation. * Rename random_seed to random * Update rustdocs * Update COMPLEXITY.md * Fix comment. * Limit the size of subject. * Bump the runtime version. * Fix doc * Update node/runtime/src/lib.rs Co-Authored-By: thiolliere --- srml/contract/COMPLEXITY.md | 8 +++-- srml/contract/src/exec.rs | 11 +++--- srml/contract/src/lib.rs | 4 +++ srml/contract/src/wasm/mod.rs | 57 +++++++++++++++++++------------ srml/contract/src/wasm/runtime.rs | 16 +++++++-- 5 files changed, 61 insertions(+), 35 deletions(-) diff --git a/srml/contract/COMPLEXITY.md b/srml/contract/COMPLEXITY.md index 3cd7fee448..c2d75efaba 100644 --- a/srml/contract/COMPLEXITY.md +++ b/srml/contract/COMPLEXITY.md @@ -298,11 +298,13 @@ This function serializes the address of the caller into the scratch buffer. **complexity**: Assuming that the address is of constant size, this function has constant complexity. -## ext_random_seed +## ext_random -This function serializes the current block's random seed into the scratch buffer. +This function serializes a random number generated by the given subject into the scratch buffer. +The complexity of this function highly depends on the complexity of `System::random`. `max_subject_len` +limits the size of the subject buffer. -**complexity**: Assuming that the random seed is of constant size, this function has constant complexity. +**complexity**: The complexity of this function depends on the implementation of `System::random`. ## ext_now diff --git a/srml/contract/src/exec.rs b/srml/contract/src/exec.rs index 9d63c037c0..1ab59fa0c2 100644 --- a/srml/contract/src/exec.rs +++ b/srml/contract/src/exec.rs @@ -106,8 +106,8 @@ pub trait Ext { /// Returns a reference to the timestamp of the current block fn now(&self) -> &MomentOf; - /// Returns a reference to the random seed for the current block - fn random_seed(&self) -> &SeedOf; + /// Returns a random number for the current block with the given subject. + fn random(&self, subject: &[u8]) -> SeedOf; /// Deposit an event with the given topics. /// @@ -353,7 +353,6 @@ where caller: self.self_account.clone(), value_transferred: value, timestamp: timestamp::Module::::now(), - random_seed: system::Module::::random_seed(), }, input_data, empty_output_buf, @@ -423,7 +422,6 @@ where caller: self.self_account.clone(), value_transferred: endowment, timestamp: timestamp::Module::::now(), - random_seed: system::Module::::random_seed(), }, input_data, EmptyOutputBuf::new(), @@ -576,7 +574,6 @@ struct CallContext<'a, 'b: 'a, T: Trait + 'b, V: Vm + 'b, L: Loader> { caller: T::AccountId, value_transferred: BalanceOf, timestamp: T::Moment, - random_seed: T::Hash, } impl<'a, 'b: 'a, T, E, V, L> Ext for CallContext<'a, 'b, T, V, L> @@ -642,8 +639,8 @@ where self.value_transferred } - fn random_seed(&self) -> &T::Hash { - &self.random_seed + fn random(&self, subject: &[u8]) -> SeedOf { + system::Module::::random(subject) } fn now(&self) -> &T::Moment { diff --git a/srml/contract/src/lib.rs b/srml/contract/src/lib.rs index b9412b3619..a255663bfb 100644 --- a/srml/contract/src/lib.rs +++ b/srml/contract/src/lib.rs @@ -690,6 +690,9 @@ pub struct Schedule { /// Whether the `ext_println` function is allowed to be used contracts. /// MUST only be enabled for `dev` chains, NOT for production chains pub enable_println: bool, + + /// The maximum length of a subject used for PRNG generation. + pub max_subject_len: u32, } impl> Default for Schedule { @@ -709,6 +712,7 @@ impl> Default for Schedule { max_stack_height: 64 * 1024, max_memory_pages: 16, enable_println: false, + max_subject_len: 32, } } } diff --git a/srml/contract/src/wasm/mod.rs b/srml/contract/src/wasm/mod.rs index 2776f4041b..d86678d383 100644 --- a/srml/contract/src/wasm/mod.rs +++ b/srml/contract/src/wasm/mod.rs @@ -177,9 +177,10 @@ mod tests { use crate::exec::{CallReceipt, Ext, InstantiateReceipt, EmptyOutputBuf, StorageKey}; use crate::gas::GasMeter; use crate::tests::{Test, Call}; - use wabt; use crate::wasm::prepare::prepare_contract; use crate::CodeHash; + use wabt; + use hex_literal::hex; #[derive(Debug, PartialEq, Eq)] struct DispatchEntry(Call); @@ -207,7 +208,6 @@ mod tests { // (topics, data) events: Vec<(Vec, Vec)>, next_account_id: u64, - random_seed: H256, } impl Ext for MockExt { type T = Test; @@ -276,8 +276,8 @@ mod tests { &1111 } - fn random_seed(&self) -> &H256{ - &self.random_seed + fn random(&self, subject: &[u8]) -> H256 { + H256::from_slice(subject) } fn deposit_event(&mut self, topics: Vec, data: Vec) { @@ -1115,11 +1115,12 @@ mod tests { .unwrap(); } - const CODE_RANDOM_SEED: &str = r#" + const CODE_RANDOM: &str = r#" (module - (import "env" "ext_random_seed" (func $ext_random_seed)) + (import "env" "ext_random" (func $ext_random (param i32 i32))) (import "env" "ext_scratch_size" (func $ext_scratch_size (result i32))) (import "env" "ext_scratch_copy" (func $ext_scratch_copy (param i32 i32 i32))) + (import "env" "ext_return" (func $ext_return (param i32 i32))) (import "env" "memory" (memory 1 1)) (func $assert (param i32) @@ -1133,7 +1134,10 @@ mod tests { (func (export "call") ;; This stores the block random seed in the scratch buffer - (call $ext_random_seed) + (call $ext_random + (i32.const 40) ;; Pointer in memory to the start of the subject buffer + (i32.const 32) ;; The subject buffer's length + ) ;; assert $ext_scratch_size == 32 (call $assert @@ -1150,35 +1154,44 @@ mod tests { (i32.const 32) ;; Count of bytes to copy. ) - ;; assert the contents of the buffer in 4 x i64 parts matches 1,2,3,4. - (call $assert (i64.eq (i64.load (i32.const 8)) (i64.const 1))) - (call $assert (i64.eq (i64.load (i32.const 16)) (i64.const 2))) - (call $assert (i64.eq (i64.load (i32.const 24)) (i64.const 3))) - (call $assert (i64.eq (i64.load (i32.const 32)) (i64.const 4))) + ;; return the data from the contract + (call $ext_return + (i32.const 8) + (i32.const 32) + ) ) (func (export "deploy")) + + ;; [8,40) is reserved for the result of PRNG. + + ;; the subject used for the PRNG. [40,72) + (data (i32.const 40) + "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F" + "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F" + ) ) "#; #[test] - fn random_seed() { + fn random() { let mut mock_ext = MockExt::default(); - let seed: [u8; 32] = [ - 1,0,0,0,0,0,0,0, - 2,0,0,0,0,0,0,0, - 3,0,0,0,0,0,0,0, - 4,0,0,0,0,0,0,0, - ]; - mock_ext.random_seed = H256::from_slice(&seed); let mut gas_meter = GasMeter::with_limit(50_000, 1); + + let mut return_buf = Vec::new(); execute( - CODE_RANDOM_SEED, + CODE_RANDOM, &[], - &mut Vec::new(), + &mut return_buf, &mut mock_ext, &mut gas_meter, ) .unwrap(); + + // The mock ext just returns the same data that was passed as the subject. + assert_eq!( + &return_buf, + &hex!("000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F") + ); } const CODE_DEPOSIT_EVENT: &str = r#" diff --git a/srml/contract/src/wasm/runtime.rs b/srml/contract/src/wasm/runtime.rs index b6f857269e..873464c5be 100644 --- a/srml/contract/src/wasm/runtime.rs +++ b/srml/contract/src/wasm/runtime.rs @@ -527,9 +527,19 @@ define_env!(Env, , Ok(()) }, - // Load the latest block RNG seed into the scratch buffer - ext_random_seed(ctx) => { - ctx.scratch_buf = ctx.ext.random_seed().encode(); + // Stores the random number for the current block for the given subject into the scratch + // buffer. + // + // The data is encoded as T::Hash. The current contents of the scratch buffer are + // overwritten. + ext_random(ctx, subject_ptr: u32, subject_len: u32) => { + // The length of a subject can't exceed `max_subject_len`. + if subject_len > ctx.schedule.max_subject_len { + return Err(sandbox::HostError); + } + + let subject_buf = read_sandbox_memory(ctx, subject_ptr, subject_len)?; + ctx.scratch_buf = ctx.ext.random(&subject_buf).encode(); Ok(()) }, -- GitLab From 02832dc8b7df35d4ccbaf62415d95e340bc0c76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Thu, 23 May 2019 10:50:36 +0100 Subject: [PATCH 021/113] core: allow setting max ws rpc connections (#2632) * core: allow setting max ws rpc connections * style: break long lines * core: fix service tests --- core/cli/src/lib.rs | 1 + core/cli/src/params.rs | 4 ++++ core/rpc-servers/src/lib.rs | 7 ++++++- core/service/src/components.rs | 21 +++++++++++++++++---- core/service/src/config.rs | 3 +++ core/service/src/lib.rs | 12 ++++++++++-- core/service/test/src/lib.rs | 1 + 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 3aa567de66..82ebf8ec05 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -487,6 +487,7 @@ where config.rpc_ws = Some( parse_address(&format!("{}:{}", ws_interface, 9944), cli.ws_port)? ); + config.rpc_ws_max_connections = cli.ws_max_connections; config.rpc_cors = cli.rpc_cors.unwrap_or_else(|| if is_dev { log::warn!("Running in --dev mode, RPC CORS has been disabled."); None diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index ab473a304b..e7d466a863 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -333,6 +333,10 @@ pub struct RunCmd { #[structopt(long = "ws-port", value_name = "PORT")] pub ws_port: Option, + /// Maximum number of WS RPC server connections. + #[structopt(long = "ws-max-connections", value_name = "COUNT")] + pub ws_max_connections: Option, + /// Specify browser Origins allowed to access the HTTP & WS RPC servers. /// It's a comma-separated list of origins (protocol://domain or special `null` value). /// Value of `all` will disable origin validation. diff --git a/core/rpc-servers/src/lib.rs b/core/rpc-servers/src/lib.rs index b37895c503..2c0672ac9c 100644 --- a/core/rpc-servers/src/lib.rs +++ b/core/rpc-servers/src/lib.rs @@ -24,9 +24,12 @@ use std::io; use log::error; use sr_primitives::{traits::{Block as BlockT, NumberFor}, generic::SignedBlock}; -/// Maximal payload accepted by RPC servers +/// Maximal payload accepted by RPC servers. const MAX_PAYLOAD: usize = 15 * 1024 * 1024; +/// Default maximum number of connections for WS RPC servers. +const WS_MAX_CONNECTIONS: usize = 100; + type Metadata = apis::metadata::Metadata; type RpcHandler = pubsub::PubSubHandler; pub type HttpServer = http::Server; @@ -76,11 +79,13 @@ pub fn start_http( /// Start WS server listening on given address. pub fn start_ws( addr: &std::net::SocketAddr, + max_connections: Option, cors: Option<&Vec>, io: RpcHandler, ) -> io::Result { ws::ServerBuilder::with_meta_extractor(io, |context: &ws::RequestContext| Metadata::new(context.sender())) .max_payload(MAX_PAYLOAD) + .max_connections(max_connections.unwrap_or(WS_MAX_CONNECTIONS)) .allowed_origins(map_cors(cors)) .start(addr) .map_err(|err| match err { diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 48ea9777bd..2536d7c8f2 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -143,6 +143,7 @@ pub trait StartRPC { system_info: SystemInfo, rpc_http: Option, rpc_ws: Option, + rpc_ws_max_connections: Option, rpc_cors: Option>, task_executor: TaskExecutor, transaction_pool: Arc>, @@ -162,6 +163,7 @@ impl StartRPC for C where rpc_system_info: SystemInfo, rpc_http: Option, rpc_ws: Option, + rpc_ws_max_connections: Option, rpc_cors: Option>, task_executor: TaskExecutor, transaction_pool: Arc>, @@ -186,8 +188,19 @@ impl StartRPC for C where }; Ok(( - maybe_start_server(rpc_http, |address| rpc::start_http(address, rpc_cors.as_ref(), handler()))?, - maybe_start_server(rpc_ws, |address| rpc::start_ws(address, rpc_cors.as_ref(), handler()))?.map(Mutex::new), + maybe_start_server( + rpc_http, + |address| rpc::start_http(address, rpc_cors.as_ref(), handler()), + )?, + maybe_start_server( + rpc_ws, + |address| rpc::start_ws( + address, + rpc_ws_max_connections, + rpc_cors.as_ref(), + handler(), + ), + )?.map(Mutex::new), )) } } @@ -330,7 +343,7 @@ pub trait ServiceFactory: 'static + Sized { /// Build the Fork Choice algorithm for full client fn build_select_chain( config: &mut FactoryFullConfiguration, - client: Arc>, + client: Arc>, ) -> Result; /// Build full service. @@ -497,7 +510,7 @@ impl Components for FullComponents { } fn build_transaction_pool( - config: TransactionPoolOptions, + config: TransactionPoolOptions, client: Arc> ) -> Result, error::Error> { Factory::build_full_transaction_pool(config, client) diff --git a/core/service/src/config.rs b/core/service/src/config.rs index c9e8e4662d..5996ec837d 100644 --- a/core/service/src/config.rs +++ b/core/service/src/config.rs @@ -66,6 +66,8 @@ pub struct Configuration { pub rpc_http: Option, /// RPC over Websockets binding address. `None` if disabled. pub rpc_ws: Option, + /// Maximum number of connections for WebSockets RPC server. `None` if default. + pub rpc_ws_max_connections: Option, /// CORS settings for HTTP & WS servers. `None` if all origins are allowed. pub rpc_cors: Option>, /// Telemetry service URL. `None` if disabled. @@ -104,6 +106,7 @@ impl Configuration Service { properties: config.chain_spec.properties(), }; let rpc = Components::RuntimeServices::start_rpc( - client.clone(), network.clone(), has_bootnodes, system_info, config.rpc_http, - config.rpc_ws, config.rpc_cors.clone(), task_executor.clone(), transaction_pool.clone(), + client.clone(), + network.clone(), + has_bootnodes, + system_info, + config.rpc_http, + config.rpc_ws, + config.rpc_ws_max_connections, + config.rpc_cors.clone(), + task_executor.clone(), + transaction_pool.clone(), )?; let telemetry_connection_sinks: Arc>>> = Default::default(); diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index a0f37709bd..7b73c370ee 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -120,6 +120,7 @@ fn node_config ( execution_strategies: Default::default(), rpc_http: None, rpc_ws: None, + rpc_ws_max_connections: None, rpc_cors: None, telemetry_endpoints: None, default_heap_pages: None, -- GitLab From 2fcf061bc003789c25aad2d84c5f26f58fa0f431 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 23 May 2019 12:07:51 +0200 Subject: [PATCH 022/113] More extractions from the Protocol struct (#2641) * Pass the TransactionPool explicitly * Extract finality_proof_provider * Remove Protocol::connected_peers * Add note and rename function * Fix tests * More test fixing * Revert the WASM locks, I guess * Add space * Remove space --- core/network/src/config.rs | 2 +- core/network/src/protocol.rs | 66 +++++++++++++++++------------------ core/network/src/service.rs | 53 ++++++++++++++++++++++------ core/network/src/test/mod.rs | 40 ++++++++++----------- core/network/src/test/sync.rs | 6 ++-- core/rpc/src/system/mod.rs | 4 +-- core/rpc/src/system/tests.rs | 2 +- core/service/test/src/lib.rs | 4 +-- 8 files changed, 103 insertions(+), 74 deletions(-) diff --git a/core/network/src/config.rs b/core/network/src/config.rs index 965aeba8c9..05cf27ca75 100644 --- a/core/network/src/config.rs +++ b/core/network/src/config.rs @@ -39,7 +39,7 @@ pub struct Params { /// On-demand service reference. pub on_demand: Option>>, /// Transaction pool. - pub transaction_pool: Arc>, + pub transaction_pool: Arc>, /// Protocol specialization. pub specialization: S, } diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index cd7a14bdbb..c9e56362d1 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -35,7 +35,6 @@ use crate::specialization::NetworkSpecialization; use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; use crate::service::{TransactionPool, ExHashT}; use crate::config::{ProtocolConfig, Roles}; -use parking_lot::RwLock; use rustc_hex::ToHex; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; @@ -92,10 +91,6 @@ pub struct Protocol, H: ExHashT> { context_data: ContextData, // Connected peers pending Status message. handshaking_peers: HashMap, - // Connected peers from whom we received a Status message, - // similar to context_data.peers but shared with the SyncProvider. - connected_peers: Arc>>>, - transaction_pool: Arc>, } /// A peer from whom we have received a Status message. @@ -261,18 +256,14 @@ struct ContextData { // All connected peers peers: HashMap>, pub chain: Arc>, - pub finality_proof_provider: Option>>, } impl, H: ExHashT> Protocol { /// Create a new instance. pub fn new( - connected_peers: Arc>>>, config: ProtocolConfig, chain: Arc>, - finality_proof_provider: Option>>, on_demand: Option>>, - transaction_pool: Arc>, specialization: S, ) -> error::Result> { let info = chain.info()?; @@ -284,7 +275,6 @@ impl, H: ExHashT> Protocol { context_data: ContextData { peers: HashMap::new(), chain, - finality_proof_provider, }, on_demand, genesis_hash: info.chain.genesis_hash, @@ -292,8 +282,6 @@ impl, H: ExHashT> Protocol { specialization: specialization, consensus_gossip: ConsensusGossip::new(), handshaking_peers: HashMap::new(), - connected_peers, - transaction_pool: transaction_pool, }) } @@ -319,13 +307,17 @@ impl, H: ExHashT> Protocol { self.sync.status().is_offline() } - pub fn poll(&mut self, network_out: &mut dyn NetworkOut) -> Poll { + pub fn poll( + &mut self, + network_out: &mut dyn NetworkOut, + transaction_pool: &(impl TransactionPool + ?Sized) + ) -> Poll { while let Ok(Async::Ready(_)) = self.tick_timeout.poll() { self.tick(network_out); } while let Ok(Async::Ready(_)) = self.propagate_timeout.poll() { - self.propagate_extrinsics(network_out); + self.propagate_extrinsics(network_out, transaction_pool); } Ok(Async::NotReady) @@ -364,19 +356,21 @@ impl, H: ExHashT> Protocol { peer.info.best_hash = info.best_hash; peer.info.best_number = info.best_number; } - let mut peers = self.connected_peers.write(); - if let Some(ref mut peer) = peers.get_mut(who) { - peer.peer_info.best_hash = info.best_hash; - peer.peer_info.best_number = info.best_number; - } } } + /// Returns information about all the peers we are connected to after the handshake message. + pub fn peers_info(&self) -> impl Iterator)> { + self.context_data.peers.iter().map(|(id, peer)| (id, &peer.info)) + } + pub fn on_custom_message( &mut self, network_out: &mut dyn NetworkOut, + transaction_pool: &(impl TransactionPool + ?Sized), who: PeerId, - message: Message + message: Message, + finality_proof_provider: Option<&FinalityProofProvider> ) -> CustomMessageOutcome { match message { GenericMessage::Status(s) => self.on_status_message(network_out, who, s), @@ -397,7 +391,8 @@ impl, H: ExHashT> Protocol { self.on_block_announce(network_out, who.clone(), announce); self.update_peer_info(&who); }, - GenericMessage::Transactions(m) => self.on_extrinsics(network_out, who, m), + GenericMessage::Transactions(m) => + self.on_extrinsics(network_out, transaction_pool, who, m), GenericMessage::RemoteCallRequest(request) => self.on_remote_call_request(network_out, who, request), GenericMessage::RemoteCallResponse(response) => self.on_remote_call_response(who, response), GenericMessage::RemoteReadRequest(request) => self.on_remote_read_request(network_out, who, request), @@ -406,7 +401,8 @@ impl, H: ExHashT> Protocol { GenericMessage::RemoteHeaderResponse(response) => self.on_remote_header_response(who, response), GenericMessage::RemoteChangesRequest(request) => self.on_remote_changes_request(network_out, who, request), GenericMessage::RemoteChangesResponse(response) => self.on_remote_changes_response(who, response), - GenericMessage::FinalityProofRequest(request) => self.on_finality_proof_request(network_out, who, request), + GenericMessage::FinalityProofRequest(request) => + self.on_finality_proof_request(network_out, who, request, finality_proof_provider), GenericMessage::FinalityProofResponse(response) => return self.on_finality_proof_response(network_out, who, response), GenericMessage::Consensus(msg) => { @@ -489,7 +485,6 @@ impl, H: ExHashT> Protocol { // lock all the the peer lists so that add/remove peer events are in order let removed = { self.handshaking_peers.remove(&peer); - self.connected_peers.write().remove(&peer); self.context_data.peers.remove(&peer) }; if let Some(peer_data) = removed { @@ -734,16 +729,12 @@ impl, H: ExHashT> Protocol { let info = match self.handshaking_peers.remove(&who) { Some(_handshaking) => { - let peer_info = PeerInfo { + PeerInfo { protocol_version: status.version, roles: status.roles, best_hash: status.best_hash, best_number: status.best_number - }; - self.connected_peers - .write() - .insert(who.clone(), ConnectedPeer { peer_info: peer_info.clone() }); - peer_info + } }, None => { error!(target: "sync", "Received status from previously unconnected node {}", who); @@ -780,6 +771,7 @@ impl, H: ExHashT> Protocol { fn on_extrinsics( &mut self, network_out: &mut dyn NetworkOut, + transaction_pool: &(impl TransactionPool + ?Sized), who: PeerId, extrinsics: message::Transactions ) { @@ -791,7 +783,7 @@ impl, H: ExHashT> Protocol { trace!(target: "sync", "Received {} extrinsics from {}", extrinsics.len(), who); if let Some(ref mut peer) = self.context_data.peers.get_mut(&who) { for t in extrinsics { - if let Some(hash) = self.transaction_pool.import(&t) { + if let Some(hash) = transaction_pool.import(&t) { network_out.report_peer(who.clone(), NEW_EXTRINSIC_REPUTATION_CHANGE); peer.known_extrinsics.insert(hash); } else { @@ -802,7 +794,11 @@ impl, H: ExHashT> Protocol { } /// Call when we must propagate ready extrinsics to peers. - pub fn propagate_extrinsics(&mut self, network_out: &mut dyn NetworkOut) { + pub fn propagate_extrinsics( + &mut self, + network_out: &mut dyn NetworkOut, + transaction_pool: &(impl TransactionPool + ?Sized) + ) { debug!(target: "sync", "Propagating extrinsics"); // Accept transactions only when fully synced @@ -810,7 +806,7 @@ impl, H: ExHashT> Protocol { return; } - let extrinsics = self.transaction_pool.transactions(); + let extrinsics = transaction_pool.transactions(); let mut propagated_to = HashMap::new(); for (who, peer) in self.context_data.peers.iter_mut() { let (hashes, to_send): (Vec<_>, Vec<_>) = extrinsics @@ -830,7 +826,8 @@ impl, H: ExHashT> Protocol { network_out.send_message(who.clone(), GenericMessage::Transactions(to_send)) } } - self.transaction_pool.on_broadcasted(propagated_to); + + transaction_pool.on_broadcasted(propagated_to); } /// Make sure an important block is propagated to peers. @@ -1203,9 +1200,10 @@ impl, H: ExHashT> Protocol { network_out: &mut dyn NetworkOut, who: PeerId, request: message::FinalityProofRequest, + finality_proof_provider: Option<&FinalityProofProvider> ) { trace!(target: "sync", "Finality proof request from {} for {}", who, request.block); - let finality_proof = self.context_data.finality_proof_provider.as_ref() + let finality_proof = finality_proof_provider.as_ref() .ok_or_else(|| String::from("Finality provider is not configured")) .and_then(|provider| provider.prove_finality(request.block, &request.request).map_err(|e| e.to_string()) diff --git a/core/network/src/service.rs b/core/network/src/service.rs index 1a966fc933..4516609c5e 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -29,6 +29,7 @@ use peerset::PeersetHandle; use consensus::import_queue::{ImportQueue, Link, SharedFinalityProofRequestBuilder}; use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use crate::chain::FinalityProofProvider; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use crate::message::Message; use crate::protocol::{self, Context, CustomMessageOutcome, Protocol, ConnectedPeer}; @@ -41,6 +42,8 @@ use tokio::runtime::Builder as RuntimeBuilder; /// Interval at which we send status updates on the SyncProvider status stream. const STATUS_INTERVAL: Duration = Duration::from_millis(5000); +/// Interval at which we update the `peers` field on the main thread. +const CONNECTED_PEERS_INTERVAL: Duration = Duration::from_millis(500); pub use network_libp2p::PeerId; @@ -53,8 +56,13 @@ pub trait SyncProvider: Send + Sync { fn status(&self) -> mpsc::UnboundedReceiver>; /// Get network state. fn network_state(&self) -> NetworkState; - /// Get currently connected peers - fn peers(&self) -> Vec<(PeerId, PeerInfo)>; + + /// Get currently connected peers. + /// + /// > **Warning**: This method can return outdated information and should only ever be used + /// > when obtaining outdated information is acceptable. + fn peers_debug_info(&self) -> Vec<(PeerId, PeerInfo)>; + /// Are we in the process of downloading the chain? fn is_major_syncing(&self) -> bool; } @@ -206,12 +214,9 @@ impl> Service { let is_major_syncing = Arc::new(AtomicBool::new(false)); let peers: Arc>>> = Arc::new(Default::default()); let protocol = Protocol::new( - peers.clone(), params.config, params.chain, - params.finality_proof_provider, params.on_demand, - params.transaction_pool, params.specialization, )?; let versions: Vec<_> = ((protocol::MIN_VERSION as u8)..=(protocol::CURRENT_VERSION as u8)).collect(); @@ -220,7 +225,10 @@ impl> Service { is_offline.clone(), is_major_syncing.clone(), protocol, + peers.clone(), import_queue.clone(), + params.transaction_pool, + params.finality_proof_provider, network_port, protocol_rx, status_sinks.clone(), @@ -392,7 +400,7 @@ impl> SyncProvider for Servi self.network.lock().state() } - fn peers(&self) -> Vec<(PeerId, PeerInfo)> { + fn peers_debug_info(&self) -> Vec<(PeerId, PeerInfo)> { let peers = (*self.peers.read()).clone(); peers.into_iter().map(|(idx, connected)| (idx, connected.peer_info)).collect() } @@ -514,7 +522,10 @@ fn start_thread, H: ExHashT>( is_offline: Arc, is_major_syncing: Arc, protocol: Protocol, + peers: Arc>>>, import_queue: Box>, + transaction_pool: Arc>, + finality_proof_provider: Option>>, network_port: mpsc::UnboundedReceiver>, protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, @@ -540,7 +551,10 @@ fn start_thread, H: ExHashT>( is_major_syncing, protocol, service_clone, + peers, import_queue, + transaction_pool, + finality_proof_provider, network_port, protocol_rx, status_sinks, @@ -567,7 +581,10 @@ fn run_thread, H: ExHashT>( is_major_syncing: Arc, mut protocol: Protocol, network_service: Arc>>>, + peers: Arc>>>, import_queue: Box>, + transaction_pool: Arc>, + finality_proof_provider: Option>>, mut network_port: mpsc::UnboundedReceiver>, mut protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, @@ -589,6 +606,8 @@ fn run_thread, H: ExHashT>( // Interval at which we send status updates on the `status_sinks`. let mut status_interval = tokio::timer::Interval::new_interval(STATUS_INTERVAL); + // Interval at which we update the `connected_peers` Arc. + let mut connected_peers_interval = tokio::timer::Interval::new_interval(CONNECTED_PEERS_INTERVAL); futures::future::poll_fn(move || { while let Ok(Async::Ready(_)) = status_interval.poll() { @@ -596,7 +615,14 @@ fn run_thread, H: ExHashT>( status_sinks.lock().retain(|sink| sink.unbounded_send(status.clone()).is_ok()); } - match protocol.poll(&mut Ctxt(&mut network_service.lock(), &peerset)) { + while let Ok(Async::Ready(_)) = connected_peers_interval.poll() { + let infos = protocol.peers_info().map(|(id, info)| { + (id.clone(), ConnectedPeer { peer_info: info.clone() }) + }).collect(); + *peers.write() = infos; + } + + match protocol.poll(&mut Ctxt(&mut network_service.lock(), &peerset), &*transaction_pool) { Ok(Async::Ready(v)) => void::unreachable(v), Ok(Async::NotReady) => {} Err(err) => void::unreachable(err), @@ -646,7 +672,7 @@ fn run_thread, H: ExHashT>( protocol.gossip_consensus_message(&mut network_out, topic, engine_id, message, recipient), ProtocolMsg::BlocksProcessed(hashes, has_error) => protocol.blocks_processed(&mut network_out, hashes, has_error), - ProtocolMsg::RestartSync => + ProtocolMsg::RestartSync => protocol.restart(&mut network_out), ProtocolMsg::AnnounceBlock(hash) => protocol.announce_block(&mut network_out, hash), @@ -664,7 +690,8 @@ fn run_thread, H: ExHashT>( protocol.request_finality_proof(&mut network_out, &hash, number), ProtocolMsg::FinalityProofImportResult(requested_block, finalziation_result) => protocol.finality_proof_import_result(requested_block, finalziation_result), - ProtocolMsg::PropagateExtrinsics => protocol.propagate_extrinsics(&mut network_out), + ProtocolMsg::PropagateExtrinsics => + protocol.propagate_extrinsics(&mut network_out, &*transaction_pool), #[cfg(any(test, feature = "test-helpers"))] ProtocolMsg::Tick => protocol.tick(&mut network_out), #[cfg(any(test, feature = "test-helpers"))] @@ -692,7 +719,13 @@ fn run_thread, H: ExHashT>( CustomMessageOutcome::None }, Ok(Async::Ready(Some(NetworkServiceEvent::CustomMessage { peer_id, message, .. }))) => - protocol.on_custom_message(&mut network_out, peer_id, message), + protocol.on_custom_message( + &mut network_out, + &*transaction_pool, + peer_id, + message, + finality_proof_provider.as_ref().map(|p| &**p) + ), Ok(Async::Ready(Some(NetworkServiceEvent::Clogged { peer_id, messages, .. }))) => { debug!(target: "sync", "{} clogging messages:", messages.len()); for msg in messages.into_iter().take(5) { diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 82d54d40b0..7cbbbf1370 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -44,7 +44,7 @@ use crate::message::Message; use network_libp2p::PeerId; use parking_lot::{Mutex, RwLock}; use primitives::{H256, sr25519::Public as AuthorityId, Blake2Hasher}; -use crate::protocol::{ConnectedPeer, Context, Protocol, ProtocolStatus, CustomMessageOutcome, NetworkOut}; +use crate::protocol::{Context, Protocol, ProtocolStatus, CustomMessageOutcome, NetworkOut}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{AuthorityIdFor, Block as BlockT, Digest, DigestItem, Header, NumberFor}; use runtime_primitives::{Justification, ConsensusEngineId}; @@ -274,7 +274,6 @@ impl> Link for TestLink { } pub struct Peer> { - peers: Arc>>>, peer_id: PeerId, client: PeersClient, net_proto_channel: ProtocolChannel, @@ -411,7 +410,7 @@ impl> ProtocolChannel { Ok(Async::Ready(None)) => None, })) }); - + if self.use_tokio { fut.wait() } else { @@ -423,7 +422,6 @@ impl> ProtocolChannel { impl> Peer { fn new( protocol_status: Arc>>, - peers: Arc>>>, client: PeersClient, import_queue: Box>, use_tokio: bool, @@ -447,7 +445,6 @@ impl> Peer { import_queue.start(Box::new(network_link)).expect("Test ImportQueue always starts"); Peer { protocol_status, - peers, peer_id: PeerId::random(), client, import_queue, @@ -792,6 +789,8 @@ pub trait TestNetFactory: Sized { &mut self, protocol_status: Arc>>, import_queue: Box>, + tx_pool: EmptyTransactionPool, + finality_proof_provider: Option>>, mut protocol: Protocol, network_sender: mpsc::UnboundedSender>, mut network_to_protocol_rx: mpsc::UnboundedReceiver>, @@ -825,7 +824,13 @@ pub trait TestNetFactory: Sized { CustomMessageOutcome::None }, Some(FromNetworkMsg::CustomMessage(peer_id, message)) => - protocol.on_custom_message(&mut Ctxt(&network_sender), peer_id, message), + protocol.on_custom_message( + &mut Ctxt(&network_sender), + &tx_pool, + peer_id, + message, + finality_proof_provider.as_ref().map(|p| &**p) + ), Some(FromNetworkMsg::Synchronize) => { let _ = network_sender.unbounded_send(NetworkMsg::Synchronized); CustomMessageOutcome::None @@ -876,7 +881,7 @@ pub trait TestNetFactory: Sized { ), ProtocolMsg::BlocksProcessed(hashes, has_error) => protocol.blocks_processed(&mut Ctxt(&network_sender), hashes, has_error), - ProtocolMsg::RestartSync => + ProtocolMsg::RestartSync => protocol.restart(&mut Ctxt(&network_sender)), ProtocolMsg::AnnounceBlock(hash) => protocol.announce_block(&mut Ctxt(&network_sender), hash), @@ -894,7 +899,8 @@ pub trait TestNetFactory: Sized { protocol.request_finality_proof(&mut Ctxt(&network_sender), &hash, number), ProtocolMsg::FinalityProofImportResult(requested_block, finalziation_result) => protocol.finality_proof_import_result(requested_block, finalziation_result), - ProtocolMsg::PropagateExtrinsics => protocol.propagate_extrinsics(&mut Ctxt(&network_sender)), + ProtocolMsg::PropagateExtrinsics => + protocol.propagate_extrinsics(&mut Ctxt(&network_sender), &tx_pool), #[cfg(any(test, feature = "test-helpers"))] ProtocolMsg::Tick => protocol.tick(&mut Ctxt(&network_sender)), #[cfg(any(test, feature = "test-helpers"))] @@ -905,7 +911,7 @@ pub trait TestNetFactory: Sized { } } - if let Async::Ready(_) = protocol.poll(&mut Ctxt(&network_sender)).unwrap() { + if let Async::Ready(_) = protocol.poll(&mut Ctxt(&network_sender), &tx_pool).unwrap() { return Ok(Async::Ready(())) } @@ -930,7 +936,6 @@ pub trait TestNetFactory: Sized { /// Add a full peer. fn add_full_peer(&mut self, config: &ProtocolConfig) { let client = Arc::new(test_client::new()); - let tx_pool = Arc::new(EmptyTransactionPool); let verifier = self.make_verifier(PeersClient::Full(client.clone()), config); let (block_import, justification_import, finality_proof_import, finality_proof_request_builder, data) = self.make_block_import(PeersClient::Full(client.clone())); @@ -944,18 +949,14 @@ pub trait TestNetFactory: Sized { finality_proof_request_builder, )); let specialization = self::SpecializationFactory::create(); - let peers: Arc>>> = Arc::new(Default::default()); let (network_to_protocol_sender, network_to_protocol_rx) = mpsc::unbounded(); let (protocol_sender, protocol_rx) = mpsc::unbounded(); let protocol = Protocol::new( - peers.clone(), config.clone(), client.clone(), - self.make_finality_proof_provider(PeersClient::Full(client.clone())), None, - tx_pool, specialization, ).unwrap(); @@ -963,13 +964,14 @@ pub trait TestNetFactory: Sized { self.add_peer( protocol_status.clone(), import_queue.clone(), + EmptyTransactionPool, + self.make_finality_proof_provider(PeersClient::Full(client.clone())), protocol, network_sender.clone(), network_to_protocol_rx, protocol_rx, Arc::new(Peer::new( protocol_status, - peers, PeersClient::Full(client), import_queue, self.uses_tokio(), @@ -988,7 +990,6 @@ pub trait TestNetFactory: Sized { config.roles = Roles::LIGHT; let client = Arc::new(test_client::new_light()); - let tx_pool = Arc::new(EmptyTransactionPool); let verifier = self.make_verifier(PeersClient::Light(client.clone()), &config); let (block_import, justification_import, finality_proof_import, finality_proof_request_builder, data) = self.make_block_import(PeersClient::Light(client.clone())); @@ -1002,18 +1003,14 @@ pub trait TestNetFactory: Sized { finality_proof_request_builder, )); let specialization = self::SpecializationFactory::create(); - let peers: Arc>>> = Arc::new(Default::default()); let (network_to_protocol_sender, network_to_protocol_rx) = mpsc::unbounded(); let (protocol_sender, protocol_rx) = mpsc::unbounded(); let protocol = Protocol::new( - peers.clone(), config, client.clone(), - self.make_finality_proof_provider(PeersClient::Light(client.clone())), None, - tx_pool, specialization, ).unwrap(); @@ -1021,13 +1018,14 @@ pub trait TestNetFactory: Sized { self.add_peer( protocol_status.clone(), import_queue.clone(), + EmptyTransactionPool, + self.make_finality_proof_provider(PeersClient::Light(client.clone())), protocol, network_sender.clone(), network_to_protocol_rx, protocol_rx, Arc::new(Peer::new( protocol_status, - peers, PeersClient::Light(client), import_queue, self.uses_tokio(), diff --git a/core/network/src/test/sync.rs b/core/network/src/test/sync.rs index da42ae4758..8462304e42 100644 --- a/core/network/src/test/sync.rs +++ b/core/network/src/test/sync.rs @@ -45,7 +45,7 @@ fn sync_peers_works() { net.sync(); for peer in 0..3 { // Assert peers is up to date. - assert_eq!(net.peer(peer).peers.read().len(), 2); + assert_eq!(net.peer(peer).protocol_status.read().num_peers, 2); // And then disconnect. for other in 0..3 { if other != peer { @@ -56,8 +56,8 @@ fn sync_peers_works() { net.sync(); // Now peers are disconnected. for peer in 0..3 { - let peers = net.peer(peer).peers.read(); - assert_eq!(peers.len(), 0); + let status = net.peer(peer).protocol_status.read(); + assert_eq!(status.num_peers, 0); } } diff --git a/core/rpc/src/system/mod.rs b/core/rpc/src/system/mod.rs index 331d9cd85b..46cbc99fab 100644 --- a/core/rpc/src/system/mod.rs +++ b/core/rpc/src/system/mod.rs @@ -110,14 +110,14 @@ impl SystemApi::Number> for Sy fn system_health(&self) -> Result { Ok(Health { - peers: self.sync.peers().len(), + peers: self.sync.peers_debug_info().len(), is_syncing: self.sync.is_major_syncing(), should_have_peers: self.should_have_peers, }) } fn system_peers(&self) -> Result::Number>>> { - Ok(self.sync.peers().into_iter().map(|(peer_id, p)| PeerInfo { + Ok(self.sync.peers_debug_info().into_iter().map(|(peer_id, p)| PeerInfo { peer_id: peer_id.to_base58(), roles: format!("{:?}", p.roles), protocol_version: p.protocol_version, diff --git a/core/rpc/src/system/tests.rs b/core/rpc/src/system/tests.rs index b4b71a7937..14cd421fd1 100644 --- a/core/rpc/src/system/tests.rs +++ b/core/rpc/src/system/tests.rs @@ -59,7 +59,7 @@ impl network::SyncProvider for Status { } } - fn peers(&self) -> Vec<(PeerId, NetworkPeerInfo)> { + fn peers_debug_info(&self) -> Vec<(PeerId, NetworkPeerInfo)> { let mut peers = vec![]; for _peer in 0..self.peers { peers.push( diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index 7b73c370ee..dc4676dc0a 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -195,7 +195,7 @@ pub fn connectivity(spec: FactoryChainSpec) { service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| - service.network().peers().len() == NUM_NODES as usize - 1 + service.network().peers_debug_info().len() == NUM_NODES as usize - 1 ); network.runtime }; @@ -215,7 +215,7 @@ pub fn connectivity(spec: FactoryChainSpec) { address = node_id.clone(); } network.run_until_all_full(|_index, service| { - service.network().peers().len() == NUM_NODES as usize - 1 + service.network().peers_debug_info().len() == NUM_NODES as usize - 1 }); } temp.close().expect("Error removing temp dir"); -- GitLab From 6d38263434aba843585c7dc8744fc89703be90b5 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Thu, 23 May 2019 15:09:16 +0200 Subject: [PATCH 023/113] Contract restoration (#2502) * partial impl * more checks * improve TestExternalities + tests * make tombstone raw to derive Eq * remove before merge * add test * fmt * update test * doc * bump version * fix testing * update runtime * Fix TrieIdGenerator * fix dummy trie id generator * update test * bump version * format * Update core/state-machine/src/testing.rs Co-Authored-By: cheme * document test * Apply suggestions from code review Co-Authored-By: DemiMarie-temp <50585338+DemiMarie-temp@users.noreply.github.com> * refactor * fix * fmt * address review * impl last_write * Fix storage size, test, remove size in tombstone * fix * Update srml/contract/src/lib.rs Co-Authored-By: Sergei Pepyakin * comment * child_storage_root as &[u8] --- Cargo.lock | 1 + core/state-machine/src/ext.rs | 2 +- core/state-machine/src/testing.rs | 154 ++++++++++++------ node/runtime/src/lib.rs | 2 +- srml/contract/Cargo.toml | 1 + srml/contract/src/account_db.rs | 5 + srml/contract/src/lib.rs | 121 ++++++++++++-- srml/contract/src/rent.rs | 5 +- srml/contract/src/tests.rs | 261 ++++++++++++++++++++++++++---- srml/executive/src/lib.rs | 2 +- 10 files changed, 453 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ebeaad998..5550265cf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3318,6 +3318,7 @@ name = "srml-contract" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/core/state-machine/src/ext.rs b/core/state-machine/src/ext.rs index 0f5a4e2ed5..b9c035a778 100644 --- a/core/state-machine/src/ext.rs +++ b/core/state-machine/src/ext.rs @@ -302,7 +302,7 @@ where .flat_map(|map| map.1.iter().map(|(k, v)| (k.clone(), v.clone()))) .chain(self.overlay.prospective.children.get(storage_key) .into_iter() - .flat_map(|map| map.1.iter().map(|(k, v)| (k.clone(), v.clone())))); + .flat_map(|map| map.1.clone().into_iter())); let root = self.backend.child_storage_root(storage_key, delta).0; diff --git a/core/state-machine/src/testing.rs b/core/state-machine/src/testing.rs index a4f650bcf2..03909f384c 100644 --- a/core/state-machine/src/testing.rs +++ b/core/state-machine/src/testing.rs @@ -16,22 +16,27 @@ //! Test implementation for Externalities. -use std::collections::HashMap; +use std::collections::{HashMap, BTreeMap}; use std::iter::FromIterator; +use std::marker::PhantomData; use hash_db::Hasher; -use trie::trie_root; -use crate::backend::InMemory; -use crate::changes_trie::{compute_changes_trie_root, InMemoryStorage as ChangesTrieInMemoryStorage, AnchorBlockId}; +use crate::backend::{InMemory, Backend}; +use primitives::storage::well_known_keys::is_child_storage_key; +use crate::changes_trie::{ + compute_changes_trie_root, InMemoryStorage as ChangesTrieInMemoryStorage, AnchorBlockId +}; use primitives::storage::well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES}; use parity_codec::Encode; use super::{ChildStorageKey, Externalities, OverlayedChanges}; +const EXT_NOT_ALLOWED_TO_FAIL: &str = "Externalities not allowed to fail within runtime"; + /// Simple HashMap-based Externalities impl. pub struct TestExternalities { - inner: HashMap, Vec>, + overlay: OverlayedChanges, + backend: InMemory, changes_trie_storage: ChangesTrieInMemoryStorage, - changes: OverlayedChanges, - code: Option>, + _hasher: PhantomData, } impl TestExternalities { @@ -43,6 +48,7 @@ impl TestExternalities { /// Create a new instance of `TestExternalities` pub fn new_with_code(code: &[u8], mut inner: HashMap, Vec>) -> Self { let mut overlay = OverlayedChanges::default(); + super::set_changes_trie_config( &mut overlay, inner.get(&CHANGES_TRIE_CONFIG.to_vec()).cloned(), @@ -50,37 +56,51 @@ impl TestExternalities { ).expect("changes trie configuration is correct in test env; qed"); inner.insert(HEAP_PAGES.to_vec(), 8u64.encode()); + inner.insert(CODE.to_vec(), code.to_vec()); TestExternalities { - inner, + overlay, changes_trie_storage: ChangesTrieInMemoryStorage::new(), - changes: overlay, - code: Some(code.to_vec()), + backend: inner.into(), + _hasher: Default::default(), } } - /// Insert key/value - pub fn insert(&mut self, k: Vec, v: Vec) -> Option> { - self.inner.insert(k, v) + /// Insert key/value into backend + pub fn insert(&mut self, k: Vec, v: Vec) { + self.backend = self.backend.update(vec![(None, k, Some(v))]); + } + + /// Iter to all pairs in key order + pub fn iter_pairs_in_order(&self) -> impl Iterator, Vec)> { + self.backend.pairs().iter() + .map(|&(ref k, ref v)| (k.to_vec(), Some(v.to_vec()))) + .chain(self.overlay.committed.top.clone().into_iter().map(|(k, v)| (k, v.value))) + .chain(self.overlay.prospective.top.clone().into_iter().map(|(k, v)| (k, v.value))) + .collect::>() + .into_iter() + .filter_map(|(k, maybe_val)| maybe_val.map(|val| (k, val))) } } impl ::std::fmt::Debug for TestExternalities { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f, "{:?}", self.inner) + write!(f, "overlay: {:?}\nbackend: {:?}", self.overlay, self.backend.pairs()) } } impl PartialEq for TestExternalities { + /// This doesn't test if they are in the same state, only if they contains the + /// same data at this state fn eq(&self, other: &TestExternalities) -> bool { - self.inner.eq(&other.inner) + self.iter_pairs_in_order().eq(other.iter_pairs_in_order()) } } impl FromIterator<(Vec, Vec)> for TestExternalities { fn from_iter, Vec)>>(iter: I) -> Self { let mut t = Self::new(Default::default()); - t.inner.extend(iter); + t.backend = t.backend.update(iter.into_iter().map(|(k, v)| (None, k, Some(v))).collect()); t } } @@ -91,81 +111,109 @@ impl Default for TestExternalities { impl From> for HashMap, Vec> { fn from(tex: TestExternalities) -> Self { - tex.inner.into() + tex.iter_pairs_in_order().collect() } } impl From< HashMap, Vec> > for TestExternalities { fn from(hashmap: HashMap, Vec>) -> Self { - TestExternalities { - inner: hashmap, - changes_trie_storage: ChangesTrieInMemoryStorage::new(), - changes: Default::default(), - code: None, - } + Self::from_iter(hashmap) } } -// TODO child test primitives are currently limited to `changes` (for non child the way -// things are defined seems utterly odd to (put changes in changes but never make them -// available for read through inner) impl Externalities for TestExternalities where H::Out: Ord { fn storage(&self, key: &[u8]) -> Option> { - match key { - CODE => self.code.clone(), - _ => self.inner.get(key).cloned(), - } + self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(|| + self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL)) } fn original_storage(&self, key: &[u8]) -> Option> { - self.storage(key) + self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL) } fn child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { - self.changes.child_storage(storage_key.as_ref(), key)?.map(Vec::from) + self.overlay + .child_storage(storage_key.as_ref(), key) + .map(|x| x.map(|x| x.to_vec())) + .unwrap_or_else(|| self.backend + .child_storage(storage_key.as_ref(), key) + .expect(EXT_NOT_ALLOWED_TO_FAIL) + ) } fn place_storage(&mut self, key: Vec, maybe_value: Option>) { - self.changes.set_storage(key.clone(), maybe_value.clone()); - match key.as_ref() { - CODE => self.code = maybe_value, - _ => { - match maybe_value { - Some(value) => { self.inner.insert(key, value); } - None => { self.inner.remove(&key); } - } - } + if is_child_storage_key(&key) { + panic!("Refuse to directly set child storage key"); } + + self.overlay.set_storage(key, maybe_value); } - fn place_child_storage(&mut self, storage_key: ChildStorageKey, key: Vec, value: Option>) { - self.changes.set_child_storage(storage_key.into_owned(), key, value); + fn place_child_storage( + &mut self, + storage_key: ChildStorageKey, + key: Vec, + value: Option> + ) { + self.overlay.set_child_storage(storage_key.into_owned(), key, value); } fn kill_child_storage(&mut self, storage_key: ChildStorageKey) { - self.changes.clear_child_storage(storage_key.as_ref()); + let backend = &self.backend; + let overlay = &mut self.overlay; + + overlay.clear_child_storage(storage_key.as_ref()); + backend.for_keys_in_child_storage(storage_key.as_ref(), |key| { + overlay.set_child_storage(storage_key.as_ref().to_vec(), key.to_vec(), None); + }); } fn clear_prefix(&mut self, prefix: &[u8]) { - self.changes.clear_prefix(prefix); - self.inner.retain(|key, _| !key.starts_with(prefix)); + if is_child_storage_key(prefix) { + panic!("Refuse to directly clear prefix that is part of child storage key"); + } + + self.overlay.clear_prefix(prefix); + + let backend = &self.backend; + let overlay = &mut self.overlay; + backend.for_keys_with_prefix(prefix, |key| { + overlay.set_storage(key.to_vec(), None); + }); } fn chain_id(&self) -> u64 { 42 } fn storage_root(&mut self) -> H::Out { - trie_root::(self.inner.clone()) + // compute and memoize + let delta = self.overlay.committed.top.iter().map(|(k, v)| (k.clone(), v.value.clone())) + .chain(self.overlay.prospective.top.iter().map(|(k, v)| (k.clone(), v.value.clone()))); + + self.backend.storage_root(delta).0 } - fn child_storage_root(&mut self, _storage_key: ChildStorageKey) -> Vec { - vec![] + fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec { + let storage_key = storage_key.as_ref(); + + let (root, _, _) = { + let delta = self.overlay.committed.children.get(storage_key) + .into_iter() + .flat_map(|map| map.1.iter().map(|(k, v)| (k.clone(), v.clone()))) + .chain(self.overlay.prospective.children.get(storage_key) + .into_iter() + .flat_map(|map| map.1.clone().into_iter())); + + self.backend.child_storage_root(storage_key, delta) + }; + self.overlay.set_storage(storage_key.into(), Some(root.clone())); + root } fn storage_changes_root(&mut self, parent: H::Out, parent_num: u64) -> Option { - compute_changes_trie_root::<_, _, H>( - &InMemory::default(), + compute_changes_trie_root::<_, ChangesTrieInMemoryStorage, H>( + &self.backend, Some(&self.changes_trie_storage), - &self.changes, + &self.overlay, &AnchorBlockId { hash: parent, number: parent_num }, ).map(|(root, _)| root.clone()) } @@ -187,7 +235,7 @@ mod tests { ext.set_storage(b"doe".to_vec(), b"reindeer".to_vec()); ext.set_storage(b"dog".to_vec(), b"puppy".to_vec()); ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); - const ROOT: [u8; 32] = hex!("0b33ed94e74e0f8e92a55923bece1ed02d16cf424e124613ddebc53ac3eeeabe"); + const ROOT: [u8; 32] = hex!("cc65c26c37ebd4abcdeb3f1ecd727527051620779a2f6c809bac0f8a87dbb816"); assert_eq!(ext.storage_root(), H256::from(ROOT)); } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index a285a246cc..e2bd336916 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 81, - impl_version: 81, + impl_version: 82, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/contract/Cargo.toml b/srml/contract/Cargo.toml index be34da3cac..7c04758171 100644 --- a/srml/contract/Cargo.toml +++ b/srml/contract/Cargo.toml @@ -25,6 +25,7 @@ assert_matches = "1.1" hex-literal = "0.2.0" consensus = { package = "srml-consensus", path = "../consensus" } balances = { package = "srml-balances", path = "../balances" } +hex = "0.3" [features] default = ["std"] diff --git a/srml/contract/src/account_db.rs b/srml/contract/src/account_db.rs index 21f2972893..5cae9f05dc 100644 --- a/srml/contract/src/account_db.rs +++ b/srml/contract/src/account_db.rs @@ -124,6 +124,7 @@ impl AccountDb for DirectAccountDb { trie_id: ::TrieIdGenerator::trie_id(&address), deduct_block: >::block_number(), rent_allowance: >::max_value(), + last_write: None, } } else { // No contract exist and no code_hash provided @@ -138,6 +139,10 @@ impl AccountDb for DirectAccountDb { new_info.code_hash = code_hash; } + if !changed.storage.is_empty() { + new_info.last_write = Some(>::block_number()); + } + for (k, v) in changed.storage.into_iter() { if let Some(value) = child::get_raw(&new_info.trie_id[..], &blake2_256(&k)) { new_info.storage_size -= value.len() as u32; diff --git a/srml/contract/src/lib.rs b/srml/contract/src/lib.rs index a255663bfb..3f05bb8a8f 100644 --- a/srml/contract/src/lib.rs +++ b/srml/contract/src/lib.rs @@ -96,9 +96,14 @@ use serde::{Serialize, Deserialize}; use substrate_primitives::crypto::UncheckedFrom; use rstd::{prelude::*, marker::PhantomData, convert::TryFrom}; use parity_codec::{Codec, Encode, Decode}; -use runtime_primitives::traits::{Hash, SimpleArithmetic, Bounded, StaticLookup, Zero}; +use runtime_io::blake2_256; +use runtime_primitives::traits::{ + Hash, SimpleArithmetic, Bounded, StaticLookup, Zero, MaybeSerializeDebug, Member +}; use srml_support::dispatch::{Result, Dispatchable}; -use srml_support::{Parameter, StorageMap, StorageValue, decl_module, decl_event, decl_storage, storage::child}; +use srml_support::{ + Parameter, StorageMap, StorageValue, decl_module, decl_event, decl_storage, storage::child +}; use srml_support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency}; use system::{ensure_signed, RawOrigin}; use substrate_primitives::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX; @@ -120,6 +125,7 @@ pub trait ComputeDispatchFee { /// Information for managing an acocunt and its sub trie abstraction. /// This is the required info to cache for an account #[derive(Encode, Decode)] +#[cfg_attr(feature = "std", derive(Debug))] pub enum ContractInfo { Alive(AliveContractInfo), Tombstone(TombstoneContractInfo), @@ -177,12 +183,14 @@ impl ContractInfo { } } -pub type AliveContractInfo = RawAliveContractInfo, BalanceOf, ::BlockNumber>; +pub type AliveContractInfo = + RawAliveContractInfo, BalanceOf, ::BlockNumber>; /// Information for managing an account and its sub trie abstraction. /// This is the required info to cache for an account. // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Encode, Decode, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] pub struct RawAliveContractInfo { /// Unique ID for the subtree encoded as a bytes vector. pub trie_id: TrieId, @@ -190,20 +198,32 @@ pub struct RawAliveContractInfo { pub storage_size: u32, /// The code associated with a given account. pub code_hash: CodeHash, + /// Pay rent at most up to this value. pub rent_allowance: Balance, + /// Last block rent has been payed. pub deduct_block: BlockNumber, + /// Last block child storage has been written. + pub last_write: Option, } -#[derive(Encode, Decode)] -pub struct TombstoneContractInfo(T::Hash); +pub type TombstoneContractInfo = + RawTombstoneContractInfo<::Hash, ::Hashing>; + +// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. +#[derive(Encode, Decode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct RawTombstoneContractInfo(H, PhantomData); -impl TombstoneContractInfo { - fn new(storage_root: Vec, storage_size: u32, code_hash: CodeHash) -> Self { +impl RawTombstoneContractInfo +where + H: Member + MaybeSerializeDebug + AsRef<[u8]> + AsMut<[u8]> + Copy + Default + rstd::hash::Hash, + Hasher: Hash, +{ + fn new(storage_root: &[u8], code_hash: H) -> Self { let mut buf = Vec::new(); storage_root.using_encoded(|encoded| buf.extend_from_slice(encoded)); - storage_size.using_encoded(|encoded| buf.extend_from_slice(encoded)); buf.extend_from_slice(code_hash.as_ref()); - TombstoneContractInfo(T::Hashing::hash(&buf[..])) + RawTombstoneContractInfo(Hasher::hash(&buf[..]), PhantomData) } } @@ -235,7 +255,10 @@ where fn trie_id(account_id: &T::AccountId) -> TrieId { // Note that skipping a value due to error is not an issue here. // We only need uniqueness, not sequence. - let new_seed = >::mutate(|v| v.wrapping_add(1)); + let new_seed = >::mutate(|v| { + *v = v.wrapping_add(1); + *v + }); let mut buf = Vec::new(); buf.extend_from_slice(account_id.as_ref()); @@ -508,6 +531,84 @@ decl_module! { } } + /// Allows a contract to restore a tombstone by giving its storage. + /// + /// The contract that wants to restore (i.e. origin of the call, or `msg.sender` in Solidity terms) will compute a + /// tombstone with its storage and the given code_hash. If the computed tombstone + /// match the destination one, the destination contract is restored with the rent_allowance` specified, + /// while the origin sends all its funds to the destination and is removed. + fn restore_to( + origin, + dest: T::AccountId, + code_hash: CodeHash, + rent_allowance: BalanceOf, + delta: Vec + ) { + let origin = ensure_signed(origin)?; + + let mut origin_contract = >::get(&origin) + .and_then(|c| c.get_alive()) + .ok_or("Cannot restore from inexisting or tombstone contract")?; + + let current_block = >::block_number(); + + if origin_contract.last_write == Some(current_block) { + return Err("Origin TrieId written in the current block"); + } + + let dest_tombstone = >::get(&dest) + .and_then(|c| c.get_tombstone()) + .ok_or("Cannot restore to inexisting or alive contract")?; + + let last_write = if !delta.is_empty() { + Some(current_block) + } else { + origin_contract.last_write + }; + + let key_values_taken = delta.iter() + .filter_map(|key| { + child::get_raw(&origin_contract.trie_id, &blake2_256(key)).map(|value| { + child::kill(&origin_contract.trie_id, &blake2_256(key)); + (key, value) + }) + }) + .collect::>(); + + let tombstone = >::new( + // This operation is cheap enough because last_write (delta not included) + // is not this block as it has been checked earlier. + &runtime_io::child_storage_root(&origin_contract.trie_id)[..], + code_hash, + ); + + if tombstone != dest_tombstone { + for (key, value) in key_values_taken { + child::put_raw(&origin_contract.trie_id, &blake2_256(key), &value); + } + + return Err("Tombstones don't match"); + } + + origin_contract.storage_size -= key_values_taken.iter() + .map(|(_, value)| value.len() as u32) + .sum::(); + + >::remove(&origin); + >::insert(&dest, ContractInfo::Alive(RawAliveContractInfo { + trie_id: origin_contract.trie_id, + storage_size: origin_contract.storage_size, + code_hash, + rent_allowance, + deduct_block: current_block, + last_write, + })); + + let origin_free_balance = T::Currency::free_balance(&origin); + T::Currency::make_free_balance_be(&origin, >::zero()); + T::Currency::deposit_creating(&dest, origin_free_balance); + } + fn on_finalize() { >::kill(); } diff --git a/srml/contract/src/rent.rs b/srml/contract/src/rent.rs index aacbb4ab7f..3baf043b90 100644 --- a/srml/contract/src/rent.rs +++ b/srml/contract/src/rent.rs @@ -163,9 +163,8 @@ fn try_evict_or_and_pay_rent( // Note: this operation is heavy. let child_storage_root = runtime_io::child_storage_root(&contract.trie_id); - let tombstone = TombstoneContractInfo::new( - child_storage_root, - contract.storage_size, + let tombstone = >::new( + &child_storage_root[..], contract.code_hash, ); >::insert(account, ContractInfo::Tombstone(tombstone)); diff --git a/srml/contract/src/tests.rs b/srml/contract/src/tests.rs index a14819850e..aeadc99353 100644 --- a/srml/contract/src/tests.rs +++ b/srml/contract/src/tests.rs @@ -34,7 +34,7 @@ use runtime_primitives::traits::{BlakeTwo256, IdentityLookup}; use runtime_primitives::BuildStorage; use srml_support::{ assert_ok, impl_outer_dispatch, impl_outer_event, impl_outer_origin, storage::child, - traits::Currency, StorageMap, + traits::Currency, StorageMap, StorageValue }; use std::sync::atomic::{AtomicUsize, Ordering}; use substrate_primitives::storage::well_known_keys; @@ -119,18 +119,21 @@ impl ContractAddressFor for DummyContractAddressFor { } } -static KEY_COUNTER: AtomicUsize = AtomicUsize::new(0); - pub struct DummyTrieIdGenerator; impl TrieIdGenerator for DummyTrieIdGenerator { fn trie_id(account_id: &u64) -> TrieId { use substrate_primitives::storage::well_known_keys; + let new_seed = >::mutate(|v| { + *v = v.wrapping_add(1); + *v + }); + // TODO: see https://github.com/paritytech/substrate/issues/2325 let mut res = vec![]; res.extend_from_slice(well_known_keys::CHILD_STORAGE_KEY_PREFIX); res.extend_from_slice(b"default:"); - res.extend_from_slice(&KEY_COUNTER.fetch_add(1, Ordering::Relaxed).to_le_bytes()); + res.extend_from_slice(&new_seed.to_le_bytes()); res.extend_from_slice(&account_id.to_le_bytes()); res } @@ -146,6 +149,7 @@ impl ComputeDispatchFee for DummyComputeDispatchFee { const ALICE: u64 = 1; const BOB: u64 = 2; const CHARLIE: u64 = 3; +const DJANGO: u64 = 4; pub struct ExtBuilder { existential_deposit: u64, @@ -263,6 +267,7 @@ fn account_removal_removes_storage() { deduct_block: System::block_number(), code_hash: H256::repeat_byte(1), rent_allowance: 40, + last_write: None, })); let mut overlay = OverlayAccountDb::::new(&DirectAccountDb); @@ -277,6 +282,7 @@ fn account_removal_removes_storage() { deduct_block: System::block_number(), code_hash: H256::repeat_byte(2), rent_allowance: 40, + last_write: None, })); let mut overlay = OverlayAccountDb::::new(&DirectAccountDb); @@ -424,7 +430,7 @@ const HASH_DISPATCH_CALL: [u8; 32] = hex!("49dfdcaf9c1553be10634467e95b8e71a3bc1 fn dispatch_call() { // This test can fail due to the encoding changes. In case it becomes too annoying // let's rewrite so as we use this module controlled call or we serialize it in runtime. - let encoded = parity_codec::Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); + let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]); let wasm = wabt::wat2wasm(CODE_DISPATCH_CALL).unwrap(); @@ -555,7 +561,7 @@ const CODE_SET_RENT: &str = r#" ;; transfer 50 to ALICE (func $call_2 (call $ext_dispatch_call - (i32.const 8) + (i32.const 68) (i32.const 11) ) ) @@ -627,10 +633,12 @@ const CODE_SET_RENT: &str = r#" (data (i32.const 0) "\28") ;; Encoding of call transfer 50 to CHARLIE - (data (i32.const 8) "\00\00\03\00\00\00\00\00\00\00\C8") + (data (i32.const 68) "\00\00\03\00\00\00\00\00\00\00\C8") ) "#; -const HASH_SET_RENT: [u8; 32] = hex!("a51c2a6f3f68936d4ae9abdb93b28eedcbd0f6f39770e168f9025f0c1e7094ef"); + +// Use test_hash_and_code test to get the actual hash if the code changed. +const HASH_SET_RENT: [u8; 32] = hex!("21d6b1d59aa6038fcad632488e9026893a1bbb48581774c771b8f24320697f05"); /// Input data for each call in set_rent code mod call { @@ -643,10 +651,10 @@ mod call { /// Test correspondance of set_rent code and its hash. /// Also test that encoded extrinsic in code correspond to the correct transfer #[test] -fn set_rent_hash_and_code() { +fn test_set_rent_code_and_hash() { // This test can fail due to the encoding changes. In case it becomes too annoying // let's rewrite so as we use this module controlled call or we serialize it in runtime. - let encoded = parity_codec::Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); + let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]); let wasm = wabt::wat2wasm(CODE_SET_RENT).unwrap(); @@ -657,7 +665,8 @@ fn set_rent_hash_and_code() { Balances::deposit_creating(&ALICE, 1_000_000); assert_ok!(Contract::put_code(Origin::signed(ALICE), 100_000, wasm)); - // If you ever need to update the wasm source this test will fail and will show you the actual hash. + // If you ever need to update the wasm source this test will fail + // and will show you the actual hash. assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), @@ -691,15 +700,15 @@ fn storage_size() { 100_000, HASH_SET_RENT.into(), ::Balance::from(1_000u32).encode() // rent allowance )); - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.storage_size, Contract::storage_size_offset() + 4); assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::set_storage_4_byte())); - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.storage_size, Contract::storage_size_offset() + 4 + 4); assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::remove_storage_4_byte())); - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.storage_size, Contract::storage_size_offset() + 4); } ); @@ -723,7 +732,7 @@ fn deduct_blocks() { )); // Check creation - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.rent_allowance, 1_000); // Advance 4 blocks @@ -736,7 +745,7 @@ fn deduct_blocks() { let rent = (8 + 4 - 3) // storage size = size_offset + deploy_set_storage - deposit_offset * 4 // rent byte price * 4; // blocks to rent - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.rent_allowance, 1_000 - rent); assert_eq!(bob_contract.deduct_block, 5); assert_eq!(Balances::free_balance(BOB), 30_000 - rent); @@ -751,7 +760,7 @@ fn deduct_blocks() { let rent_2 = (8 + 4 - 2) // storage size = size_offset + deploy_set_storage - deposit_offset * 4 // rent byte price * 7; // blocks to rent - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.rent_allowance, 1_000 - rent - rent_2); assert_eq!(bob_contract.deduct_block, 12); assert_eq!(Balances::free_balance(BOB), 30_000 - rent - rent_2); @@ -759,7 +768,7 @@ fn deduct_blocks() { // Second call on same block should have no effect on rent assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.rent_allowance, 1_000 - rent - rent_2); assert_eq!(bob_contract.deduct_block, 12); assert_eq!(Balances::free_balance(BOB), 30_000 - rent - rent_2); @@ -822,9 +831,9 @@ fn claim_surcharge(blocks: u64, trigger_call: impl Fn() -> bool, removes: bool) assert!(trigger_call()); if removes { - assert!(super::ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); } else { - assert!(super::ContractInfoOf::::get(BOB).unwrap().get_alive().is_some()); + assert!(ContractInfoOf::::get(BOB).unwrap().get_alive().is_some()); } } ); @@ -853,21 +862,21 @@ fn removals(trigger_call: impl Fn() -> bool) { // Trigger rent must have no effect assert!(trigger_call()); - assert_eq!(super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); + assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); // Advance blocks System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into()); // Trigger rent through call assert!(trigger_call()); - assert!(super::ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); // Advance blocks System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into()); // Trigger rent must have no effect assert!(trigger_call()); - assert!(super::ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); } ); @@ -887,21 +896,21 @@ fn removals(trigger_call: impl Fn() -> bool) { // Trigger rent must have no effect assert!(trigger_call()); - assert_eq!(super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 100); + assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 100); // Advance blocks System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into()); // Trigger rent through call assert!(trigger_call()); - assert!(super::ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); // Advance blocks System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into()); // Trigger rent must have no effect assert!(trigger_call()); - assert!(super::ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); } ); @@ -921,25 +930,25 @@ fn removals(trigger_call: impl Fn() -> bool) { // Trigger rent must have no effect assert!(trigger_call()); - assert_eq!(super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); + assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); // Transfer funds assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::transfer())); - assert_eq!(super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); + assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); // Advance blocks System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into()); // Trigger rent through call assert!(trigger_call()); - assert!(super::ContractInfoOf::::get(BOB).is_none()); + assert!(ContractInfoOf::::get(BOB).is_none()); // Advance blocks System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into()); // Trigger rent must have no effect assert!(trigger_call()); - assert!(super::ContractInfoOf::::get(BOB).is_none()); + assert!(ContractInfoOf::::get(BOB).is_none()); } ); } @@ -1014,7 +1023,7 @@ fn default_rent_allowance_on_create() { )); // Check creation - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.rent_allowance, >::max_value()); // Advance blocks @@ -1024,8 +1033,196 @@ fn default_rent_allowance_on_create() { assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); // Check contract is still alive - let bob_contract = super::ContractInfoOf::::get(BOB).unwrap().get_alive(); + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive(); assert!(bob_contract.is_some()) } ); } + +const CODE_RESTORATION: &str = r#" +(module + (import "env" "ext_set_storage" (func $ext_set_storage (param i32 i32 i32 i32))) + (import "env" "ext_dispatch_call" (func $ext_dispatch_call (param i32 i32))) + (import "env" "memory" (memory 1 1)) + + (func (export "call") + (call $ext_dispatch_call + (i32.const 200) ;; Pointer to the start of encoded call buffer + (i32.const 115) ;; Length of the buffer + ) + ) + (func (export "deploy") + ;; Data to restore + (call $ext_set_storage + (i32.const 0) + (i32.const 1) + (i32.const 0) + (i32.const 4) + ) + + ;; ACL + (call $ext_set_storage + (i32.const 100) + (i32.const 1) + (i32.const 0) + (i32.const 4) + ) + ) + + ;; Data to restore + (data (i32.const 0) "\28") + + ;; ACL + (data (i32.const 100) "\01") + + ;; Call + (data (i32.const 200) "\01\05\02\00\00\00\00\00\00\00\21\d6\b1\d5\9a\a6\03\8f\ca\d6\32\48\8e\90" + "\26\89\3a\1b\bb\48\58\17\74\c7\71\b8\f2\43\20\69\7f\05\32\00\00\00\00\00\00\00\08\01\00\00" + "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01" + "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" + "\00" + ) +) +"#; +const HASH_RESTORATION: [u8; 32] = hex!("b393bfa8de97b02f08ba1580b46100a80c9489a97c8d870691c9ff7236b29bc7"); + +#[test] +fn restorations_dirty_storage_and_different_storage() { + restoration(true, true); +} + +#[test] +fn restorations_dirty_storage() { + restoration(false, true); +} + +#[test] +fn restoration_different_storage() { + restoration(true, false); +} + +#[test] +fn restoration_success() { + restoration(false, false); +} + +fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage: bool) { + let acl_key = { + let mut s = [0u8; 32]; + s[0] = 1; + s + }; + + // This test can fail due to the encoding changes. In case it becomes too annoying + // let's rewrite so as we use this module controlled call or we serialize it in runtime. + let encoded = hex::encode(Encode::encode(&Call::Contract(super::Call::restore_to( + BOB, + HASH_SET_RENT.into(), + ::Balance::from(50u32), + vec![acl_key, acl_key], + )))); + + let literal = "0105020000000000000021d6b1d59aa6038fcad632488e9026893a1bbb48581774c771b8f243206\ + 97f053200000000000000080100000000000000000000000000000000000000000000000000000000000000010\ + 0000000000000000000000000000000000000000000000000000000000000"; + + assert_eq!(encoded, literal); + assert_eq!(115, hex::decode(literal).unwrap().len()); + + let restoration_wasm = wabt::wat2wasm(CODE_RESTORATION).unwrap(); + let set_rent_wasm = wabt::wat2wasm(CODE_SET_RENT).unwrap(); + + with_externalities( + &mut ExtBuilder::default().existential_deposit(50).build(), + || { + Balances::deposit_creating(&ALICE, 1_000_000); + assert_ok!(Contract::put_code(Origin::signed(ALICE), 100_000, restoration_wasm)); + assert_ok!(Contract::put_code(Origin::signed(ALICE), 100_000, set_rent_wasm)); + + // If you ever need to update the wasm source this test will fail + // and will show you the actual hash. + assert_eq!(System::events(), vec![ + EventRecord { + phase: Phase::ApplyExtrinsic(0), + event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + topics: vec![], + }, + EventRecord { + phase: Phase::ApplyExtrinsic(0), + event: MetaEvent::contract(RawEvent::CodeStored(HASH_RESTORATION.into())), + topics: vec![], + }, + EventRecord { + phase: Phase::ApplyExtrinsic(0), + event: MetaEvent::contract(RawEvent::CodeStored(HASH_SET_RENT.into())), + topics: vec![], + }, + ]); + + assert_ok!(Contract::create( + Origin::signed(ALICE), + 30_000, + 100_000, HASH_SET_RENT.into(), + ::Balance::from(0u32).encode() + )); + + // Check creation + let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); + assert_eq!(bob_contract.rent_allowance, 0); + + if test_different_storage { + assert_ok!(Contract::call( + Origin::signed(ALICE), + BOB, 0, 100_000, + call::set_storage_4_byte()) + ); + } + + // Advance 4 blocks + System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into()); + + // Trigger rent through call + assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + + Balances::deposit_creating(&CHARLIE, 1_000_000); + assert_ok!(Contract::create( + Origin::signed(CHARLIE), + 30_000, + 100_000, HASH_RESTORATION.into(), + ::Balance::from(0u32).encode() + )); + + let django_trie_id = ContractInfoOf::::get(DJANGO).unwrap() + .get_alive().unwrap().trie_id; + + if !test_restore_to_with_dirty_storage { + // Advance 1 blocks + System::initialize(&6, &[0u8; 32].into(), &[0u8; 32].into()); + } + + assert_ok!(Contract::call( + Origin::signed(ALICE), + DJANGO, 0, 100_000, + vec![], + )); + + if test_different_storage || test_restore_to_with_dirty_storage { + assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); + let django_contract = ContractInfoOf::::get(DJANGO).unwrap() + .get_alive().unwrap(); + assert_eq!(django_contract.storage_size, 16); + assert_eq!(django_contract.trie_id, django_trie_id); + assert_eq!(django_contract.deduct_block, System::block_number()); + } else { + let bob_contract = ContractInfoOf::::get(BOB).unwrap() + .get_alive().unwrap(); + assert_eq!(bob_contract.rent_allowance, 50); + assert_eq!(bob_contract.storage_size, 12); + assert_eq!(bob_contract.trie_id, django_trie_id); + assert_eq!(bob_contract.deduct_block, System::block_number()); + assert!(ContractInfoOf::::get(DJANGO).is_none()); + } + } + ); +} diff --git a/srml/executive/src/lib.rs b/srml/executive/src/lib.rs index 3dc161bb0c..33d26ce42f 100644 --- a/srml/executive/src/lib.rs +++ b/srml/executive/src/lib.rs @@ -474,7 +474,7 @@ mod tests { header: Header { parent_hash: [69u8; 32].into(), number: 1, - state_root: hex!("ac2840371d51ff2e036c8fc05af7313b7a030f735c38b2f03b94cbe87bfbb7c9").into(), + state_root: hex!("5ba497e45e379d80a4524f9509d224e9c175d0fa30f3491481e7e44a6a758adf").into(), extrinsics_root: hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into(), digest: Digest { logs: vec![], }, }, -- GitLab From 373e490f93522d5ab9aa690ca3908b2a3b0e8762 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 23 May 2019 21:13:23 +0200 Subject: [PATCH 024/113] Rework the OnDemand service (#2670) * Rework the OnDemand service * Try fix line widths --- core/network/src/config.rs | 4 +- core/network/src/lib.rs | 4 +- core/network/src/on_demand.rs | 926 ++++++++++++---------------- core/network/src/on_demand_layer.rs | 149 +++++ core/network/src/protocol.rs | 137 ++-- core/network/src/service.rs | 18 +- core/network/src/test/mod.rs | 5 +- core/service/src/lib.rs | 5 +- 8 files changed, 665 insertions(+), 583 deletions(-) create mode 100644 core/network/src/on_demand_layer.rs diff --git a/core/network/src/config.rs b/core/network/src/config.rs index 05cf27ca75..a2a34780bf 100644 --- a/core/network/src/config.rs +++ b/core/network/src/config.rs @@ -21,7 +21,7 @@ pub use network_libp2p::{NonReservedPeerMode, NetworkConfiguration, NodeKeyConfi use bitflags::bitflags; use crate::chain::{Client, FinalityProofProvider}; use parity_codec; -use crate::on_demand::OnDemandService; +use crate::on_demand_layer::OnDemand; use runtime_primitives::traits::{Block as BlockT}; use crate::service::{ExHashT, TransactionPool}; use std::sync::Arc; @@ -37,7 +37,7 @@ pub struct Params { /// Finality proof provider. pub finality_proof_provider: Option>>, /// On-demand service reference. - pub on_demand: Option>>, + pub on_demand: Option>>, /// Transaction pool. pub transaction_pool: Arc>, /// Protocol specialization. diff --git a/core/network/src/lib.rs b/core/network/src/lib.rs index 4d69767c7b..e3ed56d5ad 100644 --- a/core/network/src/lib.rs +++ b/core/network/src/lib.rs @@ -30,6 +30,7 @@ mod protocol; mod chain; mod blocks; mod on_demand; +mod on_demand_layer; mod util; pub mod config; pub mod consensus_gossip; @@ -56,6 +57,7 @@ pub use network_libp2p::{ }; pub use message::{generic as generic_message, RequestId, Status as StatusMessage}; pub use error::Error; -pub use on_demand::{OnDemand, OnDemandService, RemoteResponse}; +pub use on_demand::AlwaysBadChecker; +pub use on_demand_layer::{OnDemand, RemoteResponse}; #[doc(hidden)] pub use runtime_primitives::traits::Block as BlockT; diff --git a/core/network/src/on_demand.rs b/core/network/src/on_demand.rs index ec4c178232..f77b50dac6 100644 --- a/core/network/src/on_demand.rs +++ b/core/network/src/on_demand.rs @@ -17,22 +17,18 @@ //! On-demand requests service. use std::collections::{HashMap, VecDeque}; -use std::sync::{Arc, Weak}; +use std::sync::Arc; use std::time::{Instant, Duration}; use log::{trace, info}; -use futures::{Async, Future, Poll}; -use futures::sync::oneshot::{channel, Receiver, Sender as OneShotSender}; +use futures::sync::oneshot::{Sender as OneShotSender}; use linked_hash_map::{Entry, LinkedHashMap}; -use parking_lot::Mutex; use client::error::Error as ClientError; -use client::light::fetcher::{Fetcher, FetchChecker, RemoteHeaderRequest, +use client::light::fetcher::{FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, ChangesProof, RemoteReadChildRequest, RemoteBodyRequest}; use crate::message; use network_libp2p::PeerId; use crate::config::Roles; -use crate::service::Service as NetworkService; -use crate::specialization::NetworkSpecialization; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; /// Remote request timeout. @@ -42,97 +38,21 @@ const RETRY_COUNT: usize = 1; /// Reputation change for a peer when a request timed out. const TIMEOUT_REPUTATION_CHANGE: i32 = -(1 << 8); -/// On-demand service API. -pub trait OnDemandService: Send + Sync { - /// When new node is connected. - fn on_connect(&self, peer: PeerId, role: Roles, best_number: NumberFor); - - /// When block is announced by the peer. - fn on_block_announce(&self, peer: PeerId, best_number: NumberFor); - - /// When node is disconnected. - fn on_disconnect(&self, peer: PeerId); - - /// Maintain peers requests. - fn maintain_peers(&self); - - /// When header response is received from remote node. - fn on_remote_header_response( - &self, - peer: PeerId, - response: message::RemoteHeaderResponse - ); - - /// When read response is received from remote node. - fn on_remote_read_response(&self, peer: PeerId, response: message::RemoteReadResponse); - - /// When call response is received from remote node. - fn on_remote_call_response(&self, peer: PeerId, response: message::RemoteCallResponse); - - /// When changes response is received from remote node. - fn on_remote_changes_response( - &self, - peer: PeerId, - response: message::RemoteChangesResponse, Block::Hash> - ); - - /// When body response is received from remote node. - fn on_remote_body_response( - &self, - peer: PeerId, - response: message::BlockResponse - ); - - /// Check whether a block response is an `on_demand` response - fn is_on_demand_response(&self, peer: &PeerId, request_id: message::RequestId) -> bool; -} - -/// Trait used by the `OnDemand` service to communicate messages back to the network. +/// Trait used by the `OnDemandCore` service to communicate messages back to the network. pub trait OnDemandNetwork { /// Adjusts the reputation of the given peer. - fn report_peer(&self, who: &PeerId, reputation_change: i32); + fn report_peer(&mut self, who: &PeerId, reputation_change: i32); /// Disconnect from the given peer. Used in case of misbehaviour. - fn disconnect_peer(&self, who: &PeerId); + fn disconnect_peer(&mut self, who: &PeerId); /// Send a request to a peer. - fn send_request(&self, who: &PeerId, message: message::Message); -} - -impl> OnDemandNetwork for Weak> { - fn report_peer(&self, who: &PeerId, reputation_change: i32) { - if let Some(service) = self.upgrade() { - service.report_peer(who.clone(), reputation_change) - } - } - - fn disconnect_peer(&self, who: &PeerId) { - if let Some(service) = self.upgrade() { - service.disconnect_peer(who.clone()) - } - } - - fn send_request(&self, who: &PeerId, message: message::Message) { - if let Some(service) = self.upgrade() { - service.send_request(who.clone(), message) - } - } + fn send_request(&mut self, who: &PeerId, message: message::Message); } /// On-demand requests service. Dispatches requests to appropriate peers. -pub struct OnDemand { - core: Mutex>, - checker: Arc>, - network_interface: Mutex + Send + Sync + 'static>>>, -} - -/// On-demand remote call response. -pub struct RemoteResponse { - receiver: Receiver>, -} - -#[derive(Default)] -struct OnDemandCore { +pub struct OnDemandCore { + checker: Arc>, next_request_id: u64, pending_requests: VecDeque>, active_peers: LinkedHashMap>, @@ -147,7 +67,10 @@ struct Request { data: RequestData, } -enum RequestData { +/// One request for data made by the `Client`. +/// +/// Contains a `Sender` where to send the result. +pub(crate) enum RequestData { RemoteBody(RemoteBodyRequest, OneShotSender, ClientError>>), RemoteHeader(RemoteHeaderRequest, OneShotSender>), RemoteRead(RemoteReadRequest, OneShotSender>, ClientError>>), @@ -156,7 +79,10 @@ enum RequestData { OneShotSender>, ClientError>> ), RemoteCall(RemoteCallRequest, OneShotSender, ClientError>>), - RemoteChanges(RemoteChangesRequest, OneShotSender, u32)>, ClientError>>), + RemoteChanges( + RemoteChangesRequest, + OneShotSender, u32)>, ClientError>> + ), } enum Accept { @@ -165,103 +91,126 @@ enum Accept { Unexpected(RequestData), } -impl Future for RemoteResponse { - type Item = T; - type Error = ClientError; - - fn poll(&mut self) -> Poll { - self.receiver.poll() - .map_err(|_| ClientError::RemoteFetchCancelled.into()) - .and_then(|r| match r { - Async::Ready(Ok(ready)) => Ok(Async::Ready(ready)), - Async::Ready(Err(error)) => Err(error), - Async::NotReady => Ok(Async::NotReady), - }) +/// Dummy implementation of `FetchChecker` that always assumes that responses are bad. +/// +/// Considering that it is the responsibility of the client to build the fetcher, it can use this +/// implementation if it knows that it will never perform any request. +#[derive(Default, Clone)] +pub struct AlwaysBadChecker; + +impl FetchChecker for AlwaysBadChecker { + fn check_header_proof( + &self, + _request: &RemoteHeaderRequest, + _remote_header: Option, + _remote_proof: Vec> + ) -> Result { + Err(ClientError::Msg("AlwaysBadChecker".into())) } -} -impl OnDemand where - B::Header: HeaderT, -{ - /// Creates new on-demand service. - pub fn new(checker: Arc>) -> Self { - OnDemand { - checker, - network_interface: Mutex::new(None), - core: Mutex::new(OnDemandCore { - next_request_id: 0, - pending_requests: VecDeque::new(), - active_peers: LinkedHashMap::new(), - idle_peers: VecDeque::new(), - best_blocks: HashMap::new(), - }) - } + fn check_read_proof( + &self, + _request: &RemoteReadRequest, + _remote_proof: Vec> + ) -> Result>, ClientError> { + Err(ClientError::Msg("AlwaysBadChecker".into())) } - /// Get checker reference. - pub fn checker(&self) -> &Arc> { - &self.checker + fn check_read_child_proof( + &self, + _request: &RemoteReadChildRequest, + _remote_proof: Vec> + ) -> Result>, ClientError> { + Err(ClientError::Msg("AlwaysBadChecker".into())) + } + + fn check_execution_proof( + &self, + _request: &RemoteCallRequest, + _remote_proof: Vec> + ) -> Result, ClientError> { + Err(ClientError::Msg("AlwaysBadChecker".into())) } - /// Sets weak reference to network service. - pub fn set_network_interface(&self, network_interface: Box + Send + Sync + 'static>) { - self.network_interface.lock().replace(network_interface); + fn check_changes_proof( + &self, + _request: &RemoteChangesRequest, + _remote_proof: ChangesProof + ) -> Result, u32)>, ClientError> { + Err(ClientError::Msg("AlwaysBadChecker".into())) } - fn report_peer(&self, who: &PeerId, reputation_change: i32) { - self.network_interface - .lock() - .as_ref() - .expect("1. OnDemand is passed a network sender upon initialization of the service, 2. it should bet set by now") - .report_peer(who, reputation_change); + fn check_body_proof( + &self, + _request: &RemoteBodyRequest, + _body: Vec + ) -> Result, ClientError> { + Err(ClientError::Msg("AlwaysBadChecker".into())) } +} - fn disconnect_peer(&self, who: &PeerId) { - self.network_interface - .lock() - .as_ref() - .expect("1. OnDemand is passed a network sender upon initialization of the service, 2. it should bet set by now") - .disconnect_peer(who); +impl OnDemandCore where + B::Header: HeaderT, +{ + /// Creates new on-demand requests processer. + pub fn new(checker: Arc>) -> Self { + OnDemandCore { + checker, + next_request_id: 0, + pending_requests: VecDeque::new(), + active_peers: LinkedHashMap::new(), + idle_peers: VecDeque::new(), + best_blocks: HashMap::new(), + } } - fn send_request(&self, who: &PeerId, msg: message::Message) { - self.network_interface - .lock() - .as_ref() - .expect("1. OnDemand is passed a network sender upon initialization of the service, 2. it should bet set by now") - .send_request(who, msg); + /// Inserts a new request in the list of requests to execute. + pub(crate) fn add_request(&mut self, network: impl OnDemandNetwork, data: RequestData) { + self.insert(RETRY_COUNT, data); + self.dispatch(network); } - /// Schedule && dispatch all scheduled requests. - fn schedule_request(&self, retry_count: Option, data: RequestData, result: R) -> R { - let mut core = self.core.lock(); - core.insert(retry_count.unwrap_or(RETRY_COUNT), data); - core.dispatch(self); - result + /// Inserts a new request in the list of requests to execute. + fn insert(&mut self, retry_count: usize, data: RequestData) { + let request_id = self.next_request_id; + self.next_request_id += 1; + + self.pending_requests.push_back(Request { + id: request_id, + timestamp: Instant::now(), + retry_count, + data, + }); } /// Try to accept response from given peer. - fn accept_response) -> Accept>(&self, rtype: &str, peer: PeerId, request_id: u64, try_accept: F) { - let mut core = self.core.lock(); - let request = match core.remove(peer.clone(), request_id) { + fn accept_response( + &mut self, + rtype: &str, + mut network: impl OnDemandNetwork, + peer: PeerId, + request_id: u64, + try_accept: impl FnOnce(Request, &Arc>) -> Accept + ) { + let request = match self.remove(peer.clone(), request_id) { Some(request) => request, None => { info!("Invalid remote {} response from peer {}", rtype, peer); - self.report_peer(&peer, i32::min_value()); - self.disconnect_peer(&peer); - core.remove_peer(peer); + network.report_peer(&peer, i32::min_value()); + network.disconnect_peer(&peer); + self.remove_peer(peer); return; }, }; let retry_count = request.retry_count; - let (retry_count, retry_request_data) = match try_accept(request) { + let (retry_count, retry_request_data) = match try_accept(request, &self.checker) { Accept::Ok => (retry_count, None), Accept::CheckFailed(error, retry_request_data) => { info!("Failed to check remote {} response from peer {}: {}", rtype, peer, error); - self.report_peer(&peer, i32::min_value()); - self.disconnect_peer(&peer); - core.remove_peer(peer); + network.report_peer(&peer, i32::min_value()); + network.disconnect_peer(&peer); + self.remove_peer(peer); if retry_count > 0 { (retry_count - 1, Some(retry_request_data)) @@ -273,60 +222,78 @@ impl OnDemand where }, Accept::Unexpected(retry_request_data) => { info!("Unexpected response to remote {} from peer", rtype); - self.report_peer(&peer, i32::min_value()); - self.disconnect_peer(&peer); - core.remove_peer(peer); + network.report_peer(&peer, i32::min_value()); + network.disconnect_peer(&peer); + self.remove_peer(peer); (retry_count, Some(retry_request_data)) }, }; if let Some(request_data) = retry_request_data { - core.insert(retry_count, request_data); + self.insert(retry_count, request_data); } - core.dispatch(self); + self.dispatch(network); } -} -impl OnDemandService for OnDemand where - B: BlockT, - B::Header: HeaderT, -{ - fn on_connect(&self, peer: PeerId, role: Roles, best_number: NumberFor) { + pub fn on_connect( + &mut self, + network: impl OnDemandNetwork, + peer: PeerId, + role: Roles, + best_number: NumberFor + ) { if !role.is_full() { return; } - let mut core = self.core.lock(); - core.add_peer(peer, best_number); - core.dispatch(self); + self.idle_peers.push_back(peer.clone()); + self.best_blocks.insert(peer, best_number); + + self.dispatch(network); } - fn on_block_announce(&self, peer: PeerId, best_number: NumberFor) { - let mut core = self.core.lock(); - core.update_peer(peer, best_number); - core.dispatch(self); + pub fn on_block_announce(&mut self, network: impl OnDemandNetwork, peer: PeerId, best_number: NumberFor) { + self.best_blocks.insert(peer, best_number); + self.dispatch(network); } - fn on_disconnect(&self, peer: PeerId) { - let mut core = self.core.lock(); - core.remove_peer(peer); - core.dispatch(self); + pub fn on_disconnect(&mut self, network: impl OnDemandNetwork, peer: PeerId) { + self.remove_peer(peer); + self.dispatch(network); } - fn maintain_peers(&self) { - let mut core = self.core.lock(); - for bad_peer in core.maintain_peers() { - self.report_peer(&bad_peer, TIMEOUT_REPUTATION_CHANGE); - self.disconnect_peer(&bad_peer); + pub fn maintain_peers(&mut self, mut network: impl OnDemandNetwork) { + let now = Instant::now(); + + loop { + match self.active_peers.front() { + Some((_, request)) if now - request.timestamp >= REQUEST_TIMEOUT => (), + _ => break, + } + + let (bad_peer, request) = self.active_peers.pop_front().expect("front() is Some as checked above"); + self.pending_requests.push_front(request); + network.report_peer(&bad_peer, TIMEOUT_REPUTATION_CHANGE); + network.disconnect_peer(&bad_peer); } - core.dispatch(self); + + self.dispatch(network); } - fn on_remote_header_response(&self, peer: PeerId, response: message::RemoteHeaderResponse) { - self.accept_response("header", peer, response.id, |request| match request.data { - RequestData::RemoteHeader(request, sender) => match self.checker.check_header_proof(&request, response.header, response.proof) { + pub fn on_remote_header_response( + &mut self, + network: impl OnDemandNetwork, + peer: PeerId, + response: message::RemoteHeaderResponse + ) { + self.accept_response("header", network, peer, response.id, |request, checker| match request.data { + RequestData::RemoteHeader(request, sender) => match checker.check_header_proof( + &request, + response.header, + response.proof + ) { Ok(response) => { // we do not bother if receiver has been dropped already let _ = sender.send(Ok(response)); @@ -338,10 +305,15 @@ impl OnDemandService for OnDemand where }) } - fn on_remote_read_response(&self, peer: PeerId, response: message::RemoteReadResponse) { - self.accept_response("read", peer, response.id, |request| match request.data { + pub fn on_remote_read_response( + &mut self, + network: impl OnDemandNetwork, + peer: PeerId, + response: message::RemoteReadResponse + ) { + self.accept_response("read", network, peer, response.id, |request, checker| match request.data { RequestData::RemoteRead(request, sender) => { - match self.checker.check_read_proof(&request, response.proof) { + match checker.check_read_proof(&request, response.proof) { Ok(response) => { // we do not bother if receiver has been dropped already let _ = sender.send(Ok(response)); @@ -353,7 +325,7 @@ impl OnDemandService for OnDemand where ), }}, RequestData::RemoteReadChild(request, sender) => { - match self.checker.check_read_child_proof(&request, response.proof) { + match checker.check_read_child_proof(&request, response.proof) { Ok(response) => { // we do not bother if receiver has been dropped already let _ = sender.send(Ok(response)); @@ -368,9 +340,14 @@ impl OnDemandService for OnDemand where }) } - fn on_remote_call_response(&self, peer: PeerId, response: message::RemoteCallResponse) { - self.accept_response("call", peer, response.id, |request| match request.data { - RequestData::RemoteCall(request, sender) => match self.checker.check_execution_proof(&request, response.proof) { + pub fn on_remote_call_response( + &mut self, + network: impl OnDemandNetwork, + peer: PeerId, + response: message::RemoteCallResponse + ) { + self.accept_response("call", network, peer, response.id, |request, checker| match request.data { + RequestData::RemoteCall(request, sender) => match checker.check_execution_proof(&request, response.proof) { Ok(response) => { // we do not bother if receiver has been dropped already let _ = sender.send(Ok(response)); @@ -382,9 +359,14 @@ impl OnDemandService for OnDemand where }) } - fn on_remote_changes_response(&self, peer: PeerId, response: message::RemoteChangesResponse, B::Hash>) { - self.accept_response("changes", peer, response.id, |request| match request.data { - RequestData::RemoteChanges(request, sender) => match self.checker.check_changes_proof( + pub fn on_remote_changes_response( + &mut self, + network: impl OnDemandNetwork, + peer: PeerId, + response: message::RemoteChangesResponse, B::Hash> + ) { + self.accept_response("changes", network, peer, response.id, |request, checker| match request.data { + RequestData::RemoteChanges(request, sender) => match checker.check_changes_proof( &request, ChangesProof { max_block: response.max, proof: response.proof, @@ -402,8 +384,13 @@ impl OnDemandService for OnDemand where }) } - fn on_remote_body_response(&self, peer: PeerId, response: message::BlockResponse) { - self.accept_response("body", peer, response.id, |request| match request.data { + pub fn on_remote_body_response( + &mut self, + network: impl OnDemandNetwork, + peer: PeerId, + response: message::BlockResponse + ) { + self.accept_response("body", network, peer, response.id, |request, checker| match request.data { RequestData::RemoteBody(request, sender) => { let mut bodies: Vec<_> = response .blocks @@ -420,7 +407,7 @@ impl OnDemandService for OnDemand where } let body = bodies.remove(0); - match self.checker.check_body_proof(&request, body) { + match checker.check_body_proof(&request, body) { Ok(body) => { let _ = sender.send(Ok(body)); Accept::Ok @@ -432,83 +419,21 @@ impl OnDemandService for OnDemand where }) } - fn is_on_demand_response(&self, peer: &PeerId, request_id: message::RequestId) -> bool { - let core = self.core.lock(); - core.is_pending_request(&peer, request_id) - } -} - -impl Fetcher for OnDemand where - B: BlockT, - B::Header: HeaderT, -{ - type RemoteHeaderResult = RemoteResponse; - type RemoteReadResult = RemoteResponse>>; - type RemoteCallResult = RemoteResponse>; - type RemoteChangesResult = RemoteResponse, u32)>>; - type RemoteBodyResult = RemoteResponse>; - - fn remote_header(&self, request: RemoteHeaderRequest) -> Self::RemoteHeaderResult { - let (sender, receiver) = channel(); - self.schedule_request(request.retry_count.clone(), RequestData::RemoteHeader(request, sender), - RemoteResponse { receiver }) - } - - fn remote_read(&self, request: RemoteReadRequest) -> Self::RemoteReadResult { - let (sender, receiver) = channel(); - self.schedule_request( - request.retry_count.clone(), - RequestData::RemoteRead(request, sender), - RemoteResponse { receiver } - ) - } - - fn remote_read_child( - &self, - request: RemoteReadChildRequest - ) -> Self::RemoteReadResult { - let (sender, receiver) = channel(); - self.schedule_request( - request.retry_count.clone(), - RequestData::RemoteReadChild(request, sender), - RemoteResponse { receiver } - ) - } - - fn remote_call(&self, request: RemoteCallRequest) -> Self::RemoteCallResult { - let (sender, receiver) = channel(); - self.schedule_request(request.retry_count.clone(), RequestData::RemoteCall(request, sender), - RemoteResponse { receiver }) - } - - fn remote_changes(&self, request: RemoteChangesRequest) -> Self::RemoteChangesResult { - let (sender, receiver) = channel(); - self.schedule_request(request.retry_count.clone(), RequestData::RemoteChanges(request, sender), - RemoteResponse { receiver }) - } - - fn remote_body(&self, request: RemoteBodyRequest) -> Self::RemoteBodyResult { - let (sender, receiver) = channel(); - self.schedule_request(request.retry_count.clone(), RequestData::RemoteBody(request, sender), - RemoteResponse { receiver }) - } -} - -impl OnDemandCore where - B: BlockT, - B::Header: HeaderT, -{ - fn is_pending_request(&self, peer: &PeerId, request_id: message::RequestId) -> bool { + pub fn is_on_demand_response(&self, peer: &PeerId, request_id: message::RequestId) -> bool { self.active_peers.get(&peer).map_or(false, |r| r.id == request_id) } - pub fn add_peer(&mut self, peer: PeerId, best_number: NumberFor) { - self.idle_peers.push_back(peer.clone()); - self.best_blocks.insert(peer, best_number); - } - - pub fn update_peer(&mut self, peer: PeerId, best_number: NumberFor) { - self.best_blocks.insert(peer, best_number); + fn remove(&mut self, peer: PeerId, id: u64) -> Option> { + match self.active_peers.entry(peer.clone()) { + Entry::Occupied(entry) => match entry.get().id == id { + true => { + self.idle_peers.push_back(peer); + Some(entry.remove()) + }, + false => None, + }, + Entry::Vacant(_) => None, + } } pub fn remove_peer(&mut self, peer: PeerId) { @@ -524,48 +449,8 @@ impl OnDemandCore where } } - pub fn maintain_peers(&mut self) -> Vec { - let now = Instant::now(); - let mut bad_peers = Vec::new(); - loop { - match self.active_peers.front() { - Some((_, request)) if now - request.timestamp >= REQUEST_TIMEOUT => (), - _ => return bad_peers, - } - - let (bad_peer, request) = self.active_peers.pop_front().expect("front() is Some as checked above"); - self.pending_requests.push_front(request); - bad_peers.push(bad_peer); - } - } - - pub fn insert(&mut self, retry_count: usize, data: RequestData) { - let request_id = self.next_request_id; - self.next_request_id += 1; - - self.pending_requests.push_back(Request { - id: request_id, - timestamp: Instant::now(), - retry_count, - data, - }); - } - - pub fn remove(&mut self, peer: PeerId, id: u64) -> Option> { - match self.active_peers.entry(peer.clone()) { - Entry::Occupied(entry) => match entry.get().id == id { - true => { - self.idle_peers.push_back(peer); - Some(entry.remove()) - }, - false => None, - }, - Entry::Vacant(_) => None, - } - } - - pub fn dispatch(&mut self, on_demand: &OnDemand) { - + /// Dispatches pending requests. + fn dispatch(&mut self, mut network: impl OnDemandNetwork) { let mut last_peer = self.idle_peers.back().cloned(); let mut unhandled_requests = VecDeque::new(); @@ -610,7 +495,7 @@ impl OnDemandCore where let mut request = self.pending_requests.pop_front().expect("checked in loop condition; qed"); request.timestamp = Instant::now(); trace!(target: "sync", "Dispatching remote request {} to peer {}", request.id, peer); - on_demand.send_request(&peer, request.message()); + network.send_request(&peer, request.message()); self.active_peers.insert(peer, request); } @@ -619,7 +504,7 @@ impl OnDemandCore where } impl Request { - pub fn required_block(&self) -> NumberFor { + fn required_block(&self) -> NumberFor { match self.data { RequestData::RemoteHeader(ref data, _) => data.block, RequestData::RemoteRead(ref data, _) => *data.header.number(), @@ -630,7 +515,7 @@ impl Request { } } - pub fn message(&self) -> message::Message { + fn message(&self) -> message::Message { match self.data { RequestData::RemoteHeader(ref data, _) => message::generic::Message::RemoteHeaderRequest(message::RemoteHeaderRequest { @@ -682,7 +567,7 @@ impl Request { } impl RequestData { - pub fn fail(self, error: ClientError) { + fn fail(self, error: ClientError) { // don't care if anyone is listening match self { RequestData::RemoteHeader(_, sender) => { let _ = sender.send(Err(error)); }, @@ -698,21 +583,20 @@ impl RequestData { #[cfg(test)] pub mod tests { use std::collections::HashSet; - use std::sync::{Arc, Mutex}; + use std::sync::Arc; use std::time::Instant; - use futures::Future; + use futures::{Future, sync::oneshot}; use runtime_primitives::traits::{Block as BlockT, NumberFor}; use client::{error::{Error as ClientError, Result as ClientResult}}; - use client::light::fetcher::{Fetcher, FetchChecker, RemoteHeaderRequest, + use client::light::fetcher::{FetchChecker, RemoteHeaderRequest, ChangesProof, RemoteCallRequest, RemoteReadRequest, RemoteReadChildRequest, RemoteChangesRequest, RemoteBodyRequest}; use crate::config::Roles; use crate::message; use network_libp2p::PeerId; - use super::{REQUEST_TIMEOUT, OnDemand, OnDemandNetwork, OnDemandService}; + use super::{REQUEST_TIMEOUT, OnDemandCore, OnDemandNetwork, RequestData}; use test_client::runtime::{changes_trie_config, Block, Extrinsic, Header}; - pub struct DummyExecutor; struct DummyFetchChecker { ok: bool } impl FetchChecker for DummyFetchChecker { @@ -776,19 +660,21 @@ pub mod tests { } } - fn dummy(ok: bool) -> (Arc, Arc>) { - let executor = Arc::new(DummyExecutor); - let service = Arc::new(OnDemand::new(Arc::new(DummyFetchChecker { ok }))); - (executor, service) + fn dummy(ok: bool) -> OnDemandCore { + OnDemandCore::new(Arc::new(DummyFetchChecker { ok })) } - fn total_peers(on_demand: &OnDemand) -> usize { - let core = on_demand.core.lock(); - core.idle_peers.len() + core.active_peers.len() + fn total_peers(on_demand: &OnDemandCore) -> usize { + on_demand.idle_peers.len() + on_demand.active_peers.len() } - fn receive_call_response(on_demand: &OnDemand, peer: PeerId, id: message::RequestId) { - on_demand.on_remote_call_response(peer, message::RemoteCallResponse { + fn receive_call_response( + network_interface: impl OnDemandNetwork, + on_demand: &mut OnDemandCore, + peer: PeerId, + id: message::RequestId + ) { + on_demand.on_remote_call_response(network_interface, peer, message::RemoteCallResponse { id: id, proof: vec![vec![2]], }); @@ -806,152 +692,149 @@ pub mod tests { #[derive(Default)] struct DummyNetwork { - disconnected_peers: Mutex>, + disconnected_peers: HashSet, } - impl OnDemandNetwork for Arc { - fn report_peer(&self, _: &PeerId, _: i32) {} - fn disconnect_peer(&self, who: &PeerId) { - self.disconnected_peers.lock().unwrap().insert(who.clone()); + impl<'a, B: BlockT> OnDemandNetwork for &'a mut DummyNetwork { + fn report_peer(&mut self, _: &PeerId, _: i32) {} + fn disconnect_peer(&mut self, who: &PeerId) { + self.disconnected_peers.insert(who.clone()); } - fn send_request(&self, _: &PeerId, _: message::Message) {} + fn send_request(&mut self, _: &PeerId, _: message::Message) {} } - fn assert_disconnected_peer(dummy: Arc) { - assert_eq!(dummy.disconnected_peers.lock().unwrap().len(), 1); + fn assert_disconnected_peer(dummy: &DummyNetwork) { + assert_eq!(dummy.disconnected_peers.len(), 1); } #[test] fn knows_about_peers_roles() { - let (_, on_demand) = dummy(true); + let mut network_interface = DummyNetwork::default(); + let mut on_demand = dummy(true); let peer0 = PeerId::random(); let peer1 = PeerId::random(); let peer2 = PeerId::random(); - on_demand.on_connect(peer0, Roles::LIGHT, 1000); - on_demand.on_connect(peer1.clone(), Roles::FULL, 2000); - on_demand.on_connect(peer2.clone(), Roles::AUTHORITY, 3000); - assert_eq!(vec![peer1.clone(), peer2.clone()], on_demand.core.lock().idle_peers.iter().cloned().collect::>()); - assert_eq!(on_demand.core.lock().best_blocks.get(&peer1), Some(&2000)); - assert_eq!(on_demand.core.lock().best_blocks.get(&peer2), Some(&3000)); + on_demand.on_connect(&mut network_interface, peer0, Roles::LIGHT, 1000); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 2000); + on_demand.on_connect(&mut network_interface, peer2.clone(), Roles::AUTHORITY, 3000); + assert_eq!(vec![peer1.clone(), peer2.clone()], on_demand.idle_peers.iter().cloned().collect::>()); + assert_eq!(on_demand.best_blocks.get(&peer1), Some(&2000)); + assert_eq!(on_demand.best_blocks.get(&peer2), Some(&3000)); } #[test] fn disconnects_from_idle_peer() { let peer0 = PeerId::random(); - let (_, on_demand) = dummy(true); - on_demand.on_connect(peer0.clone(), Roles::FULL, 100); - assert_eq!(1, total_peers(&*on_demand)); - assert!(!on_demand.core.lock().best_blocks.is_empty()); + let mut network_interface = DummyNetwork::default(); + let mut on_demand = dummy(true); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 100); + assert_eq!(1, total_peers(&on_demand)); + assert!(!on_demand.best_blocks.is_empty()); - on_demand.on_disconnect(peer0); - assert_eq!(0, total_peers(&*on_demand)); - assert!(on_demand.core.lock().best_blocks.is_empty()); + on_demand.on_disconnect(&mut network_interface, peer0); + assert_eq!(0, total_peers(&on_demand)); + assert!(on_demand.best_blocks.is_empty()); } #[test] fn disconnects_from_timeouted_peer() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); let peer1 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); - on_demand.on_connect(peer1.clone(), Roles::FULL, 1000); - assert_eq!(vec![peer0.clone(), peer1.clone()], on_demand.core.lock().idle_peers.iter().cloned().collect::>()); - assert!(on_demand.core.lock().active_peers.is_empty()); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 1000); + assert_eq!(vec![peer0.clone(), peer1.clone()], on_demand.idle_peers.iter().cloned().collect::>()); + assert!(on_demand.active_peers.is_empty()); - on_demand.remote_call(RemoteCallRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteCall(RemoteCallRequest { block: Default::default(), header: dummy_header(), method: "test".into(), call_data: vec![], retry_count: None, - }); - assert_eq!(vec![peer1.clone()], on_demand.core.lock().idle_peers.iter().cloned().collect::>()); - assert_eq!(vec![peer0.clone()], on_demand.core.lock().active_peers.keys().cloned().collect::>()); - - on_demand.core.lock().active_peers[&peer0].timestamp = Instant::now() - REQUEST_TIMEOUT - REQUEST_TIMEOUT; - on_demand.maintain_peers(); - assert!(on_demand.core.lock().idle_peers.is_empty()); - assert_eq!(vec![peer1.clone()], on_demand.core.lock().active_peers.keys().cloned().collect::>()); - assert_disconnected_peer(network_interface); + }, oneshot::channel().0)); + assert_eq!(vec![peer1.clone()], on_demand.idle_peers.iter().cloned().collect::>()); + assert_eq!(vec![peer0.clone()], on_demand.active_peers.keys().cloned().collect::>()); + + on_demand.active_peers[&peer0].timestamp = Instant::now() - REQUEST_TIMEOUT - REQUEST_TIMEOUT; + on_demand.maintain_peers(&mut network_interface); + assert!(on_demand.idle_peers.is_empty()); + assert_eq!(vec![peer1.clone()], on_demand.active_peers.keys().cloned().collect::>()); + assert_disconnected_peer(&network_interface); } #[test] fn disconnects_from_peer_on_response_with_wrong_id() { - let (_x, on_demand) = dummy(true); + let mut on_demand = dummy(true); let peer0 = PeerId::random(); - let network_interface = Arc::new(DummyNetwork::default()); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + let mut network_interface = DummyNetwork::default(); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - on_demand.remote_call(RemoteCallRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteCall(RemoteCallRequest { block: Default::default(), header: dummy_header(), method: "test".into(), call_data: vec![], retry_count: None, - }); - receive_call_response(&*on_demand, peer0, 1); - assert_disconnected_peer(network_interface); - assert_eq!(on_demand.core.lock().pending_requests.len(), 1); + }, oneshot::channel().0)); + receive_call_response(&mut network_interface, &mut on_demand, peer0, 1); + assert_disconnected_peer(&network_interface); + assert_eq!(on_demand.pending_requests.len(), 1); } #[test] fn disconnects_from_peer_on_incorrect_response() { - let (_x, on_demand) = dummy(false); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(false); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.remote_call(RemoteCallRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteCall(RemoteCallRequest { block: Default::default(), header: dummy_header(), method: "test".into(), call_data: vec![], retry_count: Some(1), - }); + }, oneshot::channel().0)); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); - receive_call_response(&*on_demand, peer0.clone(), 0); - assert_disconnected_peer(network_interface); - assert_eq!(on_demand.core.lock().pending_requests.len(), 1); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); + receive_call_response(&mut network_interface, &mut on_demand, peer0.clone(), 0); + assert_disconnected_peer(&network_interface); + assert_eq!(on_demand.pending_requests.len(), 1); } #[test] fn disconnects_from_peer_on_unexpected_response() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - receive_call_response(&*on_demand, peer0, 0); - assert_disconnected_peer(network_interface); + receive_call_response(&mut network_interface, &mut on_demand, peer0, 0); + assert_disconnected_peer(&network_interface); } #[test] fn disconnects_from_peer_on_wrong_response_type() { - let (_x, on_demand) = dummy(false); + let mut on_demand = dummy(false); let peer0 = PeerId::random(); - let network_interface = Arc::new(DummyNetwork::default()); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + let mut network_interface = DummyNetwork::default(); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - on_demand.remote_call(RemoteCallRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteCall(RemoteCallRequest { block: Default::default(), header: dummy_header(), method: "test".into(), call_data: vec![], retry_count: Some(1), - }); + }, oneshot::channel().0)); - on_demand.on_remote_read_response(peer0.clone(), message::RemoteReadResponse { + on_demand.on_remote_read_response(&mut network_interface, peer0.clone(), message::RemoteReadResponse { id: 0, proof: vec![vec![2]], }); - assert_disconnected_peer(network_interface); - assert_eq!(on_demand.core.lock().pending_requests.len(), 1); + assert_disconnected_peer(&network_interface); + assert_eq!(on_demand.pending_requests.len(), 1); } #[test] @@ -960,26 +843,26 @@ pub mod tests { let retry_count = 2; let peer_ids = (0 .. retry_count + 1).map(|_| PeerId::random()).collect::>(); - let (_x, on_demand) = dummy(false); - let network_interface = Arc::new(DummyNetwork::default()); - on_demand.set_network_interface(Box::new(network_interface.clone())); + let mut on_demand = dummy(false); + let mut network_interface = DummyNetwork::default(); for i in 0..retry_count+1 { - on_demand.on_connect(peer_ids[i].clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer_ids[i].clone(), Roles::FULL, 1000); } let sync = Arc::new((Mutex::new(0), Mutex::new(0), Condvar::new())); let thread_sync = sync.clone(); - let response = on_demand.remote_call(RemoteCallRequest { + let (tx, response) = oneshot::channel(); + on_demand.add_request(&mut network_interface, RequestData::RemoteCall(RemoteCallRequest { block: Default::default(), header: dummy_header(), method: "test".into(), call_data: vec![], retry_count: Some(retry_count) - }); + }, tx)); let thread = ::std::thread::spawn(move || { let &(ref current, ref finished_at, ref finished) = &*thread_sync; - let _ = response.wait().unwrap_err(); + let _ = response.wait().unwrap().unwrap_err(); *finished_at.lock() = *current.lock(); finished.notify_one(); }); @@ -988,7 +871,7 @@ pub mod tests { for i in 0..retry_count+1 { let mut current = current.lock(); *current = *current + 1; - receive_call_response(&*on_demand, peer_ids[i].clone(), i as u64); + receive_call_response(&mut network_interface, &mut on_demand, peer_ids[i].clone(), i as u64); } let mut finished_at = finished_at.lock(); @@ -1000,48 +883,48 @@ pub mod tests { #[test] fn receives_remote_call_response() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - let response = on_demand.remote_call(RemoteCallRequest { + let (tx, response) = oneshot::channel(); + on_demand.add_request(&mut network_interface, RequestData::RemoteCall(RemoteCallRequest { block: Default::default(), header: dummy_header(), method: "test".into(), call_data: vec![], retry_count: None, - }); + }, tx)); let thread = ::std::thread::spawn(move || { - let result = response.wait().unwrap(); + let result = response.wait().unwrap().unwrap(); assert_eq!(result, vec![42]); }); - receive_call_response(&*on_demand, peer0.clone(), 0); + receive_call_response(&mut network_interface, &mut on_demand, peer0.clone(), 0); thread.join().unwrap(); } #[test] fn receives_remote_read_response() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - let response = on_demand.remote_read(RemoteReadRequest { + let (tx, response) = oneshot::channel(); + on_demand.add_request(&mut network_interface, RequestData::RemoteRead(RemoteReadRequest { header: dummy_header(), block: Default::default(), key: b":key".to_vec(), retry_count: None, - }); + }, tx)); let thread = ::std::thread::spawn(move || { - let result = response.wait().unwrap(); + let result = response.wait().unwrap().unwrap(); assert_eq!(result, Some(vec![42])); }); - on_demand.on_remote_read_response(peer0.clone(), message::RemoteReadResponse { + on_demand.on_remote_read_response(&mut network_interface, peer0.clone(), message::RemoteReadResponse { id: 0, proof: vec![vec![2]], }); @@ -1050,25 +933,25 @@ pub mod tests { #[test] fn receives_remote_read_child_response() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - let response = on_demand.remote_read_child(RemoteReadChildRequest { + let (tx, response) = oneshot::channel(); + on_demand.add_request(&mut network_interface, RequestData::RemoteReadChild(RemoteReadChildRequest { header: dummy_header(), block: Default::default(), storage_key: b":child_storage:sub".to_vec(), key: b":key".to_vec(), retry_count: None, - }); + }, tx)); let thread = ::std::thread::spawn(move || { - let result = response.wait().unwrap(); + let result = response.wait().unwrap().unwrap(); assert_eq!(result, Some(vec![42])); }); - on_demand.on_remote_read_response( + on_demand.on_remote_read_response(&mut network_interface, peer0.clone(), message::RemoteReadResponse { id: 0, proof: vec![vec![2]], @@ -1078,19 +961,19 @@ pub mod tests { #[test] fn receives_remote_header_response() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - let response = on_demand.remote_header(RemoteHeaderRequest { + let (tx, response) = oneshot::channel(); + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 1, retry_count: None, - }); + }, tx)); let thread = ::std::thread::spawn(move || { - let result = response.wait().unwrap(); + let result = response.wait().unwrap().unwrap(); assert_eq!( result.hash(), "6443a0b46e0412e626363028115a9f2c\ @@ -1098,7 +981,7 @@ pub mod tests { ); }); - on_demand.on_remote_header_response(peer0.clone(), message::RemoteHeaderResponse { + on_demand.on_remote_header_response(&mut network_interface, peer0.clone(), message::RemoteHeaderResponse { id: 0, header: Some(Header { parent_hash: Default::default(), @@ -1114,13 +997,13 @@ pub mod tests { #[test] fn receives_remote_changes_response() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer0 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer0.clone(), Roles::FULL, 1000); + on_demand.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); - let response = on_demand.remote_changes(RemoteChangesRequest { + let (tx, response) = oneshot::channel(); + on_demand.add_request(&mut network_interface, RequestData::RemoteChanges(RemoteChangesRequest { changes_trie_config: changes_trie_config(), first_block: (1, Default::default()), last_block: (100, Default::default()), @@ -1128,13 +1011,13 @@ pub mod tests { tries_roots: (1, Default::default(), vec![]), key: vec![], retry_count: None, - }); + }, tx)); let thread = ::std::thread::spawn(move || { - let result = response.wait().unwrap(); + let result = response.wait().unwrap().unwrap(); assert_eq!(result, vec![(100, 2)]); }); - on_demand.on_remote_changes_response(peer0.clone(), message::RemoteChangesResponse { + on_demand.on_remote_changes_response(&mut network_interface, peer0.clone(), message::RemoteChangesResponse { id: 0, max: 1000, proof: vec![vec![2]], @@ -1146,53 +1029,52 @@ pub mod tests { #[test] fn does_not_sends_request_to_peer_who_has_no_required_block() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer1 = PeerId::random(); let peer2 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.on_connect(peer1.clone(), Roles::FULL, 100); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 100); - on_demand.remote_header(RemoteHeaderRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 200, retry_count: None, - }); - on_demand.remote_header(RemoteHeaderRequest { + }, oneshot::channel().0)); + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 250, retry_count: None, - }); - on_demand.remote_header(RemoteHeaderRequest { + }, oneshot::channel().0)); + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 250, retry_count: None, - }); + }, oneshot::channel().0)); - on_demand.on_connect(peer2.clone(), Roles::FULL, 150); + on_demand.on_connect(&mut network_interface, peer2.clone(), Roles::FULL, 150); - assert_eq!(vec![peer1.clone(), peer2.clone()], on_demand.core.lock().idle_peers.iter().cloned().collect::>()); - assert_eq!(on_demand.core.lock().pending_requests.len(), 3); + assert_eq!(vec![peer1.clone(), peer2.clone()], on_demand.idle_peers.iter().cloned().collect::>()); + assert_eq!(on_demand.pending_requests.len(), 3); - on_demand.on_block_announce(peer1.clone(), 250); + on_demand.on_block_announce(&mut network_interface, peer1.clone(), 250); - assert_eq!(vec![peer2.clone()], on_demand.core.lock().idle_peers.iter().cloned().collect::>()); - assert_eq!(on_demand.core.lock().pending_requests.len(), 2); + assert_eq!(vec![peer2.clone()], on_demand.idle_peers.iter().cloned().collect::>()); + assert_eq!(on_demand.pending_requests.len(), 2); - on_demand.on_block_announce(peer2.clone(), 250); + on_demand.on_block_announce(&mut network_interface, peer2.clone(), 250); - assert!(!on_demand.core.lock().idle_peers.iter().any(|_| true)); - assert_eq!(on_demand.core.lock().pending_requests.len(), 1); + assert!(!on_demand.idle_peers.iter().any(|_| true)); + assert_eq!(on_demand.pending_requests.len(), 1); - on_demand.on_remote_header_response(peer1.clone(), message::RemoteHeaderResponse { + on_demand.on_remote_header_response(&mut network_interface, peer1.clone(), message::RemoteHeaderResponse { id: 0, header: Some(dummy_header()), proof: vec![], }); - assert!(!on_demand.core.lock().idle_peers.iter().any(|_| true)); - assert_eq!(on_demand.core.lock().pending_requests.len(), 0); + assert!(!on_demand.idle_peers.iter().any(|_| true)); + assert_eq!(on_demand.pending_requests.len(), 0); } #[test] @@ -1200,73 +1082,70 @@ pub mod tests { // this test is a regression for a bug where the dispatch function would // loop forever after dispatching a request to the last peer, since the // last peer was not updated - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer1 = PeerId::random(); let peer2 = PeerId::random(); let peer3 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.remote_header(RemoteHeaderRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 250, retry_count: None, - }); - on_demand.remote_header(RemoteHeaderRequest { + }, oneshot::channel().0)); + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 250, retry_count: None, - }); + }, oneshot::channel().0)); - on_demand.on_connect(peer1.clone(), Roles::FULL, 200); - on_demand.on_connect(peer2.clone(), Roles::FULL, 200); - on_demand.on_connect(peer3.clone(), Roles::FULL, 250); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 200); + on_demand.on_connect(&mut network_interface, peer2.clone(), Roles::FULL, 200); + on_demand.on_connect(&mut network_interface, peer3.clone(), Roles::FULL, 250); - assert_eq!(vec![peer1.clone(), peer2.clone()], on_demand.core.lock().idle_peers.iter().cloned().collect::>()); - assert_eq!(on_demand.core.lock().pending_requests.len(), 1); + assert_eq!(vec![peer1.clone(), peer2.clone()], on_demand.idle_peers.iter().cloned().collect::>()); + assert_eq!(on_demand.pending_requests.len(), 1); } #[test] fn tries_to_send_all_pending_requests() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer1 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); - on_demand.remote_header(RemoteHeaderRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 300, retry_count: None, - }); - on_demand.remote_header(RemoteHeaderRequest { + }, oneshot::channel().0)); + on_demand.add_request(&mut network_interface, RequestData::RemoteHeader(RemoteHeaderRequest { cht_root: Default::default(), block: 250, retry_count: None, - }); + }, oneshot::channel().0)); - on_demand.on_connect(peer1.clone(), Roles::FULL, 250); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 250); - assert!(on_demand.core.lock().idle_peers.iter().cloned().collect::>().is_empty()); - assert_eq!(on_demand.core.lock().pending_requests.len(), 1); + assert!(on_demand.idle_peers.iter().cloned().collect::>().is_empty()); + assert_eq!(on_demand.pending_requests.len(), 1); } #[test] fn remote_body_with_one_block_body_should_succeed() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer1 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); let header = dummy_header(); - on_demand.on_connect(peer1.clone(), Roles::FULL, 250); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 250); - on_demand.remote_body(RemoteBodyRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteBody(RemoteBodyRequest { header: header.clone(), retry_count: None, - }); + }, oneshot::channel().0)); - assert!(on_demand.core.lock().pending_requests.is_empty()); - assert_eq!(on_demand.core.lock().active_peers.len(), 1); + assert!(on_demand.pending_requests.is_empty()); + assert_eq!(on_demand.active_peers.len(), 1); let block = message::BlockData:: { hash: primitives::H256::random(), @@ -1282,29 +1161,28 @@ pub mod tests { blocks: vec![block], }; - on_demand.on_remote_body_response(peer1.clone(), response); + on_demand.on_remote_body_response(&mut network_interface, peer1.clone(), response); - assert!(on_demand.core.lock().active_peers.is_empty()); - assert_eq!(on_demand.core.lock().idle_peers.len(), 1); + assert!(on_demand.active_peers.is_empty()); + assert_eq!(on_demand.idle_peers.len(), 1); } #[test] fn remote_body_with_three_bodies_should_fail() { - let (_x, on_demand) = dummy(true); - let network_interface = Arc::new(DummyNetwork::default()); + let mut on_demand = dummy(true); + let mut network_interface = DummyNetwork::default(); let peer1 = PeerId::random(); - on_demand.set_network_interface(Box::new(network_interface.clone())); let header = dummy_header(); - on_demand.on_connect(peer1.clone(), Roles::FULL, 250); + on_demand.on_connect(&mut network_interface, peer1.clone(), Roles::FULL, 250); - on_demand.remote_body(RemoteBodyRequest { + on_demand.add_request(&mut network_interface, RequestData::RemoteBody(RemoteBodyRequest { header: header.clone(), retry_count: None, - }); + }, oneshot::channel().0)); - assert!(on_demand.core.lock().pending_requests.is_empty()); - assert_eq!(on_demand.core.lock().active_peers.len(), 1); + assert!(on_demand.pending_requests.is_empty()); + assert_eq!(on_demand.active_peers.len(), 1); let response = { let blocks: Vec<_> = (0..3).map(|_| message::BlockData:: { @@ -1322,8 +1200,8 @@ pub mod tests { } }; - on_demand.on_remote_body_response(peer1.clone(), response); - assert!(on_demand.core.lock().active_peers.is_empty()); - assert!(on_demand.core.lock().idle_peers.is_empty(), "peer should be disconnected after bad response"); + on_demand.on_remote_body_response(&mut network_interface, peer1.clone(), response); + assert!(on_demand.active_peers.is_empty()); + assert!(on_demand.idle_peers.is_empty(), "peer should be disconnected after bad response"); } } diff --git a/core/network/src/on_demand_layer.rs b/core/network/src/on_demand_layer.rs new file mode 100644 index 0000000000..95f9f4d67b --- /dev/null +++ b/core/network/src/on_demand_layer.rs @@ -0,0 +1,149 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! On-demand requests service. + +use crate::on_demand::RequestData; +use std::sync::Arc; +use futures::{prelude::*, sync::mpsc, sync::oneshot}; +use parking_lot::Mutex; +use client::error::Error as ClientError; +use client::light::fetcher::{Fetcher, FetchChecker, RemoteHeaderRequest, + RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, + RemoteReadChildRequest, RemoteBodyRequest}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; + +/// Implements the `Fetcher` trait of the client. Makes it possible for the light client to perform +/// network requests for some state. +/// +/// This implementation stores all the requests in a queue. The network, in parallel, is then +/// responsible for pulling elements out of that queue and fulfilling them. +pub struct OnDemand { + /// Objects that checks whether what has been retrieved is correct. + checker: Arc>, + + /// Queue of requests. Set to `Some` at initialization, then extracted by the network. + /// + /// Note that a better alternative would be to use a MPMC queue here, and add a `poll` method + /// from the `OnDemand`. However there exists no popular implementation of MPMC channels in + /// asynchronous Rust at the moment + requests_queue: Mutex>>>, + + /// Sending side of `requests_queue`. + requests_send: mpsc::UnboundedSender>, +} + +impl OnDemand where + B::Header: HeaderT, +{ + /// Creates new on-demand service. + pub fn new(checker: Arc>) -> Self { + let (requests_send, requests_queue) = mpsc::unbounded(); + let requests_queue = Mutex::new(Some(requests_queue)); + + OnDemand { + checker, + requests_queue, + requests_send, + } + } + + /// Get checker reference. + pub fn checker(&self) -> &Arc> { + &self.checker + } + + /// Extracts the queue of requests. + /// + /// Whenever one of the methods of the `Fetcher` trait is called, an element is pushed on this + /// channel. + /// + /// If this function returns `None`, that means that the receiver has already been extracted in + /// the past, and therefore that something already handles the requests. + pub(crate) fn extract_receiver(&self) -> Option>> { + self.requests_queue.lock().take() + } +} + +impl Fetcher for OnDemand where + B: BlockT, + B::Header: HeaderT, +{ + type RemoteHeaderResult = RemoteResponse; + type RemoteReadResult = RemoteResponse>>; + type RemoteCallResult = RemoteResponse>; + type RemoteChangesResult = RemoteResponse, u32)>>; + type RemoteBodyResult = RemoteResponse>; + + fn remote_header(&self, request: RemoteHeaderRequest) -> Self::RemoteHeaderResult { + let (sender, receiver) = oneshot::channel(); + let _ = self.requests_send.unbounded_send(RequestData::RemoteHeader(request, sender)); + RemoteResponse { receiver } + } + + fn remote_read(&self, request: RemoteReadRequest) -> Self::RemoteReadResult { + let (sender, receiver) = oneshot::channel(); + let _ = self.requests_send.unbounded_send(RequestData::RemoteRead(request, sender)); + RemoteResponse { receiver } + } + + fn remote_read_child( + &self, + request: RemoteReadChildRequest + ) -> Self::RemoteReadResult { + let (sender, receiver) = oneshot::channel(); + let _ = self.requests_send.unbounded_send(RequestData::RemoteReadChild(request, sender)); + RemoteResponse { receiver } + } + + fn remote_call(&self, request: RemoteCallRequest) -> Self::RemoteCallResult { + let (sender, receiver) = oneshot::channel(); + let _ = self.requests_send.unbounded_send(RequestData::RemoteCall(request, sender)); + RemoteResponse { receiver } + } + + fn remote_changes(&self, request: RemoteChangesRequest) -> Self::RemoteChangesResult { + let (sender, receiver) = oneshot::channel(); + let _ = self.requests_send.unbounded_send(RequestData::RemoteChanges(request, sender)); + RemoteResponse { receiver } + } + + fn remote_body(&self, request: RemoteBodyRequest) -> Self::RemoteBodyResult { + let (sender, receiver) = oneshot::channel(); + let _ = self.requests_send.unbounded_send(RequestData::RemoteBody(request, sender)); + RemoteResponse { receiver } + } +} + +/// Future for an on-demand remote call response. +pub struct RemoteResponse { + receiver: oneshot::Receiver>, +} + +impl Future for RemoteResponse { + type Item = T; + type Error = ClientError; + + fn poll(&mut self) -> Poll { + self.receiver.poll() + .map_err(|_| ClientError::RemoteFetchCancelled.into()) + .and_then(|r| match r { + Async::Ready(Ok(ready)) => Ok(Async::Ready(ready)), + Async::Ready(Err(error)) => Err(error), + Async::NotReady => Ok(Async::NotReady), + }) + } +} diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index c9e56362d1..b3102e588e 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -30,7 +30,7 @@ use crate::message::{ }; use crate::message::generic::{Message as GenericMessage, ConsensusMessage}; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; -use crate::on_demand::OnDemandService; +use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; use crate::specialization::NetworkSpecialization; use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; use crate::service::{TransactionPool, ExHashT}; @@ -41,7 +41,7 @@ use std::sync::Arc; use std::{cmp, num::NonZeroUsize, time}; use log::{trace, debug, warn, error}; use crate::chain::{Client, FinalityProofProvider}; -use client::light::fetcher::ChangesProof; +use client::light::fetcher::{FetchChecker, ChangesProof}; use crate::{error, util::LruHashSet}; const REQUEST_TIMEOUT_SEC: u64 = 40; @@ -83,7 +83,8 @@ pub struct Protocol, H: ExHashT> { /// Interval at which we call `propagate_extrinsics`. propagate_timeout: tokio::timer::Interval, config: ProtocolConfig, - on_demand: Option>>, + /// Handler for on-demand requests. + on_demand_core: OnDemandCore, genesis_hash: B::Hash, sync: ChainSync, specialization: S, @@ -159,6 +160,20 @@ pub trait NetworkOut { fn send_message(&mut self, who: PeerId, message: Message); } +impl<'a, 'b, B: BlockT> OnDemandNetwork for &'a mut &'b mut dyn NetworkOut { + fn report_peer(&mut self, who: &PeerId, reputation: i32) { + NetworkOut::report_peer(**self, who.clone(), reputation) + } + + fn disconnect_peer(&mut self, who: &PeerId) { + NetworkOut::disconnect_peer(**self, who.clone()) + } + + fn send_request(&mut self, who: &PeerId, message: Message) { + NetworkOut::send_message(**self, who.clone(), message) + } +} + /// Context for a network-specific handler. pub trait Context { /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or @@ -263,7 +278,7 @@ impl, H: ExHashT> Protocol { pub fn new( config: ProtocolConfig, chain: Arc>, - on_demand: Option>>, + checker: Arc>, specialization: S, ) -> error::Result> { let info = chain.info()?; @@ -276,7 +291,7 @@ impl, H: ExHashT> Protocol { peers: HashMap::new(), chain, }, - on_demand, + on_demand_core: OnDemandCore::new(checker), genesis_hash: info.chain.genesis_hash, sync, specialization: specialization, @@ -307,6 +322,13 @@ impl, H: ExHashT> Protocol { self.sync.status().is_offline() } + /// Starts a new data demand request. + /// + /// The parameter contains a `Sender` where the result, once received, must be sent. + pub(crate) fn add_on_demand_request(&mut self, mut network_out: &mut dyn NetworkOut, rq: RequestData) { + self.on_demand_core.add_request(&mut network_out, rq); + } + pub fn poll( &mut self, network_out: &mut dyn NetworkOut, @@ -324,7 +346,7 @@ impl, H: ExHashT> Protocol { } fn is_on_demand_response(&self, who: &PeerId, response_id: message::RequestId) -> bool { - self.on_demand.as_ref().map_or(false, |od| od.is_on_demand_response(&who, response_id)) + self.on_demand_core.is_on_demand_response(&who, response_id) } fn handle_response( @@ -378,7 +400,7 @@ impl, H: ExHashT> Protocol { GenericMessage::BlockResponse(r) => { // Note, this is safe because only `ordinary bodies` and `remote bodies` are received in this matter. if self.is_on_demand_response(&who, r.id) { - self.on_remote_body_response(who, r); + self.on_remote_body_response(network_out, who, r); } else { if let Some(request) = self.handle_response(network_out, who.clone(), &r) { let outcome = self.on_block_response(network_out, who.clone(), request, r); @@ -394,13 +416,20 @@ impl, H: ExHashT> Protocol { GenericMessage::Transactions(m) => self.on_extrinsics(network_out, transaction_pool, who, m), GenericMessage::RemoteCallRequest(request) => self.on_remote_call_request(network_out, who, request), - GenericMessage::RemoteCallResponse(response) => self.on_remote_call_response(who, response), - GenericMessage::RemoteReadRequest(request) => self.on_remote_read_request(network_out, who, request), - GenericMessage::RemoteReadResponse(response) => self.on_remote_read_response(who, response), - GenericMessage::RemoteHeaderRequest(request) => self.on_remote_header_request(network_out, who, request), - GenericMessage::RemoteHeaderResponse(response) => self.on_remote_header_response(who, response), - GenericMessage::RemoteChangesRequest(request) => self.on_remote_changes_request(network_out, who, request), - GenericMessage::RemoteChangesResponse(response) => self.on_remote_changes_response(who, response), + GenericMessage::RemoteCallResponse(response) => + self.on_remote_call_response(network_out, who, response), + GenericMessage::RemoteReadRequest(request) => + self.on_remote_read_request(network_out, who, request), + GenericMessage::RemoteReadResponse(response) => + self.on_remote_read_response(network_out, who, response), + GenericMessage::RemoteHeaderRequest(request) => + self.on_remote_header_request(network_out, who, request), + GenericMessage::RemoteHeaderResponse(response) => + self.on_remote_header_response(network_out, who, response), + GenericMessage::RemoteChangesRequest(request) => + self.on_remote_changes_request(network_out, who, request), + GenericMessage::RemoteChangesResponse(response) => + self.on_remote_changes_response(network_out, who, response), GenericMessage::FinalityProofRequest(request) => self.on_finality_proof_request(network_out, who, request, finality_proof_provider), GenericMessage::FinalityProofResponse(response) => @@ -480,7 +509,7 @@ impl, H: ExHashT> Protocol { } /// Called by peer when it is disconnecting - pub fn on_peer_disconnected(&mut self, network_out: &mut dyn NetworkOut, peer: PeerId, debug_info: String) { + pub fn on_peer_disconnected(&mut self, mut network_out: &mut dyn NetworkOut, peer: PeerId, debug_info: String) { trace!(target: "sync", "Disconnecting {}: {}", peer, debug_info); // lock all the the peer lists so that add/remove peer events are in order let removed = { @@ -494,7 +523,7 @@ impl, H: ExHashT> Protocol { } self.sync.peer_disconnected(&mut context, peer.clone()); self.specialization.on_disconnect(&mut context, peer.clone()); - self.on_demand.as_ref().map(|s| s.on_disconnect(peer)); + self.on_demand_core.on_disconnect(&mut network_out, peer); } } @@ -514,7 +543,12 @@ impl, H: ExHashT> Protocol { } } - fn on_block_request(&mut self, network_out: &mut dyn NetworkOut, peer: PeerId, request: message::BlockRequest) { + fn on_block_request( + &mut self, + network_out: &mut dyn NetworkOut, + peer: PeerId, + request: message::BlockRequest + ) { trace!(target: "sync", "BlockRequest {} from {}: from {:?} to {:?} max {:?}", request.id, peer, @@ -643,13 +677,11 @@ impl, H: ExHashT> Protocol { /// Perform time based maintenance. /// /// > **Note**: This method normally doesn't have to be called except for testing purposes. - pub fn tick(&mut self, network_out: &mut dyn NetworkOut) { + pub fn tick(&mut self, mut network_out: &mut dyn NetworkOut) { self.consensus_gossip.tick(&mut ProtocolContext::new(&mut self.context_data, network_out)); self.maintain_peers(network_out); self.sync.tick(&mut ProtocolContext::new(&mut self.context_data, network_out)); - self.on_demand - .as_ref() - .map(|s| s.maintain_peers()); + self.on_demand_core.maintain_peers(&mut network_out); } fn maintain_peers(&mut self, network_out: &mut dyn NetworkOut) { @@ -681,7 +713,7 @@ impl, H: ExHashT> Protocol { } /// Called by peer to report status - fn on_status_message(&mut self, network_out: &mut dyn NetworkOut, who: PeerId, status: message::Status) { + fn on_status_message(&mut self, mut network_out: &mut dyn NetworkOut, who: PeerId, status: message::Status) { trace!(target: "sync", "New peer {} {:?}", who, status); let protocol_version = { if self.context_data.peers.contains_key(&who) { @@ -756,10 +788,8 @@ impl, H: ExHashT> Protocol { status.version }; + self.on_demand_core.on_connect(&mut network_out, who.clone(), status.roles, status.best_number); let mut context = ProtocolContext::new(&mut self.context_data, network_out); - self.on_demand - .as_ref() - .map(|s| s.on_connect(who.clone(), status.roles, status.best_number)); self.sync.new_peer(&mut context, who.clone()); if protocol_version > 2 { self.consensus_gossip.new_peer(&mut context, who.clone(), status.roles); @@ -875,7 +905,7 @@ impl, H: ExHashT> Protocol { fn on_block_announce( &mut self, - network_out: &mut dyn NetworkOut, + mut network_out: &mut dyn NetworkOut, who: PeerId, announce: message::BlockAnnounce ) { @@ -886,9 +916,7 @@ impl, H: ExHashT> Protocol { peer.known_blocks.insert(hash.clone()); } } - self.on_demand - .as_ref() - .map(|s| s.on_block_announce(who.clone(), *header.number())); + self.on_demand_core.on_block_announce(&mut network_out, who.clone(), *header.number()); self.sync.on_block_announce( &mut ProtocolContext::new(&mut self.context_data, network_out), who.clone(), @@ -1029,7 +1057,12 @@ impl, H: ExHashT> Protocol { /// Request a finality proof for the given block. /// /// Queues a new finality proof request and tries to dispatch all pending requests. - pub fn request_finality_proof(&mut self, network_out: &mut dyn NetworkOut, hash: &B::Hash, number: NumberFor) { + pub fn request_finality_proof( + &mut self, + network_out: &mut dyn NetworkOut, + hash: &B::Hash, + number: NumberFor + ) { let mut context = ProtocolContext::new(&mut self.context_data, network_out); self.sync.request_finality_proof(&hash, number, &mut context); } @@ -1042,11 +1075,14 @@ impl, H: ExHashT> Protocol { self.sync.finality_proof_import_result(request_block, finalization_result) } - fn on_remote_call_response(&mut self, who: PeerId, response: message::RemoteCallResponse) { + fn on_remote_call_response( + &mut self, + mut network_out: &mut dyn NetworkOut, + who: PeerId, + response: message::RemoteCallResponse + ) { trace!(target: "sync", "Remote call response {} from {}", response.id, who); - self.on_demand - .as_ref() - .map(|s| s.on_remote_call_response(who, response)); + self.on_demand_core.on_remote_call_response(&mut network_out, who, response); } fn on_remote_read_request( @@ -1079,11 +1115,15 @@ impl, H: ExHashT> Protocol { }), ); } - fn on_remote_read_response(&mut self, who: PeerId, response: message::RemoteReadResponse) { + + fn on_remote_read_response( + &mut self, + mut network_out: &mut dyn NetworkOut, + who: PeerId, + response: message::RemoteReadResponse + ) { trace!(target: "sync", "Remote read response {} from {}", response.id, who); - self.on_demand - .as_ref() - .map(|s| s.on_remote_read_response(who, response)); + self.on_demand_core.on_remote_read_response(&mut network_out, who, response); } fn on_remote_header_request( @@ -1119,13 +1159,12 @@ impl, H: ExHashT> Protocol { fn on_remote_header_response( &mut self, + mut network_out: &mut dyn NetworkOut, who: PeerId, response: message::RemoteHeaderResponse, ) { trace!(target: "sync", "Remote header proof response {} from {}", response.id, who); - self.on_demand - .as_ref() - .map(|s| s.on_remote_header_response(who, response)); + self.on_demand_core.on_remote_header_response(&mut network_out, who, response); } fn on_remote_changes_request( @@ -1182,6 +1221,7 @@ impl, H: ExHashT> Protocol { fn on_remote_changes_response( &mut self, + mut network_out: &mut dyn NetworkOut, who: PeerId, response: message::RemoteChangesResponse, B::Hash>, ) { @@ -1190,9 +1230,7 @@ impl, H: ExHashT> Protocol { who, response.max ); - self.on_demand - .as_ref() - .map(|s| s.on_remote_changes_response(who, response)); + self.on_demand_core.on_remote_changes_response(&mut network_out, who, response); } fn on_finality_proof_request( @@ -1250,10 +1288,13 @@ impl, H: ExHashT> Protocol { } } - fn on_remote_body_response(&self, peer: PeerId, response: message::BlockResponse) { - self.on_demand - .as_ref() - .map(|od| od.on_remote_body_response(peer, response)); + fn on_remote_body_response( + &mut self, + mut network_out: &mut dyn NetworkOut, + peer: PeerId, + response: message::BlockResponse + ) { + self.on_demand_core.on_remote_body_response(&mut network_out, peer, response); } } diff --git a/core/network/src/service.rs b/core/network/src/service.rs index 4516609c5e..b2e56a83bd 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -29,9 +29,11 @@ use peerset::PeersetHandle; use consensus::import_queue::{ImportQueue, Link, SharedFinalityProofRequestBuilder}; use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use crate::AlwaysBadChecker; use crate::chain::FinalityProofProvider; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use crate::message::Message; +use crate::on_demand::RequestData; use crate::protocol::{self, Context, CustomMessageOutcome, Protocol, ConnectedPeer}; use crate::protocol::{ProtocolStatus, PeerInfo, NetworkOut}; use crate::config::Params; @@ -216,7 +218,8 @@ impl> Service { let protocol = Protocol::new( params.config, params.chain, - params.on_demand, + params.on_demand.as_ref().map(|od| od.checker().clone()) + .unwrap_or(Arc::new(AlwaysBadChecker)), params.specialization, )?; let versions: Vec<_> = ((protocol::MIN_VERSION as u8)..=(protocol::CURRENT_VERSION as u8)).collect(); @@ -234,6 +237,7 @@ impl> Service { status_sinks.clone(), params.network_config, registered, + params.on_demand.and_then(|od| od.extract_receiver()), )?; let service = Arc::new(Service { @@ -531,6 +535,7 @@ fn start_thread, H: ExHashT>( status_sinks: Arc>>>>, config: NetworkConfiguration, registered: RegisteredProtocol>, + on_demand_in: Option>>, ) -> Result<((oneshot::Sender<()>, thread::JoinHandle<()>), Arc>>>, PeersetHandle), Error> { // Start the main service. let (service, peerset) = match start_service(config, registered) { @@ -558,7 +563,8 @@ fn start_thread, H: ExHashT>( network_port, protocol_rx, status_sinks, - peerset_clone + peerset_clone, + on_demand_in ) .select(close_rx.then(|_| Ok(()))) .map(|(val, _)| val) @@ -589,6 +595,7 @@ fn run_thread, H: ExHashT>( mut protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, peerset: PeersetHandle, + mut on_demand_in: Option>>, ) -> impl Future { // Implementation of `protocol::NetworkOut` using the available local variables. struct Ctxt<'a, B: BlockT>(&'a mut NetworkService>, &'a PeersetHandle); @@ -628,6 +635,13 @@ fn run_thread, H: ExHashT>( Err(err) => void::unreachable(err), } + // Check for new incoming on-demand requests. + if let Some(on_demand_in) = on_demand_in.as_mut() { + while let Ok(Async::Ready(Some(rq))) = on_demand_in.poll() { + protocol.add_on_demand_request(&mut Ctxt(&mut network_service.lock(), &peerset), rq); + } + } + loop { match network_port.poll() { Ok(Async::NotReady) => break, diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 7cbbbf1370..13d18a0d44 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -24,6 +24,7 @@ mod sync; use std::collections::{HashMap, HashSet, VecDeque}; use std::sync::Arc; +use crate::AlwaysBadChecker; use log::trace; use crate::chain::FinalityProofProvider; use client::{self, ClientInfo, BlockchainEvents, FinalityNotifications}; @@ -956,7 +957,7 @@ pub trait TestNetFactory: Sized { let protocol = Protocol::new( config.clone(), client.clone(), - None, + Arc::new(AlwaysBadChecker), specialization, ).unwrap(); @@ -1010,7 +1011,7 @@ pub trait TestNetFactory: Sized { let protocol = Protocol::new( config, client.clone(), - None, + Arc::new(AlwaysBadChecker), specialization, ).unwrap(); diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index bc257dcd26..81e153b7ae 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -182,7 +182,7 @@ impl Service { network_config: config.network.clone(), chain: client.clone(), finality_proof_provider, - on_demand: on_demand.as_ref().map(|d| d.clone() as _), + on_demand, transaction_pool: transaction_pool_adapter.clone() as _, specialization: network_protocol, }; @@ -202,9 +202,6 @@ impl Service { let has_bootnodes = !network_params.network_config.boot_nodes.is_empty(); let network = network::Service::new(network_params, protocol_id, import_queue)?; - if let Some(on_demand) = on_demand.as_ref() { - on_demand.set_network_interface(Box::new(Arc::downgrade(&network))); - } let inherents_pool = Arc::new(InherentsPool::default()); let offchain_workers = if config.offchain_worker { -- GitLab From e7e53ea6bbb33a460d5e8fd8e9f656781cde979a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 23 May 2019 21:17:58 +0200 Subject: [PATCH 025/113] Make peerset ban nodes under a reputation (#2667) --- core/peerset/src/lib.rs | 85 +++++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/core/peerset/src/lib.rs b/core/peerset/src/lib.rs index ac076be4b5..9b5155455a 100644 --- a/core/peerset/src/lib.rs +++ b/core/peerset/src/lib.rs @@ -25,6 +25,8 @@ use libp2p::PeerId; use log::{debug, error, trace}; use serde_json::json; +/// We don't accept nodes whose reputation is under this value. +const BANNED_THRESHOLD: i32 = 82 * (i32::min_value() / 100); /// Reputation change for a node when we get disconnected from it. const DISCONNECT_REPUTATION_CHANGE: i32 = -10; @@ -232,7 +234,13 @@ impl Peerset { self.update_time(); match self.data.peer(&peer_id) { - peersstate::Peer::Connected(mut peer) => peer.add_reputation(score_diff), + peersstate::Peer::Connected(mut peer) => { + peer.add_reputation(score_diff); + if peer.reputation() < BANNED_THRESHOLD { + peer.disconnect(); + self.message_queue.push_back(Message::Drop(peer_id)); + } + }, peersstate::Peer::NotConnected(mut peer) => peer.add_reputation(score_diff), peersstate::Peer::Unknown(peer) => peer.discover().add_reputation(score_diff), } @@ -283,22 +291,27 @@ impl Peerset { fn alloc_slots(&mut self) { self.update_time(); + // Try to grab the next node to attempt to connect to. + while let Some(next) = self.data.reserved_not_connected_peer() { + match next.try_outgoing() { + Ok(conn) => self.message_queue.push_back(Message::Connect(conn.into_peer_id())), + Err(_) => break, // No more slots available. + } + } + loop { + if self.reserved_only { + break + } + // Try to grab the next node to attempt to connect to. - let next = match self.data.reserved_not_connected_peer() { + let next = match self.data.highest_not_connected_peer() { Some(p) => p, - None => if self.reserved_only { - break // No known node to add. - } else { - match self.data.highest_not_connected_peer() { - Some(p) => p, - None => break, // No known node to add. - } - } + None => break, // No known node to add. }; // Don't connect to nodes with an abysmal reputation. - if next.reputation() == i32::min_value() { + if next.reputation() < BANNED_THRESHOLD { break; } @@ -321,6 +334,7 @@ impl Peerset { // `PeerId` before that message has been read by the user. In this situation we must not answer. pub fn incoming(&mut self, peer_id: PeerId, index: IncomingIndex) { trace!(target: "peerset", "Incoming {:?}", peer_id); + self.update_time(); let not_connected = match self.data.peer(&peer_id) { // If we're already connected, don't answer, as the docs mention. @@ -329,6 +343,11 @@ impl Peerset { peersstate::Peer::Unknown(entry) => entry.discover(), }; + if not_connected.reputation() < BANNED_THRESHOLD { + self.message_queue.push_back(Message::Reject(index)); + return + } + match not_connected.try_accept_incoming() { Ok(_) => self.message_queue.push_back(Message::Accept(index)), Err(_) => self.message_queue.push_back(Message::Reject(index)), @@ -430,7 +449,8 @@ impl Stream for Peerset { mod tests { use libp2p::PeerId; use futures::prelude::*; - use super::{PeersetConfig, Peerset, Message, IncomingIndex}; + use super::{PeersetConfig, Peerset, Message, IncomingIndex, BANNED_THRESHOLD}; + use std::{thread, time::Duration}; fn assert_messages(mut peerset: Peerset, messages: Vec) -> Peerset { for expected_message in messages { @@ -528,4 +548,45 @@ mod tests { Message::Connect(discovered), ]); } + + #[test] + fn test_peerset_banned() { + let (mut peerset, handle) = Peerset::from_config(PeersetConfig { + in_peers: 25, + out_peers: 25, + bootnodes: vec![], + reserved_only: false, + reserved_nodes: vec![], + }); + + // We ban a node by setting its reputation under the threshold. + let peer_id = PeerId::random(); + handle.report_peer(peer_id.clone(), BANNED_THRESHOLD - 1); + + let fut = futures::future::poll_fn(move || -> Result<_, ()> { + // We need one polling for the message to be processed. + assert_eq!(peerset.poll().unwrap(), Async::NotReady); + + // Check that an incoming connection from that node gets refused. + peerset.incoming(peer_id.clone(), IncomingIndex(1)); + if let Async::Ready(msg) = peerset.poll().unwrap() { + assert_eq!(msg.unwrap(), Message::Reject(IncomingIndex(1))); + } else { + panic!() + } + + // Wait a bit for the node's reputation to go above the threshold. + thread::sleep(Duration::from_millis(1500)); + + // Try again. This time the node should be accepted. + peerset.incoming(peer_id.clone(), IncomingIndex(2)); + while let Async::Ready(msg) = peerset.poll().unwrap() { + assert_eq!(msg.unwrap(), Message::Accept(IncomingIndex(2))); + } + + Ok(Async::Ready(())) + }); + + tokio::runtime::current_thread::Runtime::new().unwrap().block_on(fut).unwrap(); + } } -- GitLab From c5b9acfe046f0c9707743b99c5e4936561fbd3fa Mon Sep 17 00:00:00 2001 From: Tengfei Niu Date: Fri, 24 May 2019 13:44:09 +0800 Subject: [PATCH 026/113] remove unused import (#2678) remove unused import --- core/rpc/src/chain/number.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/core/rpc/src/chain/number.rs b/core/rpc/src/chain/number.rs index 7983ac6c78..f927d51f14 100644 --- a/core/rpc/src/chain/number.rs +++ b/core/rpc/src/chain/number.rs @@ -17,7 +17,6 @@ use serde::Deserialize; use std::{convert::TryFrom, fmt::Debug}; use primitives::U256; -use runtime_primitives::traits; /// RPC Block number type /// -- GitLab From d713fbc358106ec7d400dea0a1d644a8448942ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 24 May 2019 11:35:31 +0200 Subject: [PATCH 027/113] Expunge error-chain (feat. tomaka) (#2662) * Remove error_chain * Expunge error-chain from rpc and service. * Expunge from transaction pool. * Expunge from node/cli * Expunge from keystore. * Remove some boilerplate. * Fix remaining stuff. * Improve on deprecation message. * Fix issues. * Fix trnsaction pool tests. * Fix the rest. * Fix borked merge. * Update lock --- Cargo.lock | 27 +- Cargo.toml | 1 - core/cli/Cargo.toml | 2 +- core/cli/src/error.rs | 50 ++-- core/cli/src/lib.rs | 25 +- core/client/db/src/cache/list_cache.rs | 2 +- core/client/db/src/lib.rs | 2 +- core/client/db/src/utils.rs | 2 +- core/client/src/client.rs | 14 +- core/consensus/aura/Cargo.toml | 1 - core/consensus/aura/src/lib.rs | 22 +- core/consensus/babe/Cargo.toml | 1 - core/consensus/babe/src/lib.rs | 20 +- core/consensus/common/Cargo.toml | 2 +- core/consensus/common/src/error.rs | 153 +++++------ core/consensus/common/src/evaluation.rs | 67 +++-- core/consensus/common/src/lib.rs | 2 +- core/consensus/rhd/Cargo.toml | 2 +- core/consensus/rhd/src/error.rs | 57 ++-- core/consensus/slots/Cargo.toml | 1 - core/consensus/slots/src/lib.rs | 5 - core/consensus/slots/src/slots.rs | 6 +- core/executor/Cargo.toml | 2 +- core/executor/src/error.rs | 107 ++++---- core/executor/src/native_executor.rs | 14 +- core/executor/src/sandbox.rs | 3 +- core/executor/src/wasm_executor.rs | 14 +- core/finality-grandpa/src/import.rs | 40 +-- core/finality-grandpa/src/lib.rs | 2 +- core/finality-grandpa/src/light_import.rs | 21 +- core/keystore/Cargo.toml | 2 +- core/keystore/src/lib.rs | 56 ++-- core/network-libp2p/Cargo.toml | 1 - core/network/Cargo.toml | 2 +- core/network/src/error.rs | 31 ++- core/network/src/test/mod.rs | 4 +- core/rpc/Cargo.toml | 2 +- core/rpc/src/author/error.rs | 69 ++--- core/rpc/src/author/mod.rs | 9 +- core/rpc/src/chain/error.rs | 43 +-- core/rpc/src/chain/mod.rs | 2 +- core/rpc/src/errors.rs | 8 - core/rpc/src/state/error.rs | 45 ++-- core/rpc/src/state/mod.rs | 27 +- core/rpc/src/state/tests.rs | 4 +- core/rpc/src/system/error.rs | 39 ++- core/service/Cargo.toml | 2 +- core/service/src/components.rs | 2 +- core/service/src/error.rs | 53 ++-- core/service/src/lib.rs | 4 +- core/test-runtime/wasm/Cargo.lock | 265 ++++++++----------- core/transaction-pool/Cargo.toml | 2 +- core/transaction-pool/graph/Cargo.toml | 2 +- core/transaction-pool/graph/src/base_pool.rs | 9 +- core/transaction-pool/graph/src/error.rs | 77 +++--- core/transaction-pool/graph/src/pool.rs | 22 +- core/transaction-pool/graph/src/ready.rs | 3 +- core/transaction-pool/src/error.rs | 35 +-- node-template/Cargo.toml | 2 +- node-template/runtime/wasm/Cargo.lock | 264 ++++++++---------- node-template/src/error.rs | 13 - node-template/src/main.rs | 10 +- node-template/src/service.rs | 20 +- node/cli/src/error.rs | 32 --- node/cli/src/service.rs | 4 +- node/runtime/wasm/Cargo.lock | 264 ++++++++---------- node/src/main.rs | 10 +- scripts/gitlab/check_line_width.sh | 5 +- 68 files changed, 952 insertions(+), 1159 deletions(-) delete mode 100644 node-template/src/error.rs delete mode 100644 node/cli/src/error.rs diff --git a/Cargo.lock b/Cargo.lock index 5550265cf4..5347186c37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2124,7 +2124,7 @@ name = "node-template" version = "2.0.0" dependencies = [ "ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3764,7 +3764,6 @@ name = "substrate" version = "2.0.0" dependencies = [ "ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "node-cli 2.0.0", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3806,8 +3805,8 @@ dependencies = [ "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3892,7 +3891,6 @@ name = "substrate-consensus-aura" version = "2.0.0" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3946,7 +3944,6 @@ name = "substrate-consensus-babe" version = "2.0.0" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3992,7 +3989,7 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4010,7 +4007,7 @@ dependencies = [ name = "substrate-consensus-rhd" version = "2.0.0" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4035,7 +4032,6 @@ dependencies = [ name = "substrate-consensus-slots" version = "2.0.0" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4054,7 +4050,7 @@ version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4137,7 +4133,7 @@ dependencies = [ name = "substrate-keystore" version = "2.0.0" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4151,8 +4147,8 @@ name = "substrate-network" version = "2.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4182,7 +4178,6 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4290,7 +4285,7 @@ name = "substrate-rpc" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-derive 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4341,7 +4336,7 @@ dependencies = [ name = "substrate-service" version = "2.0.0" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4487,8 +4482,8 @@ name = "substrate-transaction-graph" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4503,7 +4498,7 @@ dependencies = [ name = "substrate-transaction-pool" version = "2.0.0" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index f109d235af..3ccbb1c26d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ build = "build.rs" edition = "2018" [dependencies] -error-chain = "0.12" cli = { package = "node-cli", path = "node/cli" } futures = "0.1" ctrlc = { version = "3.0", features = ["termination"] } diff --git a/core/cli/Cargo.toml b/core/cli/Cargo.toml index 2482323c80..54cde50d1a 100644 --- a/core/cli/Cargo.toml +++ b/core/cli/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [dependencies] clap = "~2.32" +derive_more = "0.14.0" env_logger = "0.6" -error-chain = "0.12" log = "0.4" atty = "0.2" regex = "1" diff --git a/core/cli/src/error.rs b/core/cli/src/error.rs index 07d14eb479..b052a29710 100644 --- a/core/cli/src/error.rs +++ b/core/cli/src/error.rs @@ -16,26 +16,38 @@ //! Initialization errors. -// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting` -// https://github.com/paritytech/substrate/issues/1547 -#![allow(deprecated)] - use client; -use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, - impl_extract_backtrace, impl_error_chain_kind}; - -error_chain! { - foreign_links { - Io(::std::io::Error) #[doc="IO error"]; - Cli(::clap::Error) #[doc="CLI error"]; - Service(::service::Error) #[doc="Substrate service error"]; - Client(client::error::Error) #[doc="Client error"]; - } - errors { - /// Input error. - Input(m: String) { - description("Invalid input"), - display("{}", m), + +/// Result type alias for the CLI. +pub type Result = std::result::Result; + +/// Error type for the CLI. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Io error + Io(std::io::Error), + /// Cli error + Cli(clap::Error), + /// Service error + Service(service::Error), + /// Client error + Client(client::error::Error), + /// Input error + Input(String), + /// Invalid listen multiaddress + #[display(fmt="Invalid listen multiaddress")] + InvalidListenMultiaddress +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Io(ref err) => Some(err), + Error::Cli(ref err) => Some(err), + Error::Service(ref err) => Some(err), + Error::Client(ref err) => Some(err), + Error::Input(_) => None, + Error::InvalidListenMultiaddress => None, } } } diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 82ebf8ec05..e629788e80 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -55,7 +55,6 @@ use params::{ pub use params::{NoCustom, CoreParams}; pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; -use error_chain::bail; use log::info; use lazy_static::lazy_static; @@ -145,10 +144,6 @@ fn base_path(cli: &SharedParams, version: &VersionInfo) -> PathBuf { ) } -fn input_err>(msg: T) -> error::Error { - error::ErrorKind::Input(msg.into()).into() -} - /// Check whether a node name is considered as valid fn is_node_name_valid(_name: &str) -> Result<(), &str> { let name = _name.to_string(); @@ -278,7 +273,7 @@ where /// Create an error caused by an invalid node key argument. fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { - input_err(format!("Invalid node key: {}", e)) + error::Error::Input(format!("Invalid node key: {}", e)) } /// Parse a Secp256k1 secret key from a hex string into a `network::Secret`. @@ -334,7 +329,7 @@ fn fill_network_configuration( } for addr in cli.listen_addr.iter() { - let addr = addr.parse().map_err(|_| "Invalid listen multiaddress")?; + let addr = addr.parse().ok().ok_or(error::Error::InvalidListenMultiaddress)?; config.listen_addresses.push(addr); } @@ -392,14 +387,14 @@ where }; match is_node_name_valid(&config.name) { Ok(_) => (), - Err(msg) => bail!( - input_err( + Err(msg) => Err( + error::Error::Input( format!("Invalid node name '{}'. Reason: {}. If unsure, use none.", config.name, msg ) ) - ) + )? } let base_path = base_path(&cli.shared_params, version); @@ -417,7 +412,7 @@ where Some(ref s) if s == "archive" => PruningMode::ArchiveAll, None => PruningMode::default(), Some(s) => PruningMode::keep_blocks( - s.parse().map_err(|_| input_err("Invalid pruning mode specified"))? + s.parse().map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))? ), }; @@ -851,7 +846,7 @@ mod tests { NodeKeyConfig::Ed25519(network::Secret::Input(ref ski)) if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() => Ok(()), - _ => Err(input_err("Unexpected node key config")) + _ => Err(error::Error::Input("Unexpected node key config".into())) }) }) } @@ -877,7 +872,7 @@ mod tests { if node_key_type == NodeKeyType::Secp256k1 && f == &file => Ok(()), NodeKeyConfig::Ed25519(network::Secret::File(ref f)) if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()), - _ => Err(input_err("Unexpected node key config")) + _ => Err(error::Error::Input("Unexpected node key config".into())) }) }) } @@ -911,7 +906,7 @@ mod tests { if typ == NodeKeyType::Secp256k1 => Ok(()), NodeKeyConfig::Ed25519(network::Secret::New) if typ == NodeKeyType::Ed25519 => Ok(()), - _ => Err(input_err("Unexpected node key config")) + _ => Err(error::Error::Input("Unexpected node key config".into())) }) }) } @@ -928,7 +923,7 @@ mod tests { NodeKeyConfig::Ed25519(network::Secret::File(ref f)) if typ == NodeKeyType::Ed25519 && f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()), - _ => Err(input_err("Unexpected node key config")) + _ => Err(error::Error::Input("Unexpected node key config".into())) }) }) } diff --git a/core/client/db/src/cache/list_cache.rs b/core/client/db/src/cache/list_cache.rs index 3c74ac2d1f..4f343e93fd 100644 --- a/core/client/db/src/cache/list_cache.rs +++ b/core/client/db/src/cache/list_cache.rs @@ -45,7 +45,7 @@ use log::warn; use client::error::{Error as ClientError, Result as ClientResult}; use runtime_primitives::traits::{ - Block as BlockT, NumberFor, Zero, Bounded, SaturatedConversion, CheckedSub + Block as BlockT, NumberFor, Zero, Bounded, CheckedSub }; use crate::cache::{CacheItemT, ComplexBlockId, EntryType}; diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 0e65e17f8d..8f54099a78 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -48,7 +48,7 @@ use primitives::storage::well_known_keys; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, NumberFor, Zero, One, Digest, DigestItem, - SaturatedConversion, UniqueSaturatedFrom, UniqueSaturatedInto + SaturatedConversion, }; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; diff --git a/core/client/db/src/utils.rs b/core/client/db/src/utils.rs index eec476f40e..43c559b349 100644 --- a/core/client/db/src/utils.rs +++ b/core/client/db/src/utils.rs @@ -31,7 +31,7 @@ use trie::DBValue; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, Zero, UniqueSaturatedFrom, - UniqueSaturatedInto, SaturatedConversion, CheckedConversion + UniqueSaturatedInto, CheckedConversion }; use crate::DatabaseSettings; diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 5b849e1352..c9f70039ea 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -29,7 +29,7 @@ use runtime_primitives::{ generic::{BlockId, SignedBlock}, }; use consensus::{ - Error as ConsensusError, ErrorKind as ConsensusErrorKind, ImportBlock, + Error as ConsensusError, ImportBlock, ImportResult, BlockOrigin, ForkChoiceStrategy, well_known_cache_keys::Id as CacheKeyId, SelectChain, self, @@ -1387,7 +1387,7 @@ impl consensus::BlockImport for Client ) -> Result { self.lock_import_and_run(|operation| { self.apply_block(operation, import_block, new_cache) - }).map_err(|e| ConsensusErrorKind::ClientImport(e.to_string()).into()) + }).map_err(|e| ConsensusError::ClientImport(e.to_string()).into()) } /// Check block preconditions. @@ -1397,7 +1397,7 @@ impl consensus::BlockImport for Client parent_hash: Block::Hash, ) -> Result { match self.block_status(&BlockId::Hash(parent_hash)) - .map_err(|e| ConsensusError::from(ConsensusErrorKind::ClientImport(e.to_string())))? + .map_err(|e| ConsensusError::ClientImport(e.to_string()))? { BlockStatus::InChainWithState | BlockStatus::Queued => {}, BlockStatus::Unknown | BlockStatus::InChainPruned => return Ok(ImportResult::UnknownParent), @@ -1405,7 +1405,7 @@ impl consensus::BlockImport for Client } match self.block_status(&BlockId::Hash(hash)) - .map_err(|e| ConsensusError::from(ConsensusErrorKind::ClientImport(e.to_string())))? + .map_err(|e| ConsensusError::ClientImport(e.to_string()))? { BlockStatus::InChainWithState | BlockStatus::Queued => return Ok(ImportResult::AlreadyInChain), BlockStatus::Unknown | BlockStatus::InChainPruned => {}, @@ -1641,14 +1641,14 @@ where fn leaves(&self) -> Result::Hash>, ConsensusError> { LongestChain::leaves(self) - .map_err(|e| ConsensusErrorKind::ChainLookup(e.to_string()).into()) + .map_err(|e| ConsensusError::ChainLookup(e.to_string()).into()) } fn best_chain(&self) -> Result<::Header, ConsensusError> { LongestChain::best_block_header(&self) - .map_err(|e| ConsensusErrorKind::ChainLookup(e.to_string()).into()) + .map_err(|e| ConsensusError::ChainLookup(e.to_string()).into()) } fn finality_target( @@ -1657,7 +1657,7 @@ where maybe_max_number: Option> ) -> Result, ConsensusError> { LongestChain::best_containing(self, target_hash, maybe_max_number) - .map_err(|e| ConsensusErrorKind::ChainLookup(e.to_string()).into()) + .map_err(|e| ConsensusError::ChainLookup(e.to_string()).into()) } } diff --git a/core/consensus/aura/Cargo.toml b/core/consensus/aura/Cargo.toml index 8a589aa126..6e489cf8a9 100644 --- a/core/consensus/aura/Cargo.toml +++ b/core/consensus/aura/Cargo.toml @@ -24,7 +24,6 @@ runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.17" tokio = "0.1.7" parking_lot = "0.7.1" -error-chain = "0.12" log = "0.4" [dev-dependencies] diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 429666585d..59483a5688 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -50,7 +50,7 @@ use runtime_primitives::traits::{ Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi, AuthorityIdFor, Zero, }; use primitives::Pair; -use inherents::{InherentDataProviders, InherentData, RuntimeString}; +use inherents::{InherentDataProviders, InherentData}; use authorities::AuthoritiesApi; use futures::{Future, IntoFuture, future, stream::Stream}; @@ -122,10 +122,6 @@ fn slot_author(slot_num: u64, authorities: &[AuthorityId

]) -> Option Some(current_author) } -fn inherent_to_common_error(err: RuntimeString) -> consensus_common::Error { - consensus_common::ErrorKind::InherentData(err.into()).into() -} - /// A digest item which is usable with aura consensus. pub trait CompatibleDigestItem: Sized { /// Construct a digest item which contains a slot number and a signature on the @@ -177,7 +173,8 @@ impl SlotCompatible for AuraSlotCompatible { ) -> Result<(TimestampInherent, AuraInherent), consensus_common::Error> { data.timestamp_inherent_data() .and_then(|t| data.aura_inherent_data().map(|a| (t, a))) - .map_err(inherent_to_common_error) + .map_err(Into::into) + .map_err(consensus_common::Error::InherentData) } } @@ -448,7 +445,7 @@ impl SlotWorker for AuraWorker(client: &C) -> Result<(), ConsensusError> return Ok(()); } - let map_err = |error| consensus_common::Error::from(consensus_common::ErrorKind::ClientImport( + let map_err = |error| consensus_common::Error::from(consensus_common::Error::ClientImport( format!( "Error initializing authorities cache: {}", error, @@ -766,7 +763,7 @@ fn authorities(client: &C, at: &BlockId) -> Result as CompatibleDigestItem>::aura_seal( slot_num, signature, @@ -1120,7 +1118,7 @@ mod tests { // Different slot is ok. assert!(check_header::<_, B, P>(&c, 5, header3, header3_hash, &authorities, false).is_ok()); - + // Here we trigger pruning and save header 4. assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 2, header4, header4_hash, &authorities, false).is_ok()); diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 8ecfa05c4d..bc557ffb56 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -25,7 +25,6 @@ runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.26" tokio = "0.1.18" parking_lot = "0.7.1" -error-chain = "0.12.0" log = "0.4.6" schnorrkel = "0.1.1" rand = "0.6.5" diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index c3d73b6e49..cccbc160c6 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -40,7 +40,7 @@ use primitives::{ sr25519::{Public, Signature, LocalizedSignature, self}, }; use merlin::Transcript; -use inherents::{InherentDataProviders, InherentData, RuntimeString}; +use inherents::{InherentDataProviders, InherentData}; use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; use schnorrkel::{ keys::Keypair, @@ -191,10 +191,6 @@ impl Config { } } -fn inherent_to_common_error(err: RuntimeString) -> consensus_common::Error { - consensus_common::ErrorKind::InherentData(err.into()).into() -} - /// A digest item which is usable with BABE consensus. pub trait CompatibleDigestItem: Sized { /// Construct a digest item which contains a slot number and a signature @@ -243,7 +239,8 @@ impl SlotCompatible for BabeSlotCompatible { trace!(target: "babe", "extract timestamp"); data.timestamp_inherent_data() .and_then(|t| data.babe_inherent_data().map(|a| (t, a))) - .map_err(slots::inherent_to_common_error) + .map_err(Into::into) + .map_err(consensus_common::Error::InherentData) } } @@ -520,7 +517,7 @@ impl SlotWorker for BabeWorker whe }) .map_err(|e| { warn!("Client import failed: {:?}", e); - consensus_common::ErrorKind::ClientImport(format!("{:?}", e)).into() + consensus_common::Error::ClientImport(format!("{:?}", e)) }) ) } @@ -585,7 +582,7 @@ fn check_header( format!("VRF verification failed") })? }; - + if check(&inout, threshold) { match check_equivocation(&client, slot_now, slot_num, header.clone(), signer.clone()) { Ok(Some(equivocation_proof)) => { @@ -797,7 +794,7 @@ fn authorities(client: &C, at: &BlockId) -> Result< panic!("We don’t support deprecated code with new consensus algorithms, \ therefore this is unreachable; qed") } - }).ok_or_else(|| consensus_common::ErrorKind::InvalidAuthoritiesSet.into()) + }).ok_or(consensus_common::Error::InvalidAuthoritiesSet) } /// The BABE import queue type. @@ -812,7 +809,8 @@ fn register_babe_inherent_data_provider( if !inherent_data_providers.has_provider(&srml_babe::INHERENT_IDENTIFIER) { inherent_data_providers .register_provider(srml_babe::InherentDataProvider::new(slot_duration)) - .map_err(inherent_to_common_error) + .map_err(Into::into) + .map_err(consensus_common::Error::InherentData) } else { Ok(()) } @@ -1019,7 +1017,7 @@ mod tests { Default::default(), 0, ); - + let (inout, proof, _batchable_proof) = get_keypair(&pair).vrf_sign_n_check(transcript, |inout| check(inout, u64::MAX)).unwrap(); let pre_hash: H256 = header.hash(); let to_sign = (slot_num, pre_hash, proof.to_bytes()).encode(); diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index 4031830108..5e55d555dd 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -6,12 +6,12 @@ description = "Common utilities for substrate consensus" edition = "2018" [dependencies] +derive_more = "0.14.0" crossbeam-channel = "0.3.4" libp2p = { version = "0.8.1", default-features = false } log = "0.4" primitives = { package = "substrate-primitives", path= "../../primitives" } inherents = { package = "substrate-inherents", path = "../../inherents" } -error-chain = "0.12" futures = "0.1" rstd = { package = "sr-std", path = "../../sr-std" } runtime_version = { package = "sr-version", path = "../../sr-version" } diff --git a/core/consensus/common/src/error.rs b/core/consensus/common/src/error.rs index 71517c5440..a923c5f555 100644 --- a/core/consensus/common/src/error.rs +++ b/core/consensus/common/src/error.rs @@ -16,100 +16,69 @@ //! Error types in Consensus use runtime_version::RuntimeVersion; -use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, - impl_extract_backtrace, impl_error_chain_kind}; use primitives::ed25519::{Public, Signature}; +use std::error; + +/// Result type alias. +pub type Result = std::result::Result; + +/// Error type. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Missing state at block with given descriptor. + #[display(fmt="State unavailable at block {}", _0)] + StateUnavailable(String), + /// I/O terminated unexpectedly + #[display(fmt="I/O terminated unexpectedly.")] + IoTerminated, + /// Unable to schedule wakeup. + #[display(fmt="Timer error: {}", _0)] + FaultyTimer(tokio_timer::Error), + /// Error while working with inherent data. + #[display(fmt="InherentData error: {}", _0)] + InherentData(String), + /// Unable to propose a block. + #[display(fmt="Unable to create block proposal.")] + CannotPropose, + /// Error checking signature + #[display(fmt="Message signature {:?} by {:?} is invalid.", _0, _1)] + InvalidSignature(Signature, Public), + /// Invalid authorities set received from the runtime. + #[display(fmt="Current state of blockchain has invalid authorities set")] + InvalidAuthoritiesSet, + /// Account is not an authority. + #[display(fmt="Message sender {:?} is not a valid authority.", _0)] + InvalidAuthority(Public), + /// Authoring interface does not match the runtime. + #[display(fmt="Authoring for current \ + runtime is not supported. Native ({}) cannot author for on-chain ({}).", native, on_chain)] + IncompatibleAuthoringRuntime { native: RuntimeVersion, on_chain: RuntimeVersion }, + /// Authoring interface does not match the runtime. + #[display(fmt="Authoring for current runtime is not supported since it has no version.")] + RuntimeVersionMissing, + /// Authoring interface does not match the runtime. + #[display(fmt="Authoring in current build is not supported since it has no runtime.")] + NativeRuntimeMissing, + /// Justification requirements not met. + #[display(fmt="Invalid justification.")] + InvalidJustification, + /// Some other error. + #[display(fmt="Other error: {}", _0)] + Other(Box), + /// Error from the client while importing + #[display(fmt="Import failed: {}", _0)] + ClientImport(String), + /// Error from the client while importing + #[display(fmt="Chain lookup failed: {}", _0)] + ChainLookup(String), +} -error_chain! { - errors { - /// Missing state at block with given descriptor. - StateUnavailable(b: String) { - description("State missing at given block."), - display("State unavailable at block {}", b), - } - - /// I/O terminated unexpectedly - IoTerminated { - description("I/O terminated unexpectedly."), - display("I/O terminated unexpectedly."), - } - - /// Unable to schedule wakeup. - FaultyTimer(e: ::tokio_timer::Error) { - description("Timer error"), - display("Timer error: {}", e), - } - - /// Error while working with inherent data. - InherentData(e: String) { - description("InherentData error"), - display("InherentData error: {}", e), - } - - /// Unable to propose a block. - CannotPropose { - description("Unable to create block proposal."), - display("Unable to create block proposal."), - } - - /// Error checking signature - InvalidSignature(s: Signature, a: Public) { - description("Message signature is invalid"), - display("Message signature {:?} by {:?} is invalid.", s, a), - } - - /// Invalid authorities set received from the runtime. - InvalidAuthoritiesSet { - description("authorities set is invalid"), - display("Current state of blockchain has invalid authorities set"), - } - - /// Account is not an authority. - InvalidAuthority(a: Public) { - description("Message sender is not a valid authority"), - display("Message sender {:?} is not a valid authority.", a), - } - - /// Authoring interface does not match the runtime. - IncompatibleAuthoringRuntime(native: RuntimeVersion, on_chain: RuntimeVersion) { - description("Authoring for current runtime is not supported"), - display("Authoring for current runtime is not supported. Native ({}) cannot author for on-chain ({}).", native, on_chain), - } - - /// Authoring interface does not match the runtime. - RuntimeVersionMissing { - description("Current runtime has no version"), - display("Authoring for current runtime is not supported since it has no version."), - } - - /// Authoring interface does not match the runtime. - NativeRuntimeMissing { - description("This build has no native runtime"), - display("Authoring in current build is not supported since it has no runtime."), - } - - /// Justification requirements not met. - InvalidJustification { - description("Invalid justification"), - display("Invalid justification."), - } - - /// Some other error. - Other(e: Box<::std::error::Error + Send>) { - description("Other error") - display("Other error: {}", e.description()) - } - - /// Error from the client while importing - ClientImport(reason: String) { - description("Import failed"), - display("Import failed: {}", reason), - } - - /// Error from the client while importing - ChainLookup(reason: String) { - description("Looking up chain failed"), - display("Chain lookup failed: {}", reason), +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + match self { + Error::FaultyTimer(ref err) => Some(err), + Error::Other(ref err) => Some(&**err), + _ => None, } } } diff --git a/core/consensus/common/src/evaluation.rs b/core/consensus/common/src/evaluation.rs index 7f1f527042..ed7515a419 100644 --- a/core/consensus/common/src/evaluation.rs +++ b/core/consensus/common/src/evaluation.rs @@ -20,37 +20,36 @@ use super::MAX_BLOCK_SIZE; use parity_codec::Encode; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion}; -use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, - impl_extract_backtrace, impl_error_chain_kind, bail}; // This is just a best effort to encode the number. None indicated that it's too big to encode // in a u128. type BlockNumber = Option; -error_chain! { - errors { - BadProposalFormat { - description("Proposal provided not a block."), - display("Proposal provided not a block."), - } - WrongParentHash(expected: String, got: String) { - description("Proposal had wrong parent hash."), - display("Proposal had wrong parent hash. Expected {:?}, got {:?}", expected, got), - } - WrongNumber(expected: BlockNumber, got: BlockNumber) { - description("Proposal had wrong number."), - display("Proposal had wrong number. Expected {:?}, got {:?}", expected, got), - } - ProposalTooLarge(size: usize) { - description("Proposal exceeded the maximum size."), - display( - "Proposal exceeded the maximum size of {} by {} bytes.", - MAX_BLOCK_SIZE, size.saturating_sub(MAX_BLOCK_SIZE) - ), - } - } +/// Result type alias. +pub type Result = std::result::Result; + +/// Error type. +#[derive(Debug, derive_more::Display)] +pub enum Error { + /// Proposal provided not a block. + #[display(fmt="Proposal provided not a block.")] + BadProposalFormat, + /// Proposal had wrong parent hash. + #[display(fmt="Proposal had wrong parent hash. Expected {:?}, got {:?}", expected, got)] + WrongParentHash { expected: String, got: String }, + /// Proposal had wrong number. + #[display(fmt="Proposal had wrong number. Expected {:?}, got {:?}", expected, got)] + WrongNumber { expected: BlockNumber, got: BlockNumber }, + /// Proposal exceeded the maximum size. + #[display( + fmt="Proposal exceeded the maximum size of {} by {} bytes.", + "MAX_BLOCK_SIZE", "_0.saturating_sub(MAX_BLOCK_SIZE)" + )] + ProposalTooLarge(usize), } +impl std::error::Error for Error {} + /// Attempt to evaluate a substrate block as a node block, returning error /// upon any initial validity checks failing. pub fn evaluate_initial( @@ -61,24 +60,24 @@ pub fn evaluate_initial( let encoded = Encode::encode(proposal); let proposal = Block::decode(&mut &encoded[..]) - .ok_or_else(|| ErrorKind::BadProposalFormat)?; + .ok_or_else(|| Error::BadProposalFormat)?; if encoded.len() > MAX_BLOCK_SIZE { - bail!(ErrorKind::ProposalTooLarge(encoded.len())) + return Err(Error::ProposalTooLarge(encoded.len())) } if *parent_hash != *proposal.header().parent_hash() { - bail!(ErrorKind::WrongParentHash( - format!("{:?}", *parent_hash), - format!("{:?}", proposal.header().parent_hash()) - )); + return Err(Error::WrongParentHash { + expected: format!("{:?}", *parent_hash), + got: format!("{:?}", proposal.header().parent_hash()) + }); } if parent_number + One::one() != *proposal.header().number() { - bail!(ErrorKind::WrongNumber( - parent_number.checked_into::().map(|x| x + 1), - (*proposal.header().number()).checked_into::() - )); + return Err(Error::WrongNumber { + expected: parent_number.checked_into::().map(|x| x + 1), + got: (*proposal.header().number()).checked_into::(), + }); } Ok(()) diff --git a/core/consensus/common/src/lib.rs b/core/consensus/common/src/lib.rs index 5e308ba8fe..d28864a0cc 100644 --- a/core/consensus/common/src/lib.rs +++ b/core/consensus/common/src/lib.rs @@ -47,7 +47,7 @@ pub mod evaluation; // block size limit. const MAX_BLOCK_SIZE: usize = 4 * 1024 * 1024 + 512; -pub use self::error::{Error, ErrorKind}; +pub use self::error::Error; pub use block_import::{ BlockImport, BlockOrigin, ForkChoiceStrategy, ImportedAux, ImportBlock, ImportResult, JustificationImport, FinalityProofImport, FinalityProofRequestBuilder, diff --git a/core/consensus/rhd/Cargo.toml b/core/consensus/rhd/Cargo.toml index 8535f3f006..3f0a79a863 100644 --- a/core/consensus/rhd/Cargo.toml +++ b/core/consensus/rhd/Cargo.toml @@ -6,6 +6,7 @@ description = "Rhododendron Round-Based consensus-algorithm for substrate" edition = "2018" [dependencies] +derive_more = "0.14.0" futures = "0.1.17" codec = { package = "parity-codec", version = "3.2", features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../primitives" } @@ -20,7 +21,6 @@ runtime_version = { package = "sr-version", path = "../../sr-version" } runtime_io = { package = "sr-io", path = "../../sr-io" } tokio = "0.1.7" parking_lot = "0.7.1" -error-chain = "0.12" log = "0.4" rhododendron = { version = "0.5.0", features = ["codec"] } exit-future = "0.1" diff --git a/core/consensus/rhd/src/error.rs b/core/consensus/rhd/src/error.rs index 3808110975..601cf1c963 100644 --- a/core/consensus/rhd/src/error.rs +++ b/core/consensus/rhd/src/error.rs @@ -15,45 +15,36 @@ // along with Substrate. If not, see . //! Error types in the rhododendron Consensus service. -use consensus::error::{Error as CommonError, ErrorKind as CommonErrorKind}; +use consensus::error::{Error as CommonError}; use primitives::AuthorityId; use client; -use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, - impl_extract_backtrace, impl_error_chain_kind}; -error_chain! { - links { - Client(client::error::Error, client::error::ErrorKind); - Common(CommonError, CommonErrorKind); - } - errors { - NotValidator(id: AuthorityId) { - description("Local account ID not a validator at this block."), - display("Local account ID ({:?}) not a validator at this block.", id), - } - PrematureDestruction { - description("Proposer destroyed before finishing proposing or evaluating"), - display("Proposer destroyed before finishing proposing or evaluating"), - } - Timer(e: ::tokio::timer::Error) { - description("Failed to register or resolve async timer."), - display("Timer failed: {}", e), - } - Executor(e: ::futures::future::ExecuteErrorKind) { - description("Unable to dispatch agreement future"), - display("Unable to dispatch agreement future: {:?}", e), - } - } +/// A result alias. +pub type Result = std::result::Result; + +/// A RHD error type. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Client error. + Client(client::error::Error), + /// Consensus error. + Common(CommonError), + /// Local account ID not a validator at this block. + #[display(fmt="Local account ID ({:?}) not a validator at this block.", _0)] + NotValidator(AuthorityId), + /// Proposer destroyed before finishing proposing or evaluating + #[display(fmt="Proposer destroyed before finishing proposing or evaluating")] + PrematureDestruction, + /// Failed to register or resolve async timer. + #[display(fmt="Timer failed: {}", _0)] + Timer(tokio::timer::Error), + /// Unable to dispatch agreement future + #[display(fmt="Unable to dispatch agreement future: {:?}", _0)] + Executor(futures::future::ExecuteErrorKind), } impl From<::rhododendron::InputStreamConcluded> for Error { fn from(_: ::rhododendron::InputStreamConcluded) -> Self { - CommonErrorKind::IoTerminated.into() - } -} - -impl From for Error { - fn from(e: CommonErrorKind) -> Self { - CommonError::from(e).into() + CommonError::IoTerminated.into() } } diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index c02559185f..ee3571bcdc 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -15,5 +15,4 @@ inherents = { package = "substrate-inherents", path = "../../inherents" } futures = "0.1.17" tokio = "0.1.7" parking_lot = "0.7.1" -error-chain = "0.12" log = "0.4" diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index 4ae72fd92a..783cb018b9 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -65,11 +65,6 @@ pub trait SlotCompatible { ) -> Result<(u64, u64), consensus_common::Error>; } -/// Convert an inherent error to common error. -pub fn inherent_to_common_error(err: inherents::RuntimeString) -> consensus_common::Error { - consensus_common::ErrorKind::InherentData(err.into()).into() -} - /// Start a new slot worker in a separate thread. #[deprecated(since = "1.1", note = "Please spawn a thread manually")] pub fn start_slot_worker_thread( diff --git a/core/consensus/slots/src/slots.rs b/core/consensus/slots/src/slots.rs index df21ae9b83..964eeaff29 100644 --- a/core/consensus/slots/src/slots.rs +++ b/core/consensus/slots/src/slots.rs @@ -19,7 +19,7 @@ //! This is used instead of `tokio_timer::Interval` because it was unreliable. use super::SlotCompatible; -use consensus_common::{Error, ErrorKind}; +use consensus_common::Error; use futures::prelude::*; use futures::try_ready; use inherents::{InherentData, InherentDataProviders}; @@ -125,7 +125,7 @@ impl Stream for Slots { if let Some(ref mut inner_delay) = self.inner_delay { try_ready!(inner_delay .poll() - .map_err(|e| Error::from(ErrorKind::FaultyTimer(e)))); + .map_err(Error::FaultyTimer)); } // timeout has fired. @@ -133,7 +133,7 @@ impl Stream for Slots { let inherent_data = self .inherent_data_providers .create_inherent_data() - .map_err(crate::inherent_to_common_error)?; + .map_err(|s| consensus_common::Error::InherentData(s.into_owned()))?; let (timestamp, slot_num) = SC::extract_timestamp_and_slot(&inherent_data)?; // reschedule delay for next slot. diff --git a/core/executor/Cargo.toml b/core/executor/Cargo.toml index 0272ce2f47..8f39d35c79 100644 --- a/core/executor/Cargo.toml +++ b/core/executor/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -error-chain = "0.12" +derive_more = "0.14.0" parity-codec = "3.3" runtime_io = { package = "sr-io", path = "../sr-io" } primitives = { package = "substrate-primitives", path = "../primitives" } diff --git a/core/executor/src/error.rs b/core/executor/src/error.rs index b27ccf01bf..fdcb6cbc0e 100644 --- a/core/executor/src/error.rs +++ b/core/executor/src/error.rs @@ -16,72 +16,57 @@ //! Rust executor possible errors. -// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting` -// https://github.com/paritytech/substrate/issues/1547 -#![allow(deprecated)] - use state_machine; use serializer; use wasmi; -use error_chain::{ - error_chain, error_chain_processing, impl_error_chain_processed, - impl_extract_backtrace, impl_error_chain_kind -}; - -error_chain! { - foreign_links { - InvalidData(serializer::Error) #[doc = "Unserializable Data"]; - Trap(wasmi::Trap) #[doc = "Trap occured during execution"]; - Wasmi(wasmi::Error) #[doc = "Wasmi loading/instantiating error"]; - } - - errors { - /// Method is not found - MethodNotFound(t: String) { - description("method not found"), - display("Method not found: '{}'", t), - } - - /// Code is invalid (expected single byte) - InvalidCode(c: Vec) { - description("invalid code"), - display("Invalid Code: {:?}", c), - } - - /// Could not get runtime version. - VersionInvalid { - description("Runtime version error"), - display("On-chain runtime does not specify version"), - } - /// Externalities have failed. - Externalities { - description("externalities failure"), - display("Externalities error"), - } - - /// Invalid index. - InvalidIndex { - description("index given was not in range"), - display("Invalid index provided"), - } - - /// Invalid return type. - InvalidReturn { - description("u64 was not returned"), - display("Invalid type returned (should be u64)"), - } - - /// Runtime failed. - Runtime { - description("runtime failure"), - display("Runtime error"), - } +/// Result type alias. +pub type Result = std::result::Result; + +/// Error type. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Unserializable Data + InvalidData(serializer::Error), + /// Trap occured during execution + Trap(wasmi::Trap), + /// Wasmi loading/instantiating error + Wasmi(wasmi::Error), + /// Error in the API. Parameter is an error message. + ApiError(String), + /// Method is not found + #[display(fmt="Method not found: '{}'", _0)] + MethodNotFound(String), + /// Code is invalid (expected single byte) + #[display(fmt="Invalid Code: {:?}", _0)] + InvalidCode(Vec), + /// Could not get runtime version. + #[display(fmt="On-chain runtime does not specify version")] + VersionInvalid, + /// Externalities have failed. + #[display(fmt="Externalities error")] + Externalities, + /// Invalid index. + #[display(fmt="Invalid index provided")] + InvalidIndex, + /// Invalid return type. + #[display(fmt="Invalid type returned (should be u64)")] + InvalidReturn, + /// Runtime failed. + #[display(fmt="Runtime error")] + Runtime, + /// Runtime failed. + #[display(fmt="Invalid memory reference")] + InvalidMemoryReference, +} - /// Runtime failed. - InvalidMemoryReference { - description("invalid memory reference"), - display("Invalid memory reference"), +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::InvalidData(ref err) => Some(err), + Error::Trap(ref err) => Some(err), + Error::Wasmi(ref err) => Some(err), + _ => None, } } } diff --git a/core/executor/src/native_executor.rs b/core/executor/src/native_executor.rs index 0a702a5a1b..0a6f50d001 100644 --- a/core/executor/src/native_executor.rs +++ b/core/executor/src/native_executor.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use std::{borrow::BorrowMut, result, cell::{RefMut, RefCell}}; -use crate::error::{Error, ErrorKind, Result}; +use crate::error::{Error, Result}; use state_machine::{CodeExecutor, Externalities}; use crate::wasm_executor::WasmExecutor; use wasmi::{Module as WasmModule, ModuleRef as WasmModuleInstanceRef}; @@ -55,7 +55,7 @@ fn fetch_cached_runtime_version<'a, E: Externalities>( ) -> Result<(&'a WasmModuleInstanceRef, &'a Option)> { let code_hash = match ext.original_storage_hash(well_known_keys::CODE) { Some(code_hash) => code_hash, - None => return Err(ErrorKind::InvalidCode(vec![]).into()), + None => return Err(Error::InvalidCode(vec![])), }; let maybe_runtime_preproc = cache.borrow_mut().entry(code_hash.into()) @@ -69,7 +69,7 @@ fn fetch_cached_runtime_version<'a, E: Externalities>( .or(default_heap_pages) .unwrap_or(DEFAULT_HEAP_PAGES); match WasmModule::from_buffer(code) - .map_err(|_| ErrorKind::InvalidCode(vec![]).into()) + .map_err(|_| Error::InvalidCode(vec![])) .and_then(|module| wasm_executor.prepare_module(ext, heap_pages as usize, &module)) { Ok(module) => { @@ -88,7 +88,7 @@ fn fetch_cached_runtime_version<'a, E: Externalities>( match maybe_runtime_preproc { RuntimePreproc::InvalidCode => { let code = ext.original_storage(well_known_keys::CODE).unwrap_or(vec![]); - Err(ErrorKind::InvalidCode(code).into()) + Err(Error::InvalidCode(code)) }, RuntimePreproc::ValidCode(m, v) => { Ok((m, v)) @@ -101,7 +101,7 @@ fn safe_call(f: F) -> Result { // Substrate uses custom panic hook that terminates process on panic. Disable termination for the native call. let _guard = panic_handler::AbortGuard::new(false); - ::std::panic::catch_unwind(f).map_err(|_| ErrorKind::Runtime.into()) + ::std::panic::catch_unwind(f).map_err(|_| Error::Runtime) } /// Set up the externalities and safe calling environment to execute calls to a native runtime. @@ -248,7 +248,7 @@ impl CodeExecutor for NativeExecutor, method: &str, data: &[u8]) -> $crate::error::Result> { $crate::with_native_environment(ext, move || $dispatcher(method, data))? - .ok_or_else(|| $crate::error::ErrorKind::MethodNotFound(method.to_owned()).into()) + .ok_or_else(|| $crate::error::Error::MethodNotFound(method.to_owned())) } fn native_version() -> $crate::NativeVersion { diff --git a/core/executor/src/sandbox.rs b/core/executor/src/sandbox.rs index cc21d762be..24c8ad66ea 100644 --- a/core/executor/src/sandbox.rs +++ b/core/executor/src/sandbox.rs @@ -643,9 +643,8 @@ mod tests { let res = WasmExecutor::new().call(&mut ext, 8, &test_code[..], "test_exhaust_heap", &code); assert_eq!(res.is_err(), true); if let Err(err) = res { - let inner_err = err.iter().next().unwrap(); assert_eq!( - format!("{}", inner_err), + format!("{}", err), format!("{}", wasmi::Error::Trap(trap(allocator::OUT_OF_SPACE))) ); } diff --git a/core/executor/src/wasm_executor.rs b/core/executor/src/wasm_executor.rs index 3fe1a1c3cc..988b6ddcf3 100644 --- a/core/executor/src/wasm_executor.rs +++ b/core/executor/src/wasm_executor.rs @@ -26,7 +26,7 @@ use wasmi::{ use wasmi::RuntimeValue::{I32, I64, self}; use wasmi::memory_units::{Pages}; use state_machine::{Externalities, ChildStorageKey}; -use crate::error::{Error, ErrorKind, Result}; +use crate::error::{Error, Result}; use crate::wasm_utils::UserError; use primitives::{blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Pair}; use primitives::hexdisplay::HexDisplay; @@ -769,9 +769,9 @@ impl WasmExecutor { fn get_mem_instance(module: &ModuleRef) -> Result { Ok(module .export_by_name("memory") - .ok_or_else(|| Error::from(ErrorKind::InvalidMemoryReference))? + .ok_or_else(|| Error::InvalidMemoryReference)? .as_memory() - .ok_or_else(|| Error::from(ErrorKind::InvalidMemoryReference))? + .ok_or_else(|| Error::InvalidMemoryReference)? .clone()) } @@ -795,7 +795,7 @@ impl WasmExecutor { if let Some(I64(r)) = res { let offset = r as u32; let length = (r as u64 >> 32) as usize; - memory.get(offset, length).map_err(|_| ErrorKind::Runtime.into()).map(Some) + memory.get(offset, length).map_err(|_| Error::Runtime).map(Some) } else { Ok(None) } @@ -828,7 +828,7 @@ impl WasmExecutor { let used_mem = memory.used_size(); let mut fec = FunctionExecutor::new(memory.clone(), table, ext)?; let parameters = create_parameters(&mut |data: &[u8]| { - let offset = fec.heap.allocate(data.len() as u32).map_err(|_| ErrorKind::Runtime)?; + let offset = fec.heap.allocate(data.len() as u32).map_err(|_| Error::Runtime)?; memory.set(offset, &data)?; Ok(offset) })?; @@ -841,7 +841,7 @@ impl WasmExecutor { let result = match result { Ok(val) => match filter_result(val, &memory)? { Some(val) => Ok(val), - None => Err(ErrorKind::InvalidReturn.into()), + None => Err(Error::InvalidReturn), }, Err(e) => { trace!(target: "wasm-executor", "Failed to execute code with {} pages", memory.current_size().0); @@ -877,7 +877,7 @@ impl WasmExecutor { // extract a reference to a linear memory, optional reference to a table // and then initialize FunctionExecutor. let memory = Self::get_mem_instance(intermediate_instance.not_started_instance())?; - memory.grow(Pages(heap_pages)).map_err(|_| Error::from(ErrorKind::Runtime))?; + memory.grow(Pages(heap_pages)).map_err(|_| Error::Runtime)?; let table: Option = intermediate_instance .not_started_instance() .export_by_name("__indirect_function_table") diff --git a/core/finality-grandpa/src/import.rs b/core/finality-grandpa/src/import.rs index cd5ca02a5b..1966913c72 100644 --- a/core/finality-grandpa/src/import.rs +++ b/core/finality-grandpa/src/import.rs @@ -26,7 +26,7 @@ use client::blockchain::HeaderBackend; use client::backend::Backend; use client::runtime_api::ApiExt; use consensus_common::{ - BlockImport, Error as ConsensusError, ErrorKind as ConsensusErrorKind, + BlockImport, Error as ConsensusError, ImportBlock, ImportResult, JustificationImport, well_known_cache_keys, SelectChain, }; @@ -187,11 +187,11 @@ where match maybe_change { Err(e) => match api.has_api_with::, _>(&at, |v| v >= 2) { - Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()), + Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()), Ok(true) => { // API version is high enough to support forced changes // but got error, so it is legitimate. - return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()) + return Err(ConsensusError::ClientImport(e.to_string()).into()) }, Ok(false) => { // API version isn't high enough to support forced changes @@ -216,7 +216,7 @@ where ); match maybe_change { - Err(e) => Err(ConsensusErrorKind::ClientImport(e.to_string()).into()), + Err(e) => Err(ConsensusError::ClientImport(e.to_string()).into()), Ok(Some(change)) => Ok(Some(PendingChange { next_authorities: change.next_authorities, delay: change.delay, @@ -301,12 +301,12 @@ where guard.as_mut().add_pending_change( change, &is_descendent_of, - ).map_err(|e| ConsensusError::from(ConsensusErrorKind::ClientImport(e.to_string())))?; + ).map_err(|e| ConsensusError::from(ConsensusError::ClientImport(e.to_string())))?; } let applied_changes = { let forced_change_set = guard.as_mut().apply_forced_changes(hash, number, &is_descendent_of) - .map_err(|e| ConsensusErrorKind::ClientImport(e.to_string())) + .map_err(|e| ConsensusError::ClientImport(e.to_string())) .map_err(ConsensusError::from)?; if let Some((median_last_finalized_number, new_set)) = forced_change_set { @@ -318,14 +318,14 @@ where // with. we use the minimum between the median and the local // best finalized block. let best_finalized_number = self.inner.backend().blockchain().info() - .map_err(|e| ConsensusErrorKind::ClientImport(e.to_string()))? + .map_err(|e| ConsensusError::ClientImport(e.to_string()))? .finalized_number; let canon_number = best_finalized_number.min(median_last_finalized_number); let canon_hash = self.inner.backend().blockchain().header(BlockId::Number(canon_number)) - .map_err(|e| ConsensusErrorKind::ClientImport(e.to_string()))? + .map_err(|e| ConsensusError::ClientImport(e.to_string()))? .expect("the given block number is less or equal than the current best finalized number; \ current best finalized number must exist in chain; qed.") .hash(); @@ -343,7 +343,7 @@ where AppliedChanges::Forced(new_authorities) } else { let did_standard = guard.as_mut().enacts_standard_change(hash, number, &is_descendent_of) - .map_err(|e| ConsensusErrorKind::ClientImport(e.to_string())) + .map_err(|e| ConsensusError::ClientImport(e.to_string())) .map_err(ConsensusError::from)?; if let Some(root) = did_standard { @@ -399,7 +399,7 @@ impl, RA, PRA, SC> BlockImport match self.inner.backend().blockchain().status(BlockId::Hash(hash)) { Ok(blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain), Ok(blockchain::BlockStatus::Unknown) => {}, - Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()), + Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()), } let pending_changes = self.make_authorities_changes(&mut block, hash)?; @@ -420,7 +420,7 @@ impl, RA, PRA, SC> BlockImport Err(e) => { debug!(target: "afg", "Restoring old authority set after block import error: {:?}", e); pending_changes.revert(); - return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()); + return Err(ConsensusError::ClientImport(e.to_string()).into()); }, } }; @@ -509,7 +509,7 @@ impl, RA, PRA, SC> BlockImport } } -impl, RA, PRA, SC> +impl, RA, PRA, SC> GrandpaBlockImport { pub(crate) fn new( @@ -559,7 +559,7 @@ where ); let justification = match justification { - Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()), + Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()), Ok(justification) => justification, }; @@ -579,17 +579,17 @@ where command {}, signaling voter.", number, command); if let Err(e) = self.send_voter_commands.unbounded_send(command) { - return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()); + return Err(ConsensusError::ClientImport(e.to_string()).into()); } }, Err(CommandOrError::Error(e)) => { return Err(match e { - Error::Grandpa(error) => ConsensusErrorKind::ClientImport(error.to_string()), - Error::Network(error) => ConsensusErrorKind::ClientImport(error), - Error::Blockchain(error) => ConsensusErrorKind::ClientImport(error), - Error::Client(error) => ConsensusErrorKind::ClientImport(error.to_string()), - Error::Safety(error) => ConsensusErrorKind::ClientImport(error), - Error::Timer(error) => ConsensusErrorKind::ClientImport(error.to_string()), + Error::Grandpa(error) => ConsensusError::ClientImport(error.to_string()), + Error::Network(error) => ConsensusError::ClientImport(error), + Error::Blockchain(error) => ConsensusError::ClientImport(error), + Error::Client(error) => ConsensusError::ClientImport(error.to_string()), + Error::Safety(error) => ConsensusError::ClientImport(error), + Error::Timer(error) => ConsensusError::ClientImport(error.to_string()), }.into()); }, Ok(_) => { diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 53dd9d2a57..75aa4d85ce 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -441,7 +441,7 @@ fn register_finality_tracker_inherent_data_provider, RA> BlockImport block: ImportBlock, new_cache: HashMap>, ) -> Result { - do_import_block::<_, _, _, _, GrandpaJustification>(&*self.client, &mut *self.data.write(), block, new_cache) + do_import_block::<_, _, _, _, GrandpaJustification>( + &*self.client, &mut *self.data.write(), block, new_cache + ) } fn check_block( @@ -238,7 +240,7 @@ fn do_import_block, RA, J>( let mut imported_aux = match import_result { Ok(ImportResult::Imported(aux)) => aux, Ok(r) => return Ok(r), - Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()), + Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()), }; match justification { @@ -294,12 +296,13 @@ fn do_import_finality_proof, RA, J>( authorities, authority_set_provider, finality_proof, - ).map_err(|e| ConsensusError::from(ConsensusErrorKind::ClientImport(e.to_string())))?; + ).map_err(|e| ConsensusError::ClientImport(e.to_string()))?; // try to import all new headers let block_origin = BlockOrigin::NetworkBroadcast; for header_to_import in finality_effects.headers_to_import { - let (block_to_import, new_authorities) = verifier.verify(block_origin, header_to_import, None, None)?; + let (block_to_import, new_authorities) = verifier.verify(block_origin, header_to_import, None, None) + .map_err(|e| ConsensusError::ClientImport(e))?; assert!(block_to_import.justification.is_none(), "We have passed None as justification to verifier.verify"); let mut cache = HashMap::new(); @@ -313,7 +316,7 @@ fn do_import_finality_proof, RA, J>( let finalized_block_hash = finality_effects.block; let finalized_block_number = client.backend().blockchain() .expect_block_number_from_id(&BlockId::Hash(finality_effects.block)) - .map_err(|e| ConsensusError::from(ConsensusErrorKind::ClientImport(e.to_string())))?; + .map_err(|e| ConsensusError::ClientImport(e.to_string()))?; do_finalize_block( client, data, @@ -383,7 +386,7 @@ fn do_import_justification, RA, J>( hash, ); - return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()); + return Err(ConsensusError::ClientImport(e.to_string()).into()); }, Ok(justification) => { trace!( @@ -417,7 +420,7 @@ fn do_finalize_block, RA>( // finalize the block client.finalize_block(BlockId::Hash(hash), Some(justification), true).map_err(|e| { warn!(target: "finality", "Error applying finality to block {:?}: {:?}", (hash, number), e); - ConsensusError::from(ConsensusErrorKind::ClientImport(e.to_string())) + ConsensusError::ClientImport(e.to_string()) })?; // forget obsoleted consensus changes @@ -513,7 +516,7 @@ fn require_insert_aux, RA>( fn on_post_finalization_error(error: ClientError, value_type: &str) -> ConsensusError { warn!(target: "finality", "Failed to write updated {} to disk. Bailing.", value_type); warn!(target: "finality", "Node is in a potentially inconsistent state."); - ConsensusError::from(ConsensusErrorKind::ClientImport(error.to_string())) + ConsensusError::ClientImport(error.to_string()) } #[cfg(test)] diff --git a/core/keystore/Cargo.toml b/core/keystore/Cargo.toml index 99f0ebedd2..1d4f146b7e 100644 --- a/core/keystore/Cargo.toml +++ b/core/keystore/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +derive_more = "0.14.0" substrate-primitives = { path = "../primitives" } -error-chain = "0.12" hex = "0.3" rand = "0.6" serde_json = "1.0" diff --git a/core/keystore/src/lib.rs b/core/keystore/src/lib.rs index 9e6d4ec83c..67cf2c8d32 100644 --- a/core/keystore/src/lib.rs +++ b/core/keystore/src/lib.rs @@ -16,38 +16,42 @@ //! Keystore (and session key management) for ed25519 based chains like Polkadot. -// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting` -// https://github.com/paritytech/substrate/issues/1547 -#![allow(deprecated)] +#![warn(missing_docs)] use std::collections::HashMap; use std::path::PathBuf; use std::fs::{self, File}; use std::io::{self, Write}; -use error_chain::{bail, error_chain, error_chain_processing, impl_error_chain_processed, - impl_extract_backtrace, impl_error_chain_kind}; - use substrate_primitives::{ed25519::{Pair, Public}, Pair as PairT}; -error_chain! { - foreign_links { - Io(io::Error); - Json(serde_json::Error); - } +/// Keystore error. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// IO error. + Io(io::Error), + /// JSON error. + Json(serde_json::Error), + /// Invalid password. + #[display(fmt="Invalid password")] + InvalidPassword, + /// Invalid BIP39 phrase + #[display(fmt="Invalid recovery phrase (BIP39) data")] + InvalidPhrase, + /// Invalid seed + #[display(fmt="Invalid seed")] + InvalidSeed, +} - errors { - InvalidPassword { - description("Invalid password"), - display("Invalid password"), - } - InvalidPhrase { - description("Invalid recovery phrase (BIP39) data"), - display("Invalid recovery phrase (BIP39) data"), - } - InvalidSeed { - description("Invalid seed"), - display("Invalid seed"), +/// Keystore Result +pub type Result = std::result::Result; + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Io(ref err) => Some(err), + Error::Json(ref err) => Some(err), + _ => None, } } } @@ -77,7 +81,7 @@ impl Store { /// Create a new key from seed. Do not place it into the store. pub fn generate_from_seed(&mut self, seed: &str) -> Result { let pair = Pair::from_string(seed, None) - .map_err(|_| Error::from(ErrorKind::InvalidSeed))?; + .ok().ok_or(Error::InvalidSeed)?; self.additional.insert(pair.public(), pair.clone()); Ok(pair) } @@ -92,9 +96,9 @@ impl Store { let phrase: String = ::serde_json::from_reader(&file)?; let pair = Pair::from_phrase(&phrase, Some(password)) - .map_err(|_| Error::from(ErrorKind::InvalidPhrase))?; + .ok().ok_or(Error::InvalidPhrase)?; if &pair.public() != public { - bail!(ErrorKind::InvalidPassword); + return Err(Error::InvalidPassword); } Ok(pair) } diff --git a/core/network-libp2p/Cargo.toml b/core/network-libp2p/Cargo.toml index be631aa4b9..a2ea8660a2 100644 --- a/core/network-libp2p/Cargo.toml +++ b/core/network-libp2p/Cargo.toml @@ -10,7 +10,6 @@ edition = "2018" [dependencies] byteorder = "1.3" bytes = "0.4" -error-chain = { version = "0.12", default-features = false } fnv = "1.0" futures = "0.1" libp2p = { version = "0.8.1", default-features = false, features = ["secp256k1", "libp2p-websocket"] } diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index c3184ab47d..d3b7a71f03 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -9,9 +9,9 @@ edition = "2018" [lib] [dependencies] +derive_more = "0.14.0" log = "0.4" parking_lot = "0.7.1" -error-chain = "0.12" bitflags = "1.0" futures = "0.1.17" linked-hash-map = "0.5" diff --git a/core/network/src/error.rs b/core/network/src/error.rs index 87b967765c..95a1dc5abe 100644 --- a/core/network/src/error.rs +++ b/core/network/src/error.rs @@ -14,22 +14,27 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Substrate service possible errors. +//! Substrate network possible errors. -// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting` -// https://github.com/paritytech/substrate/issues/1547 -#![allow(deprecated)] - -use error_chain::*; -use std::io::Error as IoError; use client; -error_chain! { - foreign_links { - Io(IoError) #[doc = "IO error."]; - Client(client::error::Error) #[doc="Client error"]; - } +/// Result type alias for the network. +pub type Result = std::result::Result; + +/// Error type for the network. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Io error + Io(std::io::Error), + /// Client error + Client(client::error::Error), +} - errors { +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Io(ref err) => Some(err), + Error::Client(ref err) => Some(err), + } } } diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 13d18a0d44..ac9e9a98eb 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -37,7 +37,7 @@ use consensus::import_queue::{ Link, SharedBlockImport, SharedJustificationImport, Verifier, SharedFinalityProofImport, SharedFinalityProofRequestBuilder, }; -use consensus::{Error as ConsensusError, ErrorKind as ConsensusErrorKind}; +use consensus::{Error as ConsensusError}; use consensus::{BlockOrigin, ForkChoiceStrategy, ImportBlock, JustificationImport}; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient, TopicNotification}; use futures::{prelude::*, sync::{mpsc, oneshot}}; @@ -1228,7 +1228,7 @@ impl JustificationImport for ForceFinalized { justification: Justification, ) -> Result<(), Self::Error> { self.0.finalize_block(BlockId::Hash(hash), Some(justification), true) - .map_err(|_| ConsensusErrorKind::InvalidJustification.into()) + .map_err(|_| ConsensusError::InvalidJustification.into()) } } diff --git a/core/rpc/Cargo.toml b/core/rpc/Cargo.toml index d0ead8224e..d69d7e17be 100644 --- a/core/rpc/Cargo.toml +++ b/core/rpc/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -error-chain = "0.12" +derive_more = "0.14.0" jsonrpc-core = "10.0.1" jsonrpc-pubsub = "10.0.1" jsonrpc-derive = "10.0.2" diff --git a/core/rpc/src/author/error.rs b/core/rpc/src/author/error.rs index 0084c4da8f..5955108249 100644 --- a/core/rpc/src/author/error.rs +++ b/core/rpc/src/author/error.rs @@ -16,35 +16,37 @@ //! Authoring RPC module errors. -use error_chain::*; use client; use transaction_pool::txpool; use crate::rpc; use crate::errors; -error_chain! { - foreign_links { - Client(client::error::Error) #[doc = "Client error"]; - } - links { - Pool(txpool::error::Error, txpool::error::ErrorKind) #[doc = "Pool error"]; - } - errors { - /// Not implemented yet - Unimplemented { - description("not yet implemented"), - display("Method Not Implemented"), - } - /// Incorrect extrinsic format. - BadFormat { - description("bad format"), - display("Invalid extrinsic format"), - } - /// Verification error - Verification(e: Box<::std::error::Error + Send>) { - description("extrinsic verification error"), - display("Extrinsic verification error: {}", e.description()), +/// Author RPC Result type. +pub type Result = std::result::Result; + +/// Author RPC errors. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Client error. + Client(client::error::Error), + /// Transaction pool error, + Pool(txpool::error::Error), + /// Verification error + #[display(fmt="Extrinsic verification error: {}", "_0.description()")] + Verification(Box<::std::error::Error + Send>), + /// Incorrect extrinsic format. + #[display(fmt="Invalid extrinsic format")] + BadFormat, +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Client(ref err) => Some(err), + Error::Pool(ref err) => Some(err), + Error::Verification(ref err) => Some(&**err), + _ => None, } } } @@ -73,49 +75,50 @@ const POOL_IMMEDIATELY_DROPPED: i64 = POOL_INVALID_TX + 6; impl From for rpc::Error { fn from(e: Error) -> Self { + use txpool::error::{Error as PoolError}; + match e { - Error(ErrorKind::Unimplemented, _) => errors::unimplemented(), - Error(ErrorKind::BadFormat, _) => rpc::Error { + Error::BadFormat => rpc::Error { code: rpc::ErrorCode::ServerError(BAD_FORMAT), message: "Extrinsic has invalid format.".into(), data: None, }, - Error(ErrorKind::Verification(e), _) => rpc::Error { + Error::Verification(e) => rpc::Error { code: rpc::ErrorCode::ServerError(VERIFICATION_ERROR), message: e.description().into(), data: Some(format!("{:?}", e).into()), }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::InvalidTransaction(code)), _) => rpc::Error { + Error::Pool(PoolError::InvalidTransaction(code)) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_INVALID_TX), message: "Invalid Transaction".into(), data: Some(code.into()), }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::UnknownTransactionValidity(code)), _) => rpc::Error { + Error::Pool(PoolError::UnknownTransactionValidity(code)) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_UNKNOWN_VALIDITY), message: "Unknown Transaction Validity".into(), data: Some(code.into()), }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::TemporarilyBanned), _) => rpc::Error { + Error::Pool(PoolError::TemporarilyBanned) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_TEMPORARILY_BANNED), message: "Transaction is temporarily banned".into(), data: None, }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::AlreadyImported(hash)), _) => rpc::Error { + Error::Pool(PoolError::AlreadyImported(hash)) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_ALREADY_IMPORTED), message: "Transaction Already Imported".into(), data: Some(format!("{:?}", hash).into()), }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::TooLowPriority(old, new)), _) => rpc::Error { + Error::Pool(PoolError::TooLowPriority { old, new }) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_TOO_LOW_PRIORITY), message: format!("Priority is too low: ({} vs {})", old, new), data: Some("The transaction has too low priority to replace another transaction already in the pool.".into()), }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::CycleDetected), _) => rpc::Error { + Error::Pool(PoolError::CycleDetected) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_CYCLE_DETECTED), message: "Cycle Detected".into(), data: None, }, - Error(ErrorKind::Pool(txpool::error::ErrorKind::ImmediatelyDropped), _) => rpc::Error { + Error::Pool(PoolError::ImmediatelyDropped) => rpc::Error { code: rpc::ErrorCode::ServerError(POOL_IMMEDIATELY_DROPPED), message: "Immediately Dropped" .into(), data: Some("The transaction couldn't enter the pool because of the limit".into()), diff --git a/core/rpc/src/author/mod.rs b/core/rpc/src/author/mod.rs index acd500ba0b..ae160f1d1a 100644 --- a/core/rpc/src/author/mod.rs +++ b/core/rpc/src/author/mod.rs @@ -104,13 +104,13 @@ impl AuthorApi, BlockHash

> for Author whe type Metadata = crate::metadata::Metadata; fn submit_extrinsic(&self, ext: Bytes) -> Result> { - let xt = Decode::decode(&mut &ext[..]).ok_or(error::Error::from(error::ErrorKind::BadFormat))?; + let xt = Decode::decode(&mut &ext[..]).ok_or(error::Error::BadFormat)?; let best_block_hash = self.client.info()?.chain.best_hash; self.pool .submit_one(&generic::BlockId::hash(best_block_hash), xt) .map_err(|e| e.into_pool_error() .map(Into::into) - .unwrap_or_else(|e| error::ErrorKind::Verification(Box::new(e)).into()) + .unwrap_or_else(|e| error::Error::Verification(Box::new(e)).into()) ) } @@ -121,12 +121,13 @@ impl AuthorApi, BlockHash

> for Author whe fn watch_extrinsic(&self, _metadata: Self::Metadata, subscriber: Subscriber, BlockHash

>>, xt: Bytes) { let submit = || -> Result<_> { let best_block_hash = self.client.info()?.chain.best_hash; - let dxt = <

::Block as traits::Block>::Extrinsic::decode(&mut &xt[..]).ok_or(error::Error::from(error::ErrorKind::BadFormat))?; + let dxt = <

::Block as traits::Block>::Extrinsic::decode(&mut &xt[..]) + .ok_or(error::Error::BadFormat)?; self.pool .submit_and_watch(&generic::BlockId::hash(best_block_hash), dxt) .map_err(|e| e.into_pool_error() .map(Into::into) - .unwrap_or_else(|e| error::ErrorKind::Verification(Box::new(e)).into()) + .unwrap_or_else(|e| error::Error::Verification(Box::new(e)).into()) ) }; diff --git a/core/rpc/src/chain/error.rs b/core/rpc/src/chain/error.rs index 723a21d773..ffd94f4649 100644 --- a/core/rpc/src/chain/error.rs +++ b/core/rpc/src/chain/error.rs @@ -14,33 +14,42 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use error_chain::*; use client; use crate::rpc; use crate::errors; -pub use internal_errors::*; - -#[allow(deprecated)] -mod internal_errors { - use super::*; - error_chain! { - foreign_links { - Client(client::error::Error) #[doc = "Client error"]; - } - errors { - /// Not implemented yet - Unimplemented { - description("not yet implemented"), - display("Method Not Implemented"), - } + +/// Chain RPC Result type. +pub type Result = std::result::Result; + +/// Chain RPC errors. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Client error. + Client(client::error::Error), + /// Other error type. + Other(String), +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Client(ref err) => Some(err), + _ => None, } } } +/// Base error code for all chain errors. +const BASE_ERROR: i64 = 3000; + impl From for rpc::Error { fn from(e: Error) -> Self { match e { - Error(ErrorKind::Unimplemented, _) => errors::unimplemented(), + Error::Other(message) => rpc::Error { + code: rpc::ErrorCode::ServerError(BASE_ERROR + 1), + message, + data: None, + }, e => errors::internal(e), } } diff --git a/core/rpc/src/chain/mod.rs b/core/rpc/src/chain/mod.rs index ab930d0076..9dd7ad84b8 100644 --- a/core/rpc/src/chain/mod.rs +++ b/core/rpc/src/chain/mod.rs @@ -145,7 +145,7 @@ impl Chain where let header = best_block_hash() .and_then(|hash| self.header(hash.into())) .and_then(|header| { - header.ok_or_else(|| self::error::ErrorKind::Unimplemented.into()) + header.ok_or_else(|| "Best header missing.".to_owned().into()) }) .map_err(Into::into); diff --git a/core/rpc/src/errors.rs b/core/rpc/src/errors.rs index a709013ad2..da910de762 100644 --- a/core/rpc/src/errors.rs +++ b/core/rpc/src/errors.rs @@ -17,14 +17,6 @@ use crate::rpc; use log::warn; -pub fn unimplemented() -> rpc::Error { - rpc::Error { - code: rpc::ErrorCode::ServerError(1), - message: "Not implemented yet".into(), - data: None, - } -} - pub fn internal(e: E) -> rpc::Error { warn!("Unknown error: {:?}", e); rpc::Error { diff --git a/core/rpc/src/state/error.rs b/core/rpc/src/state/error.rs index d4b3013abb..30b3315b7b 100644 --- a/core/rpc/src/state/error.rs +++ b/core/rpc/src/state/error.rs @@ -14,34 +14,47 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use error_chain::*; use client; use crate::rpc; use crate::errors; -error_chain! { - foreign_links { - Client(client::error::Error) #[doc = "Client error"]; - } +/// State RPC Result type. +pub type Result = std::result::Result; - errors { - /// Provided block range couldn't be resolved to a list of blocks. - InvalidBlockRange(from: String, to: String, details: String) { - description("Invalid block range"), - display("Cannot resolve a block range ['{:?}' ... '{:?}]. {}", from, to, details), - } - /// Not implemented yet - Unimplemented { - description("not implemented yet"), - display("Method Not Implemented"), +/// State RPC errors. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Client error. + Client(client::error::Error), + /// Provided block range couldn't be resolved to a list of blocks. + #[display(fmt = "Cannot resolve a block range ['{:?}' ... '{:?}]. {}", from, to, details)] + InvalidBlockRange { + from: String, + to: String, + details: String, + }, +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Client(ref err) => Some(err), + _ => None, } } } +/// Base code for all state errors. +const BASE_ERROR: i64 = 4000; + impl From for rpc::Error { fn from(e: Error) -> Self { match e { - Error(ErrorKind::Unimplemented, _) => errors::unimplemented(), + Error::InvalidBlockRange { .. } => rpc::Error { + code: rpc::ErrorCode::ServerError(BASE_ERROR + 1), + message: format!("{}", e), + data: None, + }, e => errors::internal(e), } } diff --git a/core/rpc/src/state/mod.rs b/core/rpc/src/state/mod.rs index 0f87faa7a7..98d62d678d 100644 --- a/core/rpc/src/state/mod.rs +++ b/core/rpc/src/state/mod.rs @@ -22,7 +22,6 @@ use std::{ sync::Arc, }; -use error_chain::bail; use log::{warn, trace}; use client::{self, Client, CallExecutor, BlockchainEvents, runtime_api::Metadata}; use jsonrpc_derive::rpc; @@ -148,11 +147,15 @@ pub trait StateApi { /// New storage subscription #[pubsub(subscription = "state_storage", subscribe, name = "state_subscribeStorage")] - fn subscribe_storage(&self, metadata: Self::Metadata, subscriber: Subscriber>, keys: Option>); + fn subscribe_storage( + &self, metadata: Self::Metadata, subscriber: Subscriber>, keys: Option> + ); /// Unsubscribe from storage subscription #[pubsub(subscription = "state_storage", unsubscribe, name = "state_unsubscribeStorage")] - fn unsubscribe_storage(&self, metadata: Option, id: SubscriptionId) -> RpcResult; + fn unsubscribe_storage( + &self, metadata: Option, id: SubscriptionId + ) -> RpcResult; } /// State API with subscriptions support. @@ -213,7 +216,7 @@ impl State where blocks.push(hdr.hash()); last = hdr; } else { - bail!(invalid_block_range( + return Err(invalid_block_range( Some(from), Some(to), format!("Parent of {} ({}) not found", last.number(), last.hash()), @@ -221,7 +224,7 @@ impl State where } } if last.hash() != from.hash() { - bail!(invalid_block_range( + return Err(invalid_block_range( Some(from), Some(to), format!("Expected to reach `from`, got {} ({})", last.number(), last.hash()), @@ -241,7 +244,7 @@ impl State where filtered_range, }) }, - (from, to) => bail!( + (from, to) => Err( invalid_block_range(from.as_ref(), to.as_ref(), "Invalid range or unknown block".into()) ), } @@ -483,7 +486,9 @@ impl StateApi for State where } fn subscribe_runtime_version(&self, _meta: Self::Metadata, subscriber: Subscriber) { - let stream = match self.client.storage_changes_notification_stream(Some(&[StorageKey(storage::well_known_keys::CODE.to_vec())])) { + let stream = match self.client.storage_changes_notification_stream( + Some(&[StorageKey(storage::well_known_keys::CODE.to_vec())]) + ) { Ok(stream) => stream, Err(err) => { let _ = subscriber.reject(error::Error::from(err).into()); @@ -551,11 +556,15 @@ pub(crate) fn split_range(size: usize, middle: Option) -> (Range, (range1, range2) } -fn invalid_block_range(from: Option<&H>, to: Option<&H>, reason: String) -> error::ErrorKind { +fn invalid_block_range(from: Option<&H>, to: Option<&H>, reason: String) -> error::Error { let to_string = |x: Option<&H>| match x { None => "unknown hash".into(), Some(h) => format!("{} ({})", h.number(), h.hash()), }; - error::ErrorKind::InvalidBlockRange(to_string(from), to_string(to), reason) + error::Error::InvalidBlockRange { + from: to_string(from), + to: to_string(to), + details: reason, + } } diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 73a52fbc62..0ad983fc11 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use super::*; -use self::error::{Error, ErrorKind}; +use self::error::Error; use assert_matches::assert_matches; use consensus::BlockOrigin; @@ -80,7 +80,7 @@ fn should_call_contract() { assert_matches!( client.call("balanceOf".into(), Bytes(vec![1,2,3]), Some(genesis_hash).into()), - Err(Error(ErrorKind::Client(client::error::Error::Execution(_)), _)) + Err(Error::Client(client::error::Error::Execution(_))) ) } diff --git a/core/rpc/src/system/error.rs b/core/rpc/src/system/error.rs index d3c7e8b333..bdd4cbe667 100644 --- a/core/rpc/src/system/error.rs +++ b/core/rpc/src/system/error.rs @@ -16,40 +16,33 @@ //! System RPC module errors. -use error_chain::*; - use crate::rpc; -use crate::errors; use crate::system::helpers::Health; -error_chain! { - errors { - /// Node is not fully functional - NotHealthy(h: Health) { - description("node is not healthy"), - display("Node is not fully functional: {}", h) - } +/// System RPC Result type. +pub type Result = std::result::Result; - /// Not implemented yet - Unimplemented { - description("not yet implemented"), - display("Method Not Implemented"), - } - } +/// System RPC errors. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Provided block range couldn't be resolved to a list of blocks. + #[display(fmt = "Node is not fully functional: {}", _0)] + NotHealthy(Health), } -const ERROR: i64 = 2000; +impl std::error::Error for Error {} + +/// Base code for all system errors. +const BASE_ERROR: i64 = 2000; impl From for rpc::Error { fn from(e: Error) -> Self { match e { - Error(ErrorKind::Unimplemented, _) => errors::unimplemented(), - Error(ErrorKind::NotHealthy(h), _) => rpc::Error { - code: rpc::ErrorCode::ServerError(ERROR + 1), - message: "node is not healthy".into(), - data:serde_json::to_value(h).ok(), + Error::NotHealthy(ref h) => rpc::Error { + code: rpc::ErrorCode::ServerError(BASE_ERROR + 1), + message: format!("{}", e), + data: serde_json::to_value(h).ok(), }, - e => errors::internal(e), } } } diff --git a/core/service/Cargo.toml b/core/service/Cargo.toml index 89708683d0..e27c2d61b3 100644 --- a/core/service/Cargo.toml +++ b/core/service/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +derive_more = "0.14.0" futures = "0.1.17" parking_lot = "0.7.1" -error-chain = "0.12" lazy_static = "1.0" log = "0.4" slog = {version = "^2", features = ["nested-values"]} diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 2536d7c8f2..6e6503fc3d 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -522,7 +522,7 @@ impl Components for FullComponents { select_chain: Option, ) -> Result { let select_chain = select_chain - .ok_or_else(|| error::Error::from(error::ErrorKind::SelectChainRequired))?; + .ok_or(error::Error::SelectChainRequired)?; Factory::build_full_import_queue(config, client, select_chain) } diff --git a/core/service/src/error.rs b/core/service/src/error.rs index c5bcd61a3c..85a6892b26 100644 --- a/core/service/src/error.rs +++ b/core/service/src/error.rs @@ -16,32 +16,49 @@ //! Errors that can occur during the service operation. -// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting` -// https://github.com/paritytech/substrate/issues/1547 -#![allow(deprecated)] - use client; use network; use keystore; use consensus_common; -use error_chain::*; -error_chain! { - foreign_links { - Client(client::error::Error) #[doc="Client error"]; - Io(::std::io::Error) #[doc="IO error"]; - } +/// Service Result typedef. +pub type Result = std::result::Result; - links { - Consensus(consensus_common::Error, consensus_common::ErrorKind) #[doc="Consensus error"]; - Network(network::error::Error, network::error::ErrorKind) #[doc="Network error"]; - Keystore(keystore::Error, keystore::ErrorKind) #[doc="Keystore error"]; +/// Service errors. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Client error. + Client(client::error::Error), + /// IO error. + Io(std::io::Error), + /// Consensus error. + Consensus(consensus_common::Error), + /// Network error. + Network(network::error::Error), + /// Keystore error. + Keystore(keystore::Error), + /// Best chain selection strategy is missing. + #[display(fmt="Best chain selection strategy (SelectChain) is not provided.")] + SelectChainRequired, + /// Other error. + Other(String), +} + +impl<'a> From<&'a str> for Error { + fn from(s: &'a str) -> Self { + Error::Other(s.into()) } +} - errors { - SelectChainRequired { - description("Best chain selection strategy (SelectChain) must be provided when starting full node or authority."), - display("Best chain selection strategy (SelectChain) is not provided."), +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Client(ref err) => Some(err), + Error::Io(ref err) => Some(err), + Error::Consensus(ref err) => Some(err), + Error::Network(ref err) => Some(err), + Error::Keystore(ref err) => Some(err), + _ => None, } } } diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 81e153b7ae..2a69dc83c7 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -44,7 +44,7 @@ use runtime_primitives::traits::{Header, SaturatedConversion}; use substrate_executor::NativeExecutor; use tel::{telemetry, SUBSTRATE_INFO}; -pub use self::error::{ErrorKind, Error}; +pub use self::error::Error; pub use config::{Configuration, Roles, PruningMode}; pub use chain_spec::{ChainSpec, Properties}; pub use transaction_pool::txpool::{ @@ -515,7 +515,7 @@ impl network::TransactionPool, ComponentBlock< match self.pool.submit_one(&best_block_id, uxt) { Ok(hash) => Some(hash), Err(e) => match e.into_pool_error() { - Ok(txpool::error::Error(txpool::error::ErrorKind::AlreadyImported(hash), _)) => { + Ok(txpool::error::Error::AlreadyImported(hash)) => { hash.downcast::>().ok() .map(|x| x.as_ref().clone()) }, diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index df89cba455..eaa9acbd45 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -119,11 +119,6 @@ dependencies = [ "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "base58" version = "0.1.0" @@ -482,11 +477,6 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dns-parser" version = "0.8.0" @@ -546,14 +536,6 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "error-chain" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -886,41 +868,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -931,6 +914,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -941,21 +925,20 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core-derive" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -964,20 +947,19 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-floodsub" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -985,7 +967,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -996,13 +978,13 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1010,14 +992,14 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-kad" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1027,7 +1009,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1037,20 +1019,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mdns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1058,20 +1040,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mplex" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1081,14 +1063,16 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1099,41 +1083,42 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-plaintext" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1141,7 +1126,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1152,7 +1137,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1170,14 +1155,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1185,23 +1170,36 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-wasm-ext" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-yamux" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1972,16 +1970,6 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "secp256k1" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "semver" version = "0.9.0" @@ -2304,50 +2292,6 @@ name = "static_slice" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stdweb" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stream-cipher" version = "0.3.0" @@ -2447,9 +2391,9 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -2464,7 +2408,6 @@ dependencies = [ name = "substrate-consensus-slots" version = "2.0.0" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2482,7 +2425,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3146,6 +3089,18 @@ dependencies = [ "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasm-timer" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasmi" version = "0.4.3" @@ -3295,7 +3250,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" @@ -3341,7 +3295,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" "checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" @@ -3349,7 +3302,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" "checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" -"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" @@ -3394,23 +3346,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" -"checksum libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0231edab431064b30b7749484a39735eb36492cef4658c372c9059e58c3003aa" -"checksum libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a3bad2ed26297112847678683dd221473a0d44297250b61f004e1b35e72493" -"checksum libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f765f103b680cbed910b02bfdbdcfce5b1142899c93e51acb960bf59b6f81b1" -"checksum libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b129d20cc8cbb6ce5da8361045649c024659173e246c5dfbf20ae06071c046a" -"checksum libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70d68816b8435d6788399416eb2f0a6974fb1d15c4be5c30141f87c8e81746df" -"checksum libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "718ca645a065fd70855ca6042a7df686c24cd21add750c37a82c811fbd1e5c43" -"checksum libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bbe27c623a6a720efd5d704347838972062f89149a9c3cd149748da60bdcd3e0" -"checksum libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9bc1a5d85f4812cae6367b49a432763fe28997bac7c530dc55b70ec18a78aa7" -"checksum libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe5a858342a1cc89464474f7edc4bae1da649b9c823a3e04d9fb494493601746" -"checksum libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc6b5185c50a52a12e7bbe2ee7799059e24de4e52ab25edbfd26c8ab8515d317" -"checksum libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7905c1431ad115bee83405770629a27d6f17153ad02ec9670a7347998ef20e22" -"checksum libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc17626763ded57da8fed73187c2d9f6ebb89d30838673c430315bf560c7e4db" -"checksum libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2409d08b809ab1a74269597f7da2829d117cc11b9ed3343af33fc20831619726" -"checksum libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258cdc6742945c8f6402997bbbf36733588e2db18e5a0014da6d46e3ccfb92cf" -"checksum libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b5691e2ba2720d42bd1e93d6b90239fa9235c1956ef6a5f1dd499a7ae2767be" -"checksum libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ab0b9ca050105fd94229c48911c0c84aef4d6b86a53d1b6df81d938354e47e" -"checksum libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6ff51a5b2056bacee1c9f2ed8455cdf3c5c619261ddb4efc783119130aaf52" +"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" +"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" +"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" +"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" +"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" +"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" +"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" +"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" +"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" +"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" +"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" +"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" +"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" +"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" +"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" +"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" @@ -3496,7 +3449,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum secp256k1 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4070f3906e65249228094cf97b04a90799fba04468190bbbcfa812309cf86e32" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3519,10 +3471,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" -"checksum stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a3edad410e603184d656e2abded5fd4d3d6e93d5763d21130dbaf99795db74eb" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1635afd059cbfac7d5b1274f0c44cec110c1e013c48e8bbc22e07e52696cf887" -"checksum stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2f4a2eb556337b2d1a302630bbddf989ae383c70393e89b48152b9896cbda" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" @@ -3579,6 +3527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" "checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" "checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" "checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d" "checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" "checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" diff --git a/core/transaction-pool/Cargo.toml b/core/transaction-pool/Cargo.toml index c3f9dce5fe..5b2c2350af 100644 --- a/core/transaction-pool/Cargo.toml +++ b/core/transaction-pool/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -error-chain = "0.12" +derive_more = "0.14.0" futures = "0.1" log = "0.4" parity-codec = "3.3" diff --git a/core/transaction-pool/graph/Cargo.toml b/core/transaction-pool/graph/Cargo.toml index 29accf0eb8..0ebc74b7da 100644 --- a/core/transaction-pool/graph/Cargo.toml +++ b/core/transaction-pool/graph/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -error-chain = "0.12" +derive_more = "0.14.0" futures = "0.1" log = "0.4" parking_lot = "0.7.1" diff --git a/core/transaction-pool/graph/src/base_pool.rs b/core/transaction-pool/graph/src/base_pool.rs index 2b4b96839d..74e499674a 100644 --- a/core/transaction-pool/graph/src/base_pool.rs +++ b/core/transaction-pool/graph/src/base_pool.rs @@ -25,7 +25,6 @@ use std::{ sync::Arc, }; -use error_chain::bail; use log::{trace, debug, warn}; use serde::Serialize; use substrate_primitives::hexdisplay::HexDisplay; @@ -184,7 +183,7 @@ impl BasePool, ) -> error::Result> { if self.future.contains(&tx.hash) || self.ready.contains(&tx.hash) { - bail!(error::ErrorKind::AlreadyImported(Box::new(tx.hash.clone()))) + return Err(error::Error::AlreadyImported(Box::new(tx.hash.clone()))) } let tx = WaitingTransaction::new( @@ -259,7 +258,7 @@ impl BasePool) { - description("Transaction is already in the pool"), - display("[{:?}] Already imported", hash), - } - /// The transaction cannot be imported cause it's a replacement and has too low priority. - TooLowPriority(old: Priority, new: Priority) { - description("The priority is too low to replace transactions already in the pool."), - display("Too low priority ({} > {})", old, new) - } - /// Deps cycle detected and we couldn't import transaction. - CycleDetected { - description("Transaction was not imported because of detected cycle."), - display("Cycle Detected"), - } - /// Transaction was dropped immediately after it got inserted. - ImmediatelyDropped { - description("Transaction couldn't enter the pool because of the limit."), - display("Immediately Dropped"), - } - } +/// Transaction pool result. +pub type Result = std::result::Result; + +/// Transaction pool error type. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Transaction is not verifiable yet, but might be in the future. + #[display(fmt="Unkown Transaction Validity. Error code: {}", _0)] + UnknownTransactionValidity(i8), + /// Transaction is invalid. + #[display(fmt="Invalid Transaction. Error Code: {}", _0)] + InvalidTransaction(i8), + /// The transaction is temporarily banned. + #[display(fmt="Temporarily Banned")] + TemporarilyBanned, + /// The transaction is already in the pool. + #[display(fmt="[{:?}] Already imported", _0)] + AlreadyImported(Box), + /// The transaction cannot be imported cause it's a replacement and has too low priority. + #[display(fmt="Too low priority ({} > {})", old, new)] + TooLowPriority { + /// Transaction already in the pool. + old: Priority, + /// Transaction entering the pool. + new: Priority + }, + /// Deps cycle etected and we couldn't import transaction. + #[display(fmt="Cycle Detected")] + CycleDetected, + /// Transaction was dropped immediately after it got inserted. + #[display(fmt="Transaction couldn't enter the pool because of the limit.")] + ImmediatelyDropped, + /// Invalid block id. + InvalidBlockId(String), } +impl std::error::Error for Error {} + /// Transaction pool error conversion. pub trait IntoPoolError: ::std::error::Error + Send + Sized { /// Try to extract original `Error` diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 78d06eabb5..a5b7a3d2aa 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -27,7 +27,6 @@ use crate::listener::Listener; use crate::rotator::PoolRotator; use crate::watcher::Watcher; use serde::Serialize; -use error_chain::bail; use log::debug; use futures::sync::mpsc; @@ -119,14 +118,14 @@ impl Pool { T: IntoIterator> { let block_number = self.api.block_id_to_number(at)? - .ok_or_else(|| error::ErrorKind::Msg(format!("Invalid block id: {:?}", at)).into())?; + .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())?; let results = xts .into_iter() .map(|xt| -> Result<_, B::Error> { let (hash, bytes) = self.api.hash_and_length(&xt); if self.rotator.is_banned(&hash) { - bail!(error::Error::from(error::ErrorKind::TemporarilyBanned)) + return Err(error::Error::TemporarilyBanned.into()) } match self.api.validate_transaction(at, xt.clone())? { @@ -144,11 +143,11 @@ impl Pool { }) }, TransactionValidity::Invalid(e) => { - bail!(error::Error::from(error::ErrorKind::InvalidTransaction(e))) + Err(error::Error::InvalidTransaction(e).into()) }, TransactionValidity::Unknown(e) => { self.listener.write().invalid(&hash); - bail!(error::Error::from(error::ErrorKind::UnknownTransactionValidity(e))) + Err(error::Error::UnknownTransactionValidity(e).into()) }, } }) @@ -168,7 +167,7 @@ impl Pool { let removed = self.enforce_limits(); Ok(results.into_iter().map(|res| match res { - Ok(ref hash) if removed.contains(hash) => Err(error::Error::from(error::ErrorKind::ImmediatelyDropped).into()), + Ok(ref hash) if removed.contains(hash) => Err(error::Error::ImmediatelyDropped.into()), other => other, }).collect()) } @@ -308,10 +307,7 @@ impl Pool { // Collect the hashes of transactions that now became invalid (meaning that they are succesfully pruned). let hashes = results.into_iter().enumerate().filter_map(|(idx, r)| match r.map_err(error::IntoPoolError::into_pool_error) { - Err(Ok(err)) => match err.kind() { - error::ErrorKind::InvalidTransaction(_) => Some(hashes[idx].clone()), - _ => None, - }, + Err(Ok(error::Error::InvalidTransaction(_))) => Some(hashes[idx].clone()), _ => None, }); // Fire `pruned` notifications for collected hashes and make sure to include @@ -319,7 +315,7 @@ impl Pool { let hashes = hashes.chain(known_imported_hashes.into_iter()); { let header_hash = self.api.block_id_to_hash(at)? - .ok_or_else(|| error::ErrorKind::Msg(format!("Invalid block id: {:?}", at)).into())?; + .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())?; let mut listener = self.listener.write(); for h in hashes { listener.pruned(header_hash, &h); @@ -338,7 +334,7 @@ impl Pool { /// See `prune_tags` if you want this. pub fn clear_stale(&self, at: &BlockId) -> Result<(), B::Error> { let block_number = self.api.block_id_to_number(at)? - .ok_or_else(|| error::ErrorKind::Msg(format!("Invalid block id: {:?}", at)).into())? + .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())? .saturated_into::(); let now = time::Instant::now(); let to_remove = { @@ -569,7 +565,7 @@ mod tests { assert_eq!(pool.status().future, 0); // then - assert_matches!(res.unwrap_err().kind(), error::ErrorKind::TemporarilyBanned); + assert_matches!(res.unwrap_err(), error::Error::TemporarilyBanned); } #[test] diff --git a/core/transaction-pool/graph/src/ready.rs b/core/transaction-pool/graph/src/ready.rs index befb1b60cc..ca3d7322cc 100644 --- a/core/transaction-pool/graph/src/ready.rs +++ b/core/transaction-pool/graph/src/ready.rs @@ -23,7 +23,6 @@ use std::{ use serde::Serialize; use log::debug; -use error_chain::bail; use parking_lot::RwLock; use sr_primitives::traits::Member; use sr_primitives::transaction_validity::{ @@ -376,7 +375,7 @@ impl ReadyTransactions { // bail - the transaction has too low priority to replace the old ones if old_priority >= tx.priority { - bail!(error::ErrorKind::TooLowPriority(old_priority, tx.priority)) + return Err(error::Error::TooLowPriority { old: old_priority, new: tx.priority }) } replace_hashes.into_iter().cloned().collect::>() diff --git a/core/transaction-pool/src/error.rs b/core/transaction-pool/src/error.rs index d4cc0acee8..f3641aa8ec 100644 --- a/core/transaction-pool/src/error.rs +++ b/core/transaction-pool/src/error.rs @@ -16,29 +16,34 @@ //! Transaction pool error. -// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting` -// https://github.com/paritytech/substrate/issues/1547 -#![allow(deprecated)] - use client; use txpool; -use error_chain::{ - error_chain, error_chain_processing, impl_error_chain_processed, impl_extract_backtrace, impl_error_chain_kind -}; -error_chain! { - foreign_links { - Client(client::error::Error) #[doc = "Client error"]; - } - links { - Pool(txpool::error::Error, txpool::error::ErrorKind) #[doc = "Pool error"]; +/// Transaction pool result. +pub type Result = std::result::Result; + +/// Transaction pool error type. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Client error. + Client(client::error::Error), + /// Pool error. + Pool(txpool::error::Error), +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Client(ref err) => Some(err), + Error::Pool(ref err) => Some(err), + } } } impl txpool::IntoPoolError for Error { - fn into_pool_error(self) -> ::std::result::Result { + fn into_pool_error(self) -> std::result::Result { match self { - Error(ErrorKind::Pool(e), c) => Ok(txpool::error::Error(e, c)), + Error::Pool(e) => Ok(e), e => Err(e), } } diff --git a/node-template/Cargo.toml b/node-template/Cargo.toml index d0427ec80d..69f9c884cd 100644 --- a/node-template/Cargo.toml +++ b/node-template/Cargo.toml @@ -10,7 +10,7 @@ name = "node-template" path = "src/main.rs" [dependencies] -error-chain = "0.12" +derive_more = "0.14.0" futures = "0.1" ctrlc = { version = "3.0", features = ["termination"] } log = "0.4" diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index e458c165c0..5f46b360e4 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -119,11 +119,6 @@ dependencies = [ "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "base58" version = "0.1.0" @@ -482,11 +477,6 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dns-parser" version = "0.8.0" @@ -546,14 +536,6 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "error-chain" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -886,41 +868,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -931,6 +914,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -941,21 +925,20 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core-derive" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -964,20 +947,19 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-floodsub" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -985,7 +967,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -996,13 +978,13 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1010,14 +992,14 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-kad" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1027,7 +1009,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1037,20 +1019,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mdns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1058,20 +1040,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mplex" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1081,14 +1063,16 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1099,41 +1083,42 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-plaintext" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1141,7 +1126,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1152,7 +1137,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1170,14 +1155,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1185,23 +1170,36 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-wasm-ext" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-yamux" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2006,16 +2004,6 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "secp256k1" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "semver" version = "0.9.0" @@ -2457,50 +2445,6 @@ name = "static_slice" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stdweb" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stream-cipher" version = "0.3.0" @@ -2590,9 +2534,9 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -2608,7 +2552,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3238,6 +3182,18 @@ dependencies = [ "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasm-timer" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasmi" version = "0.4.3" @@ -3387,7 +3343,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" @@ -3433,7 +3388,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" "checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" @@ -3441,7 +3395,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" "checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" -"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" @@ -3486,23 +3439,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" -"checksum libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0231edab431064b30b7749484a39735eb36492cef4658c372c9059e58c3003aa" -"checksum libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a3bad2ed26297112847678683dd221473a0d44297250b61f004e1b35e72493" -"checksum libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f765f103b680cbed910b02bfdbdcfce5b1142899c93e51acb960bf59b6f81b1" -"checksum libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b129d20cc8cbb6ce5da8361045649c024659173e246c5dfbf20ae06071c046a" -"checksum libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70d68816b8435d6788399416eb2f0a6974fb1d15c4be5c30141f87c8e81746df" -"checksum libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "718ca645a065fd70855ca6042a7df686c24cd21add750c37a82c811fbd1e5c43" -"checksum libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bbe27c623a6a720efd5d704347838972062f89149a9c3cd149748da60bdcd3e0" -"checksum libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9bc1a5d85f4812cae6367b49a432763fe28997bac7c530dc55b70ec18a78aa7" -"checksum libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe5a858342a1cc89464474f7edc4bae1da649b9c823a3e04d9fb494493601746" -"checksum libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc6b5185c50a52a12e7bbe2ee7799059e24de4e52ab25edbfd26c8ab8515d317" -"checksum libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7905c1431ad115bee83405770629a27d6f17153ad02ec9670a7347998ef20e22" -"checksum libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc17626763ded57da8fed73187c2d9f6ebb89d30838673c430315bf560c7e4db" -"checksum libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2409d08b809ab1a74269597f7da2829d117cc11b9ed3343af33fc20831619726" -"checksum libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258cdc6742945c8f6402997bbbf36733588e2db18e5a0014da6d46e3ccfb92cf" -"checksum libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b5691e2ba2720d42bd1e93d6b90239fa9235c1956ef6a5f1dd499a7ae2767be" -"checksum libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ab0b9ca050105fd94229c48911c0c84aef4d6b86a53d1b6df81d938354e47e" -"checksum libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6ff51a5b2056bacee1c9f2ed8455cdf3c5c619261ddb4efc783119130aaf52" +"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" +"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" +"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" +"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" +"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" +"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" +"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" +"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" +"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" +"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" +"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" +"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" +"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" +"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" +"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" +"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" @@ -3588,7 +3542,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum secp256k1 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4070f3906e65249228094cf97b04a90799fba04468190bbbcfa812309cf86e32" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3611,10 +3564,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" -"checksum stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a3edad410e603184d656e2abded5fd4d3d6e93d5763d21130dbaf99795db74eb" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1635afd059cbfac7d5b1274f0c44cec110c1e013c48e8bbc22e07e52696cf887" -"checksum stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2f4a2eb556337b2d1a302630bbddf989ae383c70393e89b48152b9896cbda" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" @@ -3671,6 +3620,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" "checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" "checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" "checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d" "checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" "checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" diff --git a/node-template/src/error.rs b/node-template/src/error.rs deleted file mode 100644 index a8aa94bf32..0000000000 --- a/node-template/src/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! Initialization errors. - -use client; - -error_chain! { - foreign_links { - Io(::std::io::Error) #[doc="IO error"]; - Cli(::clap::Error) #[doc="CLI error"]; - } - links { - Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"]; - } -} diff --git a/node-template/src/main.rs b/node-template/src/main.rs index 53845ddd08..5418453a02 100644 --- a/node-template/src/main.rs +++ b/node-template/src/main.rs @@ -9,7 +9,7 @@ mod cli; pub use substrate_cli::{VersionInfo, IntoExit, error}; -fn run() -> cli::error::Result<()> { +fn main() { let version = VersionInfo { name: "Substrate Node", commit: env!("VERGEN_SHA_SHORT"), @@ -19,7 +19,9 @@ fn run() -> cli::error::Result<()> { description: "Template Node", support_url: "support.anonymous.an", }; - cli::run(::std::env::args(), cli::Exit, version) -} -error_chain::quick_main!(run); + if let Err(e) = cli::run(::std::env::args(), cli::Exit, version) { + eprintln!("Error starting the node: {}\n\n{:?}", e, e); + std::process::exit(1) + } +} diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 7a6a3f0c27..3725833e3d 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -10,7 +10,7 @@ use substrate_service::{ FactoryFullConfiguration, LightComponents, FullComponents, FullBackend, FullClient, LightClient, LightBackend, FullExecutor, LightExecutor, TaskExecutor, - error::{Error as ServiceError, ErrorKind as ServiceErrorKind}, + error::{Error as ServiceError}, }; use basic_authorship::ProposerFactory; use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, NothingExtra}; @@ -46,10 +46,18 @@ construct_service_factory! { RuntimeApi = RuntimeApi, NetworkProtocol = NodeProtocol { |config| Ok(NodeProtocol::new()) }, RuntimeDispatch = Executor, - FullTransactionPoolApi = transaction_pool::ChainApi, FullExecutor, Block, RuntimeApi>, Block> - { |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) }, - LightTransactionPoolApi = transaction_pool::ChainApi, LightExecutor, Block, RuntimeApi>, Block> - { |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) }, + FullTransactionPoolApi = transaction_pool::ChainApi< + client::Client, FullExecutor, Block, RuntimeApi>, + Block + > { + |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) + }, + LightTransactionPoolApi = transaction_pool::ChainApi< + client::Client, LightExecutor, Block, RuntimeApi>, + Block + > { + |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) + }, Genesis = GenesisConfig, Configuration = NodeConfig, FullService = FullComponents @@ -67,7 +75,7 @@ construct_service_factory! { }); let client = service.client(); let select_chain = service.select_chain() - .ok_or_else(|| ServiceError::from(ServiceErrorKind::SelectChainRequired))?; + .ok_or_else(|| ServiceError::SelectChainRequired)?; executor.spawn(start_aura( SlotDuration::get_or_compute(&*client)?, key.clone(), diff --git a/node/cli/src/error.rs b/node/cli/src/error.rs deleted file mode 100644 index dd5448ac8a..0000000000 --- a/node/cli/src/error.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2018-2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Initialization errors. - -use client; -use error_chain::{ - error_chain, error_chain_processing, impl_error_chain_processed -}; - -error_chain! { - foreign_links { - Io(::std::io::Error) #[doc="IO error"]; - Cli(::clap::Error) #[doc="CLI error"]; - } - links { - Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"]; - } -} diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 90041b4cbb..a4ac1b0660 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -31,7 +31,7 @@ use node_runtime::{GenesisConfig, RuntimeApi}; use substrate_service::{ FactoryFullConfiguration, LightComponents, FullComponents, FullBackend, FullClient, LightClient, LightBackend, FullExecutor, LightExecutor, TaskExecutor, - error::{Error as ServiceError, ErrorKind as ServiceErrorKind}, + error::{Error as ServiceError}, }; use transaction_pool::{self, txpool::{Pool as TransactionPool}}; use inherents::InherentDataProviders; @@ -92,7 +92,7 @@ construct_service_factory! { let client = service.client(); let select_chain = service.select_chain() - .ok_or_else(|| ServiceError::from(ServiceErrorKind::SelectChainRequired))?; + .ok_or(ServiceError::SelectChainRequired)?; executor.spawn(start_aura( SlotDuration::get_or_compute(&*client)?, key.clone(), diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index 50037f709e..846857caa2 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -119,11 +119,6 @@ dependencies = [ "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "base58" version = "0.1.0" @@ -482,11 +477,6 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dns-parser" version = "0.8.0" @@ -546,14 +536,6 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "error-chain" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -886,41 +868,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -931,6 +914,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -941,21 +925,20 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core-derive" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -964,20 +947,19 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-floodsub" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -985,7 +967,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -996,13 +978,13 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1010,14 +992,14 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-kad" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1027,7 +1009,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1037,20 +1019,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mdns" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1058,20 +1040,20 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-mplex" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1081,14 +1063,16 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1099,41 +1083,42 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-plaintext" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1141,7 +1126,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1152,7 +1137,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1170,14 +1155,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1185,23 +1170,36 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-wasm-ext" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-yamux" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2038,16 +2036,6 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "secp256k1" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "semver" version = "0.9.0" @@ -2592,50 +2580,6 @@ name = "static_slice" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stdweb" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stream-cipher" version = "0.3.0" @@ -2725,9 +2669,9 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -2743,7 +2687,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3384,6 +3328,18 @@ dependencies = [ "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasm-timer" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasmi" version = "0.4.3" @@ -3542,7 +3498,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" @@ -3588,7 +3543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" "checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" @@ -3596,7 +3550,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" "checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" -"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" @@ -3641,23 +3594,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" -"checksum libp2p 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0231edab431064b30b7749484a39735eb36492cef4658c372c9059e58c3003aa" -"checksum libp2p-core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a3bad2ed26297112847678683dd221473a0d44297250b61f004e1b35e72493" -"checksum libp2p-core-derive 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f765f103b680cbed910b02bfdbdcfce5b1142899c93e51acb960bf59b6f81b1" -"checksum libp2p-dns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b129d20cc8cbb6ce5da8361045649c024659173e246c5dfbf20ae06071c046a" -"checksum libp2p-floodsub 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70d68816b8435d6788399416eb2f0a6974fb1d15c4be5c30141f87c8e81746df" -"checksum libp2p-identify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "718ca645a065fd70855ca6042a7df686c24cd21add750c37a82c811fbd1e5c43" -"checksum libp2p-kad 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bbe27c623a6a720efd5d704347838972062f89149a9c3cd149748da60bdcd3e0" -"checksum libp2p-mdns 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9bc1a5d85f4812cae6367b49a432763fe28997bac7c530dc55b70ec18a78aa7" -"checksum libp2p-mplex 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe5a858342a1cc89464474f7edc4bae1da649b9c823a3e04d9fb494493601746" -"checksum libp2p-noise 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc6b5185c50a52a12e7bbe2ee7799059e24de4e52ab25edbfd26c8ab8515d317" -"checksum libp2p-ping 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7905c1431ad115bee83405770629a27d6f17153ad02ec9670a7347998ef20e22" -"checksum libp2p-plaintext 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc17626763ded57da8fed73187c2d9f6ebb89d30838673c430315bf560c7e4db" -"checksum libp2p-ratelimit 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2409d08b809ab1a74269597f7da2829d117cc11b9ed3343af33fc20831619726" -"checksum libp2p-secio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258cdc6742945c8f6402997bbbf36733588e2db18e5a0014da6d46e3ccfb92cf" -"checksum libp2p-tcp 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b5691e2ba2720d42bd1e93d6b90239fa9235c1956ef6a5f1dd499a7ae2767be" -"checksum libp2p-uds 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ab0b9ca050105fd94229c48911c0c84aef4d6b86a53d1b6df81d938354e47e" -"checksum libp2p-yamux 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6ff51a5b2056bacee1c9f2ed8455cdf3c5c619261ddb4efc783119130aaf52" +"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" +"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" +"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" +"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" +"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" +"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" +"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" +"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" +"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" +"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" +"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" +"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" +"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" +"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" +"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" +"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" @@ -3744,7 +3698,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum secp256k1 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4070f3906e65249228094cf97b04a90799fba04468190bbbcfa812309cf86e32" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3767,10 +3720,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" -"checksum stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a3edad410e603184d656e2abded5fd4d3d6e93d5763d21130dbaf99795db74eb" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1635afd059cbfac7d5b1274f0c44cec110c1e013c48e8bbc22e07e52696cf887" -"checksum stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2f4a2eb556337b2d1a302630bbddf989ae383c70393e89b48152b9896cbda" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" @@ -3827,6 +3776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" "checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" "checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" "checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" "checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" diff --git a/node/src/main.rs b/node/src/main.rs index 5ff0d7ff3b..15b603e7a2 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -43,9 +43,7 @@ impl cli::IntoExit for Exit { } } -error_chain::quick_main!(run); - -fn run() -> cli::error::Result<()> { +fn main() { let version = VersionInfo { name: "Substrate Node", commit: env!("VERGEN_SHA_SHORT"), @@ -55,5 +53,9 @@ fn run() -> cli::error::Result<()> { description: "Generic substrate node", support_url: "https://github.com/paritytech/substrate/issues/new", }; - cli::run(::std::env::args(), Exit, version) + + if let Err(e) = cli::run(::std::env::args(), Exit, version) { + eprintln!("Error starting the node: {}\n\n{:?}", e, e); + std::process::exit(1) + } } diff --git a/scripts/gitlab/check_line_width.sh b/scripts/gitlab/check_line_width.sh index ad78b24e11..f382d630b1 100755 --- a/scripts/gitlab/check_line_width.sh +++ b/scripts/gitlab/check_line_width.sh @@ -11,7 +11,10 @@ GOOD_LINE_WIDTH="101" git diff --name-only ${BASE_BRANCH}...${CI_COMMIT_SHA} \*.rs | ( while read file do - if git diff ${BASE_BRANCH}...${CI_COMMIT_SHA} ${file} | grep -q "^+.\{${LINE_WIDTH}\}" + if [ ! -f ${file} ]; + then + echo "Skipping removed file." + elif git diff ${BASE_BRANCH}...${CI_COMMIT_SHA} ${file} | grep -q "^+.\{${LINE_WIDTH}\}" then if [ -z "${FAIL}" ] then -- GitLab From 6bf7a175771863606561438c8fac2e624e3ececb Mon Sep 17 00:00:00 2001 From: TriplEight Date: Fri, 24 May 2019 12:24:37 +0200 Subject: [PATCH 028/113] rust versions (#2681) --- .gitlab-ci.yml | 59 +++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index abab05f74e..0ee23e7253 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,6 +38,12 @@ variables: environment: name: parity-build +.compiler_info: &compiler_info + before_script: + - rustup show + - cargo --version + - sccache -s + #### stage: test @@ -67,6 +73,7 @@ check-line-width: test-linux-stable: &test stage: test + <<: *compiler_info variables: RUST_TOOLCHAIN: stable # Enable debug assertions since we are running optimized builds for testing @@ -84,15 +91,14 @@ test-linux-stable: &test except: variables: - $DEPLOY_TAG - before_script: - - sccache -s - - ./scripts/build.sh script: + - ./scripts/build.sh - time cargo test --all --release --verbose --locked - sccache -s check-web-wasm: stage: test + <<: *compiler_info allow_failure: true only: - master @@ -115,6 +121,7 @@ check-web-wasm: - time cargo web build -p substrate-state-db - time cargo web build -p substrate-state-machine - time cargo web build -p substrate-trie + - sccache -s tags: - linux-docker @@ -126,19 +133,18 @@ check-web-wasm: #### stage: build -build-linux-release: &build +build-linux-release: stage: build <<: *collect-artifacts <<: *build-only + <<: *compiler_info except: variables: - $DEPLOY_TAG tags: - linux-docker - before_script: - - sccache -s - - ./scripts/build.sh script: + - ./scripts/build.sh - time cargo build --release --verbose - mkdir -p ./artifacts - mv ./target/release/substrate ./artifacts/. @@ -156,8 +162,9 @@ build-linux-release: &build - cp -r scripts/docker/* ./artifacts - sccache -s -build-rust-doc-release: &build +build-rust-doc-release: stage: build + <<: *compiler_info allow_failure: true artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc" @@ -168,10 +175,8 @@ build-rust-doc-release: &build <<: *build-only tags: - linux-docker - before_script: - - sccache -s - - ./scripts/build.sh script: + - ./scripts/build.sh - rm -f ./crate-docs/index.html # use it as an indicator if the job succeeds - time cargo +nightly doc --release --verbose - cp -R ./target/doc ./crate-docs @@ -317,46 +322,46 @@ publish-s3-doc: deploy-ew3: <<: *deploy-cibuild environment: - name: parity-prod-ew3 + name: parity-prod-ew3 deploy-ue1: <<: *deploy-cibuild environment: - name: parity-prod-ue1 + name: parity-prod-ue1 deploy-ew3-tag: <<: *deploy-tag environment: - name: parity-prod-ew3 + name: parity-prod-ew3 deploy-ue1-tag: <<: *deploy-tag environment: name: parity-prod-ue1 -.validator-deploy: &validator-deploy - stage: flaming-fir +.validator-deploy: &validator-deploy + stage: flaming-fir dependencies: - build-linux-release - image: parity/azure-ansible:v1 - allow_failure: true - when: manual + image: parity/azure-ansible:v1 + allow_failure: true + when: manual tags: - linux-docker -validator1: - <<: *validator-deploy +validator 1 4: + <<: *validator-deploy script: - ./scripts/flamingfir-deploy.sh flamingfir-validator1 -validator2: - <<: *validator-deploy +validator 2 4: + <<: *validator-deploy script: - ./scripts/flamingfir-deploy.sh flamingfir-validator2 -validator3: - <<: *validator-deploy +validator 3 4: + <<: *validator-deploy script: - ./scripts/flamingfir-deploy.sh flamingfir-validator3 -validator4: - <<: *validator-deploy +validator 4 4: + <<: *validator-deploy script: - ./scripts/flamingfir-deploy.sh flamingfir-validator4 -- GitLab From 79dd9c83027495107509b700057d04577a2ea242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 24 May 2019 15:21:19 +0200 Subject: [PATCH 029/113] Lower the required code threshold. (#2685) --- core/rpc/src/state/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 0ad983fc11..4cd4e7bfd4 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -34,7 +34,7 @@ fn should_return_storage() { assert!( client.storage(key.clone(), Some(genesis_hash).into()) .map(|x| x.map(|x| x.0.len())).unwrap().unwrap() - > 195_000 + > 10_000 ); assert_matches!( client.storage_hash(key.clone(), Some(genesis_hash).into()).map(|x| x.is_some()), @@ -42,7 +42,7 @@ fn should_return_storage() { ); assert!( client.storage_size(key.clone(), None).unwrap().unwrap() - > 195_000 + > 10_000 ); } -- GitLab From 0e911351f20e03253fe5bf5f0de4aaee435a111f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 25 May 2019 21:02:50 +0200 Subject: [PATCH 030/113] Check for exact wasm blob size in RPC tests (#2687) --- core/rpc/src/state/tests.rs | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 4cd4e7bfd4..14b6506f29 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -21,34 +21,35 @@ use assert_matches::assert_matches; use consensus::BlockOrigin; use primitives::storage::well_known_keys; use sr_io::blake2_256; -use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt}; +use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt, LocalExecutor}; +use substrate_executor::NativeExecutionDispatch; #[test] fn should_return_storage() { - let core = ::tokio::runtime::Runtime::new().unwrap(); + let core = tokio::runtime::Runtime::new().unwrap(); let client = Arc::new(test_client::new()); let genesis_hash = client.genesis_hash(); let client = State::new(client, Subscriptions::new(core.executor())); let key = StorageKey(b":code".to_vec()); - assert!( + assert_eq!( client.storage(key.clone(), Some(genesis_hash).into()) - .map(|x| x.map(|x| x.0.len())).unwrap().unwrap() - > 10_000 + .map(|x| x.map(|x| x.0.len())).unwrap().unwrap() as usize, + LocalExecutor::native_equivalent().len(), ); assert_matches!( client.storage_hash(key.clone(), Some(genesis_hash).into()).map(|x| x.is_some()), Ok(true) ); - assert!( - client.storage_size(key.clone(), None).unwrap().unwrap() - > 10_000 + assert_eq!( + client.storage_size(key.clone(), None).unwrap().unwrap() as usize, + LocalExecutor::native_equivalent().len(), ); } #[test] fn should_return_child_storage() { - let core = ::tokio::runtime::Runtime::new().unwrap(); + let core = tokio::runtime::Runtime::new().unwrap(); let client = Arc::new(test_client::new()); let genesis_hash = client.genesis_hash(); let client = State::new(client, Subscriptions::new(core.executor())); @@ -73,7 +74,7 @@ fn should_return_child_storage() { #[test] fn should_call_contract() { - let core = ::tokio::runtime::Runtime::new().unwrap(); + let core = tokio::runtime::Runtime::new().unwrap(); let client = Arc::new(test_client::new()); let genesis_hash = client.genesis_hash(); let client = State::new(client, Subscriptions::new(core.executor())); @@ -86,7 +87,7 @@ fn should_call_contract() { #[test] fn should_notify_about_storage_changes() { - let mut core = ::tokio::runtime::Runtime::new().unwrap(); + let mut core = tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); let (subscriber, id, transport) = Subscriber::new_test("test"); @@ -117,7 +118,7 @@ fn should_notify_about_storage_changes() { #[test] fn should_send_initial_storage_changes_and_notifications() { - let mut core = ::tokio::runtime::Runtime::new().unwrap(); + let mut core = tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); let (subscriber, id, transport) = Subscriber::new_test("test"); @@ -163,7 +164,7 @@ fn should_query_storage() { >; fn run_tests(client: Arc) { - let core = ::tokio::runtime::Runtime::new().unwrap(); + let core = tokio::runtime::Runtime::new().unwrap(); let api = State::new(client.clone(), Subscriptions::new(core.executor())); let add_block = |nonce| { @@ -250,20 +251,20 @@ fn should_split_ranges() { #[test] fn should_return_runtime_version() { - let core = ::tokio::runtime::Runtime::new().unwrap(); + let core = tokio::runtime::Runtime::new().unwrap(); let client = Arc::new(test_client::new()); let api = State::new(client.clone(), Subscriptions::new(core.executor())); assert_eq!( - ::serde_json::to_string(&api.runtime_version(None.into()).unwrap()).unwrap(), + serde_json::to_string(&api.runtime_version(None.into()).unwrap()).unwrap(), r#"{"specName":"test","implName":"parity-test","authoringVersion":1,"specVersion":1,"implVersion":1,"apis":[["0xdf6acb689907609b",2],["0x37e397fc7c91f5e4",1],["0xd2bc9897eed08f15",1],["0x40fe3ad401f8959a",3],["0xc6e9a76309f39b09",1],["0xdd718d5cc53262d4",1],["0xcbca25e39f142387",1],["0xf78b278be53f454c",1],["0x7801759919ee83e5",1]]}"# ); } #[test] fn should_notify_on_runtime_version_initially() { - let mut core = ::tokio::runtime::Runtime::new().unwrap(); + let mut core = tokio::runtime::Runtime::new().unwrap(); let (subscriber, id, transport) = Subscriber::new_test("test"); { -- GitLab From 85bda652419886cdd21aad4297ba2692f2b8e79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 25 May 2019 21:03:27 +0200 Subject: [PATCH 031/113] Fix doc propagation for `Call` enum (#2690) * Fix doc propagation for `Call` enum * Fix warnings while generating `srml-staking` docs * Make the line check happy --- srml/staking/src/lib.rs | 7 ++++--- srml/support/src/dispatch.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 1901752666..6a9846e07f 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -187,15 +187,16 @@ //! A validator can be _reported_ to be offline at any point via the public function //! [`on_offline_validator`](enum.Call.html#variant.on_offline_validator). Each validator declares how many times it //! can be _reported_ before it actually gets slashed via its -//! [`unstake_threshold`](./struct.ValidatorPrefs.html#structfield.unstake_threshold). +//! [`ValidatorPrefs::unstake_threshold`](./struct.ValidatorPrefs.html#structfield.unstake_threshold). //! //! On top of this, the Staking module also introduces an //! [`OfflineSlashGrace`](./struct.Module.html#method.offline_slash_grace), which applies //! to all validators and prevents them from getting immediately slashed. //! //! Essentially, a validator gets slashed once they have been reported more than -//! [`OfflineSlashGrace`] + [`unstake_threshold`] times. Getting slashed due to offline report always leads -//! to being _unstaked_ (_i.e._ removed as a validator candidate) as the consequence. +//! [`OfflineSlashGrace`] + [`ValidatorPrefs::unstake_threshold`] times. Getting slashed due to +//! offline report always leads to being _unstaked_ (_i.e._ removed as a validator candidate) as +//! the consequence. //! //! The base slash value is computed _per slash-event_ by multiplying //! [`OfflineSlash`](./struct.Module.html#method.offline_slash) and the `total` `Exposure`. This value is then diff --git a/srml/support/src/dispatch.rs b/srml/support/src/dispatch.rs index aa6282c773..f2db609dc3 100644 --- a/srml/support/src/dispatch.rs +++ b/srml/support/src/dispatch.rs @@ -773,6 +773,7 @@ macro_rules! decl_module { $type, } variant $fn_name; + $( #[doc = $doc_attr] )* $( $rest )* } }; @@ -800,6 +801,7 @@ macro_rules! decl_module { $type, } variant $fn_name; + $( #[doc = $doc_attr] )* $( $rest )* } }; @@ -859,7 +861,10 @@ macro_rules! decl_module { (@imp $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> + pub struct $mod_type:ident< + $trait_instance:ident: $trait_name:ident + $(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)? + > for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $(#[doc = $doc_attr:tt])* @@ -881,7 +886,10 @@ macro_rules! decl_module { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] - pub struct $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)?>($crate::rstd::marker::PhantomData<($trait_instance $(, $instance)?)>); + pub struct $mod_type< + $trait_instance: $trait_name + $(, $instance: $instantiable $( = $module_default_instance)?)? + >($crate::rstd::marker::PhantomData<($trait_instance $(, $instance)?)>); $crate::decl_module! { @impl_on_initialize -- GitLab From 824ccf3b95ecc6acdac9a1847b7cdedf7aa02ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Sun, 26 May 2019 22:05:02 +0100 Subject: [PATCH 032/113] Register previous rounds' votes with gossip service on startup (#2676) * grandpa: register previous round votes with gossip service on startup * gossip: fix tests * grandpa: optionally register previous round votes on startup * grandpa: fix tests --- .../finality-grandpa/src/communication/mod.rs | 54 +++++++++++++++++++ .../src/communication/tests.rs | 10 ++++ core/finality-grandpa/src/environment.rs | 4 ++ core/finality-grandpa/src/lib.rs | 10 +++- core/finality-grandpa/src/observer.rs | 10 +++- core/finality-grandpa/src/tests.rs | 14 ++++- core/network/src/consensus_gossip.rs | 36 ++++++++----- 7 files changed, 119 insertions(+), 19 deletions(-) diff --git a/core/finality-grandpa/src/communication/mod.rs b/core/finality-grandpa/src/communication/mod.rs index 395f820254..e4343352d9 100644 --- a/core/finality-grandpa/src/communication/mod.rs +++ b/core/finality-grandpa/src/communication/mod.rs @@ -99,6 +99,12 @@ pub trait Network: Clone + Send + 'static { /// Only should be used in case of consensus stall. fn gossip_message(&self, topic: Block::Hash, data: Vec, force: bool); + /// Register a message with the gossip service, it isn't broadcast right + /// away to any peers, but may be sent to new peers joining or when asked to + /// broadcast the topic. Useful to register previous messages on node + /// startup. + fn register_gossip_message(&self, topic: Block::Hash, data: Vec); + /// Send a message to a bunch of specific peers, even if they've seen it already. fn send_message(&self, who: Vec, data: Vec); @@ -145,11 +151,21 @@ impl Network for Arc> where engine_id: GRANDPA_ENGINE_ID, data, }; + self.with_gossip( move |gossip, ctx| gossip.multicast(ctx, topic, msg, force) ) } + fn register_gossip_message(&self, topic: B::Hash, data: Vec) { + let msg = ConsensusMessage { + engine_id: GRANDPA_ENGINE_ID, + data, + }; + + self.with_gossip(move |gossip, _| gossip.register_message(topic, msg)) + } + fn send_message(&self, who: Vec, data: Vec) { let msg = ConsensusMessage { engine_id: GRANDPA_ENGINE_ID, @@ -212,9 +228,12 @@ pub(crate) struct NetworkBridge> { impl> NetworkBridge { /// Create a new NetworkBridge to the given NetworkService. Returns the service /// handle and a future that must be polled to completion to finish startup. + /// If a voter set state is given it registers previous round votes with the + /// gossip service. pub(crate) fn new( service: N, config: crate::Config, + set_state: Option<(u64, &crate::environment::VoterSetState)>, on_exit: impl Future + Clone + Send + 'static, ) -> ( Self, @@ -225,6 +244,41 @@ impl> NetworkBridge { let validator = Arc::new(validator); service.register_validator(validator.clone()); + if let Some((set_id, set_state)) = set_state { + // register all previous votes with the gossip service so that they're + // available to peers potentially stuck on a previous round. + for round in set_state.completed_rounds().iter() { + let topic = round_topic::(round.number, set_id); + + // we need to note the round with the gossip validator otherwise + // messages will be ignored. + validator.note_round(Round(round.number), SetId(set_id), |_, _| {}); + + for signed in round.votes.iter() { + let message = gossip::GossipMessage::VoteOrPrecommit( + gossip::VoteOrPrecommitMessage:: { + message: signed.clone(), + round: Round(round.number), + set_id: SetId(set_id), + } + ); + + service.register_gossip_message( + topic, + message.encode(), + ); + } + + trace!(target: "afg", + "Registered {} messages for topic {:?} (round: {}, set_id: {})", + round.votes.len(), + topic, + round.number, + set_id, + ); + } + } + let (rebroadcast_job, neighbor_sender) = periodic::neighbor_packet_worker(service.clone()); let reporting_job = report_stream.consume(service.clone()); diff --git a/core/finality-grandpa/src/communication/tests.rs b/core/finality-grandpa/src/communication/tests.rs index 2ef6d28064..f2b50ab80c 100644 --- a/core/finality-grandpa/src/communication/tests.rs +++ b/core/finality-grandpa/src/communication/tests.rs @@ -72,6 +72,15 @@ impl super::Network for TestNetwork { let _ = self.sender.unbounded_send(Event::SendMessage(who, data)); } + /// Register a message with the gossip service, it isn't broadcast right + /// away to any peers, but may be sent to new peers joining or when asked to + /// broadcast the topic. Useful to register previous messages on node + /// startup. + fn register_gossip_message(&self, _topic: Hash, _data: Vec) { + // NOTE: only required to restore previous state on startup + // not required for tests currently + } + /// Report a peer's cost or benefit after some action. fn report(&self, who: network::PeerId, cost_benefit: i32) { let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit)); @@ -136,6 +145,7 @@ fn make_test_network() -> impl Future { let (bridge, startup_work) = super::NetworkBridge::new( net.clone(), config(), + None, Exit, ); diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 564b7630c4..1f3bcbca96 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -101,6 +101,10 @@ impl CompletedRounds { CompletedRounds { inner } } + pub fn iter(&self) -> impl Iterator> { + self.inner.iter() + } + /// Returns the last (latest) completed round. pub fn last(&self) -> &CompletedRound { self.inner.back() diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 75aa4d85ce..2d08bdc04e 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -490,16 +490,22 @@ pub fn run_grandpa_voter, N, RA, SC, X>( use futures::future::{self, Loop as FutureLoop}; - let (network, network_startup) = NetworkBridge::new(network, config.clone(), on_exit.clone()); - let LinkHalf { client, select_chain, persistent_data, voter_commands_rx, } = link; + let PersistentData { authority_set, set_state, consensus_changes } = persistent_data; + let (network, network_startup) = NetworkBridge::new( + network, + config.clone(), + Some((authority_set.set_id(), &set_state.read())), + on_exit.clone(), + ); + register_finality_tracker_inherent_data_provider(client.clone(), &inherent_data_providers)?; if let Some(telemetry_on_connect) = telemetry_on_connect { diff --git a/core/finality-grandpa/src/observer.rs b/core/finality-grandpa/src/observer.rs index f6d657e1ff..9f6f87f8c4 100644 --- a/core/finality-grandpa/src/observer.rs +++ b/core/finality-grandpa/src/observer.rs @@ -166,9 +166,15 @@ pub fn run_grandpa_observer, N, RA, SC>( } = link; let PersistentData { authority_set, consensus_changes, set_state } = persistent_data; - let initial_state = (authority_set, consensus_changes, set_state, voter_commands_rx.into_future()); - let (network, network_startup) = NetworkBridge::new(network, config.clone(), on_exit.clone()); + let (network, network_startup) = NetworkBridge::new( + network, + config.clone(), + None, + on_exit.clone(), + ); + + let initial_state = (authority_set, consensus_changes, set_state, voter_commands_rx.into_future()); let observer_work = future::loop_fn(initial_state, move |state| { let (authority_set, consensus_changes, set_state, voter_commands_rx) = state; diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 622eb7d470..a64060d01f 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -253,6 +253,11 @@ impl Network for MessageRouting { }) } + fn register_gossip_message(&self, _topic: Hash, _data: Vec) { + // NOTE: only required to restore previous state on startup + // not required for tests currently + } + fn report(&self, _who: network::PeerId, _cost_benefit: i32) { } @@ -1242,7 +1247,12 @@ fn voter_persists_its_votes() { name: Some(format!("peer#{}", 1)), }; let routing = MessageRouting::new(net.clone(), 1); - let (network, routing_work) = communication::NetworkBridge::new(routing, config.clone(), Exit); + let (network, routing_work) = communication::NetworkBridge::new( + routing, + config.clone(), + None, + Exit, + ); runtime.block_on(routing_work).unwrap(); let (round_rx, round_tx) = network.round_communication( @@ -1470,4 +1480,4 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ runner_net.lock().peer(3).client().info().unwrap().chain.finalized_number, if FORCE_CHANGE { 0 } else { 10 }, ); -} \ No newline at end of file +} diff --git a/core/network/src/consensus_gossip.rs b/core/network/src/consensus_gossip.rs index c7747a9101..c5f1a2d927 100644 --- a/core/network/src/consensus_gossip.rs +++ b/core/network/src/consensus_gossip.rs @@ -281,7 +281,7 @@ impl ConsensusGossip { } } - fn register_message( + fn register_message_hashed( &mut self, message_hash: B::Hash, topic: B::Hash, @@ -296,6 +296,20 @@ impl ConsensusGossip { } } + /// Registers a message without propagating it to any peers. The message + /// becomes available to new peers or when the service is asked to gossip + /// the message's topic. No validation is performed on the message, if the + /// message is already expired it should be dropped on the next garbage + /// collection. + pub fn register_message( + &mut self, + topic: B::Hash, + message: ConsensusMessage, + ) { + let message_hash = HashFor::::hash(&message.data[..]); + self.register_message_hashed(message_hash, topic, message); + } + /// Call when a peer has been disconnected to stop tracking gossip status. pub fn peer_disconnected(&mut self, protocol: &mut Context, who: PeerId) { for (engine_id, v) in self.validators.clone() { @@ -447,7 +461,7 @@ impl ConsensusGossip { } } if keep { - self.register_message(message_hash, topic, message); + self.register_message_hashed(message_hash, topic, message); } } else { trace!(target:"gossip", "Ignored statement from unregistered peer {}", who); @@ -495,7 +509,7 @@ impl ConsensusGossip { force: bool, ) { let message_hash = HashFor::::hash(&message.data); - self.register_message(message_hash, topic, message.clone()); + self.register_message_hashed(message_hash, topic, message.clone()); let intent = if force { MessageIntent::ForcedBroadcast } else { MessageIntent::Broadcast }; propagate(protocol, iter::once((&message_hash, &topic, &message)), intent, &mut self.peers, &self.validators); } @@ -604,11 +618,9 @@ mod tests { consensus.register_validator_internal([0, 0, 0, 0], Arc::new(AllowAll)); let message = ConsensusMessage { data: vec![4, 5, 6], engine_id: [0, 0, 0, 0] }; - - let message_hash = HashFor::::hash(&message.data); let topic = HashFor::::hash(&[1,2,3]); - consensus.register_message(message_hash, topic, message.clone()); + consensus.register_message(topic, message.clone()); let stream = consensus.messages_for([0, 0, 0, 0], topic); assert_eq!(stream.wait().next(), Some(Ok(TopicNotification { message: message.data, sender: None }))); @@ -622,8 +634,8 @@ mod tests { let msg_a = ConsensusMessage { data: vec![1, 2, 3], engine_id: [0, 0, 0, 0] }; let msg_b = ConsensusMessage { data: vec![4, 5, 6], engine_id: [0, 0, 0, 0] }; - consensus.register_message(HashFor::::hash(&msg_a.data), topic,msg_a); - consensus.register_message(HashFor::::hash(&msg_b.data), topic,msg_b); + consensus.register_message(topic, msg_a); + consensus.register_message(topic, msg_b); assert_eq!(consensus.messages.len(), 2); } @@ -634,11 +646,9 @@ mod tests { consensus.register_validator_internal([0, 0, 0, 0], Arc::new(AllowAll)); let message = ConsensusMessage { data: vec![4, 5, 6], engine_id: [0, 0, 0, 0] }; - - let message_hash = HashFor::::hash(&message.data); let topic = HashFor::::hash(&[1,2,3]); - consensus.register_message(message_hash, topic, message.clone()); + consensus.register_message(topic, message.clone()); let stream1 = consensus.messages_for([0, 0, 0, 0], topic); let stream2 = consensus.messages_for([0, 0, 0, 0], topic); @@ -656,8 +666,8 @@ mod tests { let msg_a = ConsensusMessage { data: vec![1, 2, 3], engine_id: [0, 0, 0, 0] }; let msg_b = ConsensusMessage { data: vec![4, 5, 6], engine_id: [0, 0, 0, 1] }; - consensus.register_message(HashFor::::hash(&msg_a.data), topic, msg_a); - consensus.register_message(HashFor::::hash(&msg_b.data), topic, msg_b); + consensus.register_message(topic, msg_a); + consensus.register_message(topic, msg_b); let mut stream = consensus.messages_for([0, 0, 0, 0], topic).wait(); -- GitLab From db453ba2e76488ba21762c466b6d1685c9d323c9 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 27 May 2019 12:01:07 +0200 Subject: [PATCH 033/113] Fix not connected peers being connected peers (#2692) --- core/network-libp2p/src/service_task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/network-libp2p/src/service_task.rs b/core/network-libp2p/src/service_task.rs index 5a6fb6978c..912c0f71ba 100644 --- a/core/network-libp2p/src/service_task.rs +++ b/core/network-libp2p/src/service_task.rs @@ -200,7 +200,7 @@ where TMessage: CustomMessage + Send + 'static { let not_connected_peers = { let swarm = &mut self.swarm; - let list = swarm.known_peers().filter(|p| !open.iter().all(|n| n != *p)) + let list = swarm.known_peers().filter(|p| open.iter().all(|n| n != *p)) .cloned().collect::>(); list.into_iter().map(move |peer_id| { (peer_id.to_base58(), NetworkStateNotConnectedPeer { -- GitLab From 8d8f923d2b479e2b4fb4631c05aeb279ad734ed7 Mon Sep 17 00:00:00 2001 From: TriplEight Date: Mon, 27 May 2019 14:06:38 +0200 Subject: [PATCH 034/113] some prettiness, fix dockerfile's metadata (#2682) --- .gitlab-ci.yml | 8 ++++---- scripts/docker/Dockerfile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ee23e7253..c11d5ccfc2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,7 @@ variables: environment: name: parity-build -.compiler_info: &compiler_info +.compiler_info: &compiler_info before_script: - rustup show - cargo --version @@ -125,7 +125,7 @@ check-web-wasm: tags: - linux-docker -.build-only: &build-only +.build-only: &build-only only: - master - tags @@ -216,7 +216,7 @@ publish-docker-release: - test -z "${VERSION}" && exit 1 - cd ./artifacts - docker build - --build-arg VCS_REF="${CI_COMMIT_SHORT_SHA}" + --build-arg VCS_REF="${CI_COMMIT_SHA}" --build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" --tag $CONTAINER_IMAGE:$VERSION --tag $CONTAINER_IMAGE:latest . @@ -337,7 +337,7 @@ deploy-ew3-tag: deploy-ue1-tag: <<: *deploy-tag environment: - name: parity-prod-ue1 + name: parity-prod-ue1 .validator-deploy: &validator-deploy stage: flaming-fir diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 4afa0101fc..2bdf49e2fc 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -8,7 +8,7 @@ LABEL io.parity.image.authors="devops-team@parity.io" \ io.parity.image.vendor="Parity Technologies" \ io.parity.image.title="parity/substrate" \ io.parity.image.description="Substrate: The platform for blockchain innovators." \ - io.parity.image.source="https://github.com/paritytech/substrate/blob/master/scripts/docker/Dockerfile" \ + io.parity.image.source="https://github.com/paritytech/substrate/blob/${VCS_REF}/scripts/docker/Dockerfile" \ io.parity.image.revision="${VCS_REF}" \ io.parity.image.created="${BUILD_DATE}" \ io.parity.image.documentation="https://wiki.parity.io/Parity-Substrate" -- GitLab From 950e90e75dc7d16dcf99972fcc733945a832dc3e Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 27 May 2019 20:08:03 +0200 Subject: [PATCH 035/113] Peerset should never return Ready(None) (#2684) --- core/peerset/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/peerset/src/lib.rs b/core/peerset/src/lib.rs index 9b5155455a..6956cd16e1 100644 --- a/core/peerset/src/lib.rs +++ b/core/peerset/src/lib.rs @@ -433,7 +433,7 @@ impl Stream for Peerset { return Ok(Async::Ready(Some(message))); } match try_ready!(self.rx.poll()) { - None => return Ok(Async::Ready(None)), + None => return Ok(Async::NotReady), Some(action) => match action { Action::AddReservedPeer(peer_id) => self.on_add_reserved_peer(peer_id), Action::RemoveReservedPeer(peer_id) => self.on_remove_reserved_peer(peer_id), -- GitLab From d8fc4485dacd4752a7e342b8c8a908db8736bd99 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 28 May 2019 10:35:00 +0200 Subject: [PATCH 036/113] Silence known deprecation warnings (#2651) * Silence known deprecation warnings 1. Prefixes known instances of usages of client.backend and client.import_lock with `#[allow(deprecated)]` to silence the warnings. 2. Remove file-global `#![allow(deprecated)]` used in these cases. Both to prevent us overlooking externally caused deprecation messages. * fixing missing ; * fix missing test cases * move deprecated markers to make CI happy * move deprecated markers to make CI happy * attempt to fix the test * bumping impl_version of node runtime * Minor cleanup --- core/cli/src/informant.rs | 2 + core/client/src/client.rs | 18 ++++-- core/consensus/aura/src/lib.rs | 1 + core/consensus/babe/src/lib.rs | 6 +- core/finality-grandpa/src/environment.rs | 12 +++- core/finality-grandpa/src/finality_proof.rs | 1 + core/finality-grandpa/src/import.rs | 4 ++ core/finality-grandpa/src/justification.rs | 1 + core/finality-grandpa/src/lib.rs | 6 +- core/finality-grandpa/src/light_import.rs | 4 ++ core/finality-grandpa/src/observer.rs | 2 + core/finality-grandpa/src/tests.rs | 5 ++ core/network/src/chain.rs | 1 + core/network/src/test/mod.rs | 2 + core/service/src/components.rs | 1 + core/sr-api-macros/tests/runtime_calls.rs | 1 + core/test-client/src/trait_tests.rs | 61 +++++++++++---------- node-template/src/service.rs | 1 + node/cli/src/service.rs | 2 + node/runtime/src/lib.rs | 2 +- 20 files changed, 95 insertions(+), 38 deletions(-) diff --git a/core/cli/src/informant.rs b/core/cli/src/informant.rs index 5c60229fab..6149d6c95b 100644 --- a/core/cli/src/informant.rs +++ b/core/cli/src/informant.rs @@ -83,6 +83,7 @@ where C: Components { TransferRateFormat(bandwidth_upload), ); + #[allow(deprecated)] let backend = (*client).backend(); let used_state_cache_size = match backend.used_state_cache_size(){ Some(size) => size, @@ -132,6 +133,7 @@ where C: Components { if let Some((ref last_num, ref last_hash)) = last { if n.header.parent_hash() != last_hash { let tree_route = ::client::blockchain::tree_route( + #[allow(deprecated)] client.backend().blockchain(), BlockId::Hash(last_hash.clone()), BlockId::Hash(n.hash), diff --git a/core/client/src/client.rs b/core/client/src/client.rs index c9f70039ea..a7e1e18847 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -1884,6 +1884,7 @@ pub(crate) mod tests { let client = test_client::new(); let genesis_hash = client.info().unwrap().chain.genesis_hash; + #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( client.backend().clone(), client.import_lock() @@ -1902,7 +1903,9 @@ pub(crate) mod tests { let client = test_client::new(); let uninserted_block = client.new_block().unwrap().bake().unwrap(); + #[allow(deprecated)] let backend = client.backend().as_in_memory(); + #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(backend), client.import_lock()); @@ -2038,7 +2041,7 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, a2.clone()).unwrap(); let genesis_hash = client.info().unwrap().chain.genesis_hash; - + #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(client.backend().as_in_memory()), client.import_lock()); @@ -2127,6 +2130,7 @@ pub(crate) mod tests { assert_eq!(client.info().unwrap().chain.best_hash, a5.hash()); let genesis_hash = client.info().unwrap().chain.genesis_hash; + #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(client.backend().as_in_memory()), client.import_lock()); @@ -2357,6 +2361,7 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, a2.clone()).unwrap(); let genesis_hash = client.info().unwrap().chain.genesis_hash; + #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(client.backend().as_in_memory()), client.import_lock() @@ -2400,23 +2405,26 @@ pub(crate) mod tests { let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); client.import_justified(BlockOrigin::Own, a3.clone(), justification.clone()).unwrap(); + #[allow(deprecated)] + let blockchain = client.backend().blockchain(); + assert_eq!( - client.backend().blockchain().last_finalized().unwrap(), + blockchain.last_finalized().unwrap(), a3.hash(), ); assert_eq!( - client.backend().blockchain().justification(BlockId::Hash(a3.hash())).unwrap(), + blockchain.justification(BlockId::Hash(a3.hash())).unwrap(), Some(justification), ); assert_eq!( - client.backend().blockchain().justification(BlockId::Hash(a1.hash())).unwrap(), + blockchain.justification(BlockId::Hash(a1.hash())).unwrap(), None, ); assert_eq!( - client.backend().blockchain().justification(BlockId::Hash(a2.hash())).unwrap(), + blockchain.justification(BlockId::Hash(a2.hash())).unwrap(), None, ); } diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 59483a5688..554a63de94 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -1026,6 +1026,7 @@ mod tests { let mut runtime = current_thread::Runtime::new().unwrap(); for (peer_id, key) in peers { let client = net.lock().peer(*peer_id).client().as_full().expect("full clients are created").clone(); + #[allow(deprecated)] let select_chain = LongestChain::new( client.backend().clone(), client.import_lock().clone(), diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index cccbc160c6..72a4e55a30 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -1079,11 +1079,15 @@ mod tests { &inherent_data_providers, config.get() ).expect("Registers babe inherent data provider"); + + #[allow(deprecated)] + let select_chain = LongestChain::new(client.backend().clone(), client.import_lock().clone()); + let babe = start_babe(BabeParams { config, local_key: Arc::new(key.clone().into()), block_import: client.clone(), - select_chain: LongestChain::new(client.backend().clone(), client.import_lock().clone()), + select_chain, client, env: environ.clone(), sync_oracle: DummyOracle, diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 1f3bcbca96..ed50629f47 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -399,6 +399,7 @@ pub(crate) fn ancestry, E, RA>( if base == block { return Err(GrandpaError::NotDescendent) } let tree_route_res = ::client::blockchain::tree_route( + #[allow(deprecated)] client.backend().blockchain(), BlockId::Hash(block), BlockId::Hash(base), @@ -521,6 +522,7 @@ where current_round: HasVoted::Yes(local_id, Vote::Propose(propose)), }; + #[allow(deprecated)] crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?; Ok(Some(set_state)) @@ -562,6 +564,7 @@ where current_round: HasVoted::Yes(local_id, Vote::Prevote(propose.cloned(), prevote)), }; + #[allow(deprecated)] crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?; Ok(Some(set_state)) @@ -601,6 +604,7 @@ where current_round: HasVoted::Yes(local_id, Vote::Precommit(propose.clone(), prevote.clone(), precommit)), }; + #[allow(deprecated)] crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?; Ok(Some(set_state)) @@ -644,6 +648,7 @@ where current_round: HasVoted::No, }; + #[allow(deprecated)] crate::aux_schema::write_voter_set_state(&**self.inner.backend(), &set_state)?; Ok(Some(set_state)) @@ -655,8 +660,10 @@ where fn finalize_block(&self, hash: Block::Hash, number: NumberFor, round: u64, commit: Commit) -> Result<(), Self::Error> { use client::blockchain::HeaderBackend; - let status = self.inner.backend().blockchain().info()?; - if number <= status.finalized_number && self.inner.backend().blockchain().hash(number)? == Some(hash) { + #[allow(deprecated)] + let blockchain = self.inner.backend().blockchain(); + let status = blockchain.info()?; + if number <= status.finalized_number && blockchain.hash(number)? == Some(hash) { // This can happen after a forced change (triggered by the finality tracker when finality is stalled), since // the voter will be restarted at the median last finalized block, which can be lower than the local best // finalized block. @@ -974,6 +981,7 @@ where B: Backend, } let tree_route = client::blockchain::tree_route( + #[allow(deprecated)] client.backend().blockchain(), BlockId::Hash(*hash), BlockId::Hash(*base), diff --git a/core/finality-grandpa/src/finality_proof.rs b/core/finality-grandpa/src/finality_proof.rs index 4cffe0dd98..c80b65741b 100644 --- a/core/finality-grandpa/src/finality_proof.rs +++ b/core/finality-grandpa/src/finality_proof.rs @@ -173,6 +173,7 @@ impl network::FinalityProofProvider for FinalityProofPro })?; match request { FinalityProofRequest::Original(request) => prove_finality::<_, _, GrandpaJustification>( + #[allow(deprecated)] &*self.client.backend().blockchain(), &*self.authority_provider, request.authorities_set_id, diff --git a/core/finality-grandpa/src/import.rs b/core/finality-grandpa/src/import.rs index 1966913c72..6d64ad6778 100644 --- a/core/finality-grandpa/src/import.rs +++ b/core/finality-grandpa/src/import.rs @@ -317,12 +317,15 @@ where // for the canon block the new authority set should start // with. we use the minimum between the median and the local // best finalized block. + + #[allow(deprecated)] let best_finalized_number = self.inner.backend().blockchain().info() .map_err(|e| ConsensusError::ClientImport(e.to_string()))? .finalized_number; let canon_number = best_finalized_number.min(median_last_finalized_number); + #[allow(deprecated)] let canon_hash = self.inner.backend().blockchain().header(BlockId::Number(canon_number)) .map_err(|e| ConsensusError::ClientImport(e.to_string()))? @@ -396,6 +399,7 @@ impl, RA, PRA, SC> BlockImport // early exit if block already in chain, otherwise the check for // authority changes will error when trying to re-import a change block + #[allow(deprecated)] match self.inner.backend().blockchain().status(BlockId::Hash(hash)) { Ok(blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain), Ok(blockchain::BlockStatus::Unknown) => {}, diff --git a/core/finality-grandpa/src/justification.rs b/core/finality-grandpa/src/justification.rs index f16824f924..fc7f833c75 100644 --- a/core/finality-grandpa/src/justification.rs +++ b/core/finality-grandpa/src/justification.rs @@ -72,6 +72,7 @@ impl> GrandpaJustification { loop { if current_hash == commit.target_hash { break; } + #[allow(deprecated)] match client.backend().blockchain().header(BlockId::Hash(current_hash))? { Some(current_header) => { if *current_header.number() <= commit.target_number { diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 2d08bdc04e..aee6c16d13 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -52,7 +52,6 @@ //! or prune any signaled changes based on whether the signaling block is //! included in the newly-finalized chain. #![forbid(warnings)] -#![allow(deprecated)] // FIXME #2532: remove once the refactor is done https://github.com/paritytech/substrate/issues/2532 use futures::prelude::*; use log::{debug, info, warn}; @@ -321,6 +320,7 @@ where let genesis_hash = chain_info.chain.genesis_hash; let persistent_data = aux_schema::load_persistent( + #[allow(deprecated)] &**client.backend(), genesis_hash, >::zero(), @@ -430,6 +430,7 @@ fn register_finality_tracker_inherent_data_provider Err(std::borrow::Cow::Owned(e.to_string())), Ok(info) => { @@ -653,6 +654,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( current_round: HasVoted::No, }; + #[allow(deprecated)] aux_schema::write_voter_set_state(&**client.backend(), &set_state)?; let set_state: SharedVoterSetState<_> = set_state.into(); @@ -678,6 +680,8 @@ pub fn run_grandpa_voter, N, RA, SC, X>( env.update_voter_set_state(|voter_set_state| { let completed_rounds = voter_set_state.completed_rounds(); let set_state = VoterSetState::Paused { completed_rounds }; + + #[allow(deprecated)] aux_schema::write_voter_set_state(&**client.backend(), &set_state)?; Ok(Some(set_state)) })?; diff --git a/core/finality-grandpa/src/light_import.rs b/core/finality-grandpa/src/light_import.rs index 10143154f9..9e257e9ccc 100644 --- a/core/finality-grandpa/src/light_import.rs +++ b/core/finality-grandpa/src/light_import.rs @@ -64,6 +64,7 @@ pub fn light_block_import, RA, PRA>( PRA::Api: GrandpaApi, { let info = client.info()?; + #[allow(deprecated)] let import_data = load_aux_import_data(info.chain.finalized_hash, &**client.backend(), api)?; Ok(GrandpaLightBlockImport { client, @@ -291,6 +292,7 @@ fn do_import_finality_proof, RA, J>( let authority_set_id = data.authority_set.set_id(); let authorities = data.authority_set.authorities(); let finality_effects = crate::finality_proof::check_finality_proof( + #[allow(deprecated)] &*client.backend().blockchain(), authority_set_id, authorities, @@ -314,6 +316,7 @@ fn do_import_finality_proof, RA, J>( // try to import latest justification let finalized_block_hash = finality_effects.block; + #[allow(deprecated)] let finalized_block_number = client.backend().blockchain() .expect_block_number_from_id(&BlockId::Hash(finality_effects.block)) .map_err(|e| ConsensusError::ClientImport(e.to_string()))?; @@ -502,6 +505,7 @@ fn require_insert_aux, RA>( B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, { + #[allow(deprecated)] let backend = &**client.backend(); let encoded = value.encode(); let update_res = Backend::insert_aux(backend, &[(key, &encoded[..])], &[]); diff --git a/core/finality-grandpa/src/observer.rs b/core/finality-grandpa/src/observer.rs index 9f6f87f8c4..3fc9665a8d 100644 --- a/core/finality-grandpa/src/observer.rs +++ b/core/finality-grandpa/src/observer.rs @@ -218,6 +218,7 @@ pub fn run_grandpa_observer, N, RA, SC>( let completed_rounds = set_state.read().completed_rounds(); let set_state = VoterSetState::Paused { completed_rounds }; + #[allow(deprecated)] crate::aux_schema::write_voter_set_state(&**client.backend(), &set_state)?; set_state @@ -238,6 +239,7 @@ pub fn run_grandpa_observer, N, RA, SC>( current_round: HasVoted::No, }; + #[allow(deprecated)] crate::aux_schema::write_voter_set_state(&**client.backend(), &set_state)?; set_state diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index a64060d01f..455afb865a 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -119,6 +119,7 @@ impl TestNetFactory for GrandpaTestNet { { match client { PeersClient::Full(ref client) => { + #[allow(deprecated)] let select_chain = LongestChain::new( client.backend().clone(), client.import_lock().clone() @@ -676,6 +677,7 @@ fn transition_3_voters_twice_1_full_observer() { "Peer #{} failed to sync", i); let set: AuthoritySet = crate::aux_schema::load_authorities( + #[allow(deprecated)] &**full_client.backend() ).unwrap(); @@ -765,6 +767,7 @@ fn transition_3_voters_twice_1_full_observer() { .map(move |()| { let full_client = client.as_full().expect("only full clients are used in test"); let set: AuthoritySet = crate::aux_schema::load_authorities( + #[allow(deprecated)] &**full_client.backend() ).unwrap(); @@ -1035,6 +1038,7 @@ fn force_change_to_new_set() { let full_client = peer.client().as_full().expect("only full clients are used in test"); let set: AuthoritySet = crate::aux_schema::load_authorities( + #[allow(deprecated)] &**full_client.backend() ).unwrap(); @@ -1288,6 +1292,7 @@ fn voter_persists_its_votes() { assert_eq!(net.lock().peer(0).client().info().unwrap().chain.best_number, 40, "Peer #{} failed to sync", 0); + #[allow(deprecated)] let block_30_hash = net.lock().peer(0).client().as_full().unwrap().backend().blockchain().hash(30).unwrap().unwrap(); diff --git a/core/network/src/chain.rs b/core/network/src/chain.rs index 9548afc9d1..f7ce4f9d5c 100644 --- a/core/network/src/chain.rs +++ b/core/network/src/chain.rs @@ -134,6 +134,7 @@ impl Client for SubstrateClient where } let tree_route = ::client::blockchain::tree_route( + #[allow(deprecated)] self.backend().blockchain(), BlockId::Hash(*block), BlockId::Hash(*base), diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index ac9e9a98eb..301f5653f1 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -143,6 +143,7 @@ impl PeersClient { } pub fn as_in_memory_backend(&self) -> InMemoryBackend { + #[allow(deprecated)] match *self { PeersClient::Full(ref client) => client.backend().as_in_memory(), PeersClient::Light(_) => unimplemented!("TODO"), @@ -150,6 +151,7 @@ impl PeersClient { } pub fn get_aux(&self, key: &[u8]) -> ClientResult>> { + #[allow(deprecated)] match *self { PeersClient::Full(ref client) => client.backend().get_aux(key), PeersClient::Light(ref client) => client.backend().get_aux(key), diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 6e6503fc3d..202bd15b2a 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -646,6 +646,7 @@ mod tests { from: AccountKeyring::Alice.into(), to: Default::default(), }.into_signed_tx(); + #[allow(deprecated)] let best = LongestChain::new(client.backend().clone(), client.import_lock()) .best_chain().unwrap(); diff --git a/core/sr-api-macros/tests/runtime_calls.rs b/core/sr-api-macros/tests/runtime_calls.rs index fb3cad3238..ca008444e1 100644 --- a/core/sr-api-macros/tests/runtime_calls.rs +++ b/core/sr-api-macros/tests/runtime_calls.rs @@ -158,6 +158,7 @@ fn record_proof_works() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + #[allow(deprecated)] let storage_root = LongestChain::new(client.backend().clone(), client.import_lock()) .best_chain().unwrap().state_root().clone(); diff --git a/core/test-client/src/trait_tests.rs b/core/test-client/src/trait_tests.rs index aa51f7d8bf..a6da3b206b 100644 --- a/core/test-client/src/trait_tests.rs +++ b/core/test-client/src/trait_tests.rs @@ -41,46 +41,49 @@ pub fn test_leaves_for_backend(backend: Arc) where // A1 -> D2 let client = new_with_backend(backend.clone(), false); + let blockchain = backend.blockchain(); let genesis_hash = client.info().unwrap().chain.genesis_hash; assert_eq!( - client.backend().blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![genesis_hash]); // G -> A1 let a1 = client.new_block().unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a1.hash()]); // A1 -> A2 let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); + + #[allow(deprecated)] assert_eq!( - client.backend().blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a2.hash()]); // A2 -> A3 let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a3.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a3.hash()]); // A3 -> A4 let a4 = client.new_block_at(&BlockId::Hash(a3.hash())).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a4.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a4.hash()]); // A4 -> A5 let a5 = client.new_block_at(&BlockId::Hash(a4.hash())).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a5.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a5.hash()]); // A1 -> B2 @@ -95,21 +98,21 @@ pub fn test_leaves_for_backend(backend: Arc) where let b2 = builder.bake().unwrap(); client.import(BlockOrigin::Own, b2.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a5.hash(), b2.hash()]); // B2 -> B3 let b3 = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b3.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a5.hash(), b3.hash()]); // B3 -> B4 let b4 = client.new_block_at(&BlockId::Hash(b3.hash())).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b4.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a5.hash(), b4.hash()]); // // B2 -> C3 @@ -124,7 +127,7 @@ pub fn test_leaves_for_backend(backend: Arc) where let c3 = builder.bake().unwrap(); client.import(BlockOrigin::Own, c3.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a5.hash(), b4.hash(), c3.hash()]); // A1 -> D2 @@ -139,7 +142,7 @@ pub fn test_leaves_for_backend(backend: Arc) where let d2 = builder.bake().unwrap(); client.import(BlockOrigin::Own, d2.clone()).unwrap(); assert_eq!( - backend.blockchain().leaves().unwrap(), + blockchain.leaves().unwrap(), vec![a5.hash(), b4.hash(), c3.hash(), d2.hash()]); } @@ -154,6 +157,7 @@ pub fn test_children_for_backend(backend: Arc) where // A1 -> D2 let client = new_with_backend(backend.clone(), false); + let blockchain = backend.blockchain(); // G -> A1 let a1 = client.new_block().unwrap().bake().unwrap(); @@ -221,16 +225,16 @@ pub fn test_children_for_backend(backend: Arc) where let genesis_hash = client.info().unwrap().chain.genesis_hash; - let children1 = backend.blockchain().children(a4.hash()).unwrap(); + let children1 = blockchain.children(a4.hash()).unwrap(); assert_eq!(vec![a5.hash()], children1); - let children2 = backend.blockchain().children(a1.hash()).unwrap(); + let children2 = blockchain.children(a1.hash()).unwrap(); assert_eq!(vec![a2.hash(), b2.hash(), d2.hash()], children2); - let children3 = backend.blockchain().children(genesis_hash).unwrap(); + let children3 = blockchain.children(genesis_hash).unwrap(); assert_eq!(vec![a1.hash()], children3); - let children4 = backend.blockchain().children(b2.hash()).unwrap(); + let children4 = blockchain.children(b2.hash()).unwrap(); assert_eq!(vec![b3.hash(), c3.hash()], children4); } @@ -242,7 +246,8 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc B2 -> B3 -> B4 // B2 -> C3 // A1 -> D2 - let client = new_with_backend(backend, false); + let client = new_with_backend(backend.clone(), false); + let blockchain = backend.blockchain(); // G -> A1 let a1 = client.new_block().unwrap().bake().unwrap(); @@ -310,21 +315,21 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc, Self::Block> { |config: &FactoryFullConfiguration, client: Arc>| { + #[allow(deprecated)] Ok(LongestChain::new( client.backend().clone(), client.import_lock() diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index a4ac1b0660..bb1c257155 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -180,6 +180,7 @@ construct_service_factory! { }}, LightImportQueue = AuraImportQueue { |config: &FactoryFullConfiguration, client: Arc>| { + #[allow(deprecated)] let fetch_checker = client.backend().blockchain().fetcher() .upgrade() .map(|fetcher| fetcher.checker().clone()) @@ -204,6 +205,7 @@ construct_service_factory! { }}, SelectChain = LongestChain, Self::Block> { |config: &FactoryFullConfiguration, client: Arc>| { + #[allow(deprecated)] Ok(LongestChain::new( client.backend().clone(), client.import_lock() diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index e2bd336916..0ec44093b4 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 81, - impl_version: 82, + impl_version: 83, apis: RUNTIME_API_VERSIONS, }; -- GitLab From 3b76ebc2b882a43d1d381cbcfa66dfd07f99e17d Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 May 2019 12:54:02 +0200 Subject: [PATCH 037/113] Allow passing an optional transport to network-libp2p (#2680) * Allow passing an optional transport * Fix tests * Fix Cargo.lock * Fix Cargo.lock again?!?! --- Cargo.lock | 24 +++++++++++++++--------- core/network-libp2p/src/config.rs | 9 +++++++++ core/network-libp2p/src/service_task.rs | 5 ++++- core/network-libp2p/src/transport.rs | 22 ++++++++++++++-------- core/service/test/src/lib.rs | 1 + 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5347186c37..5d2a6c5b29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1439,10 +1439,10 @@ dependencies = [ "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1680,7 +1680,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1693,11 +1693,11 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1735,13 +1735,13 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2349,6 +2349,11 @@ dependencies = [ "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-send-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "parity-wasm" version = "0.31.3" @@ -4988,7 +4993,7 @@ name = "twox-hash" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5625,10 +5630,10 @@ dependencies = [ "checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" "checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" "checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" "checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" "checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" "checksum libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04451aa166aa2040293f44c1c27144b65500e4a2ebbb723dfe732f39436eccbd" "checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum librocksdb-sys 5.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7dfb546562f9b450237bb8df7a31961849ee9fb1186d9e356db1d7a6b7609ff2" @@ -5676,6 +5681,7 @@ dependencies = [ "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" "checksum parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a130a727008cfcd1068a28439fe939897ccad28664422aeca65b384d6de6d0" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" +"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parity-ws 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fec5048fba72a2e01baeb0d08089db79aead4b57e2443df172fb1840075a233" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" diff --git a/core/network-libp2p/src/config.rs b/core/network-libp2p/src/config.rs index d845d132a8..b9ccbb6428 100644 --- a/core/network-libp2p/src/config.rs +++ b/core/network-libp2p/src/config.rs @@ -17,6 +17,7 @@ //! Libp2p network configuration. use libp2p::identity::{Keypair, secp256k1, ed25519}; +use libp2p::wasm_ext; use libp2p::{Multiaddr, multiaddr::Protocol}; use std::error::Error; use std::{io::{self, Write}, iter, fs, net::Ipv4Addr, path::{Path, PathBuf}}; @@ -52,6 +53,13 @@ pub struct NetworkConfiguration { /// If true, the network will use mDNS to discover other libp2p nodes on the local network /// and connect to them if they support the same chain. pub enable_mdns: bool, + /// Optional external implementation of a libp2p transport. Used in WASM contexts where we need + /// some binding between the networking provided by the operating system or environment and + /// libp2p. + /// + /// This parameter exists whatever the target platform is, but it is expected to be set to + /// `Some` only when compiling for WASM. + pub wasm_external_transport: Option, } impl Default for NetworkConfiguration { @@ -70,6 +78,7 @@ impl Default for NetworkConfiguration { client_version: "unknown".into(), node_name: "unknown".into(), enable_mdns: false, + wasm_external_transport: None, } } } diff --git a/core/network-libp2p/src/service_task.rs b/core/network-libp2p/src/service_task.rs index 912c0f71ba..a58b24cbfe 100644 --- a/core/network-libp2p/src/service_task.rs +++ b/core/network-libp2p/src/service_task.rs @@ -89,7 +89,10 @@ where TMessage: CustomMessage + Send + 'static { let user_agent = format!("{} ({})", config.client_version, config.node_name); let proto = CustomProto::new(registered_custom, peerset); let behaviour = Behaviour::new(proto, user_agent, local_public, known_addresses, config.enable_mdns); - let (transport, bandwidth) = transport::build_transport(local_identity); + let (transport, bandwidth) = transport::build_transport( + local_identity, + config.wasm_external_transport + ); (Swarm::new(transport, behaviour, local_peer_id.clone()), bandwidth) }; diff --git a/core/network-libp2p/src/transport.rs b/core/network-libp2p/src/transport.rs index 1e8b280f3b..f2860c7856 100644 --- a/core/network-libp2p/src/transport.rs +++ b/core/network-libp2p/src/transport.rs @@ -17,11 +17,11 @@ use futures::prelude::*; use libp2p::{ InboundUpgradeExt, OutboundUpgradeExt, PeerId, Transport, - mplex, identity, secio, yamux, websocket, bandwidth + mplex, identity, secio, yamux, websocket, bandwidth, wasm_ext }; #[cfg(not(target_os = "unknown"))] use libp2p::{tcp, dns}; -use libp2p::core::{self, transport::boxed::Boxed, muxing::StreamMuxerBox}; +use libp2p::core::{self, transport::boxed::Boxed, transport::OptionalTransport, muxing::StreamMuxerBox}; use std::{io, sync::Arc, time::Duration, usize}; pub use self::bandwidth::BandwidthSinks; @@ -31,20 +31,26 @@ pub use self::bandwidth::BandwidthSinks; /// Returns a `BandwidthSinks` object that allows querying the average bandwidth produced by all /// the connections spawned with this transport. pub fn build_transport( - keypair: identity::Keypair + keypair: identity::Keypair, + wasm_external_transport: Option ) -> (Boxed<(PeerId, StreamMuxerBox), io::Error>, Arc) { let mut mplex_config = mplex::MplexConfig::new(); mplex_config.max_buffer_len_behaviour(mplex::MaxBufferBehaviour::Block); mplex_config.max_buffer_len(usize::MAX); + let transport = if let Some(t) = wasm_external_transport { + OptionalTransport::some(t) + } else { + OptionalTransport::none() + }; + #[cfg(not(target_os = "unknown"))] let transport = { - let transport = tcp::TcpConfig::new(); - let transport = websocket::WsConfig::new(transport.clone()).or_transport(transport); - dns::DnsConfig::new(transport) + let desktop_trans = tcp::TcpConfig::new(); + let desktop_trans = websocket::WsConfig::new(desktop_trans.clone()) + .or_transport(desktop_trans); + transport.or_transport(dns::DnsConfig::new(desktop_trans)) }; - #[cfg(target_os = "unknown")] - let transport = websocket::BrowserWsConfig::new(); let (transport, sinks) = bandwidth::BandwidthLogging::new(transport, Duration::from_secs(5)); diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index dc4676dc0a..88425e1956 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -99,6 +99,7 @@ fn node_config ( client_version: "network/test/0.1".to_owned(), node_name: "unknown".to_owned(), enable_mdns: false, + wasm_external_transport: None, }; Configuration { -- GitLab From b5483b43e714e6365828daa64556a4dbce243a88 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 28 May 2019 16:07:16 +0300 Subject: [PATCH 038/113] Remove BlockNumber <-> u64 conversions from light-client related code (#2666) * Remove As usage from CHT * Remove As usage from CHT (continue) * Restrict BN <-> int conversions in CT * more BN <-> u64 conversions removed * upd spec_version * Apply suggestions from code review Co-Authored-By: Gavin Wood * Apply suggestions from code review Co-Authored-By: Gavin Wood * more grumbles * fix last grumbles + compilation * too long lines * too long lines --- Cargo.lock | 2 + core/client/db/src/cache/mod.rs | 2 +- core/client/db/src/lib.rs | 68 +++-- core/client/db/src/light.rs | 124 +++++---- core/client/src/backend.rs | 12 +- core/client/src/cht.rs | 177 +++++++------ core/client/src/client.rs | 81 +++--- core/client/src/error.rs | 4 +- core/client/src/genesis.rs | 12 +- core/client/src/in_mem.rs | 63 +++-- core/client/src/light/backend.rs | 2 +- core/client/src/light/blockchain.rs | 14 +- core/client/src/light/call_executor.rs | 2 +- core/client/src/light/fetcher.rs | 53 ++-- core/executor/src/sandbox.rs | 4 +- core/executor/src/wasm_executor.rs | 9 +- core/executor/wasm/Cargo.lock | 16 ++ core/primitives/Cargo.toml | 4 +- core/primitives/src/changes_trie.rs | 87 ++++--- core/sr-io/src/lib.rs | 8 +- core/sr-io/with_std.rs | 6 +- core/sr-io/without_std.rs | 6 +- core/sr-primitives/src/traits.rs | 6 +- core/state-machine/Cargo.toml | 1 + core/state-machine/src/basic.rs | 4 +- core/state-machine/src/changes_trie/build.rs | 111 +++++--- .../src/changes_trie/build_iterator.rs | 90 +++++-- .../src/changes_trie/changes_iterator.rs | 236 +++++++++++------- core/state-machine/src/changes_trie/input.rs | 51 ++-- core/state-machine/src/changes_trie/mod.rs | 98 ++++++-- core/state-machine/src/changes_trie/prune.rs | 132 +++++----- .../state-machine/src/changes_trie/storage.rs | 58 +++-- core/state-machine/src/ext.rs | 64 ++--- core/state-machine/src/lib.rs | 43 ++-- core/state-machine/src/overlayed_changes.rs | 2 +- core/state-machine/src/testing.rs | 52 ++-- .../state-machine/src/trie_backend_essence.rs | 10 - core/test-runtime/src/system.rs | 6 +- node/executor/src/lib.rs | 14 +- node/runtime/src/lib.rs | 4 +- srml/system/src/lib.rs | 5 +- 41 files changed, 1088 insertions(+), 655 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d2a6c5b29..a40f588d29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4268,6 +4268,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4410,6 +4411,7 @@ dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index d8ffaea723..d79b01ab6b 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -35,7 +35,7 @@ mod list_cache; mod list_entry; mod list_storage; -/// Minimal post-finalization age age of finalized blocks before they'll pruned. +/// Minimal post-finalization age of finalized blocks before they'll pruned. const PRUNE_DEPTH: u32 = 1024; /// The type of entry that is inserted to the cache. diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 8f54099a78..e9e9a61a76 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -48,7 +48,7 @@ use primitives::storage::well_known_keys; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, NumberFor, Zero, One, Digest, DigestItem, - SaturatedConversion, + SaturatedConversion }; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; @@ -67,7 +67,7 @@ pub use state_db::PruningMode; use client::in_mem::Backend as InMemoryBackend; const CANONICALIZATION_DELAY: u64 = 4096; -const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u64 = 32768; +const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768; /// DB-backed patricia trie state, transaction type is an overlay of changes to commit. pub type DbState = state_machine::TrieBackend>, Blake2Hasher>; @@ -423,11 +423,11 @@ impl state_machine::Storage for DbGenesisStorage { pub struct DbChangesTrieStorage { db: Arc, meta: Arc, Block::Hash>>>, - min_blocks_to_keep: Option, + min_blocks_to_keep: Option, _phantom: ::std::marker::PhantomData, } -impl DbChangesTrieStorage { +impl> DbChangesTrieStorage { /// Commit new changes trie. pub fn commit(&self, tx: &mut DBTransaction, mut changes_trie: MemoryDB) { for (key, (val, _)) in changes_trie.drain() { @@ -446,53 +446,79 @@ impl DbChangesTrieStorage { state_machine::prune_changes_tries( config, &*self, - min_blocks_to_keep, + min_blocks_to_keep.into(), &state_machine::ChangesTrieAnchorBlockId { hash: convert_hash(&block_hash), - number: block_num.saturated_into::(), + number: block_num, }, |node| tx.delete(columns::CHANGES_TRIE, node.as_ref())); } } -impl client::backend::PrunableStateChangesTrieStorage for DbChangesTrieStorage { +impl client::backend::PrunableStateChangesTrieStorage + for DbChangesTrieStorage +where + Block: BlockT, +{ fn oldest_changes_trie_block( &self, config: &ChangesTrieConfiguration, - best_finalized_block: u64 - ) -> u64 { + best_finalized_block: NumberFor, + ) -> NumberFor { match self.min_blocks_to_keep { Some(min_blocks_to_keep) => state_machine::oldest_non_pruned_changes_trie( config, - min_blocks_to_keep, + min_blocks_to_keep.into(), best_finalized_block, ), - None => 1, + None => One::one(), } } } -impl state_machine::ChangesTrieRootsStorage for DbChangesTrieStorage { - fn root(&self, anchor: &state_machine::ChangesTrieAnchorBlockId, block: u64) -> Result, String> { +impl state_machine::ChangesTrieRootsStorage> + for DbChangesTrieStorage +where + Block: BlockT, +{ + fn build_anchor( + &self, + hash: H256, + ) -> Result>, String> { + utils::read_header::(&*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Hash(hash)) + .map_err(|e| e.to_string()) + .and_then(|maybe_header| maybe_header.map(|header| + state_machine::ChangesTrieAnchorBlockId { + hash, + number: *header.number(), + } + ).ok_or_else(|| format!("Unknown header: {}", hash))) + } + + fn root( + &self, + anchor: &state_machine::ChangesTrieAnchorBlockId>, + block: NumberFor, + ) -> Result, String> { // check API requirement: we can't get NEXT block(s) based on anchor if block > anchor.number { return Err(format!("Can't get changes trie root at {} using anchor at {}", block, anchor.number)); } // we need to get hash of the block to resolve changes trie root - let block_id = if block <= self.meta.read().finalized_number.saturated_into::() { + let block_id = if block <= self.meta.read().finalized_number { // if block is finalized, we could just read canonical hash - BlockId::Number(block.saturated_into()) + BlockId::Number(block) } else { // the block is not finalized let mut current_num = anchor.number; let mut current_hash: Block::Hash = convert_hash(&anchor.hash); let maybe_anchor_header: Block::Header = utils::require_header::( - &*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Number(current_num.saturated_into()) + &*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Number(current_num) ).map_err(|e| e.to_string())?; if maybe_anchor_header.hash() == current_hash { // if anchor is canonicalized, then the block is also canonicalized - BlockId::Number(block.saturated_into()) + BlockId::Number(block) } else { // else (block is not finalized + anchor is not canonicalized): // => we should find the required block hash by traversing @@ -503,7 +529,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC ).map_err(|e| e.to_string())?; current_hash = *current_header.parent_hash(); - current_num = current_num - 1; + current_num = current_num - One::one(); } BlockId::Hash(current_hash) @@ -517,7 +543,11 @@ impl state_machine::ChangesTrieRootsStorage for DbC } } -impl state_machine::ChangesTrieStorage for DbChangesTrieStorage { +impl state_machine::ChangesTrieStorage> + for DbChangesTrieStorage +where + Block: BlockT, +{ fn get(&self, key: &H256, _prefix: &[u8]) -> Result, String> { self.db.get(columns::CHANGES_TRIE, &key[..]) .map_err(|err| format!("{}", err)) diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index 02525455ba..cbac1b730e 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -32,8 +32,9 @@ use client::light::blockchain::Storage as LightBlockchainStorage; use parity_codec::{Decode, Encode}; use primitives::Blake2Hasher; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, - Zero, One, SaturatedConversion, NumberFor, Digest, DigestItem +use runtime_primitives::traits::{ + Block as BlockT, Header as HeaderT, + Zero, One, NumberFor, Digest, DigestItem, }; use consensus_common::well_known_cache_keys; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType}; @@ -269,12 +270,18 @@ impl LightStorage { transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key); // build new CHT(s) if required - if let Some(new_cht_number) = cht::is_build_required(cht::SIZE, *header.number()) { - let new_cht_start: NumberFor = cht::start_number(cht::SIZE, new_cht_number); + if let Some(new_cht_number) = cht::is_build_required(cht::size(), *header.number()) { + let new_cht_start: NumberFor = cht::start_number(cht::size(), new_cht_number); + + let mut current_num = new_cht_start; + let cht_range = ::std::iter::from_fn(|| { + let old_current_num = current_num; + current_num = current_num + One::one(); + Some(old_current_num) + }); let new_header_cht_root = cht::compute_root::( - cht::SIZE, new_cht_number, (new_cht_start.saturated_into::()..) - .map(|num| self.hash(num.saturated_into())) + cht::size(), new_cht_number, cht_range.map(|num| self.hash(num)) )?; transaction.put( columns::CHT, @@ -284,9 +291,15 @@ impl LightStorage { // if the header includes changes trie root, let's build a changes tries roots CHT if header.digest().log(DigestItem::as_changes_trie_root).is_some() { + let mut current_num = new_cht_start; + let cht_range = ::std::iter::from_fn(|| { + let old_current_num = current_num; + current_num = current_num + One::one(); + Some(old_current_num) + }); let new_changes_trie_cht_root = cht::compute_root::( - cht::SIZE, new_cht_number, (new_cht_start.saturated_into::()..) - .map(|num| self.changes_trie_root(BlockId::Number(num.saturated_into()))) + cht::size(), new_cht_number, cht_range + .map(|num| self.changes_trie_root(BlockId::Number(num))) )?; transaction.put( columns::CHT, @@ -297,7 +310,7 @@ impl LightStorage { // prune headers that are replaced with CHT let mut prune_block = new_cht_start; - let new_cht_end = cht::end_number(cht::SIZE, new_cht_number); + let new_cht_end = cht::end_number(cht::size(), new_cht_number); trace!(target: "db", "Replacing blocks [{}..{}] with CHT#{}", new_cht_start, new_cht_end, new_cht_number); @@ -330,7 +343,7 @@ impl LightStorage { fn read_cht_root( &self, cht_type: u8, - cht_size: u64, + cht_size: NumberFor, block: NumberFor ) -> ClientResult { let no_cht_for_block = || ClientError::Backend(format!("CHT for block {} not exists", block)); @@ -482,11 +495,19 @@ impl LightBlockchainStorage for LightStorage } } - fn header_cht_root(&self, cht_size: u64, block: NumberFor) -> ClientResult { + fn header_cht_root( + &self, + cht_size: NumberFor, + block: NumberFor, + ) -> ClientResult { self.read_cht_root(HEADER_CHT_PREFIX, cht_size, block) } - fn changes_trie_cht_root(&self, cht_size: u64, block: NumberFor) -> ClientResult { + fn changes_trie_cht_root( + &self, + cht_size: NumberFor, + block: NumberFor, + ) -> ClientResult { self.read_cht_root(CHANGES_TRIE_CHT_PREFIX, cht_size, block) } @@ -670,33 +691,44 @@ pub(crate) mod tests { fn finalized_ancient_headers_are_replaced_with_cht() { fn insert_headers Header>(header_producer: F) -> LightStorage { let db = LightStorage::new_test(); + let cht_size: u64 = cht::size(); + let ucht_size: usize = cht_size as _; // insert genesis block header (never pruned) let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_producer(&Default::default(), 0)); // insert SIZE blocks && ensure that nothing is pruned - for number in 0..cht::SIZE { + + for number in 0..cht::size() { prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + number)); } - assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE) as usize); + assert_eq!(db.db.iter(columns::HEADER).count(), 1 + ucht_size); assert_eq!(db.db.iter(columns::CHT).count(), 0); // insert next SIZE blocks && ensure that nothing is pruned - for number in 0..cht::SIZE { - prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + number)); + for number in 0..(cht_size as _) { + prev_hash = insert_block( + &db, + HashMap::new(), + || header_producer(&prev_hash, 1 + cht_size + number), + ); } - assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE + cht::SIZE) as usize); + assert_eq!(db.db.iter(columns::HEADER).count(), 1 + ucht_size + ucht_size); assert_eq!(db.db.iter(columns::CHT).count(), 0); - // insert block #{2 * cht::SIZE + 1} && check that new CHT is created + headers of this CHT are pruned + // insert block #{2 * cht::size() + 1} && check that new CHT is created + headers of this CHT are pruned // nothing is yet finalized, so nothing is pruned. - prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + cht::SIZE + cht::SIZE)); - assert_eq!(db.db.iter(columns::HEADER).count(), (2 + cht::SIZE + cht::SIZE) as usize); + prev_hash = insert_block( + &db, + HashMap::new(), + || header_producer(&prev_hash, 1 + cht_size + cht_size), + ); + assert_eq!(db.db.iter(columns::HEADER).count(), 2 + ucht_size + ucht_size); assert_eq!(db.db.iter(columns::CHT).count(), 0); // now finalize the block. - for i in (0..(cht::SIZE + cht::SIZE)).map(|i| i + 1) { - db.finalize_header(BlockId::Number(i)).unwrap(); + for i in (0..(ucht_size + ucht_size)).map(|i| i + 1) { + db.finalize_header(BlockId::Number(i as _)).unwrap(); } db.finalize_header(BlockId::Hash(prev_hash)).unwrap(); db @@ -704,34 +736,36 @@ pub(crate) mod tests { // when headers are created without changes tries roots let db = insert_headers(default_header); - assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE + 1) as usize); - assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), (2 * (1 + cht::SIZE + 1)) as usize); + let cht_size: u64 = cht::size(); + assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht_size + 1) as usize); + assert_eq!(db.db.iter(columns::KEY_LOOKUP).count(), (2 * (1 + cht_size + 1)) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 1); - assert!((0..cht::SIZE).all(|i| db.header(BlockId::Number(1 + i)).unwrap().is_none())); - assert!(db.header_cht_root(cht::SIZE, cht::SIZE / 2).is_ok()); - assert!(db.header_cht_root(cht::SIZE, cht::SIZE + cht::SIZE / 2).is_err()); - assert!(db.changes_trie_cht_root(cht::SIZE, cht::SIZE / 2).is_err()); - assert!(db.changes_trie_cht_root(cht::SIZE, cht::SIZE + cht::SIZE / 2).is_err()); + assert!((0..cht_size as _).all(|i| db.header(BlockId::Number(1 + i)).unwrap().is_none())); + assert!(db.header_cht_root(cht_size, cht_size / 2).is_ok()); + assert!(db.header_cht_root(cht_size, cht_size + cht_size / 2).is_err()); + assert!(db.changes_trie_cht_root(cht_size, cht_size / 2).is_err()); + assert!(db.changes_trie_cht_root(cht_size, cht_size + cht_size / 2).is_err()); // when headers are created with changes tries roots let db = insert_headers(header_with_changes_trie); - assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht::SIZE + 1) as usize); + assert_eq!(db.db.iter(columns::HEADER).count(), (1 + cht_size + 1) as usize); assert_eq!(db.db.iter(columns::CHT).count(), 2); - assert!((0..cht::SIZE).all(|i| db.header(BlockId::Number(1 + i)).unwrap().is_none())); - assert!(db.header_cht_root(cht::SIZE, cht::SIZE / 2).is_ok()); - assert!(db.header_cht_root(cht::SIZE, cht::SIZE + cht::SIZE / 2).is_err()); - assert!(db.changes_trie_cht_root(cht::SIZE, cht::SIZE / 2).is_ok()); - assert!(db.changes_trie_cht_root(cht::SIZE, cht::SIZE + cht::SIZE / 2).is_err()); + assert!((0..cht_size as _).all(|i| db.header(BlockId::Number(1 + i)).unwrap().is_none())); + assert!(db.header_cht_root(cht_size, cht_size / 2).is_ok()); + assert!(db.header_cht_root(cht_size, cht_size + cht_size / 2).is_err()); + assert!(db.changes_trie_cht_root(cht_size, cht_size / 2).is_ok()); + assert!(db.changes_trie_cht_root(cht_size, cht_size + cht_size / 2).is_err()); } #[test] fn get_cht_fails_for_genesis_block() { - assert!(LightStorage::::new_test().header_cht_root(cht::SIZE, 0).is_err()); + assert!(LightStorage::::new_test().header_cht_root(cht::size(), 0).is_err()); } #[test] fn get_cht_fails_for_non_existant_cht() { - assert!(LightStorage::::new_test().header_cht_root(cht::SIZE, (cht::SIZE / 2) as u64).is_err()); + let cht_size: u64 = cht::size(); + assert!(LightStorage::::new_test().header_cht_root(cht_size, cht_size / 2).is_err()); } #[test] @@ -740,20 +774,22 @@ pub(crate) mod tests { // insert 1 + SIZE + SIZE + 1 blocks so that CHT#0 is created let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_with_changes_trie(&Default::default(), 0)); - for i in 1..1 + cht::SIZE + cht::SIZE + 1 { + let cht_size: u64 = cht::size(); + let ucht_size: usize = cht_size as _; + for i in 1..1 + ucht_size + ucht_size + 1 { prev_hash = insert_block(&db, HashMap::new(), || header_with_changes_trie(&prev_hash, i as u64)); db.finalize_header(BlockId::Hash(prev_hash)).unwrap(); } - let cht_root_1 = db.header_cht_root(cht::SIZE, cht::start_number(cht::SIZE, 0)).unwrap(); - let cht_root_2 = db.header_cht_root(cht::SIZE, (cht::start_number(cht::SIZE, 0) + cht::SIZE / 2) as u64).unwrap(); - let cht_root_3 = db.header_cht_root(cht::SIZE, cht::end_number(cht::SIZE, 0)).unwrap(); + let cht_root_1 = db.header_cht_root(cht_size, cht::start_number(cht_size, 0)).unwrap(); + let cht_root_2 = db.header_cht_root(cht_size, cht::start_number(cht_size, 0) + cht_size / 2).unwrap(); + let cht_root_3 = db.header_cht_root(cht_size, cht::end_number(cht_size, 0)).unwrap(); assert_eq!(cht_root_1, cht_root_2); assert_eq!(cht_root_2, cht_root_3); - let cht_root_1 = db.changes_trie_cht_root(cht::SIZE, cht::start_number(cht::SIZE, 0)).unwrap(); - let cht_root_2 = db.changes_trie_cht_root(cht::SIZE, (cht::start_number(cht::SIZE, 0) + cht::SIZE / 2) as u64).unwrap(); - let cht_root_3 = db.changes_trie_cht_root(cht::SIZE, cht::end_number(cht::SIZE, 0)).unwrap(); + let cht_root_1 = db.changes_trie_cht_root(cht_size, cht::start_number(cht_size, 0)).unwrap(); + let cht_root_2 = db.changes_trie_cht_root(cht_size, cht::start_number(cht_size, 0) + cht_size / 2).unwrap(); + let cht_root_3 = db.changes_trie_cht_root(cht_size, cht::end_number(cht_size, 0)).unwrap(); assert_eq!(cht_root_1, cht_root_2); assert_eq!(cht_root_2, cht_root_3); } diff --git a/core/client/src/backend.rs b/core/client/src/backend.rs index 09faab1a12..d2cc086ecd 100644 --- a/core/client/src/backend.rs +++ b/core/client/src/backend.rs @@ -127,7 +127,7 @@ pub trait Backend: AuxStore + Send + Sync where /// Associated state backend type. type State: StateBackend; /// Changes trie storage. - type ChangesTrieStorage: PrunableStateChangesTrieStorage; + type ChangesTrieStorage: PrunableStateChangesTrieStorage; /// Begin a new block insertion transaction with given parent block id. /// When constructing the genesis, this is called with all-zero hash. @@ -177,9 +177,15 @@ pub trait Backend: AuxStore + Send + Sync where } /// Changes trie storage that supports pruning. -pub trait PrunableStateChangesTrieStorage: StateChangesTrieStorage { +pub trait PrunableStateChangesTrieStorage: + StateChangesTrieStorage> +{ /// Get number block of oldest, non-pruned changes trie. - fn oldest_changes_trie_block(&self, config: &ChangesTrieConfiguration, best_finalized: u64) -> u64; + fn oldest_changes_trie_block( + &self, + config: &ChangesTrieConfiguration, + best_finalized: NumberFor, + ) -> NumberFor; } /// Mark for all Backend implementations, that are making use of state data, stored locally. diff --git a/core/client/src/cht.rs b/core/client/src/cht.rs index 42b4654d34..996a6b37f1 100644 --- a/core/client/src/cht.rs +++ b/core/client/src/cht.rs @@ -26,15 +26,11 @@ use std::collections::HashSet; use hash_db; +use parity_codec::Encode; use trie; use primitives::{H256, convert_hash}; -// We're using saturatedconversion in order to go back and forth to `u64`. this is stupid. -// instead we should just make the CHT generic over the block number. -use runtime_primitives::traits::{ - Header as HeaderT, SimpleArithmetic, One, SaturatedConversion, - UniqueSaturatedInto -}; +use runtime_primitives::traits::{Header as HeaderT, SimpleArithmetic, Zero, One}; use state_machine::backend::InMemory as InMemoryState; use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend}; @@ -43,14 +39,19 @@ use crate::error::{Error as ClientError, Result as ClientResult}; /// The size of each CHT. This value is passed to every CHT-related function from /// production code. Other values are passed from tests. -pub const SIZE: u64 = 2048; +const SIZE: u32 = 2048; + +/// Gets default CHT size. +pub fn size>() -> N { + SIZE.into() +} /// Returns Some(cht_number) if CHT is need to be built when the block with given number is canonized. -pub fn is_build_required(cht_size: u64, block_num: N) -> Option +pub fn is_build_required(cht_size: N, block_num: N) -> Option where N: Clone + SimpleArithmetic, { - let block_cht_num = block_to_cht_number(cht_size, block_num.clone())?; + let block_cht_num = block_to_cht_number(cht_size.clone(), block_num.clone())?; let two = N::one() + N::one(); if block_cht_num < two { return None; @@ -67,7 +68,7 @@ pub fn is_build_required(cht_size: u64, block_num: N) -> Option /// SIZE items. The items are assumed to proceed sequentially from `start_number(cht_num)`. /// Discards the trie's nodes. pub fn compute_root( - cht_size: u64, + cht_size: Header::Number, cht_num: Header::Number, hashes: I, ) -> ClientResult @@ -84,7 +85,7 @@ pub fn compute_root( /// Build CHT-based header proof. pub fn build_proof( - cht_size: u64, + cht_size: Header::Number, cht_num: Header::Number, blocks: BlocksI, hashes: HashesI @@ -175,7 +176,7 @@ fn do_check_proof( /// Group ordered blocks by CHT number and call functor with blocks of each group. pub fn for_each_cht_group( - cht_size: u64, + cht_size: Header::Number, blocks: I, mut functor: F, mut functor_param: P, @@ -188,7 +189,7 @@ pub fn for_each_cht_group( let mut current_cht_num = None; let mut current_cht_blocks = Vec::new(); for block in blocks { - let new_cht_num = match block_to_cht_number(cht_size, block.saturated_into()) { + let new_cht_num = match block_to_cht_number(cht_size, block) { Some(new_cht_num) => new_cht_num, None => return Err(ClientError::Backend(format!( "Cannot compute CHT root for the block #{}", block)).into() @@ -203,7 +204,7 @@ pub fn for_each_cht_group( functor_param = functor( functor_param, - current_cht_num.saturated_into(), + current_cht_num, ::std::mem::replace(&mut current_cht_blocks, Vec::new()), )?; } @@ -215,7 +216,7 @@ pub fn for_each_cht_group( if let Some(current_cht_num) = current_cht_num { functor( functor_param, - current_cht_num.saturated_into(), + current_cht_num, ::std::mem::replace(&mut current_cht_blocks, Vec::new()), )?; } @@ -225,7 +226,7 @@ pub fn for_each_cht_group( /// Build pairs for computing CHT. fn build_pairs( - cht_size: u64, + cht_size: Header::Number, cht_num: Header::Number, hashes: I ) -> ClientResult, Vec)>> @@ -235,28 +236,25 @@ fn build_pairs( { let start_num = start_number(cht_size, cht_num); let mut pairs = Vec::new(); - let mut hash_number = start_num; - for hash in hashes.into_iter().take(cht_size as usize) { + let mut hash_index = Header::Number::zero(); + for hash in hashes.into_iter() { let hash = hash?.ok_or_else(|| ClientError::from( - ClientError::MissingHashRequiredForCHT( - cht_num.saturated_into::(), - hash_number.saturated_into::() - ) + ClientError::MissingHashRequiredForCHT ))?; pairs.push(( - encode_cht_key(hash_number).to_vec(), + encode_cht_key(start_num + hash_index).to_vec(), encode_cht_value(hash) )); - hash_number += Header::Number::one(); + hash_index += Header::Number::one(); + if hash_index == cht_size { + break; + } } - if pairs.len() as u64 == cht_size { + if hash_index == cht_size { Ok(pairs) } else { - Err(ClientError::MissingHashRequiredForCHT( - cht_num.saturated_into::(), - hash_number.saturated_into::() - )) + Err(ClientError::MissingHashRequiredForCHT) } } @@ -266,39 +264,28 @@ fn build_pairs( /// More generally: CHT N includes block (1 + N*SIZE)...((N+1)*SIZE). /// This is because the genesis hash is assumed to be known /// and including it would be redundant. -pub fn start_number(cht_size: u64, cht_num: N) -> N { - (cht_num * cht_size.saturated_into()) + N::one() +pub fn start_number(cht_size: N, cht_num: N) -> N { + (cht_num * cht_size) + N::one() } /// Get the ending block of a given CHT. -pub fn end_number(cht_size: u64, cht_num: N) -> N { - (cht_num + N::one()) * cht_size.saturated_into() +pub fn end_number(cht_size: N, cht_num: N) -> N { + (cht_num + N::one()) * cht_size } /// Convert a block number to a CHT number. /// Returns `None` for `block_num` == 0, `Some` otherwise. -pub fn block_to_cht_number(cht_size: u64, block_num: N) -> Option { +pub fn block_to_cht_number(cht_size: N, block_num: N) -> Option { if block_num == N::zero() { None } else { - Some((block_num - N::one()) / cht_size.saturated_into()) + Some((block_num - N::one()) / cht_size) } } /// Convert header number into CHT key. -pub fn encode_cht_key>(number: N) -> Vec { - // why not just use Encode? - let number: u64 = number.saturated_into(); - vec![ - (number >> 56) as u8, - ((number >> 48) & 0xff) as u8, - ((number >> 40) & 0xff) as u8, - ((number >> 32) & 0xff) as u8, - ((number >> 24) & 0xff) as u8, - ((number >> 16) & 0xff) as u8, - ((number >> 8) & 0xff) as u8, - (number & 0xff) as u8 - ] +pub fn encode_cht_key(number: N) -> Vec { + number.encode() } /// Convert header hash into CHT value. @@ -323,8 +310,8 @@ mod tests { #[test] fn is_build_required_works() { - assert_eq!(is_build_required(SIZE, 0u64), None); - assert_eq!(is_build_required(SIZE, 1u64), None); + assert_eq!(is_build_required(SIZE, 0u32.into()), None); + assert_eq!(is_build_required(SIZE, 1u32.into()), None); assert_eq!(is_build_required(SIZE, SIZE), None); assert_eq!(is_build_required(SIZE, SIZE + 1), None); assert_eq!(is_build_required(SIZE, 2 * SIZE), None); @@ -335,73 +322,101 @@ mod tests { #[test] fn start_number_works() { - assert_eq!(start_number(SIZE, 0u64), 1u64); - assert_eq!(start_number(SIZE, 1u64), SIZE + 1); - assert_eq!(start_number(SIZE, 2u64), SIZE + SIZE + 1); + assert_eq!(start_number(SIZE, 0u32), 1u32); + assert_eq!(start_number(SIZE, 1u32), SIZE + 1); + assert_eq!(start_number(SIZE, 2u32), SIZE + SIZE + 1); } #[test] fn end_number_works() { - assert_eq!(end_number(SIZE, 0u64), SIZE); - assert_eq!(end_number(SIZE, 1u64), SIZE + SIZE); - assert_eq!(end_number(SIZE, 2u64), SIZE + SIZE + SIZE); + assert_eq!(end_number(SIZE, 0u32), SIZE); + assert_eq!(end_number(SIZE, 1u32), SIZE + SIZE); + assert_eq!(end_number(SIZE, 2u32), SIZE + SIZE + SIZE); } #[test] fn build_pairs_fails_when_no_enough_blocks() { - assert!(build_pairs::(SIZE, 0, + assert!(build_pairs::(SIZE as _, 0, ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize / 2)).is_err()); } #[test] fn build_pairs_fails_when_missing_block() { - assert!(build_pairs::(SIZE, 0, ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize / 2) - .chain(::std::iter::once(Ok(None))) - .chain(::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(2)))).take(SIZE as usize / 2 - 1))).is_err()); + assert!(build_pairs::( + SIZE as _, + 0, + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))) + .take(SIZE as usize / 2) + .chain(::std::iter::once(Ok(None))) + .chain(::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(2)))) + .take(SIZE as usize / 2 - 1)) + ).is_err()); } #[test] fn compute_root_works() { - assert!(compute_root::(SIZE, 42, - ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize)).is_ok()); + assert!(compute_root::( + SIZE as _, + 42, + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))) + .take(SIZE as usize) + ).is_ok()); } #[test] #[should_panic] fn build_proof_panics_when_querying_wrong_block() { assert!(build_proof::( - SIZE, 0, vec![(SIZE * 1000) as u64], - ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize)).is_err()); + SIZE as _, + 0, + vec![(SIZE * 1000) as u64], + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))) + .take(SIZE as usize) + ).is_err()); } #[test] fn build_proof_works() { assert!(build_proof::( - SIZE, 0, vec![(SIZE / 2) as u64], - ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))).take(SIZE as usize)).is_ok()); + SIZE as _, + 0, + vec![(SIZE / 2) as u64], + ::std::iter::repeat_with(|| Ok(Some(H256::from_low_u64_be(1)))) + .take(SIZE as usize) + ).is_ok()); } #[test] #[should_panic] fn for_each_cht_group_panics() { - let _ = for_each_cht_group::(SIZE, vec![SIZE * 5, SIZE * 2], |_, _, _| Ok(()), ()); + let cht_size = SIZE as u64; + let _ = for_each_cht_group::( + cht_size, + vec![cht_size * 5, cht_size * 2], + |_, _, _| Ok(()), + (), + ); } #[test] fn for_each_cht_group_works() { - let _ = for_each_cht_group::(SIZE, vec![ - SIZE * 2 + 1, SIZE * 2 + 2, SIZE * 2 + 5, - SIZE * 4 + 1, SIZE * 4 + 7, - SIZE * 6 + 1 - ], |_, cht_num, blocks| { - match cht_num { - 2 => assert_eq!(blocks, vec![SIZE * 2 + 1, SIZE * 2 + 2, SIZE * 2 + 5]), - 4 => assert_eq!(blocks, vec![SIZE * 4 + 1, SIZE * 4 + 7]), - 6 => assert_eq!(blocks, vec![SIZE * 6 + 1]), - _ => unreachable!(), - } - - Ok(()) - }, ()); + let cht_size = SIZE as u64; + let _ = for_each_cht_group::( + cht_size, + vec![ + cht_size * 2 + 1, cht_size * 2 + 2, cht_size * 2 + 5, + cht_size * 4 + 1, cht_size * 4 + 7, + cht_size * 6 + 1 + ], |_, cht_num, blocks| { + match cht_num { + 2 => assert_eq!(blocks, vec![cht_size * 2 + 1, cht_size * 2 + 2, cht_size * 2 + 5]), + 4 => assert_eq!(blocks, vec![cht_size * 4 + 1, cht_size * 4 + 7]), + 6 => assert_eq!(blocks, vec![cht_size * 6 + 1]), + _ => unreachable!(), + } + + Ok(()) + }, () + ); } } diff --git a/core/client/src/client.rs b/core/client/src/client.rs index a7e1e18847..f36992a14e 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -448,7 +448,7 @@ impl Client where /// Reads given header and generates CHT-based header proof. pub fn header_proof(&self, id: &BlockId) -> error::Result<(Block::Header, Vec>)> { - self.header_proof_with_cht_size(id, cht::SIZE) + self.header_proof_with_cht_size(id, cht::size()) } /// Get block hash by number. @@ -459,16 +459,23 @@ impl Client where } /// Reads given header and generates CHT-based header proof for CHT of given size. - pub fn header_proof_with_cht_size(&self, + pub fn header_proof_with_cht_size( + &self, id: &BlockId, - cht_size: u64 + cht_size: NumberFor, ) -> error::Result<(Block::Header, Vec>)> { let proof_error = || error::Error::Backend(format!("Failed to generate header proof for {:?}", id)); let header = self.backend.blockchain().expect_header(*id)?; let block_num = *header.number(); let cht_num = cht::block_to_cht_number(cht_size, block_num).ok_or_else(proof_error)?; let cht_start = cht::start_number(cht_size, cht_num); - let headers = (cht_start.saturated_into()..).map(|num| self.block_hash(num.saturated_into())); + let mut current_num = cht_start; + let cht_range = ::std::iter::from_fn(|| { + let old_current_num = current_num; + current_num = current_num + One::one(); + Some(old_current_num) + }); + let headers = cht_range.map(|num| self.block_hash(num)); let proof = cht::build_proof::(cht_size, cht_num, ::std::iter::once(block_num), headers)?; Ok((header, proof)) } @@ -486,14 +493,13 @@ impl Client where Some((config, storage)) => (config, storage), None => return Ok(None), }; - let first = first.saturated_into::(); - let last_num = self.backend.blockchain().expect_block_number_from_id(&last)?.saturated_into::(); + let last_num = self.backend.blockchain().expect_block_number_from_id(&last)?; if first > last_num { return Err(error::Error::ChangesTrieAccessFailed("Invalid changes trie range".into())); } let finalized_number = self.backend.blockchain().info()?.finalized_number; - let oldest = storage.oldest_changes_trie_block(&config, finalized_number.saturated_into::()); - let first = ::std::cmp::max(first, oldest).saturated_into::>(); + let oldest = storage.oldest_changes_trie_block(&config, finalized_number); + let first = ::std::cmp::max(first, oldest); Ok(Some((first, last))) } @@ -506,20 +512,20 @@ impl Client where key: &StorageKey ) -> error::Result, u32)>> { let (config, storage) = self.require_changes_trie()?; - let last_number = self.backend.blockchain().expect_block_number_from_id(&last)?.saturated_into::(); + let last_number = self.backend.blockchain().expect_block_number_from_id(&last)?; let last_hash = self.backend.blockchain().expect_block_hash_from_id(&last)?; - key_changes::<_, Blake2Hasher>( + key_changes::<_, Blake2Hasher, _>( &config, &*storage, - first.saturated_into::(), + first, &ChangesTrieAnchorBlockId { hash: convert_hash(&last_hash), number: last_number, }, - self.backend.blockchain().info()?.best_number.saturated_into::(), + self.backend.blockchain().info()?.best_number, &key.0) - .and_then(|r| r.map(|r| r.map(|(block, tx)| (block.saturated_into(), tx))).collect::>()) + .and_then(|r| r.map(|r| r.map(|(block, tx)| (block, tx))).collect::>()) .map_err(|err| error::Error::ChangesTrieAccessFailed(err)) } @@ -543,7 +549,7 @@ impl Client where min, max, key, - cht::SIZE, + cht::size(), ) } @@ -555,21 +561,29 @@ impl Client where min: Block::Hash, max: Block::Hash, key: &StorageKey, - cht_size: u64, + cht_size: NumberFor, ) -> error::Result> { struct AccessedRootsRecorder<'a, Block: BlockT> { - storage: &'a ChangesTrieStorage, - min: u64, + storage: &'a ChangesTrieStorage>, + min: NumberFor, required_roots_proofs: Mutex, H256>>, }; - impl<'a, Block: BlockT> ChangesTrieRootsStorage for AccessedRootsRecorder<'a, Block> { - fn root(&self, anchor: &ChangesTrieAnchorBlockId, block: u64) -> Result, String> { + impl<'a, Block: BlockT> ChangesTrieRootsStorage> for AccessedRootsRecorder<'a, Block> { + fn build_anchor(&self, hash: H256) -> Result>, String> { + self.storage.build_anchor(hash) + } + + fn root( + &self, + anchor: &ChangesTrieAnchorBlockId>, + block: NumberFor, + ) -> Result, String> { let root = self.storage.root(anchor, block)?; if block < self.min { if let Some(ref root) = root { self.required_roots_proofs.lock().insert( - block.saturated_into(), + block, root.clone() ); } @@ -578,7 +592,7 @@ impl Client where } } - impl<'a, Block: BlockT> ChangesTrieStorage for AccessedRootsRecorder<'a, Block> { + impl<'a, Block: BlockT> ChangesTrieStorage> for AccessedRootsRecorder<'a, Block> { fn get(&self, key: &H256, prefix: &[u8]) -> Result, String> { self.storage.get(key, prefix) } @@ -589,7 +603,7 @@ impl Client where let recording_storage = AccessedRootsRecorder:: { storage, - min: min_number.saturated_into::(), + min: min_number, required_roots_proofs: Mutex::new(BTreeMap::new()), }; @@ -600,12 +614,10 @@ impl Client where // fetch key changes proof let first_number = self.backend.blockchain() - .expect_block_number_from_id(&BlockId::Hash(first))? - .saturated_into::(); + .expect_block_number_from_id(&BlockId::Hash(first))?; let last_number = self.backend.blockchain() - .expect_block_number_from_id(&BlockId::Hash(last))? - .saturated_into::(); - let key_changes_proof = key_changes_proof::<_, Blake2Hasher>( + .expect_block_number_from_id(&BlockId::Hash(last))?; + let key_changes_proof = key_changes_proof::<_, Blake2Hasher, _>( &config, &recording_storage, first_number, @@ -613,7 +625,7 @@ impl Client where hash: convert_hash(&last), number: last_number, }, - max_number.saturated_into::(), + max_number, &key.0 ) .map_err(|err| error::Error::from(error::Error::ChangesTrieAccessFailed(err)))?; @@ -634,7 +646,7 @@ impl Client where /// Generate CHT-based proof for roots of changes tries at given blocks. fn changes_trie_roots_proof>>( &self, - cht_size: u64, + cht_size: NumberFor, blocks: I ) -> error::Result>> { // most probably we have touched several changes tries that are parts of the single CHT @@ -653,12 +665,19 @@ impl Client where /// Generates CHT-based proof for roots of changes tries at given blocks (that are part of single CHT). fn changes_trie_roots_proof_at_cht( &self, - cht_size: u64, + cht_size: NumberFor, cht_num: NumberFor, blocks: Vec> ) -> error::Result>> { let cht_start = cht::start_number(cht_size, cht_num); - let roots = (cht_start.saturated_into()..).map(|num| self.header(&BlockId::Number(num.saturated_into())) + let mut current_num = cht_start; + let cht_range = ::std::iter::from_fn(|| { + let old_current_num = current_num; + current_num = current_num + One::one(); + Some(old_current_num) + }); + let roots = cht_range + .map(|num| self.header(&BlockId::Number(num)) .map(|block| block.and_then(|block| block.digest().log(DigestItem::as_changes_trie_root).cloned()))); let proof = cht::build_proof::(cht_size, cht_num, blocks, roots)?; Ok(proof) diff --git a/core/client/src/error.rs b/core/client/src/error.rs index b201c092e0..bad279f2e4 100644 --- a/core/client/src/error.rs +++ b/core/client/src/error.rs @@ -92,8 +92,8 @@ pub enum Error { #[display(fmt = "Potential long-range attack: block not in finalized chain.")] NotInFinalizedChain, /// Hash that is required for building CHT is missing. - #[display(fmt = "Failed to get hash of block#{} for building CHT#{}", _0, _1)] - MissingHashRequiredForCHT(u64, u64), + #[display(fmt = "Failed to get hash of block for building CHT")] + MissingHashRequiredForCHT, /// A convenience variant for String #[display(fmt = "{}", _0)] Msg(String), diff --git a/core/client/src/genesis.rs b/core/client/src/genesis.rs index 74bc74360a..73bd1e0368 100644 --- a/core/client/src/genesis.rs +++ b/core/client/src/genesis.rs @@ -84,7 +84,7 @@ mod tests { state_machine::new( backend, - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::<_, u64>::new()), state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), @@ -97,7 +97,7 @@ mod tests { for tx in transactions.iter() { state_machine::new( backend, - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::<_, u64>::new()), state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), @@ -110,7 +110,7 @@ mod tests { let (ret_data, _, _) = state_machine::new( backend, - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::<_, u64>::new()), state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), @@ -157,7 +157,7 @@ mod tests { let mut overlay = OverlayedChanges::default(); let _ = state_machine::new( &backend, - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::<_, u64>::new()), state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), @@ -186,7 +186,7 @@ mod tests { let mut overlay = OverlayedChanges::default(); let _ = state_machine::new( &backend, - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::<_, u64>::new()), state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), @@ -215,7 +215,7 @@ mod tests { let mut overlay = OverlayedChanges::default(); let r = state_machine::new( &backend, - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::<_, u64>::new()), state_machine::NeverOffchainExt::new(), &mut overlay, &Executor::new(None), diff --git a/core/client/src/in_mem.rs b/core/client/src/in_mem.rs index 558643e887..1172939b34 100644 --- a/core/client/src/in_mem.rs +++ b/core/client/src/in_mem.rs @@ -23,7 +23,7 @@ use primitives::{ChangesTrieConfiguration, storage::well_known_keys}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, Zero, - NumberFor, SaturatedConversion, Digest, DigestItem + NumberFor, Digest, DigestItem }; use runtime_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay}; use state_machine::backend::{Backend as StateBackend, InMemory}; @@ -415,12 +415,20 @@ impl light::blockchain::Storage for Blockchain Blockchain::finalize_header(self, id, None) } - fn header_cht_root(&self, _cht_size: u64, block: NumberFor) -> error::Result { + fn header_cht_root( + &self, + _cht_size: NumberFor, + block: NumberFor, + ) -> error::Result { self.storage.read().header_cht_roots.get(&block).cloned() .ok_or_else(|| error::Error::Backend(format!("Header CHT for block {} not exists", block))) } - fn changes_trie_cht_root(&self, _cht_size: u64, block: NumberFor) -> error::Result { + fn changes_trie_cht_root( + &self, + _cht_size: NumberFor, + block: NumberFor, + ) -> error::Result { self.storage.read().changes_trie_cht_roots.get(&block).cloned() .ok_or_else(|| error::Error::Backend(format!("Changes trie CHT for block {} not exists", block))) } @@ -531,7 +539,7 @@ where H::Out: Ord, { states: RwLock>>, - changes_trie_storage: ChangesTrieStorage, + changes_trie_storage: ChangesTrieStorage, blockchain: Blockchain, } @@ -581,7 +589,7 @@ where type BlockImportOperation = BlockImportOperation; type Blockchain = Blockchain; type State = InMemory; - type ChangesTrieStorage = ChangesTrieStorage; + type ChangesTrieStorage = ChangesTrieStorage; fn begin_operation(&self) -> error::Result { let old_state = self.state_at(BlockId::Hash(Default::default()))?; @@ -622,7 +630,7 @@ where if let Some(changes_trie_update) = operation.changes_trie_update { let changes_trie_root: H::Out = changes_trie_root.into(); self.changes_trie_storage.0.insert( - (*header.number()).saturated_into::(), + *header.number(), changes_trie_root, changes_trie_update ); @@ -699,22 +707,45 @@ where } /// Prunable in-memory changes trie storage. -pub struct ChangesTrieStorage(InMemoryChangesTrieStorage); -impl backend::PrunableStateChangesTrieStorage for ChangesTrieStorage { - fn oldest_changes_trie_block(&self, _config: &ChangesTrieConfiguration, _best_finalized: u64) -> u64 { - 0 +pub struct ChangesTrieStorage(InMemoryChangesTrieStorage>); +impl backend::PrunableStateChangesTrieStorage for ChangesTrieStorage { + fn oldest_changes_trie_block( + &self, + _config: &ChangesTrieConfiguration, + _best_finalized: NumberFor, + ) -> NumberFor { + Zero::zero() } } -impl state_machine::ChangesTrieRootsStorage for ChangesTrieStorage { - fn root(&self, anchor: &ChangesTrieAnchorBlockId, block: u64) -> Result, String> { - self.0.root(anchor, block) +impl state_machine::ChangesTrieRootsStorage> for ChangesTrieStorage + where + Block: BlockT, + H: Hasher, +{ + fn build_anchor( + &self, + _hash: H::Out, + ) -> Result>, String> { + Err("Dummy implementation".into()) + } + + fn root( + &self, + _anchor: &ChangesTrieAnchorBlockId>, + _block: NumberFor, + ) -> Result, String> { + Err("Dummy implementation".into()) } } -impl state_machine::ChangesTrieStorage for ChangesTrieStorage { - fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String> { - self.0.get(key, prefix) +impl state_machine::ChangesTrieStorage> for ChangesTrieStorage + where + Block: BlockT, + H: Hasher, +{ + fn get(&self, _key: &H::Out, _prefix: &[u8]) -> Result, String> { + Err("Dummy implementation".into()) } } diff --git a/core/client/src/light/backend.rs b/core/client/src/light/backend.rs index 0579c8c8d4..bf5eb11f26 100644 --- a/core/client/src/light/backend.rs +++ b/core/client/src/light/backend.rs @@ -112,7 +112,7 @@ impl ClientBackend for Backend where type BlockImportOperation = ImportOperation; type Blockchain = Blockchain; type State = OnDemandOrGenesisState; - type ChangesTrieStorage = in_mem::ChangesTrieStorage; + type ChangesTrieStorage = in_mem::ChangesTrieStorage; fn begin_operation(&self) -> ClientResult { Ok(ImportOperation { diff --git a/core/client/src/light/blockchain.rs b/core/client/src/light/blockchain.rs index d7fcd44232..b231f7e8aa 100644 --- a/core/client/src/light/blockchain.rs +++ b/core/client/src/light/blockchain.rs @@ -56,10 +56,18 @@ pub trait Storage: AuxStore + BlockchainHeaderBackend { fn last_finalized(&self) -> ClientResult; /// Get headers CHT root for given block. Fails if the block is not pruned (not a part of any CHT). - fn header_cht_root(&self, cht_size: u64, block: NumberFor) -> ClientResult; + fn header_cht_root( + &self, + cht_size: NumberFor, + block: NumberFor, + ) -> ClientResult; /// Get changes trie CHT root for given block. Fails if the block is not pruned (not a part of any CHT). - fn changes_trie_cht_root(&self, cht_size: u64, block: NumberFor) -> ClientResult; + fn changes_trie_cht_root( + &self, + cht_size: NumberFor, + block: NumberFor, + ) -> ClientResult; /// Get storage cache. fn cache(&self) -> Option>>; @@ -116,7 +124,7 @@ impl BlockchainHeaderBackend for Blockchain where Bloc self.fetcher().upgrade().ok_or(ClientError::NotAvailableOnLightClient)? .remote_header(RemoteHeaderRequest { - cht_root: self.storage.header_cht_root(cht::SIZE, number)?, + cht_root: self.storage.header_cht_root(cht::size(), number)?, block: number, retry_count: None, }) diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index a45a166674..982f106f2a 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -435,7 +435,7 @@ pub fn check_execution_proof( Header: HeaderT, E: CodeExecutor, H: Hasher, - H::Out: Ord, + H::Out: Ord + 'static, { let local_state_root = request.header.state_root(); let root: H::Out = convert_hash(&local_state_root); diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index 29fd6f4c39..39563aa83c 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -22,11 +22,11 @@ use std::marker::PhantomData; use futures::IntoFuture; use hash_db::{HashDB, Hasher}; -use parity_codec::Encode; +use parity_codec::{Decode, Encode}; use primitives::{ChangesTrieConfiguration, convert_hash}; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor, - UniqueSaturatedInto, UniqueSaturatedFrom, SaturatedConversion + SimpleArithmetic, CheckedConversion, }; use state_machine::{CodeExecutor, ChangesTrieRootsStorage, ChangesTrieAnchorBlockId, TrieBackend, read_proof_check, key_changes_proof_check, @@ -236,7 +236,7 @@ impl, F> LightDataChecker, remote_proof: ChangesProof, - cht_size: u64, + cht_size: NumberFor, ) -> ClientResult, u32)>> where H: Hasher, @@ -284,30 +284,27 @@ impl, F> LightDataChecker( + key_changes_proof_check::<_, H, _>( &request.changes_trie_config, &RootsStorage { roots: (request.tries_roots.0, &request.tries_roots.2), prev_roots: remote_roots, }, remote_proof, - request.first_block.0.saturated_into::(), + request.first_block.0, &ChangesTrieAnchorBlockId { hash: convert_hash(&request.last_block.1), - number: request.last_block.0.saturated_into::(), + number: request.last_block.0, }, - remote_max_block.saturated_into::(), + remote_max_block, &request.key) - .map(|pairs| pairs.into_iter().map(|(b, x)| - (b.saturated_into::>(), x) - ).collect()) .map_err(|err| ClientError::ChangesTrieAccessFailed(err)) } /// Check CHT-based proof for changes tries roots. fn check_changes_tries_proof( &self, - cht_size: u64, + cht_size: NumberFor, remote_roots: &BTreeMap, B::Hash>, remote_roots_proof: Vec>, ) -> ClientResult<()> @@ -363,7 +360,7 @@ impl FetchChecker for LightDataChecker, H: Hasher, - H::Out: Ord, + H::Out: Ord + 'static, S: BlockchainStorage, F: Send + Sync, { @@ -419,7 +416,7 @@ impl FetchChecker for LightDataChecker, remote_proof: ChangesProof ) -> ClientResult, u32)>> { - self.check_changes_proof_with_cht_size(request, remote_proof, cht::SIZE) + self.check_changes_proof_with_cht_size(request, remote_proof, cht::size()) } fn check_body_proof( @@ -443,26 +440,38 @@ impl FetchChecker for LightDataChecker as a changes trie roots storage. -struct RootsStorage<'a, Number: UniqueSaturatedInto + UniqueSaturatedFrom, Hash: 'a> { +struct RootsStorage<'a, Number: SimpleArithmetic, Hash: 'a> { roots: (Number, &'a [Hash]), prev_roots: BTreeMap, } -impl<'a, H, Number, Hash> ChangesTrieRootsStorage for RootsStorage<'a, Number, Hash> +impl<'a, H, Number, Hash> ChangesTrieRootsStorage for RootsStorage<'a, Number, Hash> where H: Hasher, - Number: Send + Sync + Eq + ::std::cmp::Ord + Copy + UniqueSaturatedInto - + UniqueSaturatedFrom, + Number: ::std::fmt::Display + Clone + SimpleArithmetic + Encode + Decode + Send + Sync + 'static, Hash: 'a + Send + Sync + Clone + AsRef<[u8]>, { - fn root(&self, _anchor: &ChangesTrieAnchorBlockId, block: u64) -> Result, String> { + fn build_anchor( + &self, + _hash: H::Out, + ) -> Result, String> { + Err("build_anchor is only called when building block".into()) + } + + fn root( + &self, + _anchor: &ChangesTrieAnchorBlockId, + block: Number, + ) -> Result, String> { // we can't ask for roots from parallel forks here => ignore anchor - let root = if block < self.roots.0.saturated_into::() { + let root = if block < self.roots.0 { self.prev_roots.get(&Number::unique_saturated_from(block)).cloned() } else { - block.checked_sub(self.roots.0.saturated_into::()) - .and_then(|index| self.roots.1.get(index as usize)) - .cloned() + let index: Option = block.checked_sub(&self.roots.0).and_then(|index| index.checked_into()); + match index { + Some(index) => self.roots.1.get(index as usize).cloned(), + None => None, + } }; Ok(root.map(|root| { diff --git a/core/executor/src/sandbox.rs b/core/executor/src/sandbox.rs index 24c8ad66ea..377294f7b1 100644 --- a/core/executor/src/sandbox.rs +++ b/core/executor/src/sandbox.rs @@ -569,9 +569,11 @@ mod tests { use crate::allocator; use crate::sandbox::trap; use crate::wasm_executor::WasmExecutor; - use state_machine::TestExternalities; + use state_machine::TestExternalities as CoreTestExternalities; use wabt; + type TestExternalities = CoreTestExternalities; + #[test] fn sandbox_should_work() { let mut ext = TestExternalities::::default(); diff --git a/core/executor/src/wasm_executor.rs b/core/executor/src/wasm_executor.rs index 988b6ddcf3..bed60666f7 100644 --- a/core/executor/src/wasm_executor.rs +++ b/core/executor/src/wasm_executor.rs @@ -414,7 +414,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, .map_err(|_| UserError("Invalid attempt to write written_out in ext_child_storage_root"))?; Ok(offset) }, - ext_storage_changes_root(parent_hash_data: *const u8, parent_hash_len: u32, parent_number: u64, result: *mut u8) -> u32 => { + ext_storage_changes_root(parent_hash_data: *const u8, parent_hash_len: u32, result: *mut u8) -> u32 => { let mut parent_hash = H256::default(); if parent_hash_len != parent_hash.as_ref().len() as u32 { return Err(UserError("Invalid parent_hash_len in ext_storage_changes_root").into()); @@ -422,7 +422,8 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, let raw_parent_hash = this.memory.get(parent_hash_data, parent_hash_len as usize) .map_err(|_| UserError("Invalid attempt to get parent_hash in ext_storage_changes_root"))?; parent_hash.as_mut().copy_from_slice(&raw_parent_hash[..]); - let r = this.ext.storage_changes_root(parent_hash, parent_number); + let r = this.ext.storage_changes_root(parent_hash) + .map_err(|_| UserError("Invaid parent_hash passed to ext_storage_changes_root"))?; if let Some(r) = r { this.memory.set(result, &r[..]).map_err(|_| UserError("Invalid attempt to set memory in ext_storage_changes_root"))?; Ok(1) @@ -896,10 +897,12 @@ mod tests { use parity_codec::Encode; - use state_machine::TestExternalities; + use state_machine::TestExternalities as CoreTestExternalities; use hex_literal::hex; use primitives::map; + type TestExternalities = CoreTestExternalities; + #[test] fn returning_should_work() { let mut ext = TestExternalities::default(); diff --git a/core/executor/wasm/Cargo.lock b/core/executor/wasm/Cargo.lock index b65d8e0869..8c53b790d8 100644 --- a/core/executor/wasm/Cargo.lock +++ b/core/executor/wasm/Cargo.lock @@ -8,6 +8,11 @@ dependencies = [ "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byteorder" version = "1.3.1" @@ -52,6 +57,14 @@ name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parity-codec" version = "3.5.1" @@ -186,6 +199,7 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -227,6 +241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" "checksum fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a557e80084b05c32b455963ff565a9de6f2866da023d6671705c6aff6f65e01c" @@ -234,6 +249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1224388a21c88a80ae7087a2a245ca6d80acc97a9186b75789fb3eeefd0609af" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" "checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index 8eb62ddf84..0875de55b7 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -25,7 +25,8 @@ sha2 = { version = "0.8", optional = true } substrate-bip39 = { git = "https://github.com/paritytech/substrate-bip39", optional = true } tiny-bip39 = { version = "0.6.1", optional = true } hex = { version = "0.3", optional = true } -regex = {version = "1.1", optional = true } +regex = { version = "1.1", optional = true } +num-traits = { version = "0.2", default-features = false } [dev-dependencies] substrate-serializer = { path = "../serializer" } @@ -71,4 +72,5 @@ std = [ "sha2", "schnorrkel", "regex", + "num-traits/std", ] diff --git a/core/primitives/src/changes_trie.rs b/core/primitives/src/changes_trie.rs index 2fa11f5641..eb6a75454f 100644 --- a/core/primitives/src/changes_trie.rs +++ b/core/primitives/src/changes_trie.rs @@ -19,6 +19,7 @@ #[cfg(any(feature = "std", test))] use serde::{Serialize, Deserialize}; use parity_codec::{Encode, Decode}; +use num_traits::Zero; /// Substrate changes trie configuration. #[cfg_attr(any(feature = "std", test), derive(Serialize, Deserialize))] @@ -26,10 +27,14 @@ use parity_codec::{Encode, Decode}; pub struct ChangesTrieConfiguration { /// Interval (in blocks) at which level1-digests are created. Digests are not /// created when this is less or equal to 1. - pub digest_interval: u64, + pub digest_interval: u32, /// Maximal number of digest levels in hierarchy. 0 means that digests are not /// created at all (even level1 digests). 1 means only level1-digests are created. /// 2 means that every digest_interval^2 there will be a level2-digest, and so on. + /// Please ensure that maximum digest interval (i.e. digest_interval^digest_levels) + /// is within `u32` limits. Otherwise you'll never see digests covering such intervals + /// && maximal digests interval will be truncated to the last interval that fits + /// `u32` limits. pub digest_levels: u32, } @@ -40,20 +45,30 @@ impl ChangesTrieConfiguration { } /// Do we need to build digest at given block? - pub fn is_digest_build_required_at_block(&self, block: u64) -> bool { - block != 0 + pub fn is_digest_build_required_at_block(&self, block: Number) -> bool + where + Number: From + PartialEq + ::rstd::ops::Rem + Zero, + { + block != 0.into() && self.is_digest_build_enabled() - && block % self.digest_interval == 0 + && (block % self.digest_interval.into()).is_zero() } /// Returns max digest interval. One if digests are not created at all. - /// Returns ::std::u64::MAX instead of panic in the case of overflow. - pub fn max_digest_interval(&self) -> u64 { + pub fn max_digest_interval(&self) -> u32 { if !self.is_digest_build_enabled() { return 1; } - self.digest_interval.saturating_pow(self.digest_levels) + // we'll get >1 loop iteration only when bad configuration parameters are selected + let mut current_level = self.digest_levels; + loop { + if let Some(max_digest_interval) = self.digest_interval.checked_pow(current_level) { + return max_digest_interval; + } + + current_level = current_level - 1; + } } /// Returns Some if digest must be built at given block number. @@ -63,17 +78,21 @@ impl ChangesTrieConfiguration { /// digest interval (in blocks) /// step between blocks we're interested in when digest is built /// ) - pub fn digest_level_at_block(&self, block: u64) -> Option<(u32, u64, u64)> { - if !self.is_digest_build_required_at_block(block) { + pub fn digest_level_at_block(&self, block: Number) -> Option<(u32, u32, u32)> + where + Number: Clone + From + PartialEq + ::rstd::ops::Rem + Zero, + { + if !self.is_digest_build_required_at_block(block.clone()) { return None; } let mut digest_interval = self.digest_interval; let mut current_level = 1u32; - let mut digest_step = 1u64; + let mut digest_step = 1u32; while current_level < self.digest_levels { let new_digest_interval = match digest_interval.checked_mul(self.digest_interval) { - Some(new_digest_interval) if block % new_digest_interval == 0 => new_digest_interval, + Some(new_digest_interval) if (block.clone() % new_digest_interval.into()).is_zero() + => new_digest_interval, _ => break, }; @@ -94,7 +113,7 @@ impl ChangesTrieConfiguration { mod tests { use super::ChangesTrieConfiguration; - fn config(interval: u64, levels: u32) -> ChangesTrieConfiguration { + fn config(interval: u32, levels: u32) -> ChangesTrieConfiguration { ChangesTrieConfiguration { digest_interval: interval, digest_levels: levels, @@ -112,31 +131,31 @@ mod tests { #[test] fn is_digest_build_required_at_block_works() { - assert!(!config(8, 4).is_digest_build_required_at_block(0)); - assert!(!config(8, 4).is_digest_build_required_at_block(1)); - assert!(!config(8, 4).is_digest_build_required_at_block(2)); - assert!(!config(8, 4).is_digest_build_required_at_block(4)); - assert!(config(8, 4).is_digest_build_required_at_block(8)); - assert!(!config(8, 4).is_digest_build_required_at_block(9)); - assert!(config(8, 4).is_digest_build_required_at_block(64)); - assert!(config(8, 4).is_digest_build_required_at_block(64)); - assert!(config(8, 4).is_digest_build_required_at_block(512)); - assert!(config(8, 4).is_digest_build_required_at_block(4096)); - assert!(!config(8, 4).is_digest_build_required_at_block(4103)); - assert!(config(8, 4).is_digest_build_required_at_block(4104)); - assert!(!config(8, 4).is_digest_build_required_at_block(4108)); + assert!(!config(8, 4).is_digest_build_required_at_block(0u64)); + assert!(!config(8, 4).is_digest_build_required_at_block(1u64)); + assert!(!config(8, 4).is_digest_build_required_at_block(2u64)); + assert!(!config(8, 4).is_digest_build_required_at_block(4u64)); + assert!(config(8, 4).is_digest_build_required_at_block(8u64)); + assert!(!config(8, 4).is_digest_build_required_at_block(9u64)); + assert!(config(8, 4).is_digest_build_required_at_block(64u64)); + assert!(config(8, 4).is_digest_build_required_at_block(64u64)); + assert!(config(8, 4).is_digest_build_required_at_block(512u64)); + assert!(config(8, 4).is_digest_build_required_at_block(4096u64)); + assert!(!config(8, 4).is_digest_build_required_at_block(4103u64)); + assert!(config(8, 4).is_digest_build_required_at_block(4104u64)); + assert!(!config(8, 4).is_digest_build_required_at_block(4108u64)); } #[test] fn digest_level_at_block_works() { - assert_eq!(config(8, 4).digest_level_at_block(0), None); - assert_eq!(config(8, 4).digest_level_at_block(7), None); - assert_eq!(config(8, 4).digest_level_at_block(63), None); - assert_eq!(config(8, 4).digest_level_at_block(8), Some((1, 8, 1))); - assert_eq!(config(8, 4).digest_level_at_block(64), Some((2, 64, 8))); - assert_eq!(config(8, 4).digest_level_at_block(512), Some((3, 512, 64))); - assert_eq!(config(8, 4).digest_level_at_block(4096), Some((4, 4096, 512))); - assert_eq!(config(8, 4).digest_level_at_block(4112), Some((1, 8, 1))); + assert_eq!(config(8, 4).digest_level_at_block(0u64), None); + assert_eq!(config(8, 4).digest_level_at_block(7u64), None); + assert_eq!(config(8, 4).digest_level_at_block(63u64), None); + assert_eq!(config(8, 4).digest_level_at_block(8u64), Some((1, 8, 1))); + assert_eq!(config(8, 4).digest_level_at_block(64u64), Some((2, 64, 8))); + assert_eq!(config(8, 4).digest_level_at_block(512u64), Some((3, 512, 64))); + assert_eq!(config(8, 4).digest_level_at_block(4096u64), Some((4, 4096, 512))); + assert_eq!(config(8, 4).digest_level_at_block(4112u64), Some((1, 8, 1))); } #[test] @@ -144,6 +163,6 @@ mod tests { assert_eq!(config(0, 0).max_digest_interval(), 1); assert_eq!(config(2, 2).max_digest_interval(), 4); assert_eq!(config(8, 4).max_digest_interval(), 4096); - assert_eq!(config(::std::u64::MAX, 1024).max_digest_interval(), ::std::u64::MAX); + assert_eq!(config(::std::u32::MAX, 1024).max_digest_interval(), ::std::u32::MAX); } } diff --git a/core/sr-io/src/lib.rs b/core/sr-io/src/lib.rs index 47af4de98b..314aa3b61e 100644 --- a/core/sr-io/src/lib.rs +++ b/core/sr-io/src/lib.rs @@ -138,7 +138,7 @@ export_api! { fn child_storage_root(storage_key: &[u8]) -> Vec; /// "Commit" all existing operations and get the resultant storage change root. - fn storage_changes_root(parent_hash: [u8; 32], parent_num: u64) -> Option<[u8; 32]>; + fn storage_changes_root(parent_hash: [u8; 32]) -> Option<[u8; 32]>; /// A trie root formed from the enumerated items. /// TODO [#2382] remove (just use `ordered_trie_root` (NOTE currently not implemented for without_std)) @@ -251,6 +251,10 @@ mod imp { } #[cfg(feature = "std")] -pub use self::imp::{StorageOverlay, ChildrenStorageOverlay, with_storage, with_externalities, TestExternalities}; +pub use self::imp::{StorageOverlay, ChildrenStorageOverlay, with_storage, with_externalities}; #[cfg(not(feature = "std"))] pub use self::imp::ext::*; + +/// Type alias for Externalities implementation used in tests. +#[cfg(feature = "std")] +pub type TestExternalities = self::imp::TestExternalities; diff --git a/core/sr-io/with_std.rs b/core/sr-io/with_std.rs index d73ccf4b66..1bc0141c1d 100644 --- a/core/sr-io/with_std.rs +++ b/core/sr-io/with_std.rs @@ -158,10 +158,10 @@ impl StorageApi for () { }).expect("child_storage_root cannot be called outside of an Externalities-provided environment.") } - fn storage_changes_root(parent_hash: [u8; 32], parent_num: u64) -> Option<[u8; 32]> { + fn storage_changes_root(parent_hash: [u8; 32]) -> Option<[u8; 32]> { ext::with(|ext| - ext.storage_changes_root(parent_hash.into(), parent_num).map(Into::into) - ).unwrap_or(None) + ext.storage_changes_root(parent_hash.into()).map(|h| h.map(|h| h.into())) + ).unwrap_or(Ok(None)).expect("Invalid parent hash passed to storage_changes_root") } fn enumerated_trie_root(input: &[&[u8]]) -> H::Out diff --git a/core/sr-io/without_std.rs b/core/sr-io/without_std.rs index 2f2b482f5e..de87aeddbd 100644 --- a/core/sr-io/without_std.rs +++ b/core/sr-io/without_std.rs @@ -242,7 +242,7 @@ pub mod ext { /// /// - `1` if the change trie root was found. /// - `0` if the change trie root was not found. - fn ext_storage_changes_root(parent_hash_data: *const u8, parent_hash_len: u32, parent_num: u64, result: *mut u8) -> u32; + fn ext_storage_changes_root(parent_hash_data: *const u8, parent_hash_len: u32, result: *mut u8) -> u32; /// A child storage function. /// @@ -498,10 +498,10 @@ impl StorageApi for () { } } - fn storage_changes_root(parent_hash: [u8; 32], parent_num: u64) -> Option<[u8; 32]> { + fn storage_changes_root(parent_hash: [u8; 32]) -> Option<[u8; 32]> { let mut result: [u8; 32] = Default::default(); let is_set = unsafe { - ext_storage_changes_root.get()(parent_hash.as_ptr(), parent_hash.len() as u32, parent_num, result.as_mut_ptr()) + ext_storage_changes_root.get()(parent_hash.as_ptr(), parent_hash.len() as u32, result.as_mut_ptr()) }; if is_set != 0 { diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index 8906bbf074..dcfe8ffd24 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -435,7 +435,7 @@ pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq { // Stup fn storage_root() -> Self::Output; /// Acquire the global storage changes root. - fn storage_changes_root(parent_hash: Self::Output, parent_number: u64) -> Option; + fn storage_changes_root(parent_hash: Self::Output) -> Option; } /// Blake2-256 Hash implementation. @@ -468,8 +468,8 @@ impl Hash for BlakeTwo256 { fn storage_root() -> Self::Output { runtime_io::storage_root().into() } - fn storage_changes_root(parent_hash: Self::Output, parent_number: u64) -> Option { - runtime_io::storage_changes_root(parent_hash.into(), parent_number).map(Into::into) + fn storage_changes_root(parent_hash: Self::Output) -> Option { + runtime_io::storage_changes_root(parent_hash.into()).map(Into::into) } } diff --git a/core/state-machine/Cargo.toml b/core/state-machine/Cargo.toml index 405e62bacc..222c543f54 100644 --- a/core/state-machine/Cargo.toml +++ b/core/state-machine/Cargo.toml @@ -15,6 +15,7 @@ trie = { package = "substrate-trie", path = "../trie" } primitives = { package = "substrate-primitives", path = "../primitives" } panic-handler = { package = "substrate-panic-handler", path = "../panic-handler" } parity-codec = "3.3" +num-traits = "0.2" [dev-dependencies] hex-literal = "0.2.0" diff --git a/core/state-machine/src/basic.rs b/core/state-machine/src/basic.rs index 3021ddfd28..6cb3efd267 100644 --- a/core/state-machine/src/basic.rs +++ b/core/state-machine/src/basic.rs @@ -151,8 +151,8 @@ impl Externalities for BasicExternalities where H::Out: Ord { vec![42] } - fn storage_changes_root(&mut self, _parent: H::Out, _parent_num: u64) -> Option { - None + fn storage_changes_root(&mut self, _parent: H::Out) -> Result, ()> { + Ok(None) } fn submit_extrinsic(&mut self, _extrinsic: Vec) -> Result<(), ()> { diff --git a/core/state-machine/src/changes_trie/build.rs b/core/state-machine/src/changes_trie/build.rs index 9af058515a..487fde2e35 100644 --- a/core/state-machine/src/changes_trie/build.rs +++ b/core/state-machine/src/changes_trie/build.rs @@ -19,12 +19,13 @@ use std::collections::{BTreeMap, BTreeSet}; use parity_codec::Decode; use hash_db::Hasher; +use num_traits::One; use crate::backend::Backend; use crate::overlayed_changes::OverlayedChanges; -use crate::trie_backend_essence::{TrieBackendStorage, TrieBackendEssence}; +use crate::trie_backend_essence::TrieBackendEssence; use crate::changes_trie::build_iterator::digest_build_iterator; use crate::changes_trie::input::{InputKey, InputPair, DigestIndex, ExtrinsicIndex}; -use crate::changes_trie::{AnchorBlockId, Configuration, Storage}; +use crate::changes_trie::{AnchorBlockId, Configuration, Storage, BlockNumber}; /// Prepare input pairs for building a changes trie of given block. /// @@ -32,29 +33,25 @@ use crate::changes_trie::{AnchorBlockId, Configuration, Storage}; /// required data. /// Returns Ok(None) data required to prepare input pairs is not collected /// or storage is not provided. -pub fn prepare_input<'a, B, S, H>( +pub fn prepare_input<'a, B, S, H, Number>( backend: &B, - storage: Option<&'a S>, + storage: &'a S, + config: &'a Configuration, changes: &OverlayedChanges, - parent: &'a AnchorBlockId, -) -> Result>, String> + parent: &'a AnchorBlockId, +) -> Result>>, String> where B: Backend, - S: Storage, - &'a S: TrieBackendStorage, + S: Storage, H: Hasher, + Number: BlockNumber, { - let (storage, config) = match (storage, changes.changes_trie_config.as_ref()) { - (Some(storage), Some(config)) => (storage, config), - _ => return Ok(None), - }; - let mut input = Vec::new(); input.extend(prepare_extrinsics_input( backend, - parent.number + 1, + parent.number.clone() + 1.into(), changes)?); - input.extend(prepare_digest_input::<_, H>( + input.extend(prepare_digest_input::<_, H, Number>( parent, config, storage)?); @@ -63,14 +60,15 @@ pub fn prepare_input<'a, B, S, H>( } /// Prepare ExtrinsicIndex input pairs. -fn prepare_extrinsics_input( +fn prepare_extrinsics_input( backend: &B, - block: u64, + block: Number, changes: &OverlayedChanges, -) -> Result, String> +) -> Result>, String> where B: Backend, H: Hasher, + Number: BlockNumber, { let mut extrinsic_map = BTreeMap::, BTreeSet>::new(); for (key, val) in changes.prospective.top.iter().chain(changes.committed.top.iter()) { @@ -93,47 +91,50 @@ fn prepare_extrinsics_input( Ok(extrinsic_map.into_iter() .map(move |(key, extrinsics)| InputPair::ExtrinsicIndex(ExtrinsicIndex { - block, + block: block.clone(), key, }, extrinsics.iter().cloned().collect()))) } /// Prepare DigestIndex input pairs. -fn prepare_digest_input<'a, S, H>( - parent: &'a AnchorBlockId, +fn prepare_digest_input<'a, S, H, Number>( + parent: &'a AnchorBlockId, config: &Configuration, storage: &'a S -) -> Result + 'a, String> +) -> Result> + 'a, String> where - S: Storage, - &'a S: TrieBackendStorage, + S: Storage, H: Hasher, H::Out: 'a, + Number: BlockNumber, { - let mut digest_map = BTreeMap::, BTreeSet>::new(); - for digest_build_block in digest_build_iterator(config, parent.number + 1) { - let trie_root = storage.root(parent, digest_build_block)?; - let trie_root = trie_root.ok_or_else(|| format!("No changes trie root for block {}", digest_build_block))?; - let trie_storage = TrieBackendEssence::<_, H>::new(storage, trie_root); + let mut digest_map = BTreeMap::, BTreeSet>::new(); + for digest_build_block in digest_build_iterator(config, parent.number.clone() + One::one()) { + let trie_root = storage.root(parent, digest_build_block.clone())?; + let trie_root = trie_root.ok_or_else(|| format!("No changes trie root for block {}", digest_build_block.clone()))?; + let trie_storage = TrieBackendEssence::<_, H>::new( + crate::changes_trie::TrieBackendStorageAdapter(storage), + trie_root, + ); - let extrinsic_prefix = ExtrinsicIndex::key_neutral_prefix(digest_build_block); + let extrinsic_prefix = ExtrinsicIndex::key_neutral_prefix(digest_build_block.clone()); trie_storage.for_keys_with_prefix(&extrinsic_prefix, |key| - if let Some(InputKey::ExtrinsicIndex(trie_key)) = Decode::decode(&mut &key[..]) { + if let Some(InputKey::ExtrinsicIndex::(trie_key)) = Decode::decode(&mut &key[..]) { digest_map.entry(trie_key.key).or_default() - .insert(digest_build_block); + .insert(digest_build_block.clone()); }); - let digest_prefix = DigestIndex::key_neutral_prefix(digest_build_block); + let digest_prefix = DigestIndex::key_neutral_prefix(digest_build_block.clone()); trie_storage.for_keys_with_prefix(&digest_prefix, |key| - if let Some(InputKey::DigestIndex(trie_key)) = Decode::decode(&mut &key[..]) { + if let Some(InputKey::DigestIndex::(trie_key)) = Decode::decode(&mut &key[..]) { digest_map.entry(trie_key.key).or_default() - .insert(digest_build_block); + .insert(digest_build_block.clone()); }); } Ok(digest_map.into_iter() .map(move |(key, set)| InputPair::DigestIndex(DigestIndex { - block: parent.number + 1, + block: parent.number.clone() + One::one(), key }, set.into_iter().collect()))) } @@ -148,7 +149,7 @@ mod test { use crate::overlayed_changes::OverlayedValue; use super::*; - fn prepare_for_build() -> (InMemory, InMemoryStorage, OverlayedChanges) { + fn prepare_for_build() -> (InMemory, InMemoryStorage, OverlayedChanges) { let backend: InMemory<_> = vec![ (vec![100], vec![255]), (vec![101], vec![255]), @@ -225,7 +226,14 @@ mod test { #[test] fn build_changes_trie_nodes_on_non_digest_block() { let (backend, storage, changes) = prepare_for_build(); - let changes_trie_nodes = prepare_input(&backend, Some(&storage), &changes, &AnchorBlockId { hash: Default::default(), number: 4 }).unwrap(); + let config = changes.changes_trie_config.as_ref().unwrap(); + let changes_trie_nodes = prepare_input( + &backend, + &storage, + config, + &changes, + &AnchorBlockId { hash: Default::default(), number: 4 }, + ).unwrap(); assert_eq!(changes_trie_nodes, Some(vec![ InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 5, key: vec![100] }, vec![0, 2, 3]), InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 5, key: vec![101] }, vec![1]), @@ -236,7 +244,14 @@ mod test { #[test] fn build_changes_trie_nodes_on_digest_block_l1() { let (backend, storage, changes) = prepare_for_build(); - let changes_trie_nodes = prepare_input(&backend, Some(&storage), &changes, &AnchorBlockId { hash: Default::default(), number: 3 }).unwrap(); + let config = changes.changes_trie_config.as_ref().unwrap(); + let changes_trie_nodes = prepare_input( + &backend, + &storage, + config, + &changes, + &AnchorBlockId { hash: Default::default(), number: 3 }, + ).unwrap(); assert_eq!(changes_trie_nodes, Some(vec![ InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 4, key: vec![100] }, vec![0, 2, 3]), InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 4, key: vec![101] }, vec![1]), @@ -252,7 +267,14 @@ mod test { #[test] fn build_changes_trie_nodes_on_digest_block_l2() { let (backend, storage, changes) = prepare_for_build(); - let changes_trie_nodes = prepare_input(&backend, Some(&storage), &changes, &AnchorBlockId { hash: Default::default(), number: 15 }).unwrap(); + let config = changes.changes_trie_config.as_ref().unwrap(); + let changes_trie_nodes = prepare_input( + &backend, + &storage, + config, + &changes, + &AnchorBlockId { hash: Default::default(), number: 15 }, + ).unwrap(); assert_eq!(changes_trie_nodes, Some(vec![ InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 16, key: vec![100] }, vec![0, 2, 3]), InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 16, key: vec![101] }, vec![1]), @@ -276,7 +298,14 @@ mod test { extrinsics: Some(vec![1].into_iter().collect()) }); - let changes_trie_nodes = prepare_input(&backend, Some(&storage), &changes, &AnchorBlockId { hash: Default::default(), number: 3 }).unwrap(); + let config = changes.changes_trie_config.as_ref().unwrap(); + let changes_trie_nodes = prepare_input( + &backend, + &storage, + config, + &changes, + &AnchorBlockId { hash: Default::default(), number: 3 }, + ).unwrap(); assert_eq!(changes_trie_nodes, Some(vec![ InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 4, key: vec![100] }, vec![0, 2, 3]), InputPair::ExtrinsicIndex(ExtrinsicIndex { block: 4, key: vec![101] }, vec![1]), diff --git a/core/state-machine/src/changes_trie/build_iterator.rs b/core/state-machine/src/changes_trie/build_iterator.rs index f9c6ba6e7b..5d8a8318ab 100644 --- a/core/state-machine/src/changes_trie/build_iterator.rs +++ b/core/state-machine/src/changes_trie/build_iterator.rs @@ -17,13 +17,16 @@ //! Structures and functions to return blocks whose changes are to be included //! in given block' changes trie. -use crate::changes_trie::Configuration; +use crate::changes_trie::{Configuration, BlockNumber}; /// Returns iterator of OTHER blocks that are required for inclusion into /// changes trie of given block. -pub fn digest_build_iterator(config: &Configuration, block: u64) -> DigestBuildIterator { +pub fn digest_build_iterator( + config: &Configuration, + block: Number, +) -> DigestBuildIterator { // prepare digest build parameters - let (_, _, digest_step) = match config.digest_level_at_block(block) { + let (_, _, digest_step) = match config.digest_level_at_block(block.clone()) { Some((current_level, digest_interval, digest_step)) => (current_level, digest_interval, digest_step), None => return DigestBuildIterator::empty(), @@ -35,24 +38,26 @@ pub fn digest_build_iterator(config: &Configuration, block: u64) -> DigestBuildI /// Changes trie build iterator that returns numbers of OTHER blocks that are /// required for inclusion into changes trie of given block. #[derive(Debug)] -pub struct DigestBuildIterator { +pub struct DigestBuildIterator { /// Block we're building changes trie for. - block: u64, + block: Number, /// Interval for creation digest blocks. - digest_interval: u64, + digest_interval: u32, + /// Max step of blocks range. + max_step: u32, /// Step of current blocks range. - current_step: u64, + current_step: u32, /// Current blocks range. - current_range: Option<::std::iter::StepBy<::std::ops::Range>>, - /// Max step of blocks range. - max_step: u64, + current_range: Option>, } -impl DigestBuildIterator { +impl DigestBuildIterator { /// Create new digest build iterator. - pub fn new(block: u64, digest_interval: u64, max_step: u64) -> Self { + pub fn new(block: Number, digest_interval: u32, max_step: u32) -> Self { DigestBuildIterator { - block, digest_interval, max_step, + block, + digest_interval, + max_step, current_step: 0, current_range: None, } @@ -60,12 +65,12 @@ impl DigestBuildIterator { /// Create empty digest build iterator. pub fn empty() -> Self { - Self::new(0, 0, 0) + Self::new(0.into(), 0, 0) } } -impl Iterator for DigestBuildIterator { - type Item = u64; +impl Iterator for DigestBuildIterator { + type Item = Number; fn next(&mut self) -> Option { if let Some(next) = self.current_range.as_mut().and_then(|iter| iter.next()) { @@ -82,10 +87,11 @@ impl Iterator for DigestBuildIterator { } self.current_step = next_step; - self.current_range = Some( - ((self.block - self.current_step * self.digest_interval + self.current_step)..self.block) - .step_by(self.current_step as usize) - ); + self.current_range = Some(BlocksRange::new( + self.block.clone() - (self.current_step * self.digest_interval - self.current_step).into(), + self.block.clone(), + self.current_step.into(), + )); Some(self.current_range.as_mut() .expect("assigned one line above; qed") @@ -94,20 +100,52 @@ impl Iterator for DigestBuildIterator { } } +/// Blocks range iterator with builtin step_by support. +#[derive(Debug)] +struct BlocksRange { + current: Number, + end: Number, + step: Number, +} + +impl BlocksRange { + pub fn new(begin: Number, end: Number, step: Number) -> Self { + BlocksRange { + current: begin, + end, + step, + } + } +} + +impl Iterator for BlocksRange { + type Item = Number; + + fn next(&mut self) -> Option { + if self.current >= self.end { + return None; + } + + let current = Some(self.current.clone()); + self.current += self.step.clone(); + current + } +} + #[cfg(test)] mod tests { use super::*; - fn digest_build_iterator(digest_interval: u64, digest_levels: u32, block: u64) -> DigestBuildIterator { + fn digest_build_iterator(digest_interval: u32, digest_levels: u32, block: u64) -> DigestBuildIterator { super::digest_build_iterator(&Configuration { digest_interval, digest_levels }, block) } - fn digest_build_iterator_basic(digest_interval: u64, digest_levels: u32, block: u64) -> (u64, u64, u64) { + fn digest_build_iterator_basic(digest_interval: u32, digest_levels: u32, block: u64) -> (u64, u32, u32) { let iter = digest_build_iterator(digest_interval, digest_levels, block); (iter.block, iter.digest_interval, iter.max_step) } - fn digest_build_iterator_blocks(digest_interval: u64, digest_levels: u32, block: u64) -> Vec { + fn digest_build_iterator_blocks(digest_interval: u32, digest_levels: u32, block: u64) -> Vec { digest_build_iterator(digest_interval, digest_levels, block).collect() } @@ -122,7 +160,11 @@ mod tests { assert_eq!(digest_build_iterator_basic(4, 16, 2), empty, "digest is not required for this block"); assert_eq!(digest_build_iterator_basic(4, 16, 15), empty, "digest is not required for this block"); assert_eq!(digest_build_iterator_basic(4, 16, 17), empty, "digest is not required for this block"); - assert_eq!(digest_build_iterator_basic(::std::u64::MAX / 2 + 1, 16, ::std::u64::MAX), empty, "digest_interval * 2 is greater than u64::MAX"); + assert_eq!(digest_build_iterator_basic( + ::std::u32::MAX / 2 + 1, + 16, + ::std::u64::MAX, + ), empty, "digest_interval * 2 is greater than u64::MAX"); } #[test] diff --git a/core/state-machine/src/changes_trie/changes_iterator.rs b/core/state-machine/src/changes_trie/changes_iterator.rs index c8d6216926..0e4716ccab 100644 --- a/core/state-machine/src/changes_trie/changes_iterator.rs +++ b/core/state-machine/src/changes_trie/changes_iterator.rs @@ -21,8 +21,9 @@ use std::cell::RefCell; use std::collections::VecDeque; use parity_codec::{Decode, Encode}; use hash_db::{HashDB, Hasher}; +use num_traits::One; use trie::{Recorder, MemoryDB}; -use crate::changes_trie::{AnchorBlockId, Configuration, RootsStorage, Storage}; +use crate::changes_trie::{AnchorBlockId, Configuration, RootsStorage, Storage, BlockNumber}; use crate::changes_trie::input::{DigestIndex, ExtrinsicIndex, DigestIndexValue, ExtrinsicIndexValue}; use crate::changes_trie::storage::{TrieBackendAdapter, InMemoryStorage}; use crate::proving_backend::ProvingBackendEssence; @@ -31,25 +32,25 @@ use crate::trie_backend_essence::{TrieBackendEssence}; /// Return changes of given key at given blocks range. /// `max` is the number of best known block. /// Changes are returned in descending order (i.e. last block comes first). -pub fn key_changes<'a, S: Storage, H: Hasher>( +pub fn key_changes<'a, S: Storage, H: Hasher, Number: BlockNumber>( config: &'a Configuration, storage: &'a S, - begin: u64, - end: &'a AnchorBlockId, - max: u64, + begin: Number, + end: &'a AnchorBlockId, + max: Number, key: &'a [u8], -) -> Result, String> { +) -> Result, String> { // we can't query any roots before root - let max = ::std::cmp::min(max, end.number); + let max = ::std::cmp::min(max.clone(), end.number.clone()); Ok(DrilldownIterator { essence: DrilldownIteratorEssence { key, roots_storage: storage, storage, - begin, + begin: begin.clone(), end, - surface: surface_iterator(config, max, begin, end.number)?, + surface: surface_iterator(config, max, begin, end.number.clone())?, extrinsics: Default::default(), blocks: Default::default(), @@ -61,25 +62,25 @@ pub fn key_changes<'a, S: Storage, H: Hasher>( /// Returns proof of changes of given key at given blocks range. /// `max` is the number of best known block. -pub fn key_changes_proof, H: Hasher>( +pub fn key_changes_proof, H: Hasher, Number: BlockNumber>( config: &Configuration, storage: &S, - begin: u64, - end: &AnchorBlockId, - max: u64, + begin: Number, + end: &AnchorBlockId, + max: Number, key: &[u8], ) -> Result>, String> { // we can't query any roots before root - let max = ::std::cmp::min(max, end.number); + let max = ::std::cmp::min(max.clone(), end.number.clone()); let mut iter = ProvingDrilldownIterator { essence: DrilldownIteratorEssence { key, roots_storage: storage.clone(), storage, - begin, + begin: begin.clone(), end, - surface: surface_iterator(config, max, begin, end.number)?, + surface: surface_iterator(config, max, begin, end.number.clone())?, extrinsics: Default::default(), blocks: Default::default(), @@ -100,17 +101,17 @@ pub fn key_changes_proof, H: Hasher>( /// Check key changes proog and return changes of the key at given blocks range. /// `max` is the number of best known block. /// Changes are returned in descending order (i.e. last block comes first). -pub fn key_changes_proof_check, H: Hasher>( +pub fn key_changes_proof_check, H: Hasher, Number: BlockNumber>( config: &Configuration, roots_storage: &S, proof: Vec>, - begin: u64, - end: &AnchorBlockId, - max: u64, + begin: Number, + end: &AnchorBlockId, + max: Number, key: &[u8] -) -> Result, String> { +) -> Result, String> { // we can't query any roots before root - let max = ::std::cmp::min(max, end.number); + let max = ::std::cmp::min(max.clone(), end.number.clone()); let mut proof_db = MemoryDB::::default(); for item in proof { @@ -123,9 +124,9 @@ pub fn key_changes_proof_check, H: Hasher>( key, roots_storage, storage: &proof_db, - begin, + begin: begin.clone(), end, - surface: surface_iterator(config, max, begin, end.number)?, + surface: surface_iterator(config, max, begin, end.number.clone())?, extrinsics: Default::default(), blocks: Default::default(), @@ -137,36 +138,36 @@ pub fn key_changes_proof_check, H: Hasher>( /// Surface iterator - only traverses top-level digests from given range and tries to find /// all digest changes for the key. -pub struct SurfaceIterator<'a> { +pub struct SurfaceIterator<'a, Number: BlockNumber> { config: &'a Configuration, - begin: u64, - max: u64, - current: Option, - current_begin: u64, - digest_step: u64, + begin: Number, + max: Number, + current: Option, + current_begin: Number, + digest_step: u32, digest_level: u32, } -impl<'a> Iterator for SurfaceIterator<'a> { - type Item = Result<(u64, u32), String>; +impl<'a, Number: BlockNumber> Iterator for SurfaceIterator<'a, Number> { + type Item = Result<(Number, u32), String>; fn next(&mut self) -> Option { - let current = self.current?; + let current = self.current.clone()?; let digest_level = self.digest_level; - if current < self.digest_step { + if current < self.digest_step.into() { self.current = None; } else { - let next = current - self.digest_step; - if next == 0 || next < self.begin { + let next = current.clone() - self.digest_step.into(); + if next.is_zero() || next < self.begin { self.current = None; } else if next > self.current_begin { self.current = Some(next); } else { let (current, current_begin, digest_step, digest_level) = match - lower_bound_max_digest(self.config, self.max, self.begin, next) { + lower_bound_max_digest(self.config, self.max.clone(), self.begin.clone(), next) { Err(err) => return Some(Err(err)), Ok(range) => range, }; @@ -184,22 +185,36 @@ impl<'a> Iterator for SurfaceIterator<'a> { /// Drilldown iterator - receives 'digest points' from surface iterator and explores /// every point until extrinsic is found. -pub struct DrilldownIteratorEssence<'a, RS: 'a + RootsStorage, S: 'a + Storage, H: Hasher> where H::Out: 'a { +pub struct DrilldownIteratorEssence<'a, RS, S, H, Number> + where + RS: 'a + RootsStorage, + S: 'a + Storage, + H: Hasher, + Number: BlockNumber, + H::Out: 'a, +{ key: &'a [u8], roots_storage: &'a RS, storage: &'a S, - begin: u64, - end: &'a AnchorBlockId, - surface: SurfaceIterator<'a>, + begin: Number, + end: &'a AnchorBlockId, + surface: SurfaceIterator<'a, Number>, - extrinsics: VecDeque<(u64, u32)>, - blocks: VecDeque<(u64, u32)>, + extrinsics: VecDeque<(Number, u32)>, + blocks: VecDeque<(Number, u32)>, _hasher: ::std::marker::PhantomData, } -impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> DrilldownIteratorEssence<'a, RS, S, H> { - pub fn next(&mut self, trie_reader: F) -> Option> +impl<'a, RS, S, H, Number> DrilldownIteratorEssence<'a, RS, S, H, Number> + where + RS: 'a + RootsStorage, + S: 'a + Storage, + H: Hasher, + Number: BlockNumber, + H::Out: 'a, +{ + pub fn next(&mut self, trie_reader: F) -> Option> where F: FnMut(&S, H::Out, &[u8]) -> Result>, String>, { @@ -210,7 +225,7 @@ impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> DrilldownIteratorEs } } - fn do_next(&mut self, mut trie_reader: F) -> Result, String> + fn do_next(&mut self, mut trie_reader: F) -> Result, String> where F: FnMut(&S, H::Out, &[u8]) -> Result>, String>, { @@ -223,33 +238,33 @@ impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> DrilldownIteratorEs // not having a changes trie root is an error because: // we never query roots for future blocks // AND trie roots for old blocks are known (both on full + light node) - let trie_root = self.roots_storage.root(&self.end, block)? - .ok_or_else(|| format!("Changes trie root for block {} is not found", block))?; + let trie_root = self.roots_storage.root(&self.end, block.clone())? + .ok_or_else(|| format!("Changes trie root for block {} is not found", block.clone()))?; // only return extrinsics for blocks before self.max // most of blocks will be filtered out before pushing to `self.blocks` // here we just throwing away changes at digest blocks we're processing debug_assert!(block >= self.begin, "We shall not touch digests earlier than a range' begin"); if block <= self.end.number { - let extrinsics_key = ExtrinsicIndex { block, key: self.key.to_vec() }.encode(); + let extrinsics_key = ExtrinsicIndex { block: block.clone(), key: self.key.to_vec() }.encode(); let extrinsics = trie_reader(&self.storage, trie_root, &extrinsics_key); if let Some(extrinsics) = extrinsics? { let extrinsics: Option = Decode::decode(&mut &extrinsics[..]); if let Some(extrinsics) = extrinsics { - self.extrinsics.extend(extrinsics.into_iter().rev().map(|e| (block, e))); + self.extrinsics.extend(extrinsics.into_iter().rev().map(|e| (block.clone(), e))); } } } - let blocks_key = DigestIndex { block, key: self.key.to_vec() }.encode(); + let blocks_key = DigestIndex { block: block.clone(), key: self.key.to_vec() }.encode(); let blocks = trie_reader(&self.storage, trie_root, &blocks_key); if let Some(blocks) = blocks? { - let blocks: Option = Decode::decode(&mut &blocks[..]); + let blocks: Option> = Decode::decode(&mut &blocks[..]); if let Some(blocks) = blocks { // filter level0 blocks here because we tend to use digest blocks, // AND digest block changes could also include changes for out-of-range blocks - let begin = self.begin; - let end = self.end.number; + let begin = self.begin.clone(); + let end = self.end.number.clone(); self.blocks.extend(blocks.into_iter() .rev() .filter(|b| level > 1 || (*b >= begin && *b <= end)) @@ -271,14 +286,21 @@ impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> DrilldownIteratorEs } /// Exploring drilldown operator. -pub struct DrilldownIterator<'a, RS: 'a + RootsStorage, S: 'a + Storage, H: Hasher> where H::Out: 'a { - essence: DrilldownIteratorEssence<'a, RS, S, H>, +pub struct DrilldownIterator<'a, RS, S, H, Number> + where + Number: BlockNumber, + H: Hasher, + S: 'a + Storage, + RS: 'a + RootsStorage, + H::Out: 'a, +{ + essence: DrilldownIteratorEssence<'a, RS, S, H, Number>, } -impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> Iterator - for DrilldownIterator<'a, RS, S, H> +impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher, Number: BlockNumber> Iterator + for DrilldownIterator<'a, RS, S, H, Number> { - type Item = Result<(u64, u32), String>; + type Item = Result<(Number, u32), String>; fn next(&mut self) -> Option { self.essence.next(|storage, root, key| @@ -287,12 +309,26 @@ impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> Iterator } /// Proving drilldown iterator. -struct ProvingDrilldownIterator<'a, RS: 'a + RootsStorage, S: 'a + Storage, H: Hasher> where H::Out: 'a { - essence: DrilldownIteratorEssence<'a, RS, S, H>, +struct ProvingDrilldownIterator<'a, RS, S, H, Number> + where + Number: BlockNumber, + H: Hasher, + S: 'a + Storage, + RS: 'a + RootsStorage, + H::Out: 'a, +{ + essence: DrilldownIteratorEssence<'a, RS, S, H, Number>, proof_recorder: RefCell>, } -impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> ProvingDrilldownIterator<'a, RS, S, H> { +impl<'a, RS, S, H, Number> ProvingDrilldownIterator<'a, RS, S, H, Number> + where + Number: BlockNumber, + H: Hasher, + S: 'a + Storage, + RS: 'a + RootsStorage, + H::Out: 'a, +{ /// Consume the iterator, extracting the gathered proof in lexicographical order /// by value. pub fn extract_proof(self) -> Vec> { @@ -303,8 +339,15 @@ impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> ProvingDrilldownIte } } -impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> Iterator for ProvingDrilldownIterator<'a, RS, S, H> { - type Item = Result<(u64, u32), String>; +impl<'a, RS, S, H, Number> Iterator for ProvingDrilldownIterator<'a, RS, S, H, Number> + where + Number: BlockNumber, + H: Hasher, + S: 'a + Storage, + RS: 'a + RootsStorage, + H::Out: 'a, +{ + type Item = Result<(Number, u32), String>; fn next(&mut self) -> Option { let proof_recorder = &mut *self.proof_recorder.try_borrow_mut() @@ -318,8 +361,18 @@ impl<'a, RS: 'a + RootsStorage, S: Storage, H: Hasher> Iterator for Provin } /// Returns surface iterator for given range of blocks. -fn surface_iterator<'a>(config: &'a Configuration, max: u64, begin: u64, end: u64) -> Result, String> { - let (current, current_begin, digest_step, digest_level) = lower_bound_max_digest(config, max, begin, end)?; +fn surface_iterator<'a, Number: BlockNumber>( + config: &'a Configuration, + max: Number, + begin: Number, + end: Number, +) -> Result, String> { + let (current, current_begin, digest_step, digest_level) = lower_bound_max_digest( + config, + max.clone(), + begin.clone(), + end, + )?; Ok(SurfaceIterator { config, begin, @@ -333,31 +386,32 @@ fn surface_iterator<'a>(config: &'a Configuration, max: u64, begin: u64, end: u6 /// Returns parameters of highest level digest block that includes the end of given range /// and tends to include the whole range. -fn lower_bound_max_digest( +fn lower_bound_max_digest( config: &Configuration, - max: u64, - begin: u64, - end: u64, -) -> Result<(u64, u64, u64, u32), String> { + max: Number, + begin: Number, + end: Number, +) -> Result<(Number, Number, u32, u32), String> { if end > max || begin > end { return Err("invalid changes range".into()); } let mut digest_level = 0u32; - let mut digest_step = 1u64; - let mut digest_interval = 0u64; - let mut current = end; - let mut current_begin = begin; - if begin != end { + let mut digest_step = 1u32; + let mut digest_interval = 0u32; + let mut current = end.clone(); + let mut current_begin = begin.clone(); + if current_begin != current { while digest_level != config.digest_levels { let new_digest_level = digest_level + 1; let new_digest_step = digest_step * config.digest_interval; let new_digest_interval = config.digest_interval * { if digest_interval == 0 { 1 } else { digest_interval } }; - let new_digest_begin = ((current - 1) / new_digest_interval) * new_digest_interval; - let new_digest_end = new_digest_begin + new_digest_interval; - let new_current = new_digest_begin + new_digest_interval; + let new_digest_begin = ((current.clone() - One::one()) + / new_digest_interval.into()) * new_digest_interval.into(); + let new_digest_end = new_digest_begin.clone() + new_digest_interval.into(); + let new_current = new_digest_begin.clone() + new_digest_interval.into(); if new_digest_end > max { if begin < new_digest_begin { @@ -372,7 +426,7 @@ fn lower_bound_max_digest( current = new_current; current_begin = new_digest_begin; - if new_digest_begin <= begin && new_digest_end >= end { + if current_begin <= begin && new_digest_end >= end { break; } } @@ -394,7 +448,7 @@ mod tests { use crate::changes_trie::storage::InMemoryStorage; use super::*; - fn prepare_for_drilldown() -> (Configuration, InMemoryStorage) { + fn prepare_for_drilldown() -> (Configuration, InMemoryStorage) { let config = Configuration { digest_interval: 4, digest_levels: 2 }; let backend = InMemoryStorage::with_inputs(vec![ // digest: 1..4 => [(3, 0)] @@ -436,27 +490,27 @@ mod tests { #[test] fn drilldown_iterator_works() { let (config, storage) = prepare_for_drilldown(); - let drilldown_result = key_changes::, Blake2Hasher>( + let drilldown_result = key_changes::, Blake2Hasher, u64>( &config, &storage, 0, &AnchorBlockId { hash: Default::default(), number: 16 }, 16, &[42]) .and_then(Result::from_iter); assert_eq!(drilldown_result, Ok(vec![(8, 2), (8, 1), (6, 3), (3, 0)])); - let drilldown_result = key_changes::, Blake2Hasher>( + let drilldown_result = key_changes::, Blake2Hasher, u64>( &config, &storage, 0, &AnchorBlockId { hash: Default::default(), number: 2 }, 4, &[42]) .and_then(Result::from_iter); assert_eq!(drilldown_result, Ok(vec![])); - let drilldown_result = key_changes::, Blake2Hasher>( + let drilldown_result = key_changes::, Blake2Hasher, u64>( &config, &storage, 0, &AnchorBlockId { hash: Default::default(), number: 3 }, 4, &[42]) .and_then(Result::from_iter); assert_eq!(drilldown_result, Ok(vec![(3, 0)])); - let drilldown_result = key_changes::, Blake2Hasher>( + let drilldown_result = key_changes::, Blake2Hasher, u64>( &config, &storage, 7, &AnchorBlockId { hash: Default::default(), number: 8 }, 8, &[42]) .and_then(Result::from_iter); assert_eq!(drilldown_result, Ok(vec![(8, 2), (8, 1)])); - let drilldown_result = key_changes::, Blake2Hasher>( + let drilldown_result = key_changes::, Blake2Hasher, u64>( &config, &storage, 5, &AnchorBlockId { hash: Default::default(), number: 7 }, 8, &[42]) .and_then(Result::from_iter); assert_eq!(drilldown_result, Ok(vec![(6, 3)])); @@ -467,7 +521,7 @@ mod tests { let (config, storage) = prepare_for_drilldown(); storage.clear_storage(); - assert!(key_changes::, Blake2Hasher>( + assert!(key_changes::, Blake2Hasher, u64>( &config, &storage, 0, &AnchorBlockId { hash: Default::default(), number: 100 }, 1000, &[42]) .and_then(|i| i.collect::, _>>()).is_err()); } @@ -475,9 +529,9 @@ mod tests { #[test] fn drilldown_iterator_fails_when_range_is_invalid() { let (config, storage) = prepare_for_drilldown(); - assert!(key_changes::, Blake2Hasher>( + assert!(key_changes::, Blake2Hasher, u64>( &config, &storage, 0, &AnchorBlockId { hash: Default::default(), number: 100 }, 50, &[42]).is_err()); - assert!(key_changes::, Blake2Hasher>( + assert!(key_changes::, Blake2Hasher, u64>( &config, &storage, 20, &AnchorBlockId { hash: Default::default(), number: 10 }, 100, &[42]).is_err()); } @@ -488,7 +542,7 @@ mod tests { // create drilldown iterator that records all trie nodes during drilldown let (remote_config, remote_storage) = prepare_for_drilldown(); - let remote_proof = key_changes_proof::, Blake2Hasher>( + let remote_proof = key_changes_proof::, Blake2Hasher, u64>( &remote_config, &remote_storage, 0, &AnchorBlockId { hash: Default::default(), number: 16 }, 16, &[42]).unwrap(); @@ -497,7 +551,7 @@ mod tests { // create drilldown iterator that works the same, but only depends on trie let (local_config, local_storage) = prepare_for_drilldown(); local_storage.clear_storage(); - let local_result = key_changes_proof_check::, Blake2Hasher>( + let local_result = key_changes_proof_check::, Blake2Hasher, u64>( &local_config, &local_storage, remote_proof, 0, &AnchorBlockId { hash: Default::default(), number: 16 }, 16, &[42]); diff --git a/core/state-machine/src/changes_trie/input.rs b/core/state-machine/src/changes_trie/input.rs index 3154aff715..ae939c028b 100644 --- a/core/state-machine/src/changes_trie/input.rs +++ b/core/state-machine/src/changes_trie/input.rs @@ -17,12 +17,13 @@ //! Different types of changes trie input pairs. use parity_codec::{Decode, Encode, Input, Output}; +use crate::changes_trie::BlockNumber; /// Key of { changed key => set of extrinsic indices } mapping. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct ExtrinsicIndex { +pub struct ExtrinsicIndex { /// Block at which this key has been inserted in the trie. - pub block: u64, + pub block: Number, /// Storage key this node is responsible for. pub key: Vec, } @@ -32,35 +33,35 @@ pub type ExtrinsicIndexValue = Vec; /// Key of { changed key => block/digest block numbers } mapping. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct DigestIndex { +pub struct DigestIndex { /// Block at which this key has been inserted in the trie. - pub block: u64, + pub block: Number, /// Storage key this node is responsible for. pub key: Vec, } /// Value of { changed key => block/digest block numbers } mapping. -pub type DigestIndexValue = Vec; +pub type DigestIndexValue = Vec; /// Single input pair of changes trie. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum InputPair { +pub enum InputPair { /// Element of { key => set of extrinsics where key has been changed } element mapping. - ExtrinsicIndex(ExtrinsicIndex, ExtrinsicIndexValue), + ExtrinsicIndex(ExtrinsicIndex, ExtrinsicIndexValue), /// Element of { key => set of blocks/digest blocks where key has been changed } element mapping. - DigestIndex(DigestIndex, DigestIndexValue), + DigestIndex(DigestIndex, DigestIndexValue), } /// Single input key of changes trie. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum InputKey { +pub enum InputKey { /// Key of { key => set of extrinsics where key has been changed } element mapping. - ExtrinsicIndex(ExtrinsicIndex), + ExtrinsicIndex(ExtrinsicIndex), /// Key of { key => set of blocks/digest blocks where key has been changed } element mapping. - DigestIndex(DigestIndex), + DigestIndex(DigestIndex), } -impl Into<(Vec, Vec)> for InputPair { +impl Into<(Vec, Vec)> for InputPair { fn into(self) -> (Vec, Vec) { match self { InputPair::ExtrinsicIndex(key, value) => (key.encode(), value.encode()), @@ -69,8 +70,8 @@ impl Into<(Vec, Vec)> for InputPair { } } -impl Into for InputPair { - fn into(self) -> InputKey { +impl Into> for InputPair { + fn into(self) -> InputKey { match self { InputPair::ExtrinsicIndex(key, _) => InputKey::ExtrinsicIndex(key), InputPair::DigestIndex(key, _) => InputKey::DigestIndex(key), @@ -78,15 +79,15 @@ impl Into for InputPair { } } -impl ExtrinsicIndex { - pub fn key_neutral_prefix(block: u64) -> Vec { +impl ExtrinsicIndex { + pub fn key_neutral_prefix(block: Number) -> Vec { let mut prefix = vec![1]; prefix.extend(block.encode()); prefix } } -impl Encode for ExtrinsicIndex { +impl Encode for ExtrinsicIndex { fn encode_to(&self, dest: &mut W) { dest.push_byte(1); self.block.encode_to(dest); @@ -94,8 +95,8 @@ impl Encode for ExtrinsicIndex { } } -impl DigestIndex { - pub fn key_neutral_prefix(block: u64) -> Vec { +impl DigestIndex { + pub fn key_neutral_prefix(block: Number) -> Vec { let mut prefix = vec![2]; prefix.extend(block.encode()); prefix @@ -103,7 +104,7 @@ impl DigestIndex { } -impl Encode for DigestIndex { +impl Encode for DigestIndex { fn encode_to(&self, dest: &mut W) { dest.push_byte(2); self.block.encode_to(dest); @@ -111,7 +112,7 @@ impl Encode for DigestIndex { } } -impl Decode for InputKey { +impl Decode for InputKey { fn decode(input: &mut I) -> Option { match input.read_byte()? { 1 => Some(InputKey::ExtrinsicIndex(ExtrinsicIndex { @@ -133,17 +134,17 @@ mod tests { #[test] fn extrinsic_index_serialized_and_deserialized() { - let original = ExtrinsicIndex { block: 777, key: vec![42] }; + let original = ExtrinsicIndex { block: 777u64, key: vec![42] }; let serialized = original.encode(); - let deserialized: InputKey = Decode::decode(&mut &serialized[..]).unwrap(); + let deserialized: InputKey = Decode::decode(&mut &serialized[..]).unwrap(); assert_eq!(InputKey::ExtrinsicIndex(original), deserialized); } #[test] fn digest_index_serialized_and_deserialized() { - let original = DigestIndex { block: 777, key: vec![42] }; + let original = DigestIndex { block: 777u64, key: vec![42] }; let serialized = original.encode(); - let deserialized: InputKey = Decode::decode(&mut &serialized[..]).unwrap(); + let deserialized: InputKey = Decode::decode(&mut &serialized[..]).unwrap(); assert_eq!(InputKey::DigestIndex(original), deserialized); } } diff --git a/core/state-machine/src/changes_trie/mod.rs b/core/state-machine/src/changes_trie/mod.rs index f82d8b33df..15ea1b474f 100644 --- a/core/state-machine/src/changes_trie/mod.rs +++ b/core/state-machine/src/changes_trie/mod.rs @@ -48,58 +48,116 @@ pub use self::prune::{prune, oldest_non_pruned_trie}; use hash_db::Hasher; use crate::backend::Backend; +use num_traits::{One, Zero}; +use parity_codec::{Decode, Encode}; use primitives; use crate::changes_trie::build::prepare_input; use crate::overlayed_changes::OverlayedChanges; -use crate::trie_backend_essence::TrieBackendStorage; use trie::{DBValue, trie_root}; /// Changes that are made outside of extrinsics are marked with this index; pub const NO_EXTRINSIC_INDEX: u32 = 0xffffffff; +/// Requirements for block number that can be used with changes tries. +pub trait BlockNumber: + Send + Sync + 'static + + ::std::fmt::Display + + Clone + + From + One + Zero + + PartialEq + Ord + + ::std::ops::Add + ::std::ops::Sub + + ::std::ops::Mul + ::std::ops::Div + + ::std::ops::Rem + + ::std::ops::AddAssign + + num_traits::CheckedMul + num_traits::CheckedSub + + Decode + Encode +{} + +impl BlockNumber for T where T: + Send + Sync + 'static + + ::std::fmt::Display + + Clone + + From + One + Zero + + PartialEq + Ord + + ::std::ops::Add + ::std::ops::Sub + + ::std::ops::Mul + ::std::ops::Div + + ::std::ops::Rem + + ::std::ops::AddAssign + + num_traits::CheckedMul + num_traits::CheckedSub + + Decode + Encode, +{} + /// Block identifier that could be used to determine fork of this block. #[derive(Debug)] -pub struct AnchorBlockId { +pub struct AnchorBlockId { /// Hash of this block. pub hash: Hash, /// Number of this block. - pub number: u64, + pub number: Number, } /// Changes trie storage. Provides access to trie roots and trie nodes. -pub trait RootsStorage: Send + Sync { +pub trait RootsStorage: Send + Sync { + /// Resolve hash of the block into anchor. + fn build_anchor(&self, hash: H::Out) -> Result, String>; /// Get changes trie root for the block with given number which is an ancestor (or the block /// itself) of the anchor_block (i.e. anchor_block.number >= block). - fn root(&self, anchor: &AnchorBlockId, block: u64) -> Result, String>; + fn root(&self, anchor: &AnchorBlockId, block: Number) -> Result, String>; } /// Changes trie storage. Provides access to trie roots and trie nodes. -pub trait Storage: RootsStorage { +pub trait Storage: RootsStorage { /// Get a trie node. fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String>; } +/// Changes trie storage -> trie backend essence adapter. +pub struct TrieBackendStorageAdapter<'a, H: Hasher, Number: BlockNumber>(pub &'a Storage); + +impl<'a, H: Hasher, N: BlockNumber> crate::TrieBackendStorage for TrieBackendStorageAdapter<'a, H, N> { + type Overlay = trie::MemoryDB; + + fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String> { + self.0.get(key, prefix) + } +} + /// Changes trie configuration. pub type Configuration = primitives::ChangesTrieConfiguration; /// Compute the changes trie root and transaction for given block. -/// Returns None if there's no data to perform computation. -pub fn compute_changes_trie_root<'a, B: Backend, S: Storage, H: Hasher>( +/// Returns Err(()) if unknown `parent_hash` has been passed. +/// Returns Ok(None) if there's no data to perform computation. +/// Panics if background storage returns an error. +pub fn compute_changes_trie_root<'a, B: Backend, S: Storage, H: Hasher, Number: BlockNumber>( backend: &B, storage: Option<&'a S>, changes: &OverlayedChanges, - parent: &'a AnchorBlockId, -) -> Option<(H::Out, Vec<(Vec, Vec)>)> + parent_hash: H::Out, +) -> Result, Vec)>)>, ()> where - &'a S: TrieBackendStorage, - H::Out: Ord, + H::Out: Ord + 'static, { - let input_pairs = prepare_input::(backend, storage, changes, parent) - .expect("storage is not allowed to fail within runtime")?; - let transaction = input_pairs.into_iter() - .map(Into::into) - .collect::>(); - let root = trie_root::(transaction.iter().map(|(k, v)| (&*k, &*v))); - - Some((root, transaction)) + let (storage, config) = match (storage, changes.changes_trie_config.as_ref()) { + (Some(storage), Some(config)) => (storage, config), + _ => return Ok(None), + }; + + // build_anchor error should not be considered fatal + let parent = storage.build_anchor(parent_hash).map_err(|_| ())?; + + // storage errors are considered fatal (similar to situations when runtime fetches values from storage) + let input_pairs = prepare_input::(backend, storage, config, changes, &parent) + .expect("storage is not allowed to fail within runtime"); + match input_pairs { + Some(input_pairs) => { + let transaction = input_pairs.into_iter() + .map(Into::into) + .collect::>(); + let root = trie_root::(transaction.iter().map(|(k, v)| (&*k, &*v))); + + Ok(Some((root, transaction))) + }, + None => Ok(None), + } } diff --git a/core/state-machine/src/changes_trie/prune.rs b/core/state-machine/src/changes_trie/prune.rs index 09e53315a5..3aedf66f75 100644 --- a/core/state-machine/src/changes_trie/prune.rs +++ b/core/state-machine/src/changes_trie/prune.rs @@ -19,24 +19,26 @@ use hash_db::Hasher; use trie::Recorder; use log::warn; +use num_traits::One; use crate::proving_backend::ProvingBackendEssence; use crate::trie_backend_essence::TrieBackendEssence; -use crate::changes_trie::{AnchorBlockId, Configuration, Storage}; +use crate::changes_trie::{AnchorBlockId, Configuration, Storage, BlockNumber}; use crate::changes_trie::storage::TrieBackendAdapter; /// Get number of oldest block for which changes trie is not pruned /// given changes trie configuration, pruning parameter and number of /// best finalized block. -pub fn oldest_non_pruned_trie( +pub fn oldest_non_pruned_trie( config: &Configuration, - min_blocks_to_keep: u64, - best_finalized_block: u64, -) -> u64 { + min_blocks_to_keep: Number, + best_finalized_block: Number, +) -> Number { let max_digest_interval = config.max_digest_interval(); - let max_digest_block = best_finalized_block - best_finalized_block % max_digest_interval; + let best_finalized_block_rem = best_finalized_block.clone() % max_digest_interval.into(); + let max_digest_block = best_finalized_block - best_finalized_block_rem; match pruning_range(config, min_blocks_to_keep, max_digest_block) { - Some((_, last_pruned_block)) => last_pruned_block + 1, - None => 1, + Some((_, last_pruned_block)) => last_pruned_block + One::one(), + None => One::one(), } } @@ -45,23 +47,32 @@ pub fn oldest_non_pruned_trie( /// `min_blocks_to_keep` blocks. We only prune changes tries at `max_digest_interval` /// ranges. /// Returns MemoryDB that contains all deleted changes tries nodes. -pub fn prune, H: Hasher, F: FnMut(H::Out)>( +pub fn prune, H: Hasher, Number: BlockNumber, F: FnMut(H::Out)>( config: &Configuration, storage: &S, - min_blocks_to_keep: u64, - current_block: &AnchorBlockId, + min_blocks_to_keep: Number, + current_block: &AnchorBlockId, mut remove_trie_node: F, ) { // select range for pruning - let (first, last) = match pruning_range(config, min_blocks_to_keep, current_block.number) { + let (first, last) = match pruning_range(config, min_blocks_to_keep, current_block.number.clone()) { Some((first, last)) => (first, last), None => return, }; // delete changes trie for every block in range // FIXME: limit `max_digest_interval` so that this cycle won't involve huge ranges - for block in first..last+1 { - let root = match storage.root(current_block, block) { + let mut block = first; + loop { + if block >= last.clone() + One::one() { + break; + } + + let prev_block = block.clone(); + block += One::one(); + + let block = prev_block; + let root = match storage.root(current_block, block.clone()) { Ok(Some(root)) => root, Ok(None) => continue, Err(error) => { @@ -91,11 +102,15 @@ pub fn prune, H: Hasher, F: FnMut(H::Out)>( } /// Select blocks range (inclusive from both ends) for pruning changes tries in. -fn pruning_range(config: &Configuration, min_blocks_to_keep: u64, block: u64) -> Option<(u64, u64)> { +fn pruning_range( + config: &Configuration, + min_blocks_to_keep: Number, + block: Number, +) -> Option<(Number, Number)> { // compute number of changes tries we actually want to keep let (prune_interval, blocks_to_keep) = if config.is_digest_build_enabled() { // we only CAN prune at block where max-level-digest is created - let max_digest_interval = match config.digest_level_at_block(block) { + let max_digest_interval = match config.digest_level_at_block(block.clone()) { Some((digest_level, digest_interval, _)) if digest_level == config.digest_levels => digest_interval, _ => return None, @@ -107,7 +122,7 @@ fn pruning_range(config: &Configuration, min_blocks_to_keep: u64, block: u64) -> // number of blocks BEFORE current block where changes tries are not pruned ( max_digest_interval, - max_digest_intervals_to_keep.checked_mul(max_digest_interval) + max_digest_intervals_to_keep.checked_mul(&max_digest_interval.into()) ) } else { ( @@ -117,11 +132,11 @@ fn pruning_range(config: &Configuration, min_blocks_to_keep: u64, block: u64) -> }; // last block for which changes trie is pruned - let last_block_to_prune = blocks_to_keep.and_then(|b| block.checked_sub(b)); - let first_block_to_prune = last_block_to_prune.clone().and_then(|b| b.checked_sub(prune_interval)); + let last_block_to_prune = blocks_to_keep.and_then(|b| block.checked_sub(&b)); + let first_block_to_prune = last_block_to_prune.clone().and_then(|b| b.checked_sub(&prune_interval.into())); last_block_to_prune - .and_then(|last| first_block_to_prune.map(|first| (first + 1, last))) + .and_then(|last| first_block_to_prune.map(|first| (first + One::one(), last))) } /// Select pruning delay for the changes tries. To make sure we could build a changes @@ -132,13 +147,16 @@ fn pruning_range(config: &Configuration, min_blocks_to_keep: u64, block: u64) -> /// 0 or 1: means that only last changes trie is guaranteed to exists; /// 2: the last chnages trie + previous changes trie /// ... -fn max_digest_intervals_to_keep(min_blocks_to_keep: u64, max_digest_interval: u64) -> u64 { +fn max_digest_intervals_to_keep( + min_blocks_to_keep: Number, + max_digest_interval: u32, +) -> Number { // config.digest_level_at_block ensures that it is not zero debug_assert!(max_digest_interval != 0); - let max_digest_intervals_to_keep = min_blocks_to_keep / max_digest_interval; - if max_digest_intervals_to_keep == 0 { - 1 + let max_digest_intervals_to_keep = min_blocks_to_keep / max_digest_interval.into(); + if max_digest_intervals_to_keep.is_zero() { + One::one() } else { max_digest_intervals_to_keep } @@ -153,14 +171,14 @@ mod tests { use crate::changes_trie::storage::InMemoryStorage; use super::*; - fn config(interval: u64, levels: u32) -> Configuration { + fn config(interval: u32, levels: u32) -> Configuration { Configuration { digest_interval: interval, digest_levels: levels, } } - fn prune_by_collect, H: Hasher>( + fn prune_by_collect, H: Hasher>( config: &Configuration, storage: &S, min_blocks_to_keep: u64, @@ -174,7 +192,7 @@ mod tests { #[test] fn prune_works() { - fn prepare_storage() -> InMemoryStorage { + fn prepare_storage() -> InMemoryStorage { let mut mdb1 = MemoryDB::::default(); let root1 = insert_into_memory_db::(&mut mdb1, vec![(vec![10], vec![20])]).unwrap(); let mut mdb2 = MemoryDB::::default(); @@ -241,60 +259,60 @@ mod tests { #[test] fn pruning_range_works() { // DIGESTS ARE NOT CREATED + NO TRIES ARE PRUNED - assert_eq!(pruning_range(&config(10, 0), 2, 2), None); + assert_eq!(pruning_range(&config(10, 0), 2u64, 2u64), None); // DIGESTS ARE NOT CREATED + SOME TRIES ARE PRUNED - assert_eq!(pruning_range(&config(10, 0), 100, 110), Some((10, 10))); - assert_eq!(pruning_range(&config(10, 0), 100, 210), Some((110, 110))); + assert_eq!(pruning_range(&config(10, 0), 100u64, 110u64), Some((10, 10))); + assert_eq!(pruning_range(&config(10, 0), 100u64, 210u64), Some((110, 110))); // DIGESTS ARE CREATED + NO TRIES ARE PRUNED - assert_eq!(pruning_range(&config(10, 2), 2, 0), None); - assert_eq!(pruning_range(&config(10, 2), 30, 100), None); - assert_eq!(pruning_range(&config(::std::u64::MAX, 2), 1, 1024), None); - assert_eq!(pruning_range(&config(::std::u64::MAX, 2), ::std::u64::MAX, 1024), None); - assert_eq!(pruning_range(&config(32, 2), 2048, 512), None); - assert_eq!(pruning_range(&config(32, 2), 2048, 1024), None); + assert_eq!(pruning_range(&config(10, 2), 2u64, 0u64), None); + assert_eq!(pruning_range(&config(10, 2), 30u64, 100u64), None); + assert_eq!(pruning_range(&config(::std::u32::MAX, 2), 1u64, 1024u64), None); + assert_eq!(pruning_range(&config(::std::u32::MAX, 2), ::std::u64::MAX, 1024u64), None); + assert_eq!(pruning_range(&config(32, 2), 2048u64, 512u64), None); + assert_eq!(pruning_range(&config(32, 2), 2048u64, 1024u64), None); // DIGESTS ARE CREATED + SOME TRIES ARE PRUNED // when we do not want to keep any highest-level-digests // (system forces to keep at least one) - assert_eq!(pruning_range(&config(4, 2), 0, 32), Some((1, 16))); - assert_eq!(pruning_range(&config(4, 2), 0, 64), Some((33, 48))); + assert_eq!(pruning_range(&config(4, 2), 0u64, 32u64), Some((1, 16))); + assert_eq!(pruning_range(&config(4, 2), 0u64, 64u64), Some((33, 48))); // when we want to keep 1 (last) highest-level-digest - assert_eq!(pruning_range(&config(4, 2), 16, 32), Some((1, 16))); - assert_eq!(pruning_range(&config(4, 2), 16, 64), Some((33, 48))); + assert_eq!(pruning_range(&config(4, 2), 16u64, 32u64), Some((1, 16))); + assert_eq!(pruning_range(&config(4, 2), 16u64, 64u64), Some((33, 48))); // when we want to keep 1 (last) + 1 additional level digests - assert_eq!(pruning_range(&config(32, 2), 4096, 5120), Some((1, 1024))); - assert_eq!(pruning_range(&config(32, 2), 4096, 6144), Some((1025, 2048))); + assert_eq!(pruning_range(&config(32, 2), 4096u64, 5120u64), Some((1, 1024))); + assert_eq!(pruning_range(&config(32, 2), 4096u64, 6144u64), Some((1025, 2048))); } #[test] fn max_digest_intervals_to_keep_works() { - assert_eq!(max_digest_intervals_to_keep(1024, 1025), 1); - assert_eq!(max_digest_intervals_to_keep(1024, 1023), 1); - assert_eq!(max_digest_intervals_to_keep(1024, 512), 2); - assert_eq!(max_digest_intervals_to_keep(1024, 511), 2); - assert_eq!(max_digest_intervals_to_keep(1024, 100), 10); + assert_eq!(max_digest_intervals_to_keep(1024u64, 1025), 1u64); + assert_eq!(max_digest_intervals_to_keep(1024u64, 1023), 1u64); + assert_eq!(max_digest_intervals_to_keep(1024u64, 512), 2u64); + assert_eq!(max_digest_intervals_to_keep(1024u64, 511), 2u64); + assert_eq!(max_digest_intervals_to_keep(1024u64, 100), 10u64); } #[test] fn oldest_non_pruned_trie_works() { // when digests are not created at all - assert_eq!(oldest_non_pruned_trie(&config(0, 0), 100, 10), 1); - assert_eq!(oldest_non_pruned_trie(&config(0, 0), 100, 110), 11); + assert_eq!(oldest_non_pruned_trie(&config(0, 0), 100u64, 10u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(0, 0), 100u64, 110u64), 11); // when only l1 digests are created - assert_eq!(oldest_non_pruned_trie(&config(100, 1), 100, 50), 1); - assert_eq!(oldest_non_pruned_trie(&config(100, 1), 100, 110), 1); - assert_eq!(oldest_non_pruned_trie(&config(100, 1), 100, 210), 101); + assert_eq!(oldest_non_pruned_trie(&config(100, 1), 100u64, 50u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(100, 1), 100u64, 110u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(100, 1), 100u64, 210u64), 101); // when l2 digests are created - assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100, 50), 1); - assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100, 110), 1); - assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100, 210), 1); - assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100, 10110), 1); - assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100, 20110), 10001); + assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100u64, 50u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100u64, 110u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100u64, 210u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100u64, 10110u64), 1); + assert_eq!(oldest_non_pruned_trie(&config(100, 2), 100u64, 20110u64), 10001); } } diff --git a/core/state-machine/src/changes_trie/storage.rs b/core/state-machine/src/changes_trie/storage.rs index 8363ae4221..8da2052515 100644 --- a/core/state-machine/src/changes_trie/storage.rs +++ b/core/state-machine/src/changes_trie/storage.rs @@ -16,12 +16,12 @@ //! Changes trie storage utilities. -use std::collections::HashMap; +use std::collections::BTreeMap; use hash_db::Hasher; use trie::DBValue; use trie::MemoryDB; use parking_lot::RwLock; -use crate::changes_trie::{AnchorBlockId, RootsStorage, Storage}; +use crate::changes_trie::{RootsStorage, Storage, AnchorBlockId, BlockNumber}; use crate::trie_backend_essence::TrieBackendStorage; #[cfg(test)] @@ -32,27 +32,27 @@ use crate::backend::insert_into_memory_db; use crate::changes_trie::input::InputPair; /// In-memory implementation of changes trie storage. -pub struct InMemoryStorage { - data: RwLock>, +pub struct InMemoryStorage { + data: RwLock>, } /// Adapter for using changes trie storage as a TrieBackendEssence' storage. -pub struct TrieBackendAdapter<'a, H: Hasher, S: 'a + Storage> { +pub struct TrieBackendAdapter<'a, H: Hasher, Number: BlockNumber, S: 'a + Storage> { storage: &'a S, - _hasher: ::std::marker::PhantomData, + _hasher: ::std::marker::PhantomData<(H, Number)>, } -struct InMemoryStorageData { - roots: HashMap, +struct InMemoryStorageData { + roots: BTreeMap, mdb: MemoryDB, } -impl InMemoryStorage { +impl InMemoryStorage { /// Create the storage from given in-memory database. pub fn with_db(mdb: MemoryDB) -> Self { Self { data: RwLock::new(InMemoryStorageData { - roots: HashMap::new(), + roots: BTreeMap::new(), mdb, }), } @@ -63,10 +63,20 @@ impl InMemoryStorage { Self::with_db(Default::default()) } + /// Create the storage with given blocks. + pub fn with_blocks(blocks: Vec<(Number, H::Out)>) -> Self { + Self { + data: RwLock::new(InMemoryStorageData { + roots: blocks.into_iter().collect(), + mdb: MemoryDB::default(), + }), + } + } + #[cfg(test)] - pub fn with_inputs(inputs: Vec<(u64, Vec)>) -> Self { + pub fn with_inputs(inputs: Vec<(Number, Vec>)>) -> Self { let mut mdb = MemoryDB::default(); - let mut roots = HashMap::new(); + let mut roots = BTreeMap::new(); for (block, pairs) in inputs { let root = insert_into_memory_db::(&mut mdb, pairs.into_iter().map(Into::into)); if let Some(root) = root { @@ -101,32 +111,44 @@ impl InMemoryStorage { } /// Insert changes trie for given block. - pub fn insert(&self, block: u64, changes_trie_root: H::Out, trie: MemoryDB) { + pub fn insert(&self, block: Number, changes_trie_root: H::Out, trie: MemoryDB) { let mut data = self.data.write(); data.roots.insert(block, changes_trie_root); data.mdb.consolidate(trie); } } -impl RootsStorage for InMemoryStorage { - fn root(&self, _anchor_block: &AnchorBlockId, block: u64) -> Result, String> { +impl RootsStorage for InMemoryStorage { + fn build_anchor(&self, parent_hash: H::Out) -> Result, String> { + self.data.read().roots.iter() + .find(|(_, v)| **v == parent_hash) + .map(|(k, _)| AnchorBlockId { hash: parent_hash, number: k.clone() }) + .ok_or_else(|| format!("Can't find associated number for block {:?}", parent_hash)) + } + + fn root(&self, _anchor_block: &AnchorBlockId, block: Number) -> Result, String> { Ok(self.data.read().roots.get(&block).cloned()) } } -impl Storage for InMemoryStorage { +impl Storage for InMemoryStorage { fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String> { MemoryDB::::get(&self.data.read().mdb, key, prefix) } } -impl<'a, H: Hasher, S: 'a + Storage> TrieBackendAdapter<'a, H, S> { +impl<'a, H: Hasher, Number: BlockNumber, S: 'a + Storage> TrieBackendAdapter<'a, H, Number, S> { pub fn new(storage: &'a S) -> Self { Self { storage, _hasher: Default::default() } } } -impl<'a, H: Hasher, S: 'a + Storage> TrieBackendStorage for TrieBackendAdapter<'a, H, S> { +impl<'a, H, Number, S> TrieBackendStorage for TrieBackendAdapter<'a, H, Number, S> + where + S: 'a + Storage, + Number: BlockNumber, + H: Hasher, +{ type Overlay = MemoryDB; fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String> { diff --git a/core/state-machine/src/ext.rs b/core/state-machine/src/ext.rs index b9c035a778..f0638edf65 100644 --- a/core/state-machine/src/ext.rs +++ b/core/state-machine/src/ext.rs @@ -19,7 +19,7 @@ use std::{error, fmt, cmp::Ord}; use log::warn; use crate::backend::Backend; -use crate::changes_trie::{AnchorBlockId, Storage as ChangesTrieStorage, compute_changes_trie_root}; +use crate::changes_trie::{Storage as ChangesTrieStorage, compute_changes_trie_root}; use crate::{Externalities, OverlayedChanges, OffchainExt, ChildStorageKey}; use hash_db::Hasher; use primitives::storage::well_known_keys::is_child_storage_key; @@ -57,10 +57,9 @@ impl error::Error for Error { } /// Wraps a read-only backend, call executor, and current overlayed changes. -pub struct Ext<'a, H, B, T, O> +pub struct Ext<'a, H, N, B, T, O> where H: Hasher, - B: 'a + Backend, { /// The overlayed changes to write to. @@ -78,20 +77,23 @@ where /// This differs from `storage_transaction` behavior, because the moment when /// `storage_changes_root` is called matters + we need to remember additional /// data at this moment (block number). - changes_trie_transaction: Option<(u64, MemoryDB, H::Out)>, + changes_trie_transaction: Option<(MemoryDB, H::Out)>, /// Additional externalities for offchain workers. /// /// If None, some methods from the trait might not supported. offchain_externalities: Option<&'a mut O>, + /// Dummy usage of N arg. + _phantom: ::std::marker::PhantomData, } -impl<'a, H, B, T, O> Ext<'a, H, B, T, O> +impl<'a, H, N, B, T, O> Ext<'a, H, N, B, T, O> where H: Hasher, B: 'a + Backend, - T: 'a + ChangesTrieStorage, + T: 'a + ChangesTrieStorage, O: 'a + OffchainExt, - H::Out: Ord, + H::Out: Ord + 'static, + N: crate::changes_trie::BlockNumber, { /// Create a new `Ext` from overlayed changes and read-only backend pub fn new( @@ -107,6 +109,7 @@ where changes_trie_storage, changes_trie_transaction: None, offchain_externalities, + _phantom: Default::default(), } } @@ -118,7 +121,7 @@ where self.storage_transaction .expect("storage_transaction always set after calling storage root; qed"), self.changes_trie_transaction - .map(|(_, tx, _)| tx), + .map(|(tx, _)| tx), ); ( @@ -137,13 +140,13 @@ where } #[cfg(test)] -impl<'a, H, B, T, O> Ext<'a, H, B, T, O> +impl<'a, H, N, B, T, O> Ext<'a, H, N, B, T, O> where H: Hasher, - B: 'a + Backend, - T: 'a + ChangesTrieStorage, + T: 'a + ChangesTrieStorage, O: 'a + OffchainExt, + N: crate::changes_trie::BlockNumber, { pub fn storage_pairs(&self) -> Vec<(Vec, Vec)> { use std::collections::HashMap; @@ -159,13 +162,14 @@ where } } -impl<'a, B, T, H, O> Externalities for Ext<'a, H, B, T, O> +impl<'a, B, T, H, N, O> Externalities for Ext<'a, H, N, B, T, O> where H: Hasher, B: 'a + Backend, - T: 'a + ChangesTrieStorage, + T: 'a + ChangesTrieStorage, O: 'a + OffchainExt, - H::Out: Ord, + H::Out: Ord + 'static, + N: crate::changes_trie::BlockNumber, { fn storage(&self, key: &[u8]) -> Option> { let _guard = panic_handler::AbortGuard::new(true); @@ -313,14 +317,14 @@ where } } - fn storage_changes_root(&mut self, parent: H::Out, parent_num: u64) -> Option { + fn storage_changes_root(&mut self, parent_hash: H::Out) -> Result, ()> { let _guard = panic_handler::AbortGuard::new(true); - let root_and_tx = compute_changes_trie_root::<_, T, H>( + let root_and_tx = compute_changes_trie_root::<_, T, H, N>( self.backend, self.changes_trie_storage.clone(), self.overlay, - &AnchorBlockId { hash: parent, number: parent_num }, - ); + parent_hash, + )?; let root_and_tx = root_and_tx.map(|(root, changes)| { let mut calculated_root = Default::default(); let mut mdb = MemoryDB::default(); @@ -331,11 +335,11 @@ where } } - (parent_num + 1, mdb, root) + (mdb, root) }); - let root = root_and_tx.as_ref().map(|(_, _, root)| root.clone()); + let root = root_and_tx.as_ref().map(|(_, root)| root.clone()); self.changes_trie_transaction = root_and_tx; - root + Ok(root) } fn submit_extrinsic(&mut self, extrinsic: Vec) -> Result<(), ()> { @@ -363,8 +367,8 @@ mod tests { use super::*; type TestBackend = InMemory; - type TestChangesTrieStorage = InMemoryChangesTrieStorage; - type TestExt<'a> = Ext<'a, Blake2Hasher, TestBackend, TestChangesTrieStorage, crate::NeverOffchainExt>; + type TestChangesTrieStorage = InMemoryChangesTrieStorage; + type TestExt<'a> = Ext<'a, Blake2Hasher, u64, TestBackend, TestChangesTrieStorage, crate::NeverOffchainExt>; fn prepare_overlay_with_changes() -> OverlayedChanges { OverlayedChanges { @@ -391,26 +395,26 @@ mod tests { let mut overlay = prepare_overlay_with_changes(); let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, None, None); - assert_eq!(ext.storage_changes_root(Default::default(), 100), None); + assert_eq!(ext.storage_changes_root(Default::default()).unwrap(), None); } #[test] fn storage_changes_root_is_none_when_extrinsic_changes_are_none() { let mut overlay = prepare_overlay_with_changes(); overlay.changes_trie_config = None; - let storage = TestChangesTrieStorage::new(); + let storage = TestChangesTrieStorage::with_blocks(vec![(100, Default::default())]); let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, Some(&storage), None); - assert_eq!(ext.storage_changes_root(Default::default(), 100), None); + assert_eq!(ext.storage_changes_root(Default::default()).unwrap(), None); } #[test] fn storage_changes_root_is_some_when_extrinsic_changes_are_non_empty() { let mut overlay = prepare_overlay_with_changes(); - let storage = TestChangesTrieStorage::new(); + let storage = TestChangesTrieStorage::with_blocks(vec![(99, Default::default())]); let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, Some(&storage), None); - assert_eq!(ext.storage_changes_root(Default::default(), 99), + assert_eq!(ext.storage_changes_root(Default::default()).unwrap(), Some(hex!("5b829920b9c8d554a19ee2a1ba593c4f2ee6fc32822d083e04236d693e8358d5").into())); } @@ -418,10 +422,10 @@ mod tests { fn storage_changes_root_is_some_when_extrinsic_changes_are_empty() { let mut overlay = prepare_overlay_with_changes(); overlay.prospective.top.get_mut(&vec![1]).unwrap().value = None; - let storage = TestChangesTrieStorage::new(); + let storage = TestChangesTrieStorage::with_blocks(vec![(99, Default::default())]); let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, Some(&storage), None); - assert_eq!(ext.storage_changes_root(Default::default(), 99), + assert_eq!(ext.storage_changes_root(Default::default()).unwrap(), Some(hex!("bcf494e41e29a15c9ae5caa053fe3cb8b446ee3e02a254efbdec7a19235b76e4").into())); } } diff --git a/core/state-machine/src/lib.rs b/core/state-machine/src/lib.rs index daf8f915a1..4f51677fff 100644 --- a/core/state-machine/src/lib.rs +++ b/core/state-machine/src/lib.rs @@ -219,7 +219,7 @@ pub trait Externalities { fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec; /// Get the change trie root of the current storage overlay at a block with given parent. - fn storage_changes_root(&mut self, parent: H::Out, parent_num: u64) -> Option where H::Out: Ord; + fn storage_changes_root(&mut self, parent: H::Out) -> Result, ()> where H::Out: Ord; /// Submit extrinsic. /// @@ -338,7 +338,7 @@ pub fn always_wasm() -> ExecutionManager> { } /// Creates new substrate state machine. -pub fn new<'a, H, B, T, O, Exec>( +pub fn new<'a, H, N, B, T, O, Exec>( backend: &'a B, changes_trie_storage: Option<&'a T>, offchain_ext: Option<&'a mut O>, @@ -346,7 +346,7 @@ pub fn new<'a, H, B, T, O, Exec>( exec: &'a Exec, method: &'a str, call_data: &'a [u8], -) -> StateMachine<'a, H, B, T, O, Exec> { +) -> StateMachine<'a, H, N, B, T, O, Exec> { StateMachine { backend, changes_trie_storage, @@ -360,7 +360,7 @@ pub fn new<'a, H, B, T, O, Exec>( } /// The substrate state machine. -pub struct StateMachine<'a, H, B, T, O, Exec> { +pub struct StateMachine<'a, H, N, B, T, O, Exec> { backend: &'a B, changes_trie_storage: Option<&'a T>, offchain_ext: Option<&'a mut O>, @@ -368,16 +368,17 @@ pub struct StateMachine<'a, H, B, T, O, Exec> { exec: &'a Exec, method: &'a str, call_data: &'a [u8], - _hasher: PhantomData, + _hasher: PhantomData<(H, N)>, } -impl<'a, H, B, T, O, Exec> StateMachine<'a, H, B, T, O, Exec> where +impl<'a, H, N, B, T, O, Exec> StateMachine<'a, H, N, B, T, O, Exec> where H: Hasher, Exec: CodeExecutor, B: Backend, - T: ChangesTrieStorage, + T: ChangesTrieStorage, O: OffchainExt, - H::Out: Ord, + H::Out: Ord + 'static, + N: crate::changes_trie::BlockNumber, { /// Execute a call using the given state backend, overlayed changes, and call executor. /// Produces a state-backend-specific "transaction" which can be used to apply the changes @@ -568,7 +569,7 @@ where B: Backend, H: Hasher, Exec: CodeExecutor, - H::Out: Ord, + H::Out: Ord + 'static, { let trie_backend = backend.try_into_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; @@ -595,12 +596,12 @@ where S: trie_backend_essence::TrieBackendStorage, H: Hasher, Exec: CodeExecutor, - H::Out: Ord, + H::Out: Ord + 'static, { let proving_backend = proving_backend::ProvingBackend::new(trie_backend); let mut sm = StateMachine { backend: &proving_backend, - changes_trie_storage: None as Option<&changes_trie::InMemoryStorage>, + changes_trie_storage: None as Option<&changes_trie::InMemoryStorage>, offchain_ext: NeverOffchainExt::new(), overlay, exec, @@ -629,7 +630,7 @@ pub fn execution_proof_check( where H: Hasher, Exec: CodeExecutor, - H::Out: Ord, + H::Out: Ord + 'static, { let trie_backend = create_proof_check_backend::(root.into(), proof)?; execution_proof_check_on_trie_backend(&trie_backend, overlay, exec, method, call_data) @@ -646,11 +647,11 @@ pub fn execution_proof_check_on_trie_backend( where H: Hasher, Exec: CodeExecutor, - H::Out: Ord, + H::Out: Ord + 'static, { let mut sm = StateMachine { backend: trie_backend, - changes_trie_storage: None as Option<&changes_trie::InMemoryStorage>, + changes_trie_storage: None as Option<&changes_trie::InMemoryStorage>, offchain_ext: NeverOffchainExt::new(), overlay, exec, @@ -892,7 +893,7 @@ mod tests { fn execute_works() { assert_eq!(new( &trie_backend::tests::test_trie(), - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::::new()), NeverOffchainExt::new(), &mut Default::default(), &DummyCodeExecutor { @@ -913,7 +914,7 @@ mod tests { fn execute_works_with_native_else_wasm() { assert_eq!(new( &trie_backend::tests::test_trie(), - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::::new()), NeverOffchainExt::new(), &mut Default::default(), &DummyCodeExecutor { @@ -934,7 +935,7 @@ mod tests { let mut consensus_failed = false; assert!(new( &trie_backend::tests::test_trie(), - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::::new()), NeverOffchainExt::new(), &mut Default::default(), &DummyCodeExecutor { @@ -1003,7 +1004,7 @@ mod tests { }; { - let changes_trie_storage = InMemoryChangesTrieStorage::new(); + let changes_trie_storage = InMemoryChangesTrieStorage::::new(); let mut ext = Ext::new(&mut overlay, &backend, Some(&changes_trie_storage), NeverOffchainExt::new()); ext.clear_prefix(b"ab"); } @@ -1026,7 +1027,7 @@ mod tests { #[test] fn set_child_storage_works() { let backend = InMemory::::default().try_into_trie_backend().unwrap(); - let changes_trie_storage = InMemoryChangesTrieStorage::new(); + let changes_trie_storage = InMemoryChangesTrieStorage::::new(); let mut overlay = OverlayedChanges::default(); let mut ext = Ext::new( &mut overlay, @@ -1106,7 +1107,7 @@ mod tests { fn cannot_change_changes_trie_config() { assert!(new( &trie_backend::tests::test_trie(), - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::::new()), NeverOffchainExt::new(), &mut Default::default(), &DummyCodeExecutor { @@ -1126,7 +1127,7 @@ mod tests { fn cannot_change_changes_trie_config_with_native_else_wasm() { assert!(new( &trie_backend::tests::test_trie(), - Some(&InMemoryChangesTrieStorage::new()), + Some(&InMemoryChangesTrieStorage::::new()), NeverOffchainExt::new(), &mut Default::default(), &DummyCodeExecutor { diff --git a/core/state-machine/src/overlayed_changes.rs b/core/state-machine/src/overlayed_changes.rs index e595cff0e4..663e4ff72e 100644 --- a/core/state-machine/src/overlayed_changes.rs +++ b/core/state-machine/src/overlayed_changes.rs @@ -361,7 +361,7 @@ mod tests { ..Default::default() }; - let changes_trie_storage = InMemoryChangesTrieStorage::new(); + let changes_trie_storage = InMemoryChangesTrieStorage::::new(); let mut ext = Ext::new( &mut overlay, &backend, diff --git a/core/state-machine/src/testing.rs b/core/state-machine/src/testing.rs index 03909f384c..52d208142d 100644 --- a/core/state-machine/src/testing.rs +++ b/core/state-machine/src/testing.rs @@ -18,12 +18,12 @@ use std::collections::{HashMap, BTreeMap}; use std::iter::FromIterator; -use std::marker::PhantomData; use hash_db::Hasher; use crate::backend::{InMemory, Backend}; use primitives::storage::well_known_keys::is_child_storage_key; use crate::changes_trie::{ - compute_changes_trie_root, InMemoryStorage as ChangesTrieInMemoryStorage, AnchorBlockId + compute_changes_trie_root, InMemoryStorage as ChangesTrieInMemoryStorage, + BlockNumber as ChangesTrieBlockNumber, }; use primitives::storage::well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES}; use parity_codec::Encode; @@ -32,14 +32,13 @@ use super::{ChildStorageKey, Externalities, OverlayedChanges}; const EXT_NOT_ALLOWED_TO_FAIL: &str = "Externalities not allowed to fail within runtime"; /// Simple HashMap-based Externalities impl. -pub struct TestExternalities { +pub struct TestExternalities { overlay: OverlayedChanges, backend: InMemory, - changes_trie_storage: ChangesTrieInMemoryStorage, - _hasher: PhantomData, + changes_trie_storage: ChangesTrieInMemoryStorage, } -impl TestExternalities { +impl TestExternalities { /// Create a new instance of `TestExternalities` pub fn new(inner: HashMap, Vec>) -> Self { Self::new_with_code(&[], inner) @@ -62,7 +61,6 @@ impl TestExternalities { overlay, changes_trie_storage: ChangesTrieInMemoryStorage::new(), backend: inner.into(), - _hasher: Default::default(), } } @@ -81,23 +79,28 @@ impl TestExternalities { .into_iter() .filter_map(|(k, maybe_val)| maybe_val.map(|val| (k, val))) } + + /// Get mutable reference to changes trie storage. + pub fn changes_trie_storage(&mut self) -> &mut ChangesTrieInMemoryStorage { + &mut self.changes_trie_storage + } } -impl ::std::fmt::Debug for TestExternalities { +impl ::std::fmt::Debug for TestExternalities { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, "overlay: {:?}\nbackend: {:?}", self.overlay, self.backend.pairs()) } } -impl PartialEq for TestExternalities { +impl PartialEq for TestExternalities { /// This doesn't test if they are in the same state, only if they contains the /// same data at this state - fn eq(&self, other: &TestExternalities) -> bool { + fn eq(&self, other: &TestExternalities) -> bool { self.iter_pairs_in_order().eq(other.iter_pairs_in_order()) } } -impl FromIterator<(Vec, Vec)> for TestExternalities { +impl FromIterator<(Vec, Vec)> for TestExternalities { fn from_iter, Vec)>>(iter: I) -> Self { let mut t = Self::new(Default::default()); t.backend = t.backend.update(iter.into_iter().map(|(k, v)| (None, k, Some(v))).collect()); @@ -105,23 +108,28 @@ impl FromIterator<(Vec, Vec)> for TestExternalities { } } -impl Default for TestExternalities { +impl Default for TestExternalities { fn default() -> Self { Self::new(Default::default()) } } -impl From> for HashMap, Vec> { - fn from(tex: TestExternalities) -> Self { +impl From> for HashMap, Vec> { + fn from(tex: TestExternalities) -> Self { tex.iter_pairs_in_order().collect() } } -impl From< HashMap, Vec> > for TestExternalities { +impl From< HashMap, Vec> > for TestExternalities { fn from(hashmap: HashMap, Vec>) -> Self { Self::from_iter(hashmap) } } -impl Externalities for TestExternalities where H::Out: Ord { +impl Externalities for TestExternalities + where + H: Hasher, + N: ChangesTrieBlockNumber, + H::Out: Ord + 'static +{ fn storage(&self, key: &[u8]) -> Option> { self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(|| self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL)) @@ -209,13 +217,13 @@ impl Externalities for TestExternalities where H::Out: Ord { root } - fn storage_changes_root(&mut self, parent: H::Out, parent_num: u64) -> Option { - compute_changes_trie_root::<_, ChangesTrieInMemoryStorage, H>( + fn storage_changes_root(&mut self, parent: H::Out) -> Result, ()> { + Ok(compute_changes_trie_root::<_, _, H, N>( &self.backend, Some(&self.changes_trie_storage), &self.overlay, - &AnchorBlockId { hash: parent, number: parent_num }, - ).map(|(root, _)| root.clone()) + parent, + )?.map(|(root, _)| root.clone())) } fn submit_extrinsic(&mut self, _extrinsic: Vec) -> Result<(), ()> { @@ -231,7 +239,7 @@ mod tests { #[test] fn commit_should_work() { - let mut ext = TestExternalities::::default(); + let mut ext = TestExternalities::::default(); ext.set_storage(b"doe".to_vec(), b"reindeer".to_vec()); ext.set_storage(b"dog".to_vec(), b"puppy".to_vec()); ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); @@ -241,7 +249,7 @@ mod tests { #[test] fn set_and_retrieve_code() { - let mut ext = TestExternalities::::default(); + let mut ext = TestExternalities::::default(); let code = vec![1, 2, 3]; ext.set_storage(CODE.to_vec(), code.clone()); diff --git a/core/state-machine/src/trie_backend_essence.rs b/core/state-machine/src/trie_backend_essence.rs index dfb6cae08c..89a5b42a84 100644 --- a/core/state-machine/src/trie_backend_essence.rs +++ b/core/state-machine/src/trie_backend_essence.rs @@ -22,7 +22,6 @@ use std::sync::Arc; use log::{debug, warn}; use hash_db::{self, Hasher}; use trie::{TrieDB, Trie, MemoryDB, PrefixedMemoryDB, DBValue, TrieError, default_child_trie_root, read_trie_value, read_child_trie_value, for_keys_in_child_trie}; -use crate::changes_trie::Storage as ChangesTrieStorage; use crate::backend::Consolidate; /// Patricia trie-based storage trait. @@ -300,12 +299,3 @@ impl TrieBackendStorage for MemoryDB { Ok(hash_db::HashDB::get(self, key, prefix)) } } - -// This implementation is used by changes trie clients. -impl<'a, S, H: Hasher> TrieBackendStorage for &'a S where S: ChangesTrieStorage { - type Overlay = MemoryDB; - - fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String> { - ChangesTrieStorage::::get(*self, key, prefix) - } -} diff --git a/core/test-runtime/src/system.rs b/core/test-runtime/src/system.rs index 5345dc0cdb..804d5411d6 100644 --- a/core/test-runtime/src/system.rs +++ b/core/test-runtime/src/system.rs @@ -100,7 +100,7 @@ pub fn polish_block(block: &mut Block) { // check digest let mut digest = Digest::default(); - if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into(), header.number - 1) { + if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into()) { digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root.into())); } if let Some(new_authorities) = ::take() { @@ -133,7 +133,7 @@ pub fn execute_block(block: Block) { // check digest let mut digest = Digest::default(); - if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into(), header.number - 1) { + if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into()) { digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root.into())); } if let Some(new_authorities) = ::take() { @@ -213,7 +213,7 @@ pub fn finalize_block() -> Header { let number = ::take().expect("Number is set by `initialize_block`"); let parent_hash = ::take(); let storage_root = BlakeTwo256::storage_root(); - let storage_changes_root = BlakeTwo256::storage_changes_root(parent_hash, number - 1); + let storage_changes_root = BlakeTwo256::storage_changes_root(parent_hash); let mut digest = Digest::default(); if let Some(storage_changes_root) = storage_changes_root { diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index c6903529c4..8813850bbd 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -33,7 +33,7 @@ mod tests { use parity_codec::{Encode, Decode, Joiner}; use keyring::{AuthorityKeyring, AccountKeyring}; use runtime_support::{Hashable, StorageValue, StorageMap, traits::Currency}; - use state_machine::{CodeExecutor, Externalities, TestExternalities}; + use state_machine::{CodeExecutor, Externalities, TestExternalities as CoreTestExternalities}; use primitives::{twox_128, blake2_256, Blake2Hasher, ChangesTrieConfiguration, NeverNativeValue, NativeOrEncoded}; use node_primitives::{Hash, BlockNumber, AccountId}; @@ -52,6 +52,8 @@ mod tests { const COMPACT_CODE: &[u8] = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm"); const GENESIS_HASH: [u8; 32] = [69u8; 32]; + type TestExternalities = CoreTestExternalities; + fn alice() -> AccountId { AccountKeyring::Alice.into() } @@ -258,7 +260,7 @@ mod tests { fn new_test_ext(code: &[u8], support_changes_trie: bool) -> TestExternalities { let three = AccountId::from_raw([3u8; 32]); - TestExternalities::new_with_code(code, GenesisConfig { + let mut ext = TestExternalities::new_with_code(code, GenesisConfig { consensus: Some(Default::default()), system: Some(SystemConfig { changes_trie_config: if support_changes_trie { Some(ChangesTrieConfiguration { @@ -322,7 +324,9 @@ mod tests { grandpa: Some(GrandpaConfig { authorities: vec![], }), - }.build_storage().unwrap().0) + }.build_storage().unwrap().0); + ext.changes_trie_storage().insert(0, GENESIS_HASH.into(), Default::default()); + ext } fn construct_block( @@ -879,7 +883,7 @@ mod tests { None, ).0.unwrap(); - assert!(t.storage_changes_root(Default::default(), 0).is_some()); + assert!(t.storage_changes_root(GENESIS_HASH.into()).unwrap().is_some()); } #[test] @@ -889,7 +893,7 @@ mod tests { let mut t = new_test_ext(COMPACT_CODE, true); WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "Core_execute_block", &block1.0).unwrap(); - assert!(t.storage_changes_root(Default::default(), 0).is_some()); + assert!(t.storage_changes_root(GENESIS_HASH.into()).unwrap().is_some()); } #[cfg(feature = "benchmarks")] diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 0ec44093b4..bb066b1b98 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 81, - impl_version: 83, + spec_version: 82, + impl_version: 82, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index 9018b109e8..cf5f473bdc 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -78,7 +78,7 @@ use rstd::prelude::*; use rstd::map; use primitives::traits::{self, CheckEqual, SimpleArithmetic, SimpleBitOps, One, Bounded, Lookup, Hash, Member, MaybeDisplay, EnsureOrigin, Digest as DigestT, CurrentHeight, BlockNumberToHash, - MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup, SaturatedConversion + MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup, }; #[cfg(any(feature = "std", test))] use primitives::traits::Zero; @@ -493,8 +493,7 @@ impl Module { let mut digest = >::take(); let extrinsics_root = >::take(); let storage_root = T::Hashing::storage_root(); - let number_u64 = number.saturated_into::(); - let storage_changes_root = T::Hashing::storage_changes_root(parent_hash, number_u64 - 1); + let storage_changes_root = T::Hashing::storage_changes_root(parent_hash); // we can't compute changes trie root earlier && put it to the Digest // because it will include all currently existing temporaries. -- GitLab From d796de17f08d29372e34b2e432e6148295dcf94f Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 28 May 2019 16:07:35 +0300 Subject: [PATCH 039/113] Synchronous import queue + fix async inport queue shutdown (#2701) * sync implementation of ImportQueue * fix import queue shutdown * never clone import queue --- Cargo.lock | 1 + core/consensus/common/Cargo.toml | 1 + core/consensus/common/src/import_queue.rs | 582 ++++++++++++++-------- core/network/src/service.rs | 22 +- 4 files changed, 394 insertions(+), 212 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a40f588d29..5d32c8882b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3999,6 +3999,7 @@ dependencies = [ "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index 5e55d555dd..a64ae120f4 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -18,6 +18,7 @@ runtime_version = { package = "sr-version", path = "../../sr-version" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } tokio-timer = "0.2" parity-codec = { version = "3.3", features = ["derive"] } +parking_lot = "0.7.1" [dev-dependencies] test_client = { package = "substrate-test-client", path = "../../test-client" } diff --git a/core/consensus/common/src/import_queue.rs b/core/consensus/common/src/import_queue.rs index 4d64d799b1..26ae181b51 100644 --- a/core/consensus/common/src/import_queue.rs +++ b/core/consensus/common/src/import_queue.rs @@ -31,6 +31,7 @@ use crate::block_import::{ }; use crossbeam_channel::{self as channel, Receiver, Sender}; use parity_codec::Encode; +use parking_lot::Mutex; use std::sync::Arc; use std::thread; @@ -97,7 +98,7 @@ pub trait Verifier: Send + Sync { } /// Blocks import queue API. -pub trait ImportQueue: Send + Sync + ImportQueueClone { +pub trait ImportQueue: Send + Sync { /// Start background work for the queue as necessary. /// /// This is called automatically by the network service when synchronization @@ -105,8 +106,6 @@ pub trait ImportQueue: Send + Sync + ImportQueueClone { fn start(&self, _link: Box>) -> Result<(), std::io::Error> { Ok(()) } - /// Clears the import queue and stops importing. - fn stop(&self); /// Import bunch of blocks. fn import_blocks(&self, origin: BlockOrigin, blocks: Vec>); /// Import a block justification. @@ -115,13 +114,96 @@ pub trait ImportQueue: Send + Sync + ImportQueueClone { fn import_finality_proof(&self, who: Origin, hash: B::Hash, number: NumberFor, finality_proof: Vec); } -pub trait ImportQueueClone { - fn clone_box(&self) -> Box>; +/// Basic block import queue that performs import in the caller thread. +pub struct BasicSyncQueue> { + data: Arc>, } -impl Clone for Box> { - fn clone(&self) -> Box> { - self.clone_box() +struct BasicSyncQueueData> { + link: Mutex>>>, + block_import: SharedBlockImport, + verifier: Arc, + justification_import: Option>, + finality_proof_import: Option>, +} + +impl> BasicSyncQueue { + pub fn new( + block_import: SharedBlockImport, + verifier: Arc, + justification_import: Option>, + finality_proof_import: Option>, + ) -> Self { + BasicSyncQueue { + data: Arc::new(BasicSyncQueueData { + link: Mutex::new(None), + block_import, + verifier, + justification_import, + finality_proof_import, + }), + } + } +} + +impl> ImportQueue for BasicSyncQueue { + fn start(&self, link: Box>) -> Result<(), std::io::Error> { + if let Some(justification_import) = self.data.justification_import.as_ref() { + justification_import.on_start(&*link); + } + *self.data.link.lock() = Some(link); + Ok(()) + } + + fn import_blocks(&self, origin: BlockOrigin, blocks: Vec>) { + if blocks.is_empty() { + return; + } + + let (imported, count, results) = import_many_blocks( + &*self.data.block_import, + origin, + blocks, + self.data.verifier.clone(), + ); + + let link_ref = self.data.link.lock(); + let link = match link_ref.as_ref() { + Some(link) => link, + None => { + trace!(target: "sync", "Trying to import blocks before starting import queue"); + return; + }, + }; + + process_import_results(&**link, results); + + trace!(target: "sync", "Imported {} of {}", imported, count); + } + + fn import_justification(&self, who: Origin, hash: B::Hash, number: NumberFor, justification: Justification) { + import_single_justification( + &*self.data.link.lock(), + &self.data.justification_import, + who, + hash, + number, + justification, + ) + } + + fn import_finality_proof(&self, who: Origin, hash: B::Hash, number: NumberFor, finality_proof: Vec) { + let result = import_single_finality_proof( + &self.data.finality_proof_import, + &*self.data.verifier, + &who, + hash, + number, + finality_proof, + ); + if let Some(link) = self.data.link.lock().as_ref() { + link.finality_proof_imported(who, (hash, number), result); + } } } @@ -129,16 +211,20 @@ impl Clone for Box> { /// sequentially in a separate thread, with pluggable verification. #[derive(Clone)] pub struct BasicQueue { - sender: Sender>, + sender: Option>>, } -impl ImportQueueClone for BasicQueue { - fn clone_box(&self) -> Box> { - Box::new(self.clone()) +impl Drop for BasicQueue { + fn drop(&mut self) { + if let Some(sender) = self.sender.take() { + let (shutdown_sender, shutdown_receiver) = channel::unbounded(); + if sender.send(BlockImportMsg::Shutdown(shutdown_sender)).is_ok() { + let _ = shutdown_receiver.recv(); + } + } } } - /// "BasicQueue" is a wrapper around a channel sender to the "BlockImporter". /// "BasicQueue" itself does not keep any state or do any importing work, and /// can therefore be send to other threads. @@ -184,7 +270,7 @@ impl BasicQueue { ); Self { - sender: importer_sender, + sender: Some(importer_sender), } } @@ -194,52 +280,47 @@ impl BasicQueue { /// has synchronized with ImportQueue. #[cfg(any(test, feature = "test-helpers"))] pub fn synchronize(&self) { - self - .sender - .send(BlockImportMsg::Synchronize) - .expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed"); + if let Some(ref sender) = self.sender { + let _ = sender.send(BlockImportMsg::Synchronize); + } } } impl ImportQueue for BasicQueue { fn start(&self, link: Box>) -> Result<(), std::io::Error> { - let (sender, port) = channel::unbounded(); - let _ = self - .sender - .send(BlockImportMsg::Start(link, sender)) - .expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed"); - port.recv().expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed") - } - - fn stop(&self) { - let _ = self - .sender - .send(BlockImportMsg::Stop) - .expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed"); + let connect_err = || Err(std::io::Error::new( + std::io::ErrorKind::Other, + "Failed to connect import queue threads", + )); + if let Some(ref sender) = self.sender { + let (start_sender, start_port) = channel::unbounded(); + let _ = sender.send(BlockImportMsg::Start(link, start_sender)); + start_port.recv().unwrap_or_else(|_| connect_err()) + } else { + connect_err() + } } fn import_blocks(&self, origin: BlockOrigin, blocks: Vec>) { if blocks.is_empty() { return; } - let _ = self - .sender - .send(BlockImportMsg::ImportBlocks(origin, blocks)) - .expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed"); + + if let Some(ref sender) = self.sender { + let _ = sender.send(BlockImportMsg::ImportBlocks(origin, blocks)); + } } fn import_justification(&self, who: Origin, hash: B::Hash, number: NumberFor, justification: Justification) { - let _ = self - .sender - .send(BlockImportMsg::ImportJustification(who.clone(), hash, number, justification)) - .expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed"); + if let Some(ref sender) = self.sender { + let _ = sender.send(BlockImportMsg::ImportJustification(who.clone(), hash, number, justification)); + } } fn import_finality_proof(&self, who: Origin, hash: B::Hash, number: NumberFor, finality_proof: Vec) { - let _ = self - .sender - .send(BlockImportMsg::ImportFinalityProof(who, hash, number, finality_proof)) - .expect("1. self is holding a sender to the Importer, 2. Importer should handle messages while there are senders around; qed"); + if let Some(ref sender) = self.sender { + let _ = sender.send(BlockImportMsg::ImportFinalityProof(who, hash, number, finality_proof)); + } } } @@ -248,12 +329,12 @@ pub enum BlockImportMsg { ImportJustification(Origin, B::Hash, NumberFor, Justification), ImportFinalityProof(Origin, B::Hash, NumberFor, Vec), Start(Box>, Sender>), - Stop, + Shutdown(Sender<()>), #[cfg(any(test, feature = "test-helpers"))] Synchronize, } -#[cfg_attr(test, derive(Debug, PartialEq))] +#[cfg_attr(test, derive(Debug))] pub enum BlockImportWorkerMsg { ImportBlocks(BlockOrigin, Vec>), ImportedBlocks( @@ -264,6 +345,7 @@ pub enum BlockImportWorkerMsg { ), ImportFinalityProof(Origin, B::Hash, NumberFor, Vec), ImportedFinalityProof(Origin, (B::Hash, NumberFor), Result<(B::Hash, NumberFor), ()>), + Shutdown(Sender<()>), #[cfg(any(test, feature = "test-helpers"))] Synchronize, } @@ -276,7 +358,7 @@ enum ImportMsgType { struct BlockImporter { port: Receiver>, result_port: Receiver>, - worker_sender: Sender>, + worker_sender: Option>>, link: Option>>, verifier: Arc>, justification_import: Option>, @@ -301,7 +383,7 @@ impl BlockImporter { let mut importer = BlockImporter { port, result_port, - worker_sender, + worker_sender: Some(worker_sender), link: None, verifier, justification_import, @@ -345,7 +427,14 @@ impl BlockImporter { self.handle_import_blocks(origin, incoming_blocks) }, BlockImportMsg::ImportJustification(who, hash, number, justification) => { - self.handle_import_justification(who, hash, number, justification) + import_single_justification( + &self.link, + &self.justification_import, + who, + hash, + number, + justification, + ); }, BlockImportMsg::ImportFinalityProof(who, hash, number, finality_proof) => { self.handle_import_finality_proof(who, hash, number, finality_proof) @@ -363,13 +452,24 @@ impl BlockImporter { self.link = Some(link); let _ = sender.send(Ok(())); }, - BlockImportMsg::Stop => return false, + BlockImportMsg::Shutdown(result_sender) => { + // stop worker thread + if let Some(worker_sender) = self.worker_sender.take() { + let (sender, receiver) = channel::unbounded(); + if worker_sender.send(BlockImportWorkerMsg::Shutdown(sender)).is_ok() { + let _ = receiver.recv(); + } + } + // send shutdown notification + let _ = result_sender.send(()); + return false; + }, #[cfg(any(test, feature = "test-helpers"))] BlockImportMsg::Synchronize => { trace!(target: "sync", "Received synchronization message"); - self.worker_sender - .send(BlockImportWorkerMsg::Synchronize) - .expect("1. This is holding a sender to the worker, 2. the worker should not quit while a sender is still held; qed"); + if let Some(ref worker_sender) = self.worker_sender { + let _ = worker_sender.send(BlockImportWorkerMsg::Synchronize); + } }, } true @@ -398,106 +498,26 @@ impl BlockImporter { }, BlockImportWorkerMsg::ImportBlocks(_, _) | BlockImportWorkerMsg::ImportFinalityProof(_, _, _, _) - => unreachable!("Import Worker does not send Import* message; qed"), + | BlockImportWorkerMsg::Shutdown(_) + => unreachable!("Import Worker does not send Import*/Shutdown messages; qed"), }; - let mut has_error = false; - let mut hashes = vec![]; - for (result, hash) in results { - hashes.push(hash); - - if has_error { - continue; - } - - if result.is_err() { - has_error = true; - } - - match result { - Ok(BlockImportResult::ImportedKnown(number)) => link.block_imported(&hash, number), - Ok(BlockImportResult::ImportedUnknown(number, aux, who)) => { - link.block_imported(&hash, number); - - if aux.clear_justification_requests { - trace!(target: "sync", "Block imported clears all pending justification requests {}: {:?}", number, hash); - link.clear_justification_requests(); - } - - if aux.needs_justification { - trace!(target: "sync", "Block imported but requires justification {}: {:?}", number, hash); - link.request_justification(&hash, number); - } - - if aux.bad_justification { - if let Some(peer) = who { - info!("Sent block with bad justification to import"); - link.report_peer(peer, BAD_JUSTIFICATION_REPUTATION_CHANGE); - } - } - if aux.needs_finality_proof { - trace!(target: "sync", "Block imported but requires finality proof {}: {:?}", number, hash); - link.request_finality_proof(&hash, number); - } - }, - Err(BlockImportError::IncompleteHeader(who)) => { - if let Some(peer) = who { - info!("Peer sent block with incomplete header to import"); - link.report_peer(peer, INCOMPLETE_HEADER_REPUTATION_CHANGE); - link.restart(); - } - }, - Err(BlockImportError::VerificationFailed(who, e)) => { - if let Some(peer) = who { - info!("Verification failed from peer: {}", e); - link.report_peer(peer, VERIFICATION_FAIL_REPUTATION_CHANGE); - link.restart(); - } - }, - Err(BlockImportError::BadBlock(who)) => { - if let Some(peer) = who { - info!("Bad block"); - link.report_peer(peer, BAD_BLOCK_REPUTATION_CHANGE); - link.restart(); - } - }, - Err(BlockImportError::UnknownParent) | Err(BlockImportError::Error) => { - link.restart(); - }, - }; - } - if let Some(link) = self.link.as_ref() { - link.blocks_processed(hashes, has_error); - } + process_import_results(&**link, results); true } - fn handle_import_justification(&self, who: Origin, hash: B::Hash, number: NumberFor, justification: Justification) { - let success = self.justification_import.as_ref().map(|justification_import| { - justification_import.import_justification(hash, number, justification) - .map_err(|e| { - debug!(target: "sync", "Justification import failed with {:?} for hash: {:?} number: {:?} coming from node: {:?}", e, hash, number, who); - e - }).is_ok() - }).unwrap_or(false); - - if let Some(link) = self.link.as_ref() { - link.justification_imported(who, &hash, number, success); - } - } - fn handle_import_finality_proof(&self, who: Origin, hash: B::Hash, number: NumberFor, finality_proof: Vec) { - trace!(target: "sync", "Scheduling finality proof of {}/{} for import", number, hash); - self.worker_sender - .send(BlockImportWorkerMsg::ImportFinalityProof(who, hash, number, finality_proof)) - .expect("1. This is holding a sender to the worker, 2. the worker should not quit while a sender is still held; qed"); + if let Some(ref worker_sender) = self.worker_sender { + trace!(target: "sync", "Scheduling finality proof of {}/{} for import", number, hash); + let _ = worker_sender.send(BlockImportWorkerMsg::ImportFinalityProof(who, hash, number, finality_proof)); + } } fn handle_import_blocks(&mut self, origin: BlockOrigin, blocks: Vec>) { - trace!(target: "sync", "Scheduling {} blocks for import", blocks.len()); - self.worker_sender - .send(BlockImportWorkerMsg::ImportBlocks(origin, blocks)) - .expect("1. This is holding a sender to the worker, 2. the worker should not quit while a sender is still held; qed"); + if let Some(ref worker_sender) = self.worker_sender { + trace!(target: "sync", "Scheduling {} blocks for import", blocks.len()); + let _ = worker_sender.send(BlockImportWorkerMsg::ImportBlocks(origin, blocks)); + } } } @@ -534,6 +554,10 @@ impl> BlockImportWorker { BlockImportWorkerMsg::ImportFinalityProof(who, hash, number, proof) => { worker.import_finality_proof(who, hash, number, proof); }, + BlockImportWorkerMsg::Shutdown(result_sender) => { + let _ = result_sender.send(()); + break; + }, #[cfg(any(test, feature = "test-helpers"))] BlockImportWorkerMsg::Synchronize => { trace!(target: "sync", "Sending sync message"); @@ -550,44 +574,12 @@ impl> BlockImportWorker { } fn import_a_batch_of_blocks(&self, origin: BlockOrigin, blocks: Vec>) { - let count = blocks.len(); - let mut imported = 0; - - let blocks_range = match ( - blocks.first().and_then(|b| b.header.as_ref().map(|h| h.number())), - blocks.last().and_then(|b| b.header.as_ref().map(|h| h.number())), - ) { - (Some(first), Some(last)) if first != last => format!(" ({}..{})", first, last), - (Some(first), Some(_)) => format!(" ({})", first), - _ => Default::default(), - }; - - trace!(target: "sync", "Starting import of {} blocks {}", count, blocks_range); - - let mut results = vec![]; - - let mut has_error = false; - - // Blocks in the response/drain should be in ascending order. - for block in blocks { - let import_result = if has_error { - Err(BlockImportError::Error) - } else { - import_single_block( - &*self.block_import, - origin.clone(), - block.clone(), - self.verifier.clone(), - ) - }; - let was_ok = import_result.is_ok(); - results.push((import_result, block.hash)); - if was_ok { - imported += 1; - } else { - has_error = true; - } - } + let (imported, count, results) = import_many_blocks( + &*self.block_import, + origin, + blocks, + self.verifier.clone(), + ); let _ = self .result_sender @@ -597,24 +589,18 @@ impl> BlockImportWorker { } fn import_finality_proof(&self, who: Origin, hash: B::Hash, number: NumberFor, finality_proof: Vec) { - let result = self.finality_proof_import.as_ref().map(|finality_proof_import| { - finality_proof_import.import_finality_proof(hash, number, finality_proof, &*self.verifier) - .map_err(|e| { - debug!( - "Finality proof import failed with {:?} for hash: {:?} number: {:?} coming from node: {:?}", - e, - hash, - number, - who, - ); - }) - }).unwrap_or(Err(())); + let result = import_single_finality_proof( + &self.finality_proof_import, + &*self.verifier, + &who, + hash, + number, + finality_proof, + ); let _ = self .result_sender .send(BlockImportWorkerMsg::ImportedFinalityProof(who, (hash, number), result)); - - trace!(target: "sync", "Imported finality proof for {}/{}", number, hash); } } @@ -679,6 +665,193 @@ pub enum BlockImportError { Error, } +/// Imports single notification and send notification to the link (if provided). +fn import_single_justification( + link: &Option>>, + justification_import: &Option>, + who: Origin, + hash: B::Hash, + number: NumberFor, + justification: Justification, +) { + let success = justification_import.as_ref().map(|justification_import| { + justification_import.import_justification(hash, number, justification) + .map_err(|e| { + debug!( + target: "sync", + "Justification import failed with {:?} for hash: {:?} number: {:?} coming from node: {:?}", + e, + hash, + number, + who, + ); + e + }).is_ok() + }).unwrap_or(false); + + if let Some(ref link) = link { + link.justification_imported(who, &hash, number, success); + } +} + +/// Imports single finality_proof. +fn import_single_finality_proof>( + finality_proof_import: &Option>, + verifier: &V, + who: &Origin, + hash: B::Hash, + number: NumberFor, + finality_proof: Vec, +) -> Result<(B::Hash, NumberFor), ()> { + let result = finality_proof_import.as_ref().map(|finality_proof_import| { + finality_proof_import.import_finality_proof(hash, number, finality_proof, verifier) + .map_err(|e| { + debug!( + "Finality proof import failed with {:?} for hash: {:?} number: {:?} coming from node: {:?}", + e, + hash, + number, + who, + ); + }) + }).unwrap_or(Err(())); + + trace!(target: "sync", "Imported finality proof for {}/{}", number, hash); + + result +} + +/// Process result of block(s) import. +fn process_import_results( + link: &Link, + results: Vec<( + Result>, BlockImportError>, + B::Hash, + )>, +) +{ + let mut has_error = false; + let mut hashes = vec![]; + for (result, hash) in results { + hashes.push(hash); + + if has_error { + continue; + } + + if result.is_err() { + has_error = true; + } + + match result { + Ok(BlockImportResult::ImportedKnown(number)) => link.block_imported(&hash, number), + Ok(BlockImportResult::ImportedUnknown(number, aux, who)) => { + link.block_imported(&hash, number); + + if aux.clear_justification_requests { + trace!(target: "sync", "Block imported clears all pending justification requests {}: {:?}", number, hash); + link.clear_justification_requests(); + } + + if aux.needs_justification { + trace!(target: "sync", "Block imported but requires justification {}: {:?}", number, hash); + link.request_justification(&hash, number); + } + + if aux.bad_justification { + if let Some(peer) = who { + info!("Sent block with bad justification to import"); + link.report_peer(peer, BAD_JUSTIFICATION_REPUTATION_CHANGE); + } + } + + if aux.needs_finality_proof { + trace!(target: "sync", "Block imported but requires finality proof {}: {:?}", number, hash); + link.request_finality_proof(&hash, number); + } + }, + Err(BlockImportError::IncompleteHeader(who)) => { + if let Some(peer) = who { + info!("Peer sent block with incomplete header to import"); + link.report_peer(peer, INCOMPLETE_HEADER_REPUTATION_CHANGE); + link.restart(); + } + }, + Err(BlockImportError::VerificationFailed(who, e)) => { + if let Some(peer) = who { + info!("Verification failed from peer: {}", e); + link.report_peer(peer, VERIFICATION_FAIL_REPUTATION_CHANGE); + link.restart(); + } + }, + Err(BlockImportError::BadBlock(who)) => { + if let Some(peer) = who { + info!("Bad block"); + link.report_peer(peer, BAD_BLOCK_REPUTATION_CHANGE); + link.restart(); + } + }, + Err(BlockImportError::UnknownParent) | Err(BlockImportError::Error) => { + link.restart(); + }, + }; + } + link.blocks_processed(hashes, has_error); +} + +/// Import several blocks at once, returning import result for each block. +fn import_many_blocks>( + import_handle: &BlockImport, + blocks_origin: BlockOrigin, + blocks: Vec>, + verifier: Arc, +) -> (usize, usize, Vec<( + Result>, BlockImportError>, + B::Hash, +)>) { + let count = blocks.len(); + let mut imported = 0; + + let blocks_range = match ( + blocks.first().and_then(|b| b.header.as_ref().map(|h| h.number())), + blocks.last().and_then(|b| b.header.as_ref().map(|h| h.number())), + ) { + (Some(first), Some(last)) if first != last => format!(" ({}..{})", first, last), + (Some(first), Some(_)) => format!(" ({})", first), + _ => Default::default(), + }; + + trace!(target: "sync", "Starting import of {} blocks {}", count, blocks_range); + + let mut results = vec![]; + + let mut has_error = false; + + // Blocks in the response/drain should be in ascending order. + for block in blocks { + let block_hash = block.hash; + let import_result = if has_error { + Err(BlockImportError::Error) + } else { + import_single_block( + import_handle, + blocks_origin.clone(), + block, + verifier.clone(), + ) + }; + let was_ok = import_result.is_ok(); + results.push((import_result, block_hash)); + if was_ok { + imported += 1; + } else { + has_error = true; + } + } + + (imported, count, results) +} + /// Single block import function. pub fn import_single_block>( import_handle: &BlockImport, @@ -909,12 +1082,19 @@ mod tests { )).unwrap(); // Wait until this request is redirected to the BlockImportWorker - assert_eq!(worker_receiver.recv(), Ok(BlockImportWorkerMsg::ImportFinalityProof( - who.clone(), - Default::default(), - 1, - vec![42], - ))); + match worker_receiver.recv().unwrap() { + BlockImportWorkerMsg::ImportFinalityProof( + cwho, + chash, + 1, + cproof, + ) => { + assert_eq!(cwho, who); + assert_eq!(chash, Default::default()); + assert_eq!(cproof, vec![42]); + }, + _ => unreachable!("Unexpected work request received"), + } // Send ack of proof import from BlockImportWorker to BlockImporter result_sender.send(BlockImportWorkerMsg::ImportedFinalityProof( diff --git a/core/network/src/service.rs b/core/network/src/service.rs index b2e56a83bd..c8679c96f7 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -211,6 +211,14 @@ impl> Service { let (network_chan, network_port) = mpsc::unbounded(); let (protocol_sender, protocol_rx) = mpsc::unbounded(); let status_sinks = Arc::new(Mutex::new(Vec::new())); + + // connect the import-queue to the network service. + let link = NetworkLink { + protocol_sender: protocol_sender.clone(), + network_sender: network_chan.clone(), + }; + import_queue.start(Box::new(link))?; + // Start in off-line mode, since we're not connected to any nodes yet. let is_offline = Arc::new(AtomicBool::new(true)); let is_major_syncing = Arc::new(AtomicBool::new(false)); @@ -229,7 +237,7 @@ impl> Service { is_major_syncing.clone(), protocol, peers.clone(), - import_queue.clone(), + import_queue, params.transaction_pool, params.finality_proof_provider, network_port, @@ -244,22 +252,14 @@ impl> Service { status_sinks, is_offline, is_major_syncing, - network_chan: network_chan.clone(), + network_chan, peers, peerset, network, - protocol_sender: protocol_sender.clone(), + protocol_sender, bg_thread: Some(thread), }); - // connect the import-queue to the network service. - let link = NetworkLink { - protocol_sender, - network_sender: network_chan, - }; - - import_queue.start(Box::new(link))?; - Ok(service) } -- GitLab From 752a22247c03f75ce3cfbb2229821c972e04e54d Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 May 2019 15:07:55 +0200 Subject: [PATCH 040/113] Deprecate NetworkSpecialization::on_abort (#2697) --- core/network/src/specialization.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/network/src/specialization.rs b/core/network/src/specialization.rs index 58a63bb7a3..41d6c2edc8 100644 --- a/core/network/src/specialization.rs +++ b/core/network/src/specialization.rs @@ -35,6 +35,7 @@ pub trait NetworkSpecialization: Send + Sync + 'static { fn on_message(&mut self, ctx: &mut Context, who: PeerId, message: &mut Option>); /// Called on abort. + #[deprecated(note = "This method is never called; aborting corresponds to dropping the object")] fn on_abort(&mut self) { } /// Called periodically to maintain peers and handle timeouts. -- GitLab From 20f82748f40c95c4a9d0b188961abffe28729e07 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 28 May 2019 15:10:19 +0200 Subject: [PATCH 041/113] Update docs on `Imbalance` in the Balances module (#2704) * Update docs on `Imbalance` in the Balances module * Update lib.rs --- srml/balances/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srml/balances/src/lib.rs b/srml/balances/src/lib.rs index 9fe93a9d4a..e205fa0aaa 100644 --- a/srml/balances/src/lib.rs +++ b/srml/balances/src/lib.rs @@ -51,7 +51,8 @@ //! deleted, then the account is said to be dead. //! - **Imbalance:** A condition when some funds were credited or debited without equal and opposite accounting //! (i.e. a difference between total issuance and account balances). Functions that result in an imbalance will -//! return an object of the `Imbalance` trait that must be handled. +//! return an object of the `Imbalance` trait that can be managed within your runtime logic. (If an imbalance is +//! simply dropped, it should automatically maintain any book-keeping such as total issuance.) //! - **Lock:** A freeze on a specified amount of an account's free balance until a specified block number. Multiple //! locks always operate over the same funds, so they "overlay" rather than "stack". //! - **Vesting:** Similar to a lock, this is another, but independent, liquidity restriction that reduces linearly -- GitLab From 8412fef0585c8ec5cf3c0b1e019a2e74e309551e Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 May 2019 15:12:55 +0200 Subject: [PATCH 042/113] Make RocksDB optional in client-db (#2686) --- core/client/db/Cargo.toml | 7 +++---- core/client/db/src/lib.rs | 15 +++++++++++++-- core/client/db/src/light.rs | 16 +++++++++++++--- core/client/db/src/utils.rs | 2 ++ core/service/Cargo.toml | 2 +- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/core/client/db/Cargo.toml b/core/client/db/Cargo.toml index 3fea4fd812..77512ec269 100644 --- a/core/client/db/Cargo.toml +++ b/core/client/db/Cargo.toml @@ -9,8 +9,8 @@ parking_lot = "0.7.1" log = "0.4" kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } # FIXME replace with release as soon as our rocksdb changes are released upstream https://github.com/paritytech/parity-common/issues/88 -kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } +kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } lru-cache = "0.1.1" hash-db = { version = "0.12" } primitives = { package = "substrate-primitives", path = "../../primitives" } @@ -24,11 +24,10 @@ trie = { package = "substrate-trie", path = "../../trie" } consensus_common = { package = "substrate-consensus-common", path = "../../consensus/common" } [dev-dependencies] -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } substrate-keyring = { path = "../../keyring" } test-client = { package = "substrate-test-client", path = "../../test-client" } env_logger = { version = "0.6" } [features] default = [] -test-helpers = ["kvdb-memorydb"] +test-helpers = [] diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index e9e9a61a76..82d570567b 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -54,7 +54,7 @@ use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; use executor::RuntimeInfo; use state_machine::{CodeExecutor, DBValue}; -use crate::utils::{Meta, db_err, meta_keys, open_database, read_db, block_id_to_lookup_key, read_meta}; +use crate::utils::{Meta, db_err, meta_keys, read_db, block_id_to_lookup_key, read_meta}; use client::leaves::{LeafSet, FinalizationDisplaced}; use client::children; use state_db::StateDb; @@ -572,8 +572,19 @@ impl> Backend { /// /// The pruning window is how old a block must be before the state is pruned. pub fn new(config: DatabaseSettings, canonicalization_delay: u64) -> Result { - let db = open_database(&config, columns::META, "full")?; + Self::new_inner(config, canonicalization_delay) + } + + #[cfg(feature = "kvdb-rocksdb")] + fn new_inner(config: DatabaseSettings, canonicalization_delay: u64) -> Result { + let db = crate::utils::open_database(&config, columns::META, "full")?; + Backend::from_kvdb(db as Arc<_>, config.pruning, canonicalization_delay, config.state_cache_size) + } + #[cfg(not(feature = "kvdb-rocksdb"))] + fn new_inner(config: DatabaseSettings, canonicalization_delay: u64) -> Result { + log::warn!("Running without the RocksDB feature. The database will NOT be saved."); + let db = Arc::new(kvdb_memorydb::create(crate::utils::NUM_COLUMNS)); Backend::from_kvdb(db as Arc<_>, config.pruning, canonicalization_delay, config.state_cache_size) } diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index cbac1b730e..e145e63cb7 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -38,8 +38,7 @@ use runtime_primitives::traits::{ }; use consensus_common::well_known_cache_keys; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType}; -use crate::utils::{self, meta_keys, Meta, db_err, open_database, - read_db, block_id_to_lookup_key, read_meta}; +use crate::utils::{self, meta_keys, Meta, db_err, read_db, block_id_to_lookup_key, read_meta}; use crate::DatabaseSettings; use log::{trace, warn, debug}; @@ -72,8 +71,19 @@ impl LightStorage { /// Create new storage with given settings. pub fn new(config: DatabaseSettings) -> ClientResult { - let db = open_database(&config, columns::META, "light")?; + Self::new_inner(config) + } + + #[cfg(feature = "kvdb-rocksdb")] + fn new_inner(config: DatabaseSettings) -> ClientResult { + let db = crate::utils::open_database(&config, columns::META, "light")?; + Self::from_kvdb(db as Arc<_>) + } + #[cfg(not(feature = "kvdb-rocksdb"))] + fn new_inner(_config: DatabaseSettings) -> ClientResult { + log::warn!("Running without the RocksDB feature. The database will NOT be saved."); + let db = Arc::new(kvdb_memorydb::create(crate::utils::NUM_COLUMNS)); Self::from_kvdb(db as Arc<_>) } diff --git a/core/client/db/src/utils.rs b/core/client/db/src/utils.rs index 43c559b349..846bf05f3c 100644 --- a/core/client/db/src/utils.rs +++ b/core/client/db/src/utils.rs @@ -22,6 +22,7 @@ use std::io; use std::convert::TryInto; use kvdb::{KeyValueDB, DBTransaction}; +#[cfg(feature = "kvdb-rocksdb")] use kvdb_rocksdb::{Database, DatabaseConfig}; use log::debug; @@ -195,6 +196,7 @@ pub fn db_err(err: io::Error) -> client::error::Error { } /// Open RocksDB database. +#[cfg(feature = "kvdb-rocksdb")] pub fn open_database(config: &DatabaseSettings, col_meta: Option, db_type: &str) -> client::error::Result> { let mut db_config = DatabaseConfig::with_columns(Some(NUM_COLUMNS)); db_config.memory_budget = config.cache_size; diff --git a/core/service/Cargo.toml b/core/service/Cargo.toml index e27c2d61b3..bf13a51fac 100644 --- a/core/service/Cargo.toml +++ b/core/service/Cargo.toml @@ -24,7 +24,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives" consensus_common = { package = "substrate-consensus-common", path = "../../core/consensus/common" } network = { package = "substrate-network", path = "../../core/network" } client = { package = "substrate-client", path = "../../core/client" } -client_db = { package = "substrate-client-db", path = "../../core/client/db" } +client_db = { package = "substrate-client-db", path = "../../core/client/db", features = ["kvdb-rocksdb"] } parity-codec = "3.3" substrate-executor = { path = "../../core/executor" } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } -- GitLab From c21002acec970cd8d67006ca640eb05ed2289bd6 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 May 2019 16:50:36 +0200 Subject: [PATCH 043/113] The network configuration now makes more sense (#2706) * The network configuration now makes more sense * Reexport ProtocolConfig --- core/network/src/config.rs | 27 +++++++++------------------ core/network/src/protocol.rs | 17 ++++++++++++++++- core/network/src/service.rs | 19 +++++++------------ core/network/src/test/mod.rs | 4 ++-- core/service/src/lib.rs | 24 +++++++++++++----------- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/core/network/src/config.rs b/core/network/src/config.rs index a2a34780bf..e6c1a4ddd5 100644 --- a/core/network/src/config.rs +++ b/core/network/src/config.rs @@ -16,9 +16,11 @@ //! Configuration for the networking layer of Substrate. -pub use network_libp2p::{NonReservedPeerMode, NetworkConfiguration, NodeKeyConfig, Secret}; +pub use crate::protocol::ProtocolConfig; +pub use network_libp2p::{NonReservedPeerMode, NetworkConfiguration, NodeKeyConfig, ProtocolId, Secret}; use bitflags::bitflags; +use consensus::import_queue::ImportQueue; use crate::chain::{Client, FinalityProofProvider}; use parity_codec; use crate::on_demand_layer::OnDemand; @@ -28,8 +30,8 @@ use std::sync::Arc; /// Service initialization parameters. pub struct Params { - /// Configuration. - pub config: ProtocolConfig, + /// Assigned roles for our node. + pub roles: Roles, /// Network layer configuration. pub network_config: NetworkConfiguration, /// Substrate relay chain access point. @@ -40,25 +42,14 @@ pub struct Params { pub on_demand: Option>>, /// Transaction pool. pub transaction_pool: Arc>, + /// Name of the protocol to use on the wire. Should be different for each chain. + pub protocol_id: ProtocolId, + /// Import queue to use. + pub import_queue: Box>, /// Protocol specialization. pub specialization: S, } -/// Configuration for the Substrate-specific part of the networking layer. -#[derive(Clone)] -pub struct ProtocolConfig { - /// Assigned roles. - pub roles: Roles, -} - -impl Default for ProtocolConfig { - fn default() -> ProtocolConfig { - ProtocolConfig { - roles: Roles::FULL, - } - } -} - bitflags! { /// Bitmask of the roles that a node fulfills. pub struct Roles: u8 { diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index b3102e588e..2fafc9e756 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -34,7 +34,7 @@ use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; use crate::specialization::NetworkSpecialization; use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; use crate::service::{TransactionPool, ExHashT}; -use crate::config::{ProtocolConfig, Roles}; +use crate::config::Roles; use rustc_hex::ToHex; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; @@ -273,6 +273,21 @@ struct ContextData { pub chain: Arc>, } +/// Configuration for the Substrate-specific part of the networking layer. +#[derive(Clone)] +pub struct ProtocolConfig { + /// Assigned roles. + pub roles: Roles, +} + +impl Default for ProtocolConfig { + fn default() -> ProtocolConfig { + ProtocolConfig { + roles: Roles::FULL, + } + } +} + impl, H: ExHashT> Protocol { /// Create a new instance. pub fn new( diff --git a/core/network/src/service.rs b/core/network/src/service.rs index c8679c96f7..805fb55ddb 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -22,9 +22,8 @@ use std::{io, thread, time::Duration}; use log::{warn, debug, error, info}; use futures::{Async, Future, Stream, sync::oneshot, sync::mpsc}; use parking_lot::{Mutex, RwLock}; -use network_libp2p::{ProtocolId, NetworkConfiguration}; use network_libp2p::{start_service, parse_str_addr, Service as NetworkService, ServiceEvent as NetworkServiceEvent}; -use network_libp2p::{RegisteredProtocol, NetworkState}; +use network_libp2p::{NetworkConfiguration, RegisteredProtocol, NetworkState}; use peerset::PeersetHandle; use consensus::import_queue::{ImportQueue, Link, SharedFinalityProofRequestBuilder}; use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; @@ -205,8 +204,6 @@ impl> Service { /// Creates and register protocol with the network service pub fn new( params: Params, - protocol_id: ProtocolId, - import_queue: Box>, ) -> Result>, Error> { let (network_chan, network_port) = mpsc::unbounded(); let (protocol_sender, protocol_rx) = mpsc::unbounded(); @@ -217,27 +214,27 @@ impl> Service { protocol_sender: protocol_sender.clone(), network_sender: network_chan.clone(), }; - import_queue.start(Box::new(link))?; + params.import_queue.start(Box::new(link))?; // Start in off-line mode, since we're not connected to any nodes yet. let is_offline = Arc::new(AtomicBool::new(true)); let is_major_syncing = Arc::new(AtomicBool::new(false)); let peers: Arc>>> = Arc::new(Default::default()); let protocol = Protocol::new( - params.config, + protocol::ProtocolConfig { roles: params.roles }, params.chain, params.on_demand.as_ref().map(|od| od.checker().clone()) .unwrap_or(Arc::new(AlwaysBadChecker)), params.specialization, )?; let versions: Vec<_> = ((protocol::MIN_VERSION as u8)..=(protocol::CURRENT_VERSION as u8)).collect(); - let registered = RegisteredProtocol::new(protocol_id, &versions); + let registered = RegisteredProtocol::new(params.protocol_id, &versions); let (thread, network, peerset) = start_thread( is_offline.clone(), is_major_syncing.clone(), protocol, peers.clone(), - import_queue, + params.import_queue, params.transaction_pool, params.finality_proof_provider, network_port, @@ -248,7 +245,7 @@ impl> Service { params.on_demand.and_then(|od| od.extract_receiver()), )?; - let service = Arc::new(Service { + Ok(Arc::new(Service { status_sinks, is_offline, is_major_syncing, @@ -258,9 +255,7 @@ impl> Service { network, protocol_sender, bg_thread: Some(thread), - }); - - Ok(service) + })) } /// Returns the downloaded bytes per second averaged over the past few seconds. diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 301f5653f1..9e2059fd61 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -31,7 +31,7 @@ use client::{self, ClientInfo, BlockchainEvents, FinalityNotifications}; use client::{in_mem::Backend as InMemoryBackend, error::Result as ClientResult}; use client::block_builder::BlockBuilder; use client::backend::AuxStore; -use crate::config::{ProtocolConfig, Roles}; +use crate::config::Roles; use consensus::import_queue::{BasicQueue, ImportQueue, IncomingBlock}; use consensus::import_queue::{ Link, SharedBlockImport, SharedJustificationImport, Verifier, SharedFinalityProofImport, @@ -45,7 +45,7 @@ use crate::message::Message; use network_libp2p::PeerId; use parking_lot::{Mutex, RwLock}; use primitives::{H256, sr25519::Public as AuthorityId, Blake2Hasher}; -use crate::protocol::{Context, Protocol, ProtocolStatus, CustomMessageOutcome, NetworkOut}; +use crate::protocol::{Context, Protocol, ProtocolConfig, ProtocolStatus, CustomMessageOutcome, NetworkOut}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{AuthorityIdFor, Block as BlockT, Digest, DigestItem, Header, NumberFor}; use runtime_primitives::{Justification, ConsensusEngineId}; diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 2a69dc83c7..d2b4a66c5b 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -177,16 +177,6 @@ impl Service { client: client.clone(), }); - let network_params = network::config::Params { - config: network::config::ProtocolConfig { roles: config.roles }, - network_config: config.network.clone(), - chain: client.clone(), - finality_proof_provider, - on_demand, - transaction_pool: transaction_pool_adapter.clone() as _, - specialization: network_protocol, - }; - let protocol_id = { let protocol_id_full = match config.chain_spec.protocol_id() { Some(pid) => pid, @@ -200,8 +190,20 @@ impl Service { network::ProtocolId::from(protocol_id_full) }; + let network_params = network::config::Params { + roles: config.roles, + network_config: config.network.clone(), + chain: client.clone(), + finality_proof_provider, + on_demand, + transaction_pool: transaction_pool_adapter.clone() as _, + import_queue, + protocol_id, + specialization: network_protocol, + }; + let has_bootnodes = !network_params.network_config.boot_nodes.is_empty(); - let network = network::Service::new(network_params, protocol_id, import_queue)?; + let network = network::Service::new(network_params)?; let inherents_pool = Arc::new(InherentsPool::default()); let offchain_workers = if config.offchain_worker { -- GitLab From ae37cb869c217c9a2167660509472f388281a5b6 Mon Sep 17 00:00:00 2001 From: Jordan Beauchamp Date: Wed, 29 May 2019 02:51:10 +1200 Subject: [PATCH 044/113] Pass through authority key with --dev (#2603) --- core/cli/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index e629788e80..c8df07ad1f 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -465,7 +465,7 @@ where config.keys.push(key); } - if cli.shared_params.dev { + if cli.shared_params.dev && cli.keyring.account.is_none() { config.keys.push("//Alice".into()); } -- GitLab From 2416e360ca5b51ac9d155dce1229213029ebd469 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Wed, 29 May 2019 00:58:31 +1000 Subject: [PATCH 045/113] Fix typo in block_builder.rs (#2674) * Fix typo in block_builder.rs * Fix the typo fix again in block_builder.rs Co-Authored-By: Gavin Wood --- core/client/src/block_builder/block_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/client/src/block_builder/block_builder.rs b/core/client/src/block_builder/block_builder.rs index 4d40bed9b0..995b303699 100644 --- a/core/client/src/block_builder/block_builder.rs +++ b/core/client/src/block_builder/block_builder.rs @@ -52,7 +52,7 @@ where /// particular block's ID to build upon with optional proof recording enabled. /// /// While proof recording is enabled, all accessed trie nodes are saved. - /// These recorded trie nodes can be used by a third party to proof the + /// These recorded trie nodes can be used by a third party to prove the /// output of this block builder without having access to the full storage. pub fn at_block( block_id: &BlockId, -- GitLab From 1e580a5c090d630986cc64801862f22b5f1c1b52 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Wed, 29 May 2019 00:59:09 +1000 Subject: [PATCH 046/113] docs: Try fix typo (#2677) --- core/sr-primitives/src/transaction_validity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-primitives/src/transaction_validity.rs b/core/sr-primitives/src/transaction_validity.rs index d927bd74e4..29d2a82a24 100644 --- a/core/sr-primitives/src/transaction_validity.rs +++ b/core/sr-primitives/src/transaction_validity.rs @@ -51,7 +51,7 @@ pub enum TransactionValidity { /// /// A list of tags this transaction provides. Successfully importing the transaction /// will enable other transactions that depend on (require) those tags to be included as well. - /// Provided and requried tags allow Substrate to build a dependency graph of transactions + /// Provided and required tags allow Substrate to build a dependency graph of transactions /// and import them in the right (linear) order. provides: Vec, /// Transaction longevity -- GitLab From 7e7185cefdaa38c6439655365cfda2eca7d7c8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Tue, 28 May 2019 17:01:43 +0200 Subject: [PATCH 047/113] Transaction factory (#2481) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix typos * Add transaction factory `cargo run -- purge-chain -y --chain dev && cargo run -- --dev --transaction-factory 10` * Fix comment and remove build deps * Move crate to test-utils * Switch from flag to subcommand `cargo run -- factory --dev --num 5` * Decouple factory from node specifics * Introduce different manufacturing modes * Remove unrelated changes * Update Cargo.lock * Use SelectChain to fetch best block * Improve expect proof * Panic if factory executed with unsupported chain spec * Link ToDo comments to follow-up ticket * Address comments and improve style * Remove unused dependencies * Fix indent level * Replace naked unwrap * Update node/cli/src/factory_impl.rs * Fix typo * Use inherent_extrinsics instead of timestamp * Generalize factory and remove saturated conversions * Format imports * Make it clearer that database needs to be empty * Ensure factory settings * Apply suggestions from code review Co-Authored-By: Bastian Köcher * Update test-utils/transaction-factory/src/lib.rs Co-Authored-By: Bastian Köcher * Fix match guard syntax * Simplify import, remove empty line * Update node/cli/Cargo.toml * Update lockfile --- Cargo.lock | 20 ++ core/cli/src/lib.rs | 9 +- core/cli/src/traits.rs | 2 +- core/consensus/common/src/lib.rs | 2 +- core/inherents/src/lib.rs | 2 +- core/sr-primitives/src/generic/mod.rs | 2 +- node/cli/Cargo.toml | 7 + node/cli/src/factory_impl.rs | 259 ++++++++++++++++++ node/cli/src/lib.rs | 103 ++++++- test-utils/transaction-factory/Cargo.toml | 22 ++ .../transaction-factory/src/complex_mode.rs | 156 +++++++++++ test-utils/transaction-factory/src/lib.rs | 179 ++++++++++++ test-utils/transaction-factory/src/modes.rs | 41 +++ .../transaction-factory/src/simple_modes.rs | 106 +++++++ 14 files changed, 898 insertions(+), 12 deletions(-) create mode 100644 node/cli/src/factory_impl.rs create mode 100644 test-utils/transaction-factory/Cargo.toml create mode 100644 test-utils/transaction-factory/src/complex_mode.rs create mode 100644 test-utils/transaction-factory/src/lib.rs create mode 100644 test-utils/transaction-factory/src/modes.rs create mode 100644 test-utils/transaction-factory/src/simple_modes.rs diff --git a/Cargo.lock b/Cargo.lock index 5d32c8882b..ac6f721d81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2020,8 +2020,12 @@ dependencies = [ "node-primitives 2.0.0", "node-runtime 2.0.0", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "srml-finality-tracker 2.0.0", + "srml-indices 2.0.0", + "srml-timestamp 2.0.0", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-basic-authorship 2.0.0", "substrate-cli 2.0.0", @@ -2029,6 +2033,7 @@ dependencies = [ "substrate-consensus-aura 2.0.0", "substrate-finality-grandpa 2.0.0", "substrate-inherents 2.0.0", + "substrate-keyring 2.0.0", "substrate-keystore 2.0.0", "substrate-network 2.0.0", "substrate-primitives 2.0.0", @@ -2037,6 +2042,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-transaction-pool 2.0.0", "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "transaction-factory 0.0.1", ] [[package]] @@ -4918,6 +4924,20 @@ name = "traitobject" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "transaction-factory" +version = "0.0.1" +dependencies = [ + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 2.0.0", + "substrate-cli 2.0.0", + "substrate-client 2.0.0", + "substrate-consensus-common 2.0.0", + "substrate-primitives 2.0.0", + "substrate-service 2.0.0", +] + [[package]] name = "trie-bench" version = "0.12.2" diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index c8df07ad1f..101151ea0d 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -49,10 +49,10 @@ use structopt::{StructOpt, clap::AppSettings}; pub use structopt::clap::App; use params::{ RunCmd, PurgeChainCmd, RevertCmd, ImportBlocksCmd, ExportBlocksCmd, BuildSpecCmd, - NetworkConfigurationParams, SharedParams, MergeParameters, TransactionPoolParams, + NetworkConfigurationParams, MergeParameters, TransactionPoolParams, NodeKeyParams, NodeKeyType }; -pub use params::{NoCustom, CoreParams}; +pub use params::{NoCustom, CoreParams, SharedParams}; pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; use log::info; @@ -178,7 +178,7 @@ fn is_node_name_valid(_name: &str) -> Result<(), &str> { /// /// `CC` is a custom subcommand. This needs to be an `enum`! If no custom subcommand is required, /// `NoCustom` can be used as type here. -/// `RP` is are custom parameters for the run command. This needs to be a `struct`! The custom +/// `RP` are custom parameters for the run command. This needs to be a `struct`! The custom /// parameters are visible to the user as if they were normal run command parameters. If no custom /// parameters are required, `NoCustom` can be used as type here. pub fn parse_and_execute<'a, F, CC, RP, S, RS, E, I, T>( @@ -582,7 +582,8 @@ where Ok(()) } -fn create_config_with_db_path( +/// Creates a configuration including the database path. +pub fn create_config_with_db_path( spec_factory: S, cli: &SharedParams, version: &VersionInfo, ) -> error::Result> where diff --git a/core/cli/src/traits.rs b/core/cli/src/traits.rs index ddb389e454..0f8d247e49 100644 --- a/core/cli/src/traits.rs +++ b/core/cli/src/traits.rs @@ -16,7 +16,7 @@ use structopt::{StructOpt, clap::App}; -/// Something that can augment a clapp app with further parameters. +/// Something that can augment a clap app with further parameters. /// `derive(StructOpt)` is implementing this function by default, so a macro `impl_augment_clap!` /// is provided to simplify the implementation of this trait. pub trait AugmentClap: StructOpt { diff --git a/core/consensus/common/src/lib.rs b/core/consensus/common/src/lib.rs index d28864a0cc..2d6c53d164 100644 --- a/core/consensus/common/src/lib.rs +++ b/core/consensus/common/src/lib.rs @@ -39,7 +39,7 @@ pub use inherents::InherentData; pub mod offline_tracker; pub mod error; -mod block_import; +pub mod block_import; mod select_chain; pub mod import_queue; pub mod evaluation; diff --git a/core/inherents/src/lib.rs b/core/inherents/src/lib.rs index 87fa39fe06..62b6f655cf 100644 --- a/core/inherents/src/lib.rs +++ b/core/inherents/src/lib.rs @@ -69,7 +69,7 @@ impl InherentData { /// /// # Return /// - /// Returns `Ok(())` if the data could be inserted an no data for an inherent with the same + /// Returns `Ok(())` if the data could be inserted and no data for an inherent with the same /// identifier existed, otherwise an error is returned. /// /// Inherent identifiers need to be unique, otherwise decoding of these values will not work! diff --git a/core/sr-primitives/src/generic/mod.rs b/core/sr-primitives/src/generic/mod.rs index b0f86f959f..3d7682407e 100644 --- a/core/sr-primitives/src/generic/mod.rs +++ b/core/sr-primitives/src/generic/mod.rs @@ -32,7 +32,7 @@ mod tests; pub use self::unchecked_extrinsic::UncheckedExtrinsic; pub use self::unchecked_mortal_extrinsic::UncheckedMortalExtrinsic; pub use self::unchecked_mortal_compact_extrinsic::UncheckedMortalCompactExtrinsic; -pub use self::era::Era; +pub use self::era::{Era, Phase}; pub use self::checked_extrinsic::CheckedExtrinsic; pub use self::header::Header; pub use self::block::{Block, SignedBlock, BlockId}; diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index 38cf49c35f..3c46f48f3f 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -30,6 +30,13 @@ sr-primitives = { path = "../../core/sr-primitives" } node-executor = { path = "../executor" } substrate-keystore = { path = "../../core/keystore" } substrate-telemetry = { package = "substrate-telemetry", path = "../../core/telemetry" } +structopt = "0.2" +transaction-factory = { path = "../../test-utils/transaction-factory" } +keyring = { package = "substrate-keyring", path = "../../core/keyring" } +indices = { package = "srml-indices", path = "../../srml/indices" } +timestamp = { package = "srml-timestamp", path = "../../srml/timestamp", default-features = false } +rand = "0.6" +finality_tracker = { package = "srml-finality-tracker", path = "../../srml/finality-tracker", default-features = false } [dev-dependencies] service-test = { package = "substrate-service-test", path = "../../core/service/test" } diff --git a/node/cli/src/factory_impl.rs b/node/cli/src/factory_impl.rs new file mode 100644 index 0000000000..a2ac6f5b29 --- /dev/null +++ b/node/cli/src/factory_impl.rs @@ -0,0 +1,259 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Implementation of the transaction factory trait, which enables +//! using the cli to manufacture transactions and distribute them +//! to accounts. + +use rand::{Rng, SeedableRng}; +use rand::rngs::StdRng; + +use parity_codec::Decode; +use keyring::sr25519::Keyring; +use node_primitives::Hash; +use node_runtime::{Call, CheckedExtrinsic, UncheckedExtrinsic, BalancesCall}; +use primitives::sr25519; +use primitives::crypto::Pair; +use parity_codec::Encode; +use sr_primitives::generic::Era; +use sr_primitives::traits::{Block as BlockT, Header as HeaderT}; +use substrate_service::ServiceFactory; +use transaction_factory::RuntimeAdapter; +use transaction_factory::modes::Mode; +use crate::service; +use inherents::InherentData; +use timestamp; +use finality_tracker; + +// TODO get via api: >::minimum_period(). See #2587. +const MINIMUM_PERIOD: u64 = 99; + +pub struct FactoryState { + block_no: N, + + mode: Mode, + start_number: u64, + rounds: u64, + round: u64, + block_in_round: u64, + num: u64, +} + +type Number = <::Header as HeaderT>::Number; + +impl RuntimeAdapter for FactoryState { + type AccountId = node_primitives::AccountId; + type Balance = node_primitives::Balance; + type Block = node_primitives::Block; + type Phase = sr_primitives::generic::Phase; + type Secret = sr25519::Pair; + type Index = node_primitives::Index; + + type Number = Number; + + fn new( + mode: Mode, + num: u64, + rounds: u64, + ) -> FactoryState { + FactoryState { + mode, + num: num, + round: 0, + rounds, + block_in_round: 0, + block_no: 0, + start_number: 0, + } + } + + fn block_no(&self) -> Self::Number { + self.block_no + } + + fn block_in_round(&self) -> Self::Number { + self.block_in_round + } + + fn rounds(&self) -> Self::Number { + self.rounds + } + + fn num(&self) -> Self::Number { + self.num + } + + fn round(&self) -> Self::Number { + self.round + } + + fn start_number(&self) -> Self::Number { + self.start_number + } + + fn mode(&self) -> &Mode { + &self.mode + } + + fn set_block_no(&mut self, val: Self::Number) { + self.block_no = val; + } + + fn set_block_in_round(&mut self, val: Self::Number) { + self.block_in_round = val; + } + + fn set_round(&mut self, val: Self::Number) { + self.round = val; + } + + fn transfer_extrinsic( + &self, + sender: &Self::AccountId, + key: &Self::Secret, + destination: &Self::AccountId, + amount: &Self::Number, + prior_block_hash: &::Hash, + ) -> ::Extrinsic { + let index = self.extract_index(&sender, prior_block_hash); + let phase = self.extract_phase(*prior_block_hash); + + sign::(CheckedExtrinsic { + signed: Some((sender.clone(), index)), + function: Call::Balances( + BalancesCall::transfer( + indices::address::Address::Id( + destination.clone().into() + ), + (*amount).into() + ) + ) + }, key, &prior_block_hash, phase) + } + + fn inherent_extrinsics(&self) -> InherentData { + let timestamp = self.block_no * MINIMUM_PERIOD; + + let mut inherent = InherentData::new(); + inherent.put_data(timestamp::INHERENT_IDENTIFIER, ×tamp) + .expect("Failed putting timestamp inherent"); + inherent.put_data(finality_tracker::INHERENT_IDENTIFIER, &self.block_no) + .expect("Failed putting finalized number inherent"); + inherent + } + + fn minimum_balance() -> Self::Number { + // TODO get correct amount via api. See #2587. + 1337 + } + + fn master_account_id() -> Self::AccountId { + Keyring::Alice.pair().public() + } + + fn master_account_secret() -> Self::Secret { + Keyring::Alice.pair() + } + + /// Generates a random `AccountId` from `seed`. + fn gen_random_account_id(seed: &Self::Number) -> Self::AccountId { + let pair: sr25519::Pair = sr25519::Pair::from_seed(gen_seed_bytes(*seed)); + pair.public().into() + } + + /// Generates a random `Secret` from `seed`. + fn gen_random_account_secret(seed: &Self::Number) -> Self::Secret { + let pair: sr25519::Pair = sr25519::Pair::from_seed(gen_seed_bytes(*seed)); + pair + } + + fn extract_index( + &self, + _account_id: &Self::AccountId, + _block_hash: &::Hash, + ) -> Self::Index { + // TODO get correct index for account via api. See #2587. + // This currently prevents the factory from being used + // without a preceding purge of the database. + if self.mode == Mode::MasterToN || self.mode == Mode::MasterTo1 { + self.block_no() + } else { + match self.round() { + 0 => + // if round is 0 all transactions will be done with master as a sender + self.block_no(), + _ => + // if round is e.g. 1 every sender account will be new and not yet have + // any transactions done + 0 + } + } + } + + fn extract_phase( + &self, + _block_hash: ::Hash + ) -> Self::Phase { + // TODO get correct phase via api. See #2587. + // This currently prevents the factory from being used + // without a preceding purge of the database. + self.block_no + } +} + +fn gen_seed_bytes(seed: u64) -> [u8; 32] { + let mut rng: StdRng = SeedableRng::seed_from_u64(seed); + + let mut seed_bytes = [0u8; 32]; + for i in 0..32 { + seed_bytes[i] = rng.gen::(); + } + seed_bytes +} + +/// Creates an `UncheckedExtrinsic` containing the appropriate signature for +/// a `CheckedExtrinsics`. +fn sign( + xt: CheckedExtrinsic, + key: &sr25519::Pair, + prior_block_hash: &Hash, + phase: u64, +) -> ::Extrinsic { + let s = match xt.signed { + Some((signed, index)) => { + let era = Era::mortal(256, phase); + let payload = (index.into(), xt.function, era, prior_block_hash); + let signature = payload.using_encoded(|b| { + if b.len() > 256 { + key.sign(&sr_io::blake2_256(b)) + } else { + key.sign(b) + } + }).into(); + UncheckedExtrinsic { + signature: Some((indices::address::Address::Id(signed), signature, payload.0, era)), + function: payload.1, + } + } + None => UncheckedExtrinsic { + signature: None, + function: xt.function, + }, + }; + + let e = Encode::encode(&s); + Decode::decode(&mut &e[..]).expect("Failed to decode signed unchecked extrinsic") +} diff --git a/node/cli/src/lib.rs b/node/cli/src/lib.rs index 886c6eef77..ab1fd03ae7 100644 --- a/node/cli/src/lib.rs +++ b/node/cli/src/lib.rs @@ -22,16 +22,21 @@ pub use cli::error; pub mod chain_spec; mod service; +mod factory_impl; use tokio::prelude::Future; use tokio::runtime::{Builder as RuntimeBuilder, Runtime}; -pub use cli::{VersionInfo, IntoExit, NoCustom}; +pub use cli::{VersionInfo, IntoExit, NoCustom, SharedParams}; use substrate_service::{ServiceFactory, Roles as ServiceRoles}; use std::ops::Deref; use log::info; +use structopt::{StructOpt, clap::App}; +use cli::{AugmentClap, GetLogFilter}; +use crate::factory_impl::FactoryState; +use transaction_factory::RuntimeAdapter; /// The chain specification option. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub enum ChainSpec { /// Whatever the current runtime is, with just Alice as an auth. Development, @@ -43,6 +48,68 @@ pub enum ChainSpec { StagingTestnet, } +/// Custom subcommands. +#[derive(Clone, Debug, StructOpt)] +pub enum CustomSubcommands { + /// The custom factory subcommmand for manufacturing transactions. + #[structopt( + name = "factory", + about = "Manufactures num transactions from Alice to random accounts. \ + Only supported for development or local testnet." + )] + Factory(FactoryCmd), +} + +impl GetLogFilter for CustomSubcommands { + fn get_log_filter(&self) -> Option { + None + } +} + +/// The `factory` command used to generate transactions. +/// Please note: this command currently only works on an empty database! +#[derive(Debug, StructOpt, Clone)] +pub struct FactoryCmd { + /// How often to repeat. This option only has an effect in mode `MasterToNToM`. + #[structopt(long="rounds", default_value = "1")] + pub rounds: u64, + + /// MasterToN: Manufacture `num` transactions from the master account + /// to `num` randomly created accounts, one each. + /// + /// MasterTo1: Manufacture `num` transactions from the master account + /// to exactly one other randomly created account. + /// + /// MasterToNToM: Manufacture `num` transactions from the master account + /// to `num` randomly created accounts. + /// From each of these randomly created accounts manufacture + /// a transaction to another randomly created account. + /// Repeat this `rounds` times. If `rounds` = 1 the behavior + /// is the same as `MasterToN`.{n} + /// A -> B, A -> C, A -> D, ... x `num`{n} + /// B -> E, C -> F, D -> G, ...{n} + /// ... x `rounds` + /// + /// These three modes control manufacturing. + #[structopt(long="mode", default_value = "MasterToN")] + pub mode: transaction_factory::Mode, + + /// Number of transactions to generate. In mode `MasterNToNToM` this is + /// the number of transactions per round. + #[structopt(long="num", default_value = "8")] + pub num: u64, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub shared_params: SharedParams, +} + +impl AugmentClap for FactoryCmd { + fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + FactoryCmd::augment_clap(app) + } +} + /// Get a chain config from a spec setting. impl ChainSpec { pub(crate) fn load(self) -> Result { @@ -78,7 +145,7 @@ pub fn run(args: I, exit: E, version: cli::VersionInfo) -> error::Resul T: Into + Clone, E: IntoExit, { - cli::parse_and_execute::( + let ret = cli::parse_and_execute::( load_spec, &version, "substrate-node", args, exit, |exit, _cli_args, _custom_args, config| { info!("{}", version.name); @@ -103,7 +170,35 @@ pub fn run(args: I, exit: E, version: cli::VersionInfo) -> error::Resul ), }.map_err(|e| format!("{:?}", e)) } - ).map_err(Into::into).map(|_| ()) + ); + + match &ret { + Ok(Some(CustomSubcommands::Factory(cli_args))) => { + let config = cli::create_config_with_db_path::( + load_spec, + &cli_args.shared_params, + &version, + )?; + + match ChainSpec::from(config.chain_spec.id()) { + Some(ref c) if c == &ChainSpec::Development || c == &ChainSpec::LocalTestnet => {}, + _ => panic!("Factory is only supported for development and local testnet."), + } + + let factory_state = FactoryState::new( + cli_args.mode.clone(), + cli_args.num, + cli_args.rounds, + ); + transaction_factory::factory::>( + factory_state, + config, + ).map_err(|e| format!("Error in transaction factory: {}", e))?; + + Ok(()) + }, + _ => ret.map_err(Into::into).map(|_| ()) + } } fn run_until_exit( diff --git a/test-utils/transaction-factory/Cargo.toml b/test-utils/transaction-factory/Cargo.toml new file mode 100644 index 0000000000..66faaf6b34 --- /dev/null +++ b/test-utils/transaction-factory/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "transaction-factory" +version = "0.0.1" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +cli = { package = "substrate-cli", path = "../../core/cli" } +client = { package = "substrate-client", path = "../../core/client" } +consensus_common = { package = "substrate-consensus-common", path = "../../core/consensus/common" } +log = "0.4" +parity-codec = { version = "3.3", default-features = false, features = ["derive"] } +primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } +sr_primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } +substrate-service = { path = "../../core/service" } + +[features] +default = ["std"] +std = [ + "parity-codec/std", + "primitives/std", +] diff --git a/test-utils/transaction-factory/src/complex_mode.rs b/test-utils/transaction-factory/src/complex_mode.rs new file mode 100644 index 0000000000..6200affaea --- /dev/null +++ b/test-utils/transaction-factory/src/complex_mode.rs @@ -0,0 +1,156 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +/// This module implements the `MasterToNToM` mode: +/// +/// Manufacture `num` transactions from the master account to `num` +/// randomly created accounts. From each of these randomly created +/// accounts manufacture a transaction to another randomly created +/// account. +/// Repeat this round `rounds` times. If `rounds` = 1 the behavior +/// is the same as `MasterToN`. +/// +/// A -> B +/// A -> C +/// A -> D +/// ... x `num` +/// +/// B -> E +/// C -> F +/// D -> G +/// ... +/// E -> H +/// F -> I +/// G -> J +/// ... +/// ... x `rounds` + +use std::sync::Arc; + +use log::info; +use client::block_builder::api::BlockBuilder; +use client::runtime_api::ConstructRuntimeApi; +use sr_primitives::generic::BlockId; +use sr_primitives::traits::{Block as BlockT, ProvideRuntimeApi, One, Zero}; +use substrate_service::{ + FactoryBlock, FullClient, ServiceFactory, ComponentClient, FullComponents +}; + +use crate::{RuntimeAdapter, create_block}; + +pub fn next( + factory_state: &mut RA, + client: &Arc>>, + prior_block_hash: ::Hash, + prior_block_id: BlockId, +) -> Option<::Block> +where + F: ServiceFactory, + F::RuntimeApi: ConstructRuntimeApi, FullClient>, + FullClient: ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: BlockBuilder>, + RA: RuntimeAdapter, +{ + let total = factory_state.start_number() + factory_state.num() * factory_state.rounds(); + + if factory_state.block_no() >= total || factory_state.round() >= factory_state.rounds() { + return None; + } + + info!( + "Round {}: Creating {} transactions in total, {} per round. {} rounds in total.", + factory_state.round() + RA::Number::one(), + factory_state.num() * factory_state.rounds(), + factory_state.num(), + factory_state.rounds(), + ); + + let from = from::(factory_state); + + let seed = factory_state.start_number() + factory_state.block_no(); + let to = RA::gen_random_account_id(&seed); + + let mut amount; + if factory_state.round() == RA::Number::zero() { + amount = RA::minimum_balance() * factory_state.rounds(); + } else { + let rounds_left = factory_state.rounds() - factory_state.round(); + amount = RA::minimum_balance() * rounds_left; + }; + + let transfer = factory_state.transfer_extrinsic( + &from.0, + &from.1, + &to, + &amount, + &prior_block_hash, + ); + + let inherents = factory_state.inherent_extrinsics(); + let inherents = client.runtime_api().inherent_extrinsics(&prior_block_id, inherents) + .expect("Failed to create inherent extrinsics"); + + let block = create_block::(&client, transfer, inherents); + info!( + "Created block {} with hash {}. Transferring {} from {} to {}.", + factory_state.block_no() + RA::Number::one(), + prior_block_hash, + amount, + from.0, + to + ); + + factory_state.set_block_no(factory_state.block_no() + RA::Number::one()); + + let new_round = factory_state.block_no() > RA::Number::zero() + && factory_state.block_no() % factory_state.num() == RA::Number::zero(); + if new_round { + factory_state.set_round(factory_state.round() + RA::Number::one()); + factory_state.set_block_in_round(RA::Number::zero()); + } else { + factory_state.set_block_in_round(factory_state.block_in_round() + RA::Number::one()); + } + + Some(block) +} + +/// Return the account which received tokens at this point in the previous round. +fn from( + factory_state: &mut RA +) -> (::AccountId, ::Secret) +where RA: RuntimeAdapter +{ + let is_first_round = factory_state.round() == RA::Number::zero(); + match is_first_round { + true => { + // first round always uses master account + (RA::master_account_id(), RA::master_account_secret()) + }, + _ => { + // the account to which was sent in the last round + let is_round_one = factory_state.round() == RA::Number::one(); + let seed = match is_round_one { + true => factory_state.start_number() + factory_state.block_in_round(), + _ => { + let block_no_in_prior_round = + factory_state.num() * (factory_state.round() - RA::Number::one()) + factory_state.block_in_round(); + factory_state.start_number() + block_no_in_prior_round + } + }; + (RA::gen_random_account_id(&seed), RA::gen_random_account_secret(&seed)) + }, + } +} diff --git a/test-utils/transaction-factory/src/lib.rs b/test-utils/transaction-factory/src/lib.rs new file mode 100644 index 0000000000..02772daf18 --- /dev/null +++ b/test-utils/transaction-factory/src/lib.rs @@ -0,0 +1,179 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Simple transaction factory which distributes tokens from a master +//! account to a specified number of newly created accounts. +//! +//! The factory currently only works on an empty database! + +use std::collections::HashMap; +use std::sync::Arc; +use std::ops::Mul; +use std::cmp::PartialOrd; +use std::fmt::Display; + +use log::info; + +use client::block_builder::api::BlockBuilder; +use client::runtime_api::ConstructRuntimeApi; +use consensus_common::{ + BlockOrigin, ImportBlock, InherentData, ForkChoiceStrategy, + SelectChain +}; +use consensus_common::block_import::BlockImport; +use parity_codec::{Decode, Encode}; +use sr_primitives::generic::BlockId; +use sr_primitives::traits::{ + Block as BlockT, Header as HeaderT, ProvideRuntimeApi, SimpleArithmetic, + One, Zero, +}; +use substrate_service::{ + FactoryBlock, FactoryFullConfiguration, FullClient, new_client, + ServiceFactory, ComponentClient, FullComponents}; +pub use crate::modes::Mode; + +pub mod modes; +mod complex_mode; +mod simple_modes; + +pub trait RuntimeAdapter { + type AccountId: Display; + type Balance: Display + Mul; + type Block: BlockT; + type Index: Copy; + type Number: Display + PartialOrd + SimpleArithmetic + Zero + One; + type Phase: Copy; + type Secret; + + fn new(mode: Mode, rounds: u64, start_number: u64) -> Self; + + fn block_no(&self) -> Self::Number; + fn block_in_round(&self) -> Self::Number; + fn mode(&self) -> &Mode; + fn num(&self) -> Self::Number; + fn rounds(&self) -> Self::Number; + fn round(&self) -> Self::Number; + fn start_number(&self) -> Self::Number; + + fn set_block_in_round(&mut self, val: Self::Number); + fn set_block_no(&mut self, val: Self::Number); + fn set_round(&mut self, val: Self::Number); + + fn transfer_extrinsic( + &self, + sender: &Self::AccountId, + key: &Self::Secret, + destination: &Self::AccountId, + amount: &Self::Number, + prior_block_hash: &::Hash, + ) -> ::Extrinsic; + + fn inherent_extrinsics(&self) -> InherentData; + + fn minimum_balance() -> Self::Number; + fn master_account_id() -> Self::AccountId; + fn master_account_secret() -> Self::Secret; + fn extract_index(&self, account_id: &Self::AccountId, block_hash: &::Hash) -> Self::Index; + fn extract_phase(&self, block_hash: ::Hash) -> Self::Phase; + fn gen_random_account_id(seed: &Self::Number) -> Self::AccountId; + fn gen_random_account_secret(seed: &Self::Number) -> Self::Secret; +} + +/// Manufactures transactions. The exact amount depends on +/// `mode`, `num` and `rounds`. +pub fn factory( + mut factory_state: RA, + mut config: FactoryFullConfiguration, +) -> cli::error::Result<()> +where + F: ServiceFactory, + F::RuntimeApi: ConstructRuntimeApi, FullClient>, + FullClient: ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: BlockBuilder>, + RA: RuntimeAdapter, + <::Block as BlockT>::Hash: From, +{ + if *factory_state.mode() != Mode::MasterToNToM && factory_state.rounds() > RA::Number::one() { + return Err("The factory can only be used with rounds set to 1 in this mode.".into()); + } + + let client = new_client::(&config)?; + + let select_chain = F::build_select_chain(&mut config, client.clone())?; + + let best_header: Result<::Header, cli::error::Error> = + select_chain.best_chain().map_err(|e| format!("{:?}", e).into()); + let mut best_hash = best_header?.hash(); + let best_block_id = BlockId::::hash(best_hash); + + while let Some(block) = match factory_state.mode() { + Mode::MasterToNToM => + complex_mode::next::(&mut factory_state, &client, best_hash.into(), best_block_id), + _ => + simple_modes::next::(&mut factory_state, &client, best_hash.into(), best_block_id) + } { + best_hash = block.header().hash(); + import_block::(&client, block); + + info!("Imported block at {}", factory_state.block_no()); + } + + Ok(()) +} + +/// Create a baked block from a transfer extrinsic and timestamp inherent. +pub fn create_block( + client: &Arc>>, + transfer: ::Extrinsic, + inherent_extrinsics: Vec<::Extrinsic>, +) -> ::Block +where + F: ServiceFactory, + FullClient: ProvideRuntimeApi, + F::RuntimeApi: ConstructRuntimeApi, FullClient>, + as ProvideRuntimeApi>::Api: BlockBuilder>, + RA: RuntimeAdapter, +{ + let mut block = client.new_block().expect("Failed to create new block"); + block.push( + Decode::decode(&mut &transfer.encode()[..]) + .expect("Failed to decode transfer extrinsic") + ).expect("Failed to push transfer extrinsic into block"); + + for inherent in inherent_extrinsics { + block.push(inherent).expect("Failed ..."); + } + + block.bake().expect("Failed to bake block") +} + +fn import_block( + client: &Arc>>, + block: ::Block +) -> () where F: ServiceFactory +{ + let import = ImportBlock { + origin: BlockOrigin::File, + header: block.header().clone(), + post_digests: Vec::new(), + body: Some(block.extrinsics().to_vec()), + finalized: false, + justification: None, + auxiliary: Vec::new(), + fork_choice: ForkChoiceStrategy::LongestChain, + }; + client.import_block(import, HashMap::new()).expect("Failed to import block"); +} diff --git a/test-utils/transaction-factory/src/modes.rs b/test-utils/transaction-factory/src/modes.rs new file mode 100644 index 0000000000..f3d278bbbf --- /dev/null +++ b/test-utils/transaction-factory/src/modes.rs @@ -0,0 +1,41 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! The transaction factory can operate in different modes. See +//! the `simple_mode` and `complex_mode` modules for details. + +use std::str::FromStr; + +/// Token distribution modes. +#[derive(Debug, Clone, PartialEq)] +pub enum Mode { + MasterToN, + MasterTo1, + MasterToNToM +} + +impl FromStr for Mode { + type Err = String; + fn from_str(mode: &str) -> Result { + match mode { + "MasterToN" => Ok(Mode::MasterToN), + "MasterTo1" => Ok(Mode::MasterTo1), + "MasterToNToM" => Ok(Mode::MasterToNToM), + _ => Err(format!("Invalid mode: {}", mode)), + } + } +} + diff --git a/test-utils/transaction-factory/src/simple_modes.rs b/test-utils/transaction-factory/src/simple_modes.rs new file mode 100644 index 0000000000..4ce7b47e6f --- /dev/null +++ b/test-utils/transaction-factory/src/simple_modes.rs @@ -0,0 +1,106 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +/// This module implements two manufacturing modes: +/// +/// # MasterToN +/// Manufacture `num` transactions from the master account +/// to `num` randomly created accounts, one each. +/// +/// A -> B +/// A -> C +/// ... x `num` +/// +/// +/// # MasterTo1 +/// Manufacture `num` transactions from the master account +/// to exactly one other randomly created account. +/// +/// A -> B +/// A -> B +/// ... x `num` + +use std::sync::Arc; + +use log::info; +use client::block_builder::api::BlockBuilder; +use client::runtime_api::ConstructRuntimeApi; +use sr_primitives::traits::{Block as BlockT, ProvideRuntimeApi, One}; +use sr_primitives::generic::BlockId; +use substrate_service::{ + FactoryBlock, FullClient, ServiceFactory, ComponentClient, FullComponents +}; + +use crate::{Mode, RuntimeAdapter, create_block}; + +pub fn next( + factory_state: &mut RA, + client: &Arc>>, + prior_block_hash: ::Hash, + prior_block_id: BlockId, +) -> Option<::Block> +where + F: ServiceFactory, + F::RuntimeApi: ConstructRuntimeApi, FullClient>, + FullClient: ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: BlockBuilder>, + RA: RuntimeAdapter, +{ + if factory_state.block_no() >= factory_state.num() { + return None; + } + + let from = (RA::master_account_id(), RA::master_account_secret()); + + let seed = match factory_state.mode() { + // choose the same receiver for all transactions + Mode::MasterTo1 => factory_state.start_number(), + + // different receiver for each transaction + Mode::MasterToN => factory_state.start_number() + factory_state.block_no(), + _ => unreachable!("Mode not covered!"), + }; + let to = RA::gen_random_account_id(&seed); + + let amount = RA::minimum_balance(); + + let transfer = factory_state.transfer_extrinsic( + &from.0, + &from.1, + &to, + &amount, + &prior_block_hash, + ); + + let inherents = RA::inherent_extrinsics(&factory_state); + let inherents = client.runtime_api().inherent_extrinsics(&prior_block_id, inherents) + .expect("Failed to create inherent extrinsics"); + + let block = create_block::(&client, transfer, inherents); + + factory_state.set_block_no(factory_state.block_no() + RA::Number::one()); + + info!( + "Created block {} with hash {}. Transferring {} from {} to {}.", + factory_state.block_no(), + prior_block_hash, + amount, + from.0, + to + ); + + Some(block) +} -- GitLab From f29c764b704d988daf1a4dd4eacb7d94d052b84d Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 May 2019 17:13:54 +0200 Subject: [PATCH 048/113] Split the send_request method in multiple requests (#2696) --- core/network/src/on_demand.rs | 155 +++++++++++++++++++++++----------- core/network/src/protocol.rs | 98 ++++++++++++++++++++- 2 files changed, 204 insertions(+), 49 deletions(-) diff --git a/core/network/src/on_demand.rs b/core/network/src/on_demand.rs index f77b50dac6..9ce75c4749 100644 --- a/core/network/src/on_demand.rs +++ b/core/network/src/on_demand.rs @@ -26,7 +26,7 @@ use client::error::Error as ClientError; use client::light::fetcher::{FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, ChangesProof, RemoteReadChildRequest, RemoteBodyRequest}; -use crate::message; +use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId}; use network_libp2p::PeerId; use crate::config::Roles; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; @@ -46,8 +46,55 @@ pub trait OnDemandNetwork { /// Disconnect from the given peer. Used in case of misbehaviour. fn disconnect_peer(&mut self, who: &PeerId); - /// Send a request to a peer. - fn send_request(&mut self, who: &PeerId, message: message::Message); + /// Send to `who` a request for a header. + fn send_header_request(&mut self, who: &PeerId, id: RequestId, block: <::Header as HeaderT>::Number); + + /// Send to `who` a read request. + fn send_read_request(&mut self, who: &PeerId, id: RequestId, block: ::Hash, key: Vec); + + /// Send to `who` a child read request. + fn send_read_child_request( + &mut self, + who: &PeerId, + id: RequestId, + block: ::Hash, + storage_key: Vec, + key: Vec + ); + + /// Send to `who` a call request. + fn send_call_request( + &mut self, + who: &PeerId, + id: RequestId, + block: ::Hash, + method: String, + data: Vec + ); + + /// Send to `who` a changes request. + fn send_changes_request( + &mut self, + who: &PeerId, + id: RequestId, + first: ::Hash, + last: ::Hash, + min: ::Hash, + max: ::Hash, + key: Vec + ); + + /// Send to `who` a body request. + fn send_body_request( + &mut self, + who: &PeerId, + id: RequestId, + fields: BlockAttributes, + from: FromBlock<::Hash, <::Header as HeaderT>::Number>, + to: Option, + direction: Direction, + max: Option + ); } /// On-demand requests service. Dispatches requests to appropriate peers. @@ -495,7 +542,7 @@ impl OnDemandCore where let mut request = self.pending_requests.pop_front().expect("checked in loop condition; qed"); request.timestamp = Instant::now(); trace!(target: "sync", "Dispatching remote request {} to peer {}", request.id, peer); - network.send_request(&peer, request.message()); + request.send_to(&mut network, &peer); self.active_peers.insert(peer, request); } @@ -515,53 +562,57 @@ impl Request { } } - fn message(&self) -> message::Message { + fn send_to(&self, out: &mut impl OnDemandNetwork, peer: &PeerId) { match self.data { RequestData::RemoteHeader(ref data, _) => - message::generic::Message::RemoteHeaderRequest(message::RemoteHeaderRequest { - id: self.id, - block: data.block, - }), + out.send_header_request( + peer, + self.id, + data.block, + ), RequestData::RemoteRead(ref data, _) => - message::generic::Message::RemoteReadRequest(message::RemoteReadRequest { - id: self.id, - block: data.block, - key: data.key.clone(), - }), + out.send_read_request( + peer, + self.id, + data.block, + data.key.clone(), + ), RequestData::RemoteReadChild(ref data, _) => - message::generic::Message::RemoteReadChildRequest( - message::RemoteReadChildRequest { - id: self.id, - block: data.block, - storage_key: data.storage_key.clone(), - key: data.key.clone(), - }), + out.send_read_child_request( + peer, + self.id, + data.block, + data.storage_key.clone(), + data.key.clone(), + ), RequestData::RemoteCall(ref data, _) => - message::generic::Message::RemoteCallRequest(message::RemoteCallRequest { - id: self.id, - block: data.block, - method: data.method.clone(), - data: data.call_data.clone(), - }), + out.send_call_request( + peer, + self.id, + data.block, + data.method.clone(), + data.call_data.clone(), + ), RequestData::RemoteChanges(ref data, _) => - message::generic::Message::RemoteChangesRequest(message::RemoteChangesRequest { - id: self.id, - first: data.first_block.1.clone(), - last: data.last_block.1.clone(), - min: data.tries_roots.1.clone(), - max: data.max_block.1.clone(), - key: data.key.clone(), - }), - RequestData::RemoteBody(ref data, _) => { - message::generic::Message::BlockRequest(message::BlockRequest:: { - id: self.id, - fields: message::BlockAttributes::BODY, - from: message::FromBlock::Hash(data.header.hash()), - to: None, - direction: message::Direction::Ascending, - max: Some(1), - }) - } + out.send_changes_request( + peer, + self.id, + data.first_block.1.clone(), + data.last_block.1.clone(), + data.tries_roots.1.clone(), + data.max_block.1.clone(), + data.key.clone(), + ), + RequestData::RemoteBody(ref data, _) => + out.send_body_request( + peer, + self.id, + message::BlockAttributes::BODY, + message::FromBlock::Hash(data.header.hash()), + None, + message::Direction::Ascending, + Some(1) + ), } } } @@ -586,13 +637,13 @@ pub mod tests { use std::sync::Arc; use std::time::Instant; use futures::{Future, sync::oneshot}; - use runtime_primitives::traits::{Block as BlockT, NumberFor}; + use runtime_primitives::traits::{Block as BlockT, NumberFor, Header as HeaderT}; use client::{error::{Error as ClientError, Result as ClientResult}}; use client::light::fetcher::{FetchChecker, RemoteHeaderRequest, ChangesProof, RemoteCallRequest, RemoteReadRequest, RemoteReadChildRequest, RemoteChangesRequest, RemoteBodyRequest}; use crate::config::Roles; - use crate::message; + use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId}; use network_libp2p::PeerId; use super::{REQUEST_TIMEOUT, OnDemandCore, OnDemandNetwork, RequestData}; use test_client::runtime::{changes_trie_config, Block, Extrinsic, Header}; @@ -700,7 +751,15 @@ pub mod tests { fn disconnect_peer(&mut self, who: &PeerId) { self.disconnected_peers.insert(who.clone()); } - fn send_request(&mut self, _: &PeerId, _: message::Message) {} + fn send_header_request(&mut self, _: &PeerId, _: RequestId, _: <::Header as HeaderT>::Number) {} + fn send_read_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: Vec) {} + fn send_read_child_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: Vec, + _: Vec) {} + fn send_call_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: String, _: Vec) {} + fn send_changes_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: ::Hash, + _: ::Hash, _: ::Hash, _: Vec) {} + fn send_body_request(&mut self, _: &PeerId, _: RequestId, _: BlockAttributes, _: FromBlock<::Hash, + <::Header as HeaderT>::Number>, _: Option, _: Direction, _: Option) {} } fn assert_disconnected_peer(dummy: &DummyNetwork) { diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 2fafc9e756..d0b14bada7 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -28,6 +28,7 @@ use crate::message::{ self, BlockRequest as BlockRequestMessage, FinalityProofRequest as FinalityProofRequestMessage, Message, }; +use crate::message::{BlockAttributes, Direction, FromBlock, RequestId}; use crate::message::generic::{Message as GenericMessage, ConsensusMessage}; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; @@ -169,7 +170,102 @@ impl<'a, 'b, B: BlockT> OnDemandNetwork for &'a mut &'b mut dyn NetworkOut NetworkOut::disconnect_peer(**self, who.clone()) } - fn send_request(&mut self, who: &PeerId, message: Message) { + fn send_header_request(&mut self, who: &PeerId, id: RequestId, block: <::Header as HeaderT>::Number) { + let message = message::generic::Message::RemoteHeaderRequest(message::RemoteHeaderRequest { + id, + block, + }); + + NetworkOut::send_message(**self, who.clone(), message) + } + + fn send_read_request(&mut self, who: &PeerId, id: RequestId, block: ::Hash, key: Vec) { + let message = message::generic::Message::RemoteReadRequest(message::RemoteReadRequest { + id, + block, + key, + }); + + NetworkOut::send_message(**self, who.clone(), message) + } + + fn send_read_child_request( + &mut self, + who: &PeerId, + id: RequestId, + block: ::Hash, + storage_key: Vec, + key: Vec + ) { + let message = message::generic::Message::RemoteReadChildRequest(message::RemoteReadChildRequest { + id, + block, + storage_key, + key, + }); + + NetworkOut::send_message(**self, who.clone(), message) + } + + fn send_call_request( + &mut self, + who: &PeerId, + id: RequestId, + block: ::Hash, + method: String, + data: Vec + ) { + let message = message::generic::Message::RemoteCallRequest(message::RemoteCallRequest { + id, + block, + method, + data, + }); + + NetworkOut::send_message(**self, who.clone(), message) + } + + fn send_changes_request( + &mut self, + who: &PeerId, + id: RequestId, + first: ::Hash, + last: ::Hash, + min: ::Hash, + max: ::Hash, + key: Vec + ) { + let message = message::generic::Message::RemoteChangesRequest(message::RemoteChangesRequest { + id, + first, + last, + min, + max, + key, + }); + + NetworkOut::send_message(**self, who.clone(), message) + } + + fn send_body_request( + &mut self, + who: &PeerId, + id: RequestId, + fields: BlockAttributes, + from: FromBlock<::Hash, <::Header as HeaderT>::Number>, + to: Option<::Hash>, + direction: Direction, + max: Option + ) { + let message = message::generic::Message::BlockRequest(message::BlockRequest:: { + id, + fields, + from, + to, + direction, + max, + }); + NetworkOut::send_message(**self, who.clone(), message) } } -- GitLab From 8037b2528121fda8ad338cb343fed8b491d9e674 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 28 May 2019 18:14:48 +0300 Subject: [PATCH 049/113] Use $crate inside of native_executor_instance and parameter_types macros (#2702) * Use inside of native_executor_instance macro * Same for the parameter_types macro --- core/executor/src/native_executor.rs | 2 +- srml/support/src/traits.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/executor/src/native_executor.rs b/core/executor/src/native_executor.rs index 0a6f50d001..729346cbee 100644 --- a/core/executor/src/native_executor.rs +++ b/core/executor/src/native_executor.rs @@ -272,7 +272,7 @@ macro_rules! native_executor_instance { ( $pub:vis $name:ident, $dispatcher:path, $version:path, $code:expr) => { /// A unit struct which implements `NativeExecutionDispatch` feeding in the hard-coded runtime. $pub struct $name; - native_executor_instance!(IMPL $name, $dispatcher, $version, $code); + $crate::native_executor_instance!(IMPL $name, $dispatcher, $version, $code); }; (IMPL $name:ident, $dispatcher:path, $version:path, $code:expr) => { impl $crate::NativeExecutionDispatch for $name { diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index a8db5a946e..dd4398844c 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -47,13 +47,13 @@ pub trait Get { macro_rules! parameter_types { (pub const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => ( pub struct $name; - parameter_types!{IMPL $name , $type , $value} - parameter_types!{ $( $rest )* } + $crate::parameter_types!{IMPL $name , $type , $value} + $crate::parameter_types!{ $( $rest )* } ); (const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => ( struct $name; - parameter_types!{IMPL $name , $type , $value} - parameter_types!{ $( $rest )* } + $crate::parameter_types!{IMPL $name , $type , $value} + $crate::parameter_types!{ $( $rest )* } ); () => (); (IMPL $name:ident , $type:ty , $value:expr) => { -- GitLab From 76e03c7df457982295782f62eaee12c9d5a07dbf Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 28 May 2019 18:01:20 +0200 Subject: [PATCH 050/113] Fix compilation (#2708) --- test-utils/transaction-factory/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-utils/transaction-factory/src/lib.rs b/test-utils/transaction-factory/src/lib.rs index 02772daf18..b046cf74c9 100644 --- a/test-utils/transaction-factory/src/lib.rs +++ b/test-utils/transaction-factory/src/lib.rs @@ -107,7 +107,8 @@ where <::Block as BlockT>::Hash: From, { if *factory_state.mode() != Mode::MasterToNToM && factory_state.rounds() > RA::Number::one() { - return Err("The factory can only be used with rounds set to 1 in this mode.".into()); + let msg = "The factory can only be used with rounds set to 1 in this mode.".into(); + return Err(cli::error::Error::Input(msg)); } let client = new_client::(&config)?; -- GitLab From b003878652dc0102137438bc5f802b34d31d6fdb Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 29 May 2019 11:58:02 +0200 Subject: [PATCH 051/113] Rewrite sync and network layers to use futures (#2683) * Remove background thread from network * Primarily use tokio-timer instead of tokio * Minor style fix * Reintroduce tokio as an optional dependency * Renames * Line width * Ctxt -> Context * Merge NetworkWorker and NetworkService --- Cargo.lock | 17 +- .../finality-grandpa/src/communication/mod.rs | 2 +- core/network/Cargo.toml | 6 +- core/network/src/lib.rs | 4 +- core/network/src/protocol.rs | 8 +- core/network/src/service.rs | 327 ++++++++---------- core/service/src/components.rs | 3 +- core/service/src/lib.rs | 8 +- 8 files changed, 171 insertions(+), 204 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac6f721d81..32bcf235ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,7 +57,7 @@ dependencies = [ "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1180,7 +1180,7 @@ dependencies = [ "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4012,7 +4012,7 @@ dependencies = [ "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4180,6 +4180,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4206,7 +4207,7 @@ dependencies = [ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4722,7 +4723,7 @@ dependencies = [ "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4845,7 +4846,7 @@ dependencies = [ [[package]] name = "tokio-timer" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5272,7 +5273,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5838,7 +5839,7 @@ dependencies = [ "checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" -"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" +"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" "checksum tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" diff --git a/core/finality-grandpa/src/communication/mod.rs b/core/finality-grandpa/src/communication/mod.rs index e4343352d9..05033c2c41 100644 --- a/core/finality-grandpa/src/communication/mod.rs +++ b/core/finality-grandpa/src/communication/mod.rs @@ -39,7 +39,7 @@ use substrate_primitives::{ed25519, Pair}; use substrate_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO}; use runtime_primitives::ConsensusEngineId; use runtime_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; -use network::{consensus_gossip as network_gossip, Service as NetworkService}; +use network::{consensus_gossip as network_gossip, NetworkService}; use network_gossip::ConsensusMessage; use crate::{Error, Message, SignedMessage, Commit, CompactCommit}; diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index d3b7a71f03..6576ccabbf 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -27,7 +27,8 @@ runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitiv parity-codec = { version = "3.3", features = ["derive"] } network_libp2p = { package = "substrate-network-libp2p", path = "../../core/network-libp2p" } peerset = { package = "substrate-peerset", path = "../../core/peerset" } -tokio = "0.1.11" +tokio-timer = "0.2.11" +tokio = { version = "0.1.11", optional = true } keyring = { package = "substrate-keyring", path = "../../core/keyring", optional = true } test_client = { package = "substrate-test-client", path = "../../core/test-client", optional = true } void = "1.0" @@ -37,7 +38,8 @@ env_logger = { version = "0.6" } keyring = { package = "substrate-keyring", path = "../../core/keyring" } test_client = { package = "substrate-test-client", path = "../../core/test-client" } consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common", features = ["test-helpers"] } +tokio = "0.1.11" [features] default = [] -test-helpers = ["keyring", "test_client", "consensus/test-helpers"] +test-helpers = ["keyring", "test_client", "consensus/test-helpers", "tokio"] diff --git a/core/network/src/lib.rs b/core/network/src/lib.rs index e3ed56d5ad..e2def15425 100644 --- a/core/network/src/lib.rs +++ b/core/network/src/lib.rs @@ -43,8 +43,8 @@ pub mod test; pub use chain::{Client as ClientHandle, FinalityProofProvider}; pub use service::{ - Service, FetchFuture, TransactionPool, ManageNetwork, NetworkMsg, - SyncProvider, ExHashT, ReportHandle, + NetworkService, NetworkWorker, FetchFuture, TransactionPool, ManageNetwork, + NetworkMsg, SyncProvider, ExHashT, ReportHandle, }; pub use protocol::{ProtocolStatus, PeerInfo, Context}; pub use sync::{Status as SyncStatus, SyncState}; diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index d0b14bada7..2d7799b5bb 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -80,9 +80,9 @@ const RPC_FAILED_REPUTATION_CHANGE: i32 = -(1 << 12); // Lock must always be taken in order declared here. pub struct Protocol, H: ExHashT> { /// Interval at which we call `tick`. - tick_timeout: tokio::timer::Interval, + tick_timeout: tokio_timer::Interval, /// Interval at which we call `propagate_extrinsics`. - propagate_timeout: tokio::timer::Interval, + propagate_timeout: tokio_timer::Interval, config: ProtocolConfig, /// Handler for on-demand requests. on_demand_core: OnDemandCore, @@ -395,8 +395,8 @@ impl, H: ExHashT> Protocol { let info = chain.info()?; let sync = ChainSync::new(config.roles, &info); Ok(Protocol { - tick_timeout: tokio::timer::Interval::new_interval(TICK_TIMEOUT), - propagate_timeout: tokio::timer::Interval::new_interval(PROPAGATE_TIMEOUT), + tick_timeout: tokio_timer::Interval::new_interval(TICK_TIMEOUT), + propagate_timeout: tokio_timer::Interval::new_interval(PROPAGATE_TIMEOUT), config: config, context_data: ContextData { peers: HashMap::new(), diff --git a/core/network/src/service.rs b/core/network/src/service.rs index 805fb55ddb..c7a32d472f 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -15,15 +15,16 @@ // along with Substrate. If not, see . use std::collections::HashMap; +use std::io; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use std::{io, thread, time::Duration}; +use std::time::Duration; use log::{warn, debug, error, info}; -use futures::{Async, Future, Stream, sync::oneshot, sync::mpsc}; +use futures::{prelude::*, sync::oneshot, sync::mpsc}; use parking_lot::{Mutex, RwLock}; -use network_libp2p::{start_service, parse_str_addr, Service as NetworkService, ServiceEvent as NetworkServiceEvent}; -use network_libp2p::{NetworkConfiguration, RegisteredProtocol, NetworkState}; +use network_libp2p::{start_service, parse_str_addr, Service as Libp2pNetService, ServiceEvent as Libp2pNetServiceEvent}; +use network_libp2p::{RegisteredProtocol, NetworkState}; use peerset::PeersetHandle; use consensus::import_queue::{ImportQueue, Link, SharedFinalityProofRequestBuilder}; use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; @@ -39,8 +40,6 @@ use crate::config::Params; use crate::error::Error; use crate::specialization::NetworkSpecialization; -use tokio::runtime::Builder as RuntimeBuilder; - /// Interval at which we send status updates on the SyncProvider status stream. const STATUS_INTERVAL: Duration = Duration::from_millis(5000); /// Interval at which we update the `peers` field on the main thread. @@ -176,7 +175,7 @@ impl ReportHandle { } /// Substrate network service. Handles network IO and manages connectivity. -pub struct Service> { +pub struct NetworkService> { /// Sinks to propagate status updates. status_sinks: Arc>>>>, /// Are we connected to any peer? @@ -188,23 +187,23 @@ pub struct Service> { /// Channel for networking messages processed by the background thread. network_chan: mpsc::UnboundedSender>, /// Network service - network: Arc>>>, + network: Arc>>>, /// Peerset manager (PSM); manages the reputation of nodes and indicates the network which /// nodes it should be connected to or not. peerset: PeersetHandle, /// Protocol sender protocol_sender: mpsc::UnboundedSender>, - /// Sender for messages to the background service task, and handle for the background thread. - /// Dropping the sender should close the task and the thread. - /// This is an `Option` because we need to extract it in the destructor. - bg_thread: Option<(oneshot::Sender<()>, thread::JoinHandle<()>)>, } -impl> Service { - /// Creates and register protocol with the network service - pub fn new( +impl, H: ExHashT> NetworkWorker { + /// Creates the network service. + /// + /// Returns a `NetworkWorker` that implements `Future` and must be regularly polled in order + /// for the network processing to advance. From it, you can extract a `NetworkService` using + /// `worker.service()`. The `NetworkService` can be shared through the codebase. + pub fn new( params: Params, - ) -> Result>, Error> { + ) -> Result, Error> { let (network_chan, network_port) = mpsc::unbounded(); let (protocol_sender, protocol_rx) = mpsc::unbounded(); let status_sinks = Arc::new(Mutex::new(Vec::new())); @@ -229,35 +228,55 @@ impl> Service { )?; let versions: Vec<_> = ((protocol::MIN_VERSION as u8)..=(protocol::CURRENT_VERSION as u8)).collect(); let registered = RegisteredProtocol::new(params.protocol_id, &versions); - let (thread, network, peerset) = start_thread( - is_offline.clone(), - is_major_syncing.clone(), - protocol, - peers.clone(), - params.import_queue, - params.transaction_pool, - params.finality_proof_provider, - network_port, - protocol_rx, - status_sinks.clone(), - params.network_config, - registered, - params.on_demand.and_then(|od| od.extract_receiver()), - )?; - Ok(Arc::new(Service { - status_sinks, + // Start the main service. + let (network, peerset) = match start_service(params.network_config, registered) { + Ok((network, peerset)) => (Arc::new(Mutex::new(network)), peerset), + Err(err) => { + warn!("Error starting network: {}", err); + return Err(err.into()) + }, + }; + + let service = Arc::new(NetworkService { + status_sinks: status_sinks.clone(), + is_offline: is_offline.clone(), + is_major_syncing: is_major_syncing.clone(), + network_chan, + peers: peers.clone(), + peerset: peerset.clone(), + network: network.clone(), + protocol_sender: protocol_sender.clone(), + }); + + Ok(NetworkWorker { is_offline, is_major_syncing, - network_chan, - peers, + network_service: network, peerset, - network, - protocol_sender, - bg_thread: Some(thread), - })) + service, + protocol, + peers, + import_queue: params.import_queue, + transaction_pool: params.transaction_pool, + finality_proof_provider: params.finality_proof_provider, + network_port, + protocol_rx, + status_sinks, + on_demand_in: params.on_demand.and_then(|od| od.extract_receiver()), + status_interval: tokio_timer::Interval::new_interval(STATUS_INTERVAL), + connected_peers_interval: tokio_timer::Interval::new_interval(CONNECTED_PEERS_INTERVAL), + }) } + /// Return a `NetworkService` that can be shared through the code base and can be used to + /// manipulate the worker. + pub fn service(&self) -> &Arc> { + &self.service + } +} + +impl> NetworkService { /// Returns the downloaded bytes per second averaged over the past few seconds. #[inline] pub fn average_download_per_sec(&self) -> u64 { @@ -362,7 +381,7 @@ impl> Service { } } -impl> ::consensus::SyncOracle for Service { +impl> ::consensus::SyncOracle for NetworkService { fn is_major_syncing(&self) -> bool { self.is_major_syncing() } @@ -372,18 +391,7 @@ impl> ::consensus::SyncOracle f } } -impl> Drop for Service { - fn drop(&mut self) { - if let Some((sender, join)) = self.bg_thread.take() { - let _ = sender.send(()); - if let Err(e) = join.join() { - error!("Error while waiting on background thread: {:?}", e); - } - } - } -} - -impl> SyncProvider for Service { +impl> SyncProvider for NetworkService { fn is_major_syncing(&self) -> bool { self.is_major_syncing() } @@ -417,7 +425,7 @@ pub trait ManageNetwork { fn add_reserved_peer(&self, peer: String) -> Result<(), String>; } -impl> ManageNetwork for Service { +impl> ManageNetwork for NetworkService { fn accept_unreserved_peers(&self) { self.peerset.set_reserved_only(false); } @@ -438,7 +446,7 @@ impl> ManageNetwork for Service } } -/// Messages to be handled by NetworkService. +/// Messages to be handled by Libp2pNetService. #[derive(Debug)] pub enum NetworkMsg { /// Send an outgoing custom message. @@ -516,11 +524,16 @@ impl, &mut Context)> GossipTask< } } -/// Starts the background thread that handles the networking. -fn start_thread, H: ExHashT>( +/// Future tied to the `Network` service and that must be polled in order for the network to +/// advance. +#[must_use = "The NetworkWorker must be polled in order for the network to work"] +pub struct NetworkWorker, H: ExHashT> { is_offline: Arc, is_major_syncing: Arc, protocol: Protocol, + /// The network service that can be extracted and shared through the codebase. + service: Arc>, + network_service: Arc>>>, peers: Arc>>>, import_queue: Box>, transaction_pool: Arc>, @@ -528,124 +541,68 @@ fn start_thread, H: ExHashT>( network_port: mpsc::UnboundedReceiver>, protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, - config: NetworkConfiguration, - registered: RegisteredProtocol>, + peerset: PeersetHandle, on_demand_in: Option>>, -) -> Result<((oneshot::Sender<()>, thread::JoinHandle<()>), Arc>>>, PeersetHandle), Error> { - // Start the main service. - let (service, peerset) = match start_service(config, registered) { - Ok((service, peerset)) => (Arc::new(Mutex::new(service)), peerset), - Err(err) => { - warn!("Error starting network: {}", err); - return Err(err.into()) - }, - }; - - let (close_tx, close_rx) = oneshot::channel(); - let service_clone = service.clone(); - let mut runtime = RuntimeBuilder::new().name_prefix("libp2p-").build()?; - let peerset_clone = peerset.clone(); - let thread = thread::Builder::new().name("network".to_string()).spawn(move || { - let fut = run_thread( - is_offline, - is_major_syncing, - protocol, - service_clone, - peers, - import_queue, - transaction_pool, - finality_proof_provider, - network_port, - protocol_rx, - status_sinks, - peerset_clone, - on_demand_in - ) - .select(close_rx.then(|_| Ok(()))) - .map(|(val, _)| val) - .map_err(|(err,_ )| err); - - // Note that we use `block_on` and not `block_on_all` because we want to kill the thread - // instantly if `close_rx` receives something. - match runtime.block_on(fut) { - Ok(()) => debug!(target: "sub-libp2p", "Networking thread finished"), - Err(err) => error!(target: "sub-libp2p", "Error while running libp2p: {:?}", err), - }; - })?; - Ok(((close_tx, thread), service, peerset)) + /// Interval at which we send status updates on the `status_sinks`. + status_interval: tokio_timer::Interval, + /// Interval at which we update the `connected_peers` Arc. + connected_peers_interval: tokio_timer::Interval, } -/// Runs the background thread that handles the networking. -fn run_thread, H: ExHashT>( - is_offline: Arc, - is_major_syncing: Arc, - mut protocol: Protocol, - network_service: Arc>>>, - peers: Arc>>>, - import_queue: Box>, - transaction_pool: Arc>, - finality_proof_provider: Option>>, - mut network_port: mpsc::UnboundedReceiver>, - mut protocol_rx: mpsc::UnboundedReceiver>, - status_sinks: Arc>>>>, - peerset: PeersetHandle, - mut on_demand_in: Option>>, -) -> impl Future { - // Implementation of `protocol::NetworkOut` using the available local variables. - struct Ctxt<'a, B: BlockT>(&'a mut NetworkService>, &'a PeersetHandle); - impl<'a, B: BlockT> NetworkOut for Ctxt<'a, B> { - fn report_peer(&mut self, who: PeerId, reputation: i32) { - self.1.report_peer(who, reputation) - } - fn disconnect_peer(&mut self, who: PeerId) { - self.0.drop_node(&who) - } - fn send_message(&mut self, who: PeerId, message: Message) { - self.0.send_custom_message(&who, message) - } - } +impl, H: ExHashT> Future for NetworkWorker { + type Item = (); + type Error = io::Error; - // Interval at which we send status updates on the `status_sinks`. - let mut status_interval = tokio::timer::Interval::new_interval(STATUS_INTERVAL); - // Interval at which we update the `connected_peers` Arc. - let mut connected_peers_interval = tokio::timer::Interval::new_interval(CONNECTED_PEERS_INTERVAL); + fn poll(&mut self) -> Poll { + // Implementation of `protocol::NetworkOut` using the available local variables. + struct Context<'a, B: BlockT>(&'a mut Libp2pNetService>, &'a PeersetHandle); + impl<'a, B: BlockT> NetworkOut for Context<'a, B> { + fn report_peer(&mut self, who: PeerId, reputation: i32) { + self.1.report_peer(who, reputation) + } + fn disconnect_peer(&mut self, who: PeerId) { + self.0.drop_node(&who) + } + fn send_message(&mut self, who: PeerId, message: Message) { + self.0.send_custom_message(&who, message) + } + } - futures::future::poll_fn(move || { - while let Ok(Async::Ready(_)) = status_interval.poll() { - let status = protocol.status(); - status_sinks.lock().retain(|sink| sink.unbounded_send(status.clone()).is_ok()); + while let Ok(Async::Ready(_)) = self.status_interval.poll() { + let status = self.protocol.status(); + self.status_sinks.lock().retain(|sink| sink.unbounded_send(status.clone()).is_ok()); } - while let Ok(Async::Ready(_)) = connected_peers_interval.poll() { - let infos = protocol.peers_info().map(|(id, info)| { + while let Ok(Async::Ready(_)) = self.connected_peers_interval.poll() { + let infos = self.protocol.peers_info().map(|(id, info)| { (id.clone(), ConnectedPeer { peer_info: info.clone() }) }).collect(); - *peers.write() = infos; + *self.peers.write() = infos; } - match protocol.poll(&mut Ctxt(&mut network_service.lock(), &peerset), &*transaction_pool) { + match self.protocol.poll(&mut Context(&mut self.network_service.lock(), &self.peerset), &*self.transaction_pool) { Ok(Async::Ready(v)) => void::unreachable(v), Ok(Async::NotReady) => {} Err(err) => void::unreachable(err), } // Check for new incoming on-demand requests. - if let Some(on_demand_in) = on_demand_in.as_mut() { + if let Some(on_demand_in) = self.on_demand_in.as_mut() { while let Ok(Async::Ready(Some(rq))) = on_demand_in.poll() { - protocol.add_on_demand_request(&mut Ctxt(&mut network_service.lock(), &peerset), rq); + self.protocol.add_on_demand_request(&mut Context(&mut self.network_service.lock(), &self.peerset), rq); } } loop { - match network_port.poll() { + match self.network_port.poll() { Ok(Async::NotReady) => break, Ok(Async::Ready(Some(NetworkMsg::Outgoing(who, outgoing_message)))) => - network_service.lock().send_custom_message(&who, outgoing_message), + self.network_service.lock().send_custom_message(&who, outgoing_message), Ok(Async::Ready(Some(NetworkMsg::ReportPeer(who, reputation)))) => - peerset.report_peer(who, reputation), + self.peerset.report_peer(who, reputation), Ok(Async::Ready(Some(NetworkMsg::DisconnectPeer(who)))) => - network_service.lock().drop_node(&who), + self.network_service.lock().drop_node(&who), #[cfg(any(test, feature = "test-helpers"))] Ok(Async::Ready(Some(NetworkMsg::Synchronized))) => {} @@ -655,91 +612,91 @@ fn run_thread, H: ExHashT>( } loop { - let msg = match protocol_rx.poll() { + let msg = match self.protocol_rx.poll() { Ok(Async::Ready(Some(msg))) => msg, Ok(Async::Ready(None)) | Err(_) => return Ok(Async::Ready(())), Ok(Async::NotReady) => break, }; - let mut network_service = network_service.lock(); - let mut network_out = Ctxt(&mut network_service, &peerset); + let mut network_service = self.network_service.lock(); + let mut network_out = Context(&mut network_service, &self.peerset); match msg { ProtocolMsg::BlockImported(hash, header) => - protocol.on_block_imported(&mut network_out, hash, &header), + self.protocol.on_block_imported(&mut network_out, hash, &header), ProtocolMsg::BlockFinalized(hash, header) => - protocol.on_block_finalized(&mut network_out, hash, &header), + self.protocol.on_block_finalized(&mut network_out, hash, &header), ProtocolMsg::ExecuteWithSpec(task) => { - let (mut context, spec) = protocol.specialization_lock(&mut network_out); + let (mut context, spec) = self.protocol.specialization_lock(&mut network_out); task.call_box(spec, &mut context); }, ProtocolMsg::ExecuteWithGossip(task) => { - let (mut context, gossip) = protocol.consensus_gossip_lock(&mut network_out); + let (mut context, gossip) = self.protocol.consensus_gossip_lock(&mut network_out); task.call_box(gossip, &mut context); } ProtocolMsg::GossipConsensusMessage(topic, engine_id, message, recipient) => - protocol.gossip_consensus_message(&mut network_out, topic, engine_id, message, recipient), + self.protocol.gossip_consensus_message(&mut network_out, topic, engine_id, message, recipient), ProtocolMsg::BlocksProcessed(hashes, has_error) => - protocol.blocks_processed(&mut network_out, hashes, has_error), + self.protocol.blocks_processed(&mut network_out, hashes, has_error), ProtocolMsg::RestartSync => - protocol.restart(&mut network_out), + self.protocol.restart(&mut network_out), ProtocolMsg::AnnounceBlock(hash) => - protocol.announce_block(&mut network_out, hash), + self.protocol.announce_block(&mut network_out, hash), ProtocolMsg::BlockImportedSync(hash, number) => - protocol.block_imported(&hash, number), + self.protocol.block_imported(&hash, number), ProtocolMsg::ClearJustificationRequests => - protocol.clear_justification_requests(), + self.protocol.clear_justification_requests(), ProtocolMsg::RequestJustification(hash, number) => - protocol.request_justification(&mut network_out, &hash, number), + self.protocol.request_justification(&mut network_out, &hash, number), ProtocolMsg::JustificationImportResult(hash, number, success) => - protocol.justification_import_result(hash, number, success), + self.protocol.justification_import_result(hash, number, success), ProtocolMsg::SetFinalityProofRequestBuilder(builder) => - protocol.set_finality_proof_request_builder(builder), + self.protocol.set_finality_proof_request_builder(builder), ProtocolMsg::RequestFinalityProof(hash, number) => - protocol.request_finality_proof(&mut network_out, &hash, number), + self.protocol.request_finality_proof(&mut network_out, &hash, number), ProtocolMsg::FinalityProofImportResult(requested_block, finalziation_result) => - protocol.finality_proof_import_result(requested_block, finalziation_result), + self.protocol.finality_proof_import_result(requested_block, finalziation_result), ProtocolMsg::PropagateExtrinsics => - protocol.propagate_extrinsics(&mut network_out, &*transaction_pool), + self.protocol.propagate_extrinsics(&mut network_out, &*self.transaction_pool), #[cfg(any(test, feature = "test-helpers"))] - ProtocolMsg::Tick => protocol.tick(&mut network_out), + ProtocolMsg::Tick => self.protocol.tick(&mut network_out), #[cfg(any(test, feature = "test-helpers"))] ProtocolMsg::Synchronize => {}, } } loop { - let mut network_service = network_service.lock(); + let mut network_service = self.network_service.lock(); let poll_value = network_service.poll(); - let mut network_out = Ctxt(&mut network_service, &peerset); + let mut network_out = Context(&mut network_service, &self.peerset); let outcome = match poll_value { Ok(Async::NotReady) => break, - Ok(Async::Ready(Some(NetworkServiceEvent::OpenedCustomProtocol { peer_id, version, debug_info, .. }))) => { + Ok(Async::Ready(Some(Libp2pNetServiceEvent::OpenedCustomProtocol { peer_id, version, debug_info, .. }))) => { debug_assert!( version <= protocol::CURRENT_VERSION as u8 && version >= protocol::MIN_VERSION as u8 ); - protocol.on_peer_connected(&mut network_out, peer_id, debug_info); + self.protocol.on_peer_connected(&mut network_out, peer_id, debug_info); CustomMessageOutcome::None } - Ok(Async::Ready(Some(NetworkServiceEvent::ClosedCustomProtocol { peer_id, debug_info, .. }))) => { - protocol.on_peer_disconnected(&mut network_out, peer_id, debug_info); + Ok(Async::Ready(Some(Libp2pNetServiceEvent::ClosedCustomProtocol { peer_id, debug_info, .. }))) => { + self.protocol.on_peer_disconnected(&mut network_out, peer_id, debug_info); CustomMessageOutcome::None }, - Ok(Async::Ready(Some(NetworkServiceEvent::CustomMessage { peer_id, message, .. }))) => - protocol.on_custom_message( + Ok(Async::Ready(Some(Libp2pNetServiceEvent::CustomMessage { peer_id, message, .. }))) => + self.protocol.on_custom_message( &mut network_out, - &*transaction_pool, + &*self.transaction_pool, peer_id, message, - finality_proof_provider.as_ref().map(|p| &**p) + self.finality_proof_provider.as_ref().map(|p| &**p) ), - Ok(Async::Ready(Some(NetworkServiceEvent::Clogged { peer_id, messages, .. }))) => { + Ok(Async::Ready(Some(Libp2pNetServiceEvent::Clogged { peer_id, messages, .. }))) => { debug!(target: "sync", "{} clogging messages:", messages.len()); for msg in messages.into_iter().take(5) { debug!(target: "sync", "{:?}", msg); - protocol.on_clogged_peer(&mut network_out, peer_id.clone(), Some(msg)); + self.protocol.on_clogged_peer(&mut network_out, peer_id.clone(), Some(msg)); } CustomMessageOutcome::None } @@ -752,18 +709,18 @@ fn run_thread, H: ExHashT>( match outcome { CustomMessageOutcome::BlockImport(origin, blocks) => - import_queue.import_blocks(origin, blocks), + self.import_queue.import_blocks(origin, blocks), CustomMessageOutcome::JustificationImport(origin, hash, nb, justification) => - import_queue.import_justification(origin, hash, nb, justification), + self.import_queue.import_justification(origin, hash, nb, justification), CustomMessageOutcome::FinalityProofImport(origin, hash, nb, proof) => - import_queue.import_finality_proof(origin, hash, nb, proof), + self.import_queue.import_finality_proof(origin, hash, nb, proof), CustomMessageOutcome::None => {} } } - is_offline.store(protocol.is_offline(), Ordering::Relaxed); - is_major_syncing.store(protocol.is_major_syncing(), Ordering::Relaxed); + self.is_offline.store(self.protocol.is_offline(), Ordering::Relaxed); + self.is_major_syncing.store(self.protocol.is_major_syncing(), Ordering::Relaxed); Ok(Async::NotReady) - }) + } } diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 202bd15b2a..238d84b522 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -38,7 +38,8 @@ use parking_lot::Mutex; // Type aliases. // These exist mainly to avoid typing `::Foo` all over the code. /// Network service type for a factory. -pub type NetworkService = network::Service<::Block, ::NetworkProtocol>; +pub type NetworkService = + network::NetworkService<::Block, ::NetworkProtocol>; /// Code executor type for a factory. pub type CodeExecutor = NativeExecutor<::RuntimeDispatch>; diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index d2b4a66c5b..1eb59872ce 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -203,7 +203,13 @@ impl Service { }; let has_bootnodes = !network_params.network_config.boot_nodes.is_empty(); - let network = network::Service::new(network_params)?; + let network_mut = network::NetworkWorker::new(network_params)?; + let network = network_mut.service().clone(); + + task_executor.spawn(network_mut + .map_err(|_| ()) + .select(exit.clone()) + .then(|_| Ok(()))); let inherents_pool = Arc::new(InherentsPool::default()); let offchain_workers = if config.offchain_worker { -- GitLab From 6e253c899e67ce4e29b70e5eca3a3763fa42233f Mon Sep 17 00:00:00 2001 From: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> Date: Wed, 29 May 2019 08:13:38 -0400 Subject: [PATCH 052/113] Introduce inherent digests (#2466) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Introduce inherent digests * Implement inherent digests * fix silly error * Implementation of inherent digests in BABE All tests pass. There are still limitations: 1. The runtime strips out inherent digests, so BABE must re-add them. 2. The test runtime checks that it can re-compute all digests. It can’t, so I had to comment out that test. * Fix compilation and seal import Seals were not imported correctly: the pre-digest was imported twice, instead of both it and the seal being imported. Also, other parts of the code did not compile due to incomplete refactoring. * Remove bogus assertion * Fix testsuite compilation * Remove unused import * Fix compiler diagnostics * Add inherent digest parameters to block constructors This enforces that inherent digests are added first. * Fixup Cargo.lock * Fix build errors * Re-add an incorrectly removed import * Bump primitive-types version * Update Cargo.lock * Refactoring * Use inherent digests for AuRa They do reach the runtime, but get stripped. I have not figured out where. * Fix compilation errors * Fix compilation errors due to incorrect types * Fix whitespace Suggested-by: Tomasz Drwiega * Add preamble Suggested-by: Tomasz Drwiega * Fix silly compile error * Refactor pre-digest finding code into a separate function * Remove unwanted assertion It is too likely to bring down the entire blockchain. Suggested-by: Tomasz Drwiega * Use `find_pre_digest` after runtime, too Also, use `Member` trait rather than rolling our own requirements. Suggested-by: Tomasz Drwiega * Fix various warnings mostly due to upgrading the dependency on `error_chain`. * Pre-digests nearly complete This nearly completes the implementation of pre-runtime digests. * `Seal2` → `Seal` and fix test suite * Try to fix the storage error * Try to fix storage (again) * Fix tests * Hopefully finish pre-runtime digests The key is to pass *only* the pre-runtime digests to the runtime. The others must be stripped out by `initialize_block`. * Fix silly typo * Fix another silly mistake * Remove unnecessary filtering of BABE pre-digests We no longer get duplicate BABE pre-digests, so if they appear, the header should be rejected outright. * Update Cargo.lock files * Reformatting * Fix silly typo in inherent digest code Also, revert `error.rs` files that contained calls to the `error_chain!` macro. * Try to keep the runtime from stripping pre-digests Currently runs into the “Storage root must match that calculated” assertion. * Don’t compute storage root until storage changes are done. Also, fix a compilation error. * Fix compile-time error * Fix compilation errors * Fix more compile errors * Hopefully it compiles this time… * Fix compilation and add docs * Prevent BABE from adding duplicate pre-runtime digests Found by comparing with the AuRa code. I also did some refactoring. * Respond to review and fix some warnings * Delete some dead code introduced earlier * More dead code goes away * `ref mut` → `&mut` * Respond to review and fix some warnings * Fix compilation error * Remove unneeded `HashT` type parameter Suggested-by: Robert Habermeier * Remove spurious #[allow(deprecated)] * Document inherent digest parameter to `build_block` * Delete `Simple` trait It wasn’t needed * delete wrongly added files * Fix trait bounds * Digest serialization tests I also did some reformatting and cleanup. * Apply suggestions from code review Reformatting Co-Authored-By: André Silva * Swap two arguments to `propose` and `propose_with` Also, remove some needless unsafe code. * Remove bogus `#![allow(deprecated)]` annotations With the removal of the deprecated `Seal` variant, these are not needed. * Add a missing `#[allow(deprecated)]` in the AuRa tests * Fix silly compile error * Fix silly compiler error RLS did not tell me that I hadn’t fixed `babe/lib.rs`, so I missed it. * Fixes made automatically by Cargo --- .gitlab-ci.yml | 4 +- Cargo.lock | 25 +- Dockerfile | 4 +- core/basic-authorship/src/basic_authorship.rs | 38 +- core/client/db/src/light.rs | 2 +- .../client/src/block_builder/block_builder.rs | 16 +- core/client/src/client.rs | 90 +-- core/client/src/light/call_executor.rs | 4 +- core/client/src/light/fetcher.rs | 2 +- core/consensus/aura/src/digest.rs | 67 +++ core/consensus/aura/src/lib.rs | 449 ++++++--------- core/consensus/babe/primitives/src/lib.rs | 2 +- core/consensus/babe/src/digest.rs | 149 +++++ core/consensus/babe/src/lib.rs | 531 ++++++++---------- core/consensus/common/src/import_queue.rs | 4 +- core/consensus/common/src/lib.rs | 9 +- core/consensus/common/src/select_chain.rs | 6 +- core/consensus/slots/src/aux_schema.rs | 2 +- core/executor/src/allocator.rs | 3 +- core/executor/src/wasm_executor.rs | 6 +- core/executor/wasm/Cargo.lock | 12 +- core/finality-grandpa/src/finality_proof.rs | 2 +- core/finality-grandpa/src/import.rs | 2 +- core/finality-grandpa/src/tests.rs | 6 +- core/network/src/on_demand.rs | 4 +- core/network/src/test/block_import.rs | 9 +- core/network/src/test/mod.rs | 3 +- core/primitives/Cargo.toml | 2 +- core/rpc/src/chain/tests.rs | 10 +- core/rpc/src/state/tests.rs | 6 +- core/service/src/components.rs | 2 +- core/sr-api-macros/tests/runtime_calls.rs | 2 +- .../tests/ui/invalid_api_version_2.rs | 1 - core/sr-primitives/src/generic/digest.rs | 89 ++- core/sr-primitives/src/generic/header.rs | 18 +- core/sr-primitives/src/lib.rs | 4 + core/sr-primitives/src/testing.rs | 7 +- core/sr-primitives/src/traits.rs | 9 +- core/test-client/src/trait_tests.rs | 60 +- core/test-runtime/src/system.rs | 21 +- core/test-runtime/wasm/Cargo.lock | 12 +- node-template/runtime/wasm/Cargo.lock | 12 +- node/executor/src/lib.rs | 4 +- node/runtime/src/lib.rs | 4 +- node/runtime/wasm/Cargo.lock | 26 +- scripts/flamingfir-deploy.sh | 6 +- srml/aura/src/tests.rs | 4 +- srml/consensus/src/tests.rs | 12 +- srml/contract/src/tests.rs | 24 +- srml/executive/src/lib.rs | 13 +- srml/finality-tracker/src/lib.rs | 4 +- srml/grandpa/src/tests.rs | 24 +- srml/system/src/lib.rs | 76 ++- test-utils/transaction-factory/src/lib.rs | 2 +- test-utils/transaction-factory/src/modes.rs | 1 - 55 files changed, 1033 insertions(+), 873 deletions(-) create mode 100644 core/consensus/aura/src/digest.rs create mode 100644 core/consensus/babe/src/digest.rs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c11d5ccfc2..55c83328d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -218,7 +218,7 @@ publish-docker-release: - docker build --build-arg VCS_REF="${CI_COMMIT_SHA}" --build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" - --tag $CONTAINER_IMAGE:$VERSION + --tag $CONTAINER_IMAGE:$VERSION --tag $CONTAINER_IMAGE:latest . - docker push $CONTAINER_IMAGE:$VERSION - docker push $CONTAINER_IMAGE:latest @@ -272,7 +272,7 @@ publish-s3-doc: --human-readable --summarize .deploy-template: &deploy - stage: kubernetes + stage: kubernetes when: manual retry: 1 image: parity/kubetools:latest diff --git a/Cargo.lock b/Cargo.lock index 32bcf235ab..83a85c4d69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1211,6 +1211,14 @@ dependencies = [ "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "impl-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "indexmap" version = "1.0.2" @@ -2514,13 +2522,13 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3196,7 +3204,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4279,7 +4287,7 @@ dependencies = [ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5037,7 +5045,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5617,6 +5625,7 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56" +"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" @@ -5722,7 +5731,7 @@ dependencies = [ "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" -"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" +"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" "checksum proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6a9bed9ebc40cf53e3a76d7486c54d05002eae6485b2711ab9104476fb2eb8bc" @@ -5858,7 +5867,7 @@ dependencies = [ "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708" +"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41d17211f887da8e4a70a45b9536f26fc5de166b81e2d5d80de4a17fd22553bd" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/Dockerfile b/Dockerfile index df39db5abb..c5944dbab6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,8 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ rustup target add wasm32-unknown-unknown --toolchain nightly && \ cargo install --git https://github.com/alexcrichton/wasm-gc && \ rustup default nightly && \ - ./scripts/build.sh && \ - rustup default stable && \ + ./scripts/build.sh && \ + rustup default stable && \ cargo build --$PROFILE # ===== SECOND STAGE ====== diff --git a/core/basic-authorship/src/basic_authorship.rs b/core/basic-authorship/src/basic_authorship.rs index 9f0db708da..62aad4c9c7 100644 --- a/core/basic-authorship/src/basic_authorship.rs +++ b/core/basic-authorship/src/basic_authorship.rs @@ -30,7 +30,8 @@ use codec::Decode; use consensus_common::{self, evaluation}; use primitives::{H256, Blake2Hasher, ExecutionContext}; use runtime_primitives::traits::{ - Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, AuthorityIdFor + Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, + AuthorityIdFor, DigestFor, }; use runtime_primitives::generic::BlockId; use runtime_primitives::ApplyError; @@ -53,11 +54,13 @@ pub trait AuthoringApi: Send + Sync + ProvideRuntimeApi where /// The error used by this API type. type Error: std::error::Error; - /// Build a block on top of the given, with inherent extrinsics pre-pushed. + /// Build a block on top of the given block, with inherent extrinsics and + /// inherent digests pre-pushed. fn build_block) -> ()>( &self, at: &BlockId, inherent_data: InherentData, + inherent_digests: DigestFor, build_ctx: F, ) -> Result; } @@ -92,9 +95,11 @@ impl AuthoringApi for SubstrateClient where &self, at: &BlockId, inherent_data: InherentData, + inherent_digests: DigestFor, mut build_ctx: F, ) -> Result { - let mut block_builder = self.new_block_at(at)?; + + let mut block_builder = self.new_block_at(at, inherent_digests)?; let runtime_api = self.runtime_api(); // We don't check the API versions any further here since the dispatch compatibility @@ -174,12 +179,16 @@ impl consensus_common::Proposer<::Block> for Pro type Create = Result<::Block, error::Error>; type Error = error::Error; - fn propose(&self, inherent_data: InherentData, max_duration: time::Duration) - -> Result<::Block, error::Error> + fn propose( + &self, + inherent_data: InherentData, + inherent_digests: DigestFor, + max_duration: time::Duration, + ) -> Result<::Block, error::Error> { // leave some time for evaluation and block finalization (33%) let deadline = (self.now)() + max_duration - max_duration / 3; - self.propose_with(inherent_data, deadline) + self.propose_with(inherent_data, inherent_digests, deadline) } } @@ -190,8 +199,12 @@ impl Proposer where A: txpool::ChainApi, client::error::Error: From<::Error>, { - fn propose_with(&self, inherent_data: InherentData, deadline: time::Instant) - -> Result<::Block, error::Error> + fn propose_with( + &self, + inherent_data: InherentData, + inherent_digests: DigestFor, + deadline: time::Instant, + ) -> Result<::Block, error::Error> { use runtime_primitives::traits::BlakeTwo256; @@ -203,17 +216,16 @@ impl Proposer where let block = self.client.build_block( &self.parent_id, inherent_data, + inherent_digests.clone(), |block_builder| { // Add inherents from the internal pool - let inherents = self.inherents_pool.drain(); - debug!("Pushing {} queued inherents.", inherents.len()); + debug!("Pushing {} queued inherent extrinsics.", inherents.len()); for i in inherents { if let Err(e) = block_builder.push_extrinsic(i) { warn!("Error while pushing inherent extrinsic from the pool: {:?}", e); } } - // proceed with transactions let mut is_first = true; let mut skipped = 0; @@ -331,7 +343,7 @@ mod tests { cell.replace(new) }); let deadline = time::Duration::from_secs(3); - let block = proposer.propose(Default::default(), deadline).unwrap(); + let block = proposer.propose(Default::default(), Default::default(), deadline).unwrap(); // then // block should have some extrinsics although we have some more in the pool. @@ -362,7 +374,7 @@ mod tests { // when let deadline = time::Duration::from_secs(3); - let block = proposer.propose(Default::default(), deadline).unwrap(); + let block = proposer.propose(Default::default(), Default::default(), deadline).unwrap(); // then assert_eq!(block.extrinsics().len(), 1); diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index e145e63cb7..16b0fc616a 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -708,7 +708,7 @@ pub(crate) mod tests { let mut prev_hash = insert_final_block(&db, HashMap::new(), || header_producer(&Default::default(), 0)); // insert SIZE blocks && ensure that nothing is pruned - + for number in 0..cht::size() { prev_hash = insert_block(&db, HashMap::new(), || header_producer(&prev_hash, 1 + number)); } diff --git a/core/client/src/block_builder/block_builder.rs b/core/client/src/block_builder/block_builder.rs index 995b303699..eb7d81f978 100644 --- a/core/client/src/block_builder/block_builder.rs +++ b/core/client/src/block_builder/block_builder.rs @@ -20,7 +20,7 @@ use parity_codec::Encode; use runtime_primitives::ApplyOutcome; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ - Header as HeaderT, Hash, Block as BlockT, One, HashFor, ProvideRuntimeApi, ApiRef + Header as HeaderT, Hash, Block as BlockT, One, HashFor, ProvideRuntimeApi, ApiRef, DigestFor, }; use primitives::{H256, ExecutionContext}; use crate::blockchain::HeaderBackend; @@ -41,10 +41,11 @@ where A: ProvideRuntimeApi + HeaderBackend + 'a, A::Api: BlockBuilderApi, { - /// Create a new instance of builder from the given client, building on the latest block. - pub fn new(api: &'a A) -> error::Result { + /// Create a new instance of builder from the given client, building on the + /// latest block. + pub fn new(api: &'a A, inherent_digests: DigestFor) -> error::Result { api.info().and_then(|i| - Self::at_block(&BlockId::Hash(i.best_hash), api, false) + Self::at_block(&BlockId::Hash(i.best_hash), api, false, inherent_digests) ) } @@ -57,7 +58,8 @@ where pub fn at_block( block_id: &BlockId, api: &'a A, - proof_recording: bool + proof_recording: bool, + inherent_digests: DigestFor, ) -> error::Result { let number = api.block_number_from_id(block_id)? .ok_or_else(|| error::Error::UnknownBlock(format!("{}", block_id)))? @@ -70,7 +72,7 @@ where Default::default(), Default::default(), parent_hash, - Default::default() + inherent_digests, ); let mut api = api.runtime_api(); @@ -80,7 +82,7 @@ where } api.initialize_block_with_context( - block_id, ExecutionContext::BlockConstruction, &header + block_id, ExecutionContext::BlockConstruction, &header, )?; Ok(BlockBuilder { diff --git a/core/client/src/client.rs b/core/client/src/client.rs index f36992a14e..874cf7636b 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -37,7 +37,7 @@ use consensus::{ use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, Zero, NumberFor, CurrentHeight, BlockNumberToHash, ApiRef, ProvideRuntimeApi, Digest, DigestItem, - SaturatedConversion, One + SaturatedConversion, One, DigestFor, }; use runtime_primitives::BuildStorage; use crate::runtime_api::{ @@ -695,26 +695,29 @@ impl Client where /// Create a new block, built on the head of the chain. pub fn new_block( - &self + &self, + inherent_digests: DigestFor, ) -> error::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, ::Api: BlockBuilderAPI { - block_builder::BlockBuilder::new(self) + block_builder::BlockBuilder::new(self, inherent_digests) } /// Create a new block, built on top of `parent`. pub fn new_block_at( - &self, parent: &BlockId + &self, + parent: &BlockId, + inherent_digests: DigestFor, ) -> error::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, ::Api: BlockBuilderAPI { - block_builder::BlockBuilder::at_block(parent, &self, false) + block_builder::BlockBuilder::at_block(parent, &self, false, inherent_digests) } /// Create a new block, built on top of `parent` with proof recording enabled. @@ -723,14 +726,16 @@ impl Client where /// These recorded trie nodes can be used by a third party to proof the /// output of this block builder without having access to the full storage. pub fn new_block_at_with_proof_recording( - &self, parent: &BlockId + &self, + parent: &BlockId, + inherent_digests: DigestFor, ) -> error::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, ::Api: BlockBuilderAPI { - block_builder::BlockBuilder::at_block(parent, &self, true) + block_builder::BlockBuilder::at_block(parent, &self, true, inherent_digests) } /// Lock the import lock, and run operations inside. @@ -1272,11 +1277,12 @@ impl Client where /// Prepare in-memory header that is used in execution environment. fn prepare_environment_block(&self, parent: &BlockId) -> error::Result { + let parent_header = self.backend().blockchain().expect_header(*parent)?; Ok(<::Header as HeaderT>::new( self.backend.blockchain().expect_block_number_from_id(parent)? + One::one(), Default::default(), Default::default(), - self.backend.blockchain().expect_block_hash_from_id(&parent)?, + parent_header.hash(), Default::default(), )) } @@ -1753,7 +1759,7 @@ pub(crate) mod tests { let remote_client = test_client::new_with_changes_trie(); let mut nonces: HashMap<_, u64> = Default::default(); for (i, block_transfers) in blocks_transfers.into_iter().enumerate() { - let mut builder = remote_client.new_block().unwrap(); + let mut builder = remote_client.new_block(Default::default()).unwrap(); for (from, to) in block_transfers { builder.push_transfer(Transfer { from: from.into(), @@ -1828,7 +1834,7 @@ pub(crate) mod tests { fn block_builder_works_with_no_transactions() { let client = test_client::new(); - let builder = client.new_block().unwrap(); + let builder = client.new_block(Default::default()).unwrap(); client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); @@ -1839,7 +1845,7 @@ pub(crate) mod tests { fn block_builder_works_with_transactions() { let client = test_client::new(); - let mut builder = client.new_block().unwrap(); + let mut builder = client.new_block(Default::default()).unwrap(); builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -1872,7 +1878,7 @@ pub(crate) mod tests { fn block_builder_does_not_include_invalid() { let client = test_client::new(); - let mut builder = client.new_block().unwrap(); + let mut builder = client.new_block(Default::default()).unwrap(); builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -1921,7 +1927,7 @@ pub(crate) mod tests { let client = test_client::new(); - let uninserted_block = client.new_block().unwrap().bake().unwrap(); + let uninserted_block = client.new_block(Default::default()).unwrap().bake().unwrap(); #[allow(deprecated)] let backend = client.backend().as_in_memory(); #[allow(deprecated)] @@ -1940,11 +1946,11 @@ pub(crate) mod tests { let client = test_client::new(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block().unwrap().bake().unwrap(); + let a2 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); let v: Vec = Vec::new(); assert_eq!(v, client.uncles(a2.hash(), 3).unwrap()); @@ -1960,27 +1966,27 @@ pub(crate) mod tests { let client = test_client::new(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); + let a2 = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); // A2 -> A3 - let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); + let a3 = client.new_block_at(&BlockId::Hash(a2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a3.clone()).unwrap(); // A3 -> A4 - let a4 = client.new_block_at(&BlockId::Hash(a3.hash())).unwrap().bake().unwrap(); + let a4 = client.new_block_at(&BlockId::Hash(a3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a4.clone()).unwrap(); // A4 -> A5 - let a5 = client.new_block_at(&BlockId::Hash(a4.hash())).unwrap().bake().unwrap(); + let a5 = client.new_block_at(&BlockId::Hash(a4.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a5.clone()).unwrap(); // A1 -> B2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise B2 has the same hash as A2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -1992,15 +1998,15 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, b2.clone()).unwrap(); // B2 -> B3 - let b3 = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap().bake().unwrap(); + let b3 = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b3.clone()).unwrap(); // B3 -> B4 - let b4 = client.new_block_at(&BlockId::Hash(b3.hash())).unwrap().bake().unwrap(); + let b4 = client.new_block_at(&BlockId::Hash(b3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b4.clone()).unwrap(); // // B2 -> C3 - let mut builder = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap(); // this push is required as otherwise C3 has the same hash as B3 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -2012,7 +2018,7 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, c3.clone()).unwrap(); // A1 -> D2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise D2 has the same hash as B2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -2052,11 +2058,11 @@ pub(crate) mod tests { let client = test_client::new(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block().unwrap().bake().unwrap(); + let a2 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); let genesis_hash = client.info().unwrap().chain.genesis_hash; @@ -2083,27 +2089,27 @@ pub(crate) mod tests { let client = test_client::new(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); + let a2 = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); // A2 -> A3 - let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); + let a3 = client.new_block_at(&BlockId::Hash(a2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a3.clone()).unwrap(); // A3 -> A4 - let a4 = client.new_block_at(&BlockId::Hash(a3.hash())).unwrap().bake().unwrap(); + let a4 = client.new_block_at(&BlockId::Hash(a3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a4.clone()).unwrap(); // A4 -> A5 - let a5 = client.new_block_at(&BlockId::Hash(a4.hash())).unwrap().bake().unwrap(); + let a5 = client.new_block_at(&BlockId::Hash(a4.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a5.clone()).unwrap(); // A1 -> B2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise B2 has the same hash as A2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -2115,15 +2121,15 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, b2.clone()).unwrap(); // B2 -> B3 - let b3 = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap().bake().unwrap(); + let b3 = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b3.clone()).unwrap(); // B3 -> B4 - let b4 = client.new_block_at(&BlockId::Hash(b3.hash())).unwrap().bake().unwrap(); + let b4 = client.new_block_at(&BlockId::Hash(b3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b4.clone()).unwrap(); // // B2 -> C3 - let mut builder = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap(); // this push is required as otherwise C3 has the same hash as B3 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -2135,7 +2141,7 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, c3.clone()).unwrap(); // A1 -> D2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise D2 has the same hash as B2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -2372,11 +2378,11 @@ pub(crate) mod tests { let client = test_client::new(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block().unwrap().bake().unwrap(); + let a2 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); let genesis_hash = client.info().unwrap().chain.genesis_hash; @@ -2412,16 +2418,16 @@ pub(crate) mod tests { let client = test_client::new(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); + let a2 = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); // A2 -> A3 let justification = vec![1, 2, 3]; - let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); + let a3 = client.new_block_at(&BlockId::Hash(a2.hash()), Default::default()).unwrap().bake().unwrap(); client.import_justified(BlockOrigin::Own, a3.clone(), justification.clone()).unwrap(); #[allow(deprecated)] diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index 982f106f2a..9959d29a1b 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -448,7 +448,7 @@ pub fn check_execution_proof( Default::default(), Default::default(), request.header.hash(), - Default::default(), + request.header.digest().clone(), ); execution_proof_check_on_trie_backend::( &trie_backend, @@ -525,7 +525,7 @@ mod tests { for _ in 1..3 { remote_client.import_justified( BlockOrigin::Own, - remote_client.new_block().unwrap().bake().unwrap(), + remote_client.new_block(Default::default()).unwrap().bake().unwrap(), Default::default(), ).unwrap(); } diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index 39563aa83c..0a8a05b850 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -588,7 +588,7 @@ pub mod tests { let remote_client = test_client::new(); let mut local_headers_hashes = Vec::new(); for i in 0..4 { - let builder = remote_client.new_block().unwrap(); + let builder = remote_client.new_block(Default::default()).unwrap(); remote_client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); local_headers_hashes.push(remote_client.block_hash(i + 1) .map_err(|_| ClientError::Backend("TestError".into()))); diff --git a/core/consensus/aura/src/digest.rs b/core/consensus/aura/src/digest.rs new file mode 100644 index 0000000000..fe85c5807e --- /dev/null +++ b/core/consensus/aura/src/digest.rs @@ -0,0 +1,67 @@ +// Copyright 2018-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Aura (Authority-Round) digests +//! +//! This implements the digests for AuRa, to allow the private +//! `CompatibleDigestItem` trait to appear in public interfaces. +use primitives::Pair; +use aura_primitives::AURA_ENGINE_ID; +use runtime_primitives::generic::DigestItem; +use parity_codec::{Encode, Decode}; + +type Signature

=

::Signature; + +/// A digest item which is usable with aura consensus. +pub trait CompatibleDigestItem: Sized { + /// Construct a digest item which contains a signature on the hash. + fn aura_seal(signature: Signature) -> Self; + + /// If this item is an Aura seal, return the signature. + fn as_aura_seal(&self) -> Option<&Signature>; + + /// Construct a digest item which contains the slot number + fn aura_pre_digest(slot_num: u64) -> Self; + + /// If this item is an AuRa pre-digest, return the slot number + fn as_aura_pre_digest(&self) -> Option; +} + +impl CompatibleDigestItem

for DigestItem + where P: Pair, P::Signature: Clone + Encode + Decode, +{ + fn aura_seal(signature: Signature

) -> Self { + DigestItem::Seal(AURA_ENGINE_ID, signature) + } + + fn as_aura_seal(&self) -> Option<&Signature

> { + match self { + DigestItem::Seal(AURA_ENGINE_ID, ref sig) => Some(sig), + _ => None, + } + } + + fn aura_pre_digest(slot_num: u64) -> Self { + DigestItem::PreRuntime(AURA_ENGINE_ID, slot_num.encode()) + } + + fn as_aura_pre_digest(&self) -> Option { + match self { + DigestItem::PreRuntime(AURA_ENGINE_ID, ref buffer) => Decode::decode(&mut &buffer[..]), + _ => None, + } + } +} diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 554a63de94..e3ab9e31cf 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -44,18 +44,20 @@ use client::{ error::Result as CResult, backend::AuxStore, }; -use aura_primitives::AURA_ENGINE_ID; -use runtime_primitives::{generic, generic::BlockId, Justification}; + +use runtime_primitives::{generic::{self, BlockId}, Justification}; use runtime_primitives::traits::{ - Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi, AuthorityIdFor, Zero, + Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi, AuthorityIdFor, + Zero, Member, }; + use primitives::Pair; use inherents::{InherentDataProviders, InherentData}; use authorities::AuthoritiesApi; -use futures::{Future, IntoFuture, future, stream::Stream}; +use futures::{Future, IntoFuture, future}; use tokio::timer::Timeout; -use log::{warn, debug, info, trace}; +use log::{error, warn, debug, info, trace}; use srml_aura::{ InherentType as AuraInherent, AuraInherentData, @@ -68,24 +70,10 @@ use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible, slot_now, check pub use aura_primitives::*; pub use consensus_common::{SyncOracle, ExtraVerification}; -type AuthorityId

=

::Public; -type Signature

=

::Signature; +mod digest; +use digest::CompatibleDigestItem; -/// A handle to the network. This is generally implemented by providing some -/// handle to a gossip service or similar. -/// -/// Intended to be a lightweight handle such as an `Arc`. -#[deprecated( - since = "1.0.1", - note = "This is dead code and will be removed in a future release", -)] -pub trait Network: Clone { - /// A stream of input messages for a topic. - type In: Stream,Error=()>; - - /// Send a message at a specific round out. - fn send_message(&self, slot: u64, message: Vec); -} +type AuthorityId

=

::Public; /// A slot duration. Create with `get_or_compute`. #[derive(Clone, Copy, Debug, Encode, Decode, Hash, PartialOrd, Ord, PartialEq, Eq)] @@ -122,48 +110,6 @@ fn slot_author(slot_num: u64, authorities: &[AuthorityId

]) -> Option Some(current_author) } -/// A digest item which is usable with aura consensus. -pub trait CompatibleDigestItem: Sized { - /// Construct a digest item which contains a slot number and a signature on the - /// hash. - fn aura_seal(slot_num: u64, signature: Signature) -> Self; - - /// If this item is an Aura seal, return the slot number and signature. - fn as_aura_seal(&self) -> Option<(u64, Signature)>; - - /// Return `true` if this seal type is deprecated. Otherwise, return - /// `false`. - fn is_deprecated(&self) -> bool; -} - -impl CompatibleDigestItem

for generic::DigestItem - where P: Pair, P::Signature: Clone + Encode + Decode, -{ - /// Construct a digest item which is a slot number and a signature on the - /// hash. - fn aura_seal(slot_number: u64, signature: Signature

) -> Self { - generic::DigestItem::Consensus(AURA_ENGINE_ID, (slot_number, signature).encode()) - } - - /// If this item is an Aura seal, return the slot number and signature. - #[allow(deprecated)] - fn as_aura_seal(&self) -> Option<(u64, Signature

)> { - match self { - generic::DigestItem::Seal(slot, ref sig) => Some((*slot, (*sig).clone())), - generic::DigestItem::Consensus(AURA_ENGINE_ID, seal) => Decode::decode(&mut &seal[..]), - _ => None, - } - } - - #[allow(deprecated)] - fn is_deprecated(&self) -> bool { - match self { - generic::DigestItem::Seal(_, _) => true, - _ => false, - } - } -} - #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] struct AuraSlotCompatible; @@ -178,60 +124,8 @@ impl SlotCompatible for AuraSlotCompatible { } } -/// Start the aura worker in a separate thread. -#[deprecated(since = "1.1", note = "Please spawn a thread manually")] -pub fn start_aura_thread( - slot_duration: SlotDuration, - local_key: Arc

, - client: Arc, - select_chain: SC, - block_import: Arc, - env: Arc, - sync_oracle: SO, - on_exit: OnExit, - inherent_data_providers: InherentDataProviders, - force_authoring: bool, -) -> Result<(), consensus_common::Error> where - B: Block + 'static, - C: ProvideRuntimeApi + ProvideCache + AuxStore + Send + Sync + 'static, - C::Api: AuthoritiesApi, - SC: SelectChain + Clone + 'static, - E: Environment + Send + Sync + 'static, - E::Proposer: Proposer + Send + 'static, - <>::Create as IntoFuture>::Future: Send + 'static, - I: BlockImport + Send + Sync + 'static, - Error: From + 'static, - P: Pair + Send + Sync + 'static, - P::Public: Encode + Decode + Eq + Clone + Debug + Hash + Send + Sync + 'static, - P::Signature: Encode, - SO: SyncOracle + Send + Sync + Clone + 'static, - OnExit: Future + Send + 'static, - DigestItemFor: CompatibleDigestItem

+ DigestItem> + 'static, - Error: ::std::error::Error + Send + From<::consensus_common::Error> + 'static, -{ - let worker = AuraWorker { - client: client.clone(), - block_import, - env, - local_key, - inherent_data_providers: inherent_data_providers.clone(), - sync_oracle: sync_oracle.clone(), - force_authoring, - }; - - #[allow(deprecated)] // The function we are in is also deprecated. - slots::start_slot_worker_thread::<_, _, _, _, AuraSlotCompatible, u64, _>( - slot_duration.0, - select_chain, - Arc::new(worker), - sync_oracle, - on_exit, - inherent_data_providers - ) -} - /// Start the aura worker. The returned future should be run in a tokio runtime. -pub fn start_aura( +pub fn start_aura( slot_duration: SlotDuration, local_key: Arc

, client: Arc, @@ -243,20 +137,25 @@ pub fn start_aura( inherent_data_providers: InherentDataProviders, force_authoring: bool, ) -> Result, consensus_common::Error> where - B: Block, - C: ProvideRuntimeApi + ProvideCache + AuxStore, + B: Block, + C: ProvideRuntimeApi + ProvideCache + AuxStore + Send + Sync, C::Api: AuthoritiesApi, - SC: SelectChain + Clone, - E: Environment, + SC: SelectChain, + generic::DigestItem: DigestItem, E::Proposer: Proposer, <>::Create as IntoFuture>::Future: Send + 'static, - I: BlockImport + Send + Sync + 'static, P: Pair + Send + Sync + 'static, - P::Public: Hash + Eq + Send + Sync + Clone + Debug + Encode + Decode + 'static, - P::Signature: Encode, - SO: SyncOracle + Send + Sync + Clone, + P::Public: Hash + Member + Encode + Decode, + P::Signature: Hash + Member + Encode + Decode, DigestItemFor: CompatibleDigestItem

+ DigestItem>, + H: Header< + Digest=generic::Digest>, + Hash=B::Hash, + >, + E: Environment, + I: BlockImport + Send + Sync + 'static, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, + SO: SyncOracle + Send + Sync + Clone, OnExit: Future, { let worker = AuraWorker { @@ -288,18 +187,23 @@ struct AuraWorker { force_authoring: bool, } -impl SlotWorker for AuraWorker where - C: ProvideRuntimeApi + ProvideCache + AuxStore, +impl SlotWorker for AuraWorker where + B: Block, + C: ProvideRuntimeApi + ProvideCache + Sync, C::Api: AuthoritiesApi, E: Environment, E::Proposer: Proposer, <>::Create as IntoFuture>::Future: Send + 'static, + H: Header< + Digest=generic::Digest>, + Hash=B::Hash, + >, I: BlockImport + Send + Sync + 'static, P: Pair + Send + Sync + 'static, - P::Public: Hash + Eq + Send + Sync + Clone + Debug + Encode + Decode + 'static, - P::Signature: Encode, + P::Public: Member + Encode + Decode + Hash, + P::Signature: Member + Encode + Decode + Hash + Debug, SO: SyncOracle + Send + Clone, - DigestItemFor: CompatibleDigestItem

+ DigestItem>, + DigestItemFor: CompatibleDigestItem

+ DigestItem, Hash=B::Hash>, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, { type OnSlot = Box + Send>; @@ -376,7 +280,15 @@ impl SlotWorker for AuraWorker as CompatibleDigestItem

>::aura_pre_digest(slot_num), + ], + }, + remaining_duration, + ).into_future(), remaining_duration, ) } else { @@ -384,72 +296,98 @@ impl SlotWorker for AuraWorker slot_num - ); - return - } + Box::new(proposal_work.map(move |b| { + // minor hack since we don't have access to the timestamp + // that is actually set by the proposer. + let slot_after_building = slot_now(slot_duration); + if slot_after_building != Some(slot_num) { + info!( + "Discarding proposal for slot {}; block production took too long", + slot_num + ); + telemetry!(CONSENSUS_INFO; "aura.discarding_proposal_took_too_long"; + "slot" => slot_num + ); + return + } - let (header, body) = b.deconstruct(); - let header_num = header.number().clone(); - let pre_hash = header.hash(); - let parent_hash = header.parent_hash().clone(); + let (header, body) = b.deconstruct(); + let pre_digest: Result = find_pre_digest::(&header); + if let Err(e) = pre_digest { + error!(target: "aura", "FATAL ERROR: Invalid pre-digest: {}!", e); + return + } else { + trace!(target: "aura", "Got correct number of seals. Good!") + }; + + let header_num = header.number().clone(); + let parent_hash = header.parent_hash().clone(); + + // sign the pre-sealed hash of the block and then + // add it to a digest item. + let header_hash = header.hash(); + let signature = pair.sign(header_hash.as_ref()); + let signature_digest_item = as CompatibleDigestItem

>::aura_seal(signature); + + let import_block: ImportBlock = ImportBlock { + origin: BlockOrigin::Own, + header, + justification: None, + post_digests: vec![signature_digest_item], + body: Some(body), + finalized: false, + auxiliary: Vec::new(), + fork_choice: ForkChoiceStrategy::LongestChain, + }; + + info!("Pre-sealed block for proposal at {}. Hash now {:?}, previously {:?}.", + header_num, + import_block.post_header().hash(), + header_hash + ); + telemetry!(CONSENSUS_INFO; "aura.pre_sealed_block"; + "header_num" => ?header_num, + "hash_now" => ?import_block.post_header().hash(), + "hash_previously" => ?header_hash + ); - // sign the pre-sealed hash of the block and then - // add it to a digest item. - let to_sign = (slot_num, pre_hash).encode(); - let signature = pair.sign(&to_sign[..]); - let item = as CompatibleDigestItem

>::aura_seal( - slot_num, - signature, - ); + if let Err(e) = block_import.import_block(import_block, Default::default()) { + warn!(target: "aura", "Error with block built on {:?}: {:?}", + parent_hash, e); + telemetry!(CONSENSUS_WARN; "aura.err_with_block_built_on"; + "hash" => ?parent_hash, "err" => ?e + ); + } + }).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e)).into())) + } +} - let import_block: ImportBlock = ImportBlock { - origin: BlockOrigin::Own, - header, - justification: None, - post_digests: vec![item], - body: Some(body), - finalized: false, - auxiliary: Vec::new(), - fork_choice: ForkChoiceStrategy::LongestChain, - }; - - info!("Pre-sealed block for proposal at {}. Hash now {:?}, previously {:?}.", - header_num, - import_block.post_header().hash(), - pre_hash - ); - telemetry!(CONSENSUS_INFO; "aura.pre_sealed_block"; - "header_num" => ?header_num, - "hash_now" => ?import_block.post_header().hash(), - "hash_previously" => ?pre_hash - ); +macro_rules! aura_err { + ($($i: expr),+) => { + { debug!(target: "aura", $($i),+) + ; format!($($i),+) + } + }; +} - if let Err(e) = block_import.import_block(import_block, Default::default()) { - warn!(target: "aura", "Error with block built on {:?}: {:?}", - parent_hash, e); - telemetry!(CONSENSUS_WARN; "aura.err_with_block_built_on"; - "hash" => ?parent_hash, "err" => ?e - ); - } - }) - .map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e)).into()) - ) +fn find_pre_digest(header: &B::Header) -> Result + where DigestItemFor: CompatibleDigestItem

, + P::Signature: Decode, + P::Public: Encode + Decode + PartialEq + Clone, +{ + let mut pre_digest: Option = None; + for log in header.digest().logs() { + trace!(target: "aura", "Checking log {:?}", log); + match (log.as_aura_pre_digest(), pre_digest.is_some()) { + (Some(_), true) => Err(aura_err!("Multiple AuRa pre-runtime headers, rejecting!"))?, + (None, _) => trace!(target: "aura", "Ignoring digest not meant for us"), + (s, false) => pre_digest = s, + } } + pre_digest.ok_or_else(|| aura_err!("No AuRa pre-runtime digest found")) } + /// check a header has been signed by the right key. If the slot is too far in the future, an error will be returned. /// if it's successful, returns the pre-header and the digest item containing the seal. /// @@ -462,30 +400,25 @@ fn check_header( mut header: B::Header, hash: B::Hash, authorities: &[AuthorityId

], - allow_old_seals: bool, -) -> Result>, String> - where DigestItemFor: CompatibleDigestItem

, - P::Signature: Decode, - C: client::backend::AuxStore, - P::Public: AsRef + Encode + Decode + PartialEq + Clone, +) -> Result)>, String> where + DigestItemFor: CompatibleDigestItem

, + P::Signature: Decode, + C: client::backend::AuxStore, + P::Public: AsRef + Encode + Decode + PartialEq + Clone, { - let digest_item = match header.digest_mut().pop() { + let seal = match header.digest_mut().pop() { Some(x) => x, None => return Err(format!("Header {:?} is unsealed", hash)), }; - if !allow_old_seals && digest_item.is_deprecated() { - debug!(target: "aura", "Header {:?} uses old seal format, rejecting", hash); - return Err(format!("Header {:?} uses old seal format, rejecting", hash)) - } - - let (slot_num, sig) = digest_item.as_aura_seal().ok_or_else(|| { - debug!(target: "aura", "Header {:?} is unsealed", hash); - format!("Header {:?} is unsealed", hash) + let sig = seal.as_aura_seal().ok_or_else(|| { + aura_err!("Header {:?} has a bad seal", hash) })?; + let slot_num = find_pre_digest::(&header)?; + if slot_num > slot_now { - header.digest_mut().push(digest_item); + header.digest_mut().push(seal); Ok(CheckedHeader::Deferred(header, slot_num)) } else { // check the signature is valid under the expected authority and @@ -496,16 +429,14 @@ fn check_header( }; let pre_hash = header.hash(); - let to_sign = (slot_num, pre_hash).encode(); - let public = expected_author; - if P::verify(&sig, &to_sign[..], public) { + if P::verify(&sig, pre_hash.as_ref(), expected_author) { match check_equivocation::<_, _,

::Public>( client, slot_now, slot_num, header.clone(), - public.clone(), + expected_author.clone(), ) { Ok(Some(equivocation_proof)) => { let log_str = format!( @@ -517,7 +448,7 @@ fn check_header( info!("{}", log_str); Err(log_str) }, - Ok(None) => Ok(CheckedHeader::Checked(header, digest_item)), + Ok(None) => Ok(CheckedHeader::Checked(header, (slot_num, seal))), Err(e) => Err(e.to_string()), } } else { @@ -532,7 +463,6 @@ pub struct AuraVerifier { extra: E, phantom: PhantomData

, inherent_data_providers: inherents::InherentDataProviders, - allow_old_seals: bool, } impl AuraVerifier @@ -631,20 +561,17 @@ impl Verifier for AuraVerifier where ); // we add one to allow for some small drift. - // FIXME #1019 in the future, alter this queue to allow deferring of headers + // FIXME #1019 in the future, alter this queue to allow deferring of + // headers let checked_header = check_header::( &self.client, slot_now + 1, header, hash, &authorities[..], - self.allow_old_seals, )?; match checked_header { - CheckedHeader::Checked(pre_header, seal) => { - let (slot_num, _) = seal.as_aura_seal() - .expect("check_header always returns a seal digest item; qed"); - + CheckedHeader::Checked(pre_header, (slot_num, seal)) => { // if the body is passed through, we need to use the runtime // to check that the internally-set timestamp in the inherents // actually matches the slot set in the seal. @@ -813,52 +740,6 @@ pub fn import_queue( extra, inherent_data_providers, phantom: PhantomData, - allow_old_seals: false, - } - ); - Ok(BasicQueue::new( - verifier, - block_import, - justification_import, - finality_proof_import, - finality_proof_request_builder, - )) -} - -/// Start an import queue for the Aura consensus algorithm with backwards compatibility. -#[deprecated( - since = "1.0.1", - note = "should not be used unless backwards compatibility with an older chain is needed.", -)] -pub fn import_queue_accept_old_seals( - slot_duration: SlotDuration, - block_import: SharedBlockImport, - justification_import: Option>, - finality_proof_import: Option>, - finality_proof_request_builder: Option>, - client: Arc, - extra: E, - inherent_data_providers: InherentDataProviders, -) -> Result, consensus_common::Error> where - B: Block, - C: 'static + ProvideRuntimeApi + ProvideCache + Send + Sync + AuxStore, - C::Api: BlockBuilderApi + AuthoritiesApi, - DigestItemFor: CompatibleDigestItem

+ DigestItem>, - E: 'static + ExtraVerification, - P: Pair + Send + Sync + 'static, - P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode + AsRef, - P::Signature: Encode + Decode, -{ - register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?; - initialize_authorities_cache(&*client)?; - - let verifier = Arc::new( - AuraVerifier { - client: client.clone(), - extra, - inherent_data_providers, - phantom: PhantomData, - allow_old_seals: true, } ); Ok(BasicQueue::new( @@ -873,10 +754,11 @@ pub fn import_queue_accept_old_seals( #[cfg(test)] mod tests { use super::*; + use futures::stream::Stream as _; use consensus_common::NoNetwork as DummyOracle; use network::test::*; use network::test::{Block as TestBlock, PeersClient, PeersFullClient}; - use runtime_primitives::traits::Block as BlockT; + use runtime_primitives::traits::{Block as BlockT, DigestFor}; use network::config::ProtocolConfig; use parking_lot::Mutex; use tokio::runtime::current_thread; @@ -910,8 +792,13 @@ mod tests { type Error = Error; type Create = Result; - fn propose(&self, _: InherentData, _: Duration) -> Result { - self.1.new_block().unwrap().bake().map_err(|e| e.into()) + fn propose( + &self, + _: InherentData, + digests: DigestFor, + _: Duration, + ) -> Result { + self.1.new_block(digests).unwrap().bake().map_err(|e| e.into()) } } @@ -955,7 +842,6 @@ mod tests { extra: NothingExtra, inherent_data_providers, phantom: Default::default(), - allow_old_seals: false, }) }, PeersClient::Light(_) => unreachable!("No (yet) tests for light client + Aura"), @@ -995,19 +881,18 @@ mod tests { extrinsics_root: Default::default(), digest: DigestTest { logs: vec![], }, }; + let item = as CompatibleDigestItem>::aura_pre_digest(slot_num); + header.digest_mut().push(item); let header_hash: H256 = header.hash(); - let to_sign = (slot_num, header_hash).encode(); - let signature = pair.sign(&to_sign[..]); + let signature = pair.sign(&header_hash[..]); - let item = as CompatibleDigestItem>::aura_seal( - slot_num, - signature, - ); + let item = CompatibleDigestItem::::aura_seal(signature); header.digest_mut().push(item); (header, header_hash) } #[test] + #[allow(deprecated)] fn authoring_blocks() { let _ = ::env_logger::try_init(); let mut net = AuraTestNet::new(3); @@ -1046,7 +931,7 @@ mod tests { &inherent_data_providers, slot_duration.get() ).expect("Registers aura inherent data provider"); - let aura = start_aura::<_, _, _, _, _, sr25519::Pair, _, _, _>( + let aura = start_aura::<_, _, _, _, _, sr25519::Pair, _, _, _, _>( slot_duration, Arc::new(key.clone().into()), client.clone(), @@ -1111,22 +996,22 @@ mod tests { let c = Arc::new(client); // It's ok to sign same headers. - assert!(check_header::<_, B, P>(&c, 2, header1.clone(), header1_hash, &authorities, false).is_ok()); - assert!(check_header::<_, B, P>(&c, 3, header1, header1_hash, &authorities, false).is_ok()); + check_header::<_, B, P>(&c, 2, header1.clone(), header1_hash, &authorities).unwrap(); + assert!(check_header::<_, B, P>(&c, 3, header1, header1_hash, &authorities).is_ok()); // But not two different headers at the same slot. - assert!(check_header::<_, B, P>(&c, 4, header2, header2_hash, &authorities, false).is_err()); + assert!(check_header::<_, B, P>(&c, 4, header2, header2_hash, &authorities).is_err()); // Different slot is ok. - assert!(check_header::<_, B, P>(&c, 5, header3, header3_hash, &authorities, false).is_ok()); + assert!(check_header::<_, B, P>(&c, 5, header3, header3_hash, &authorities).is_ok()); // Here we trigger pruning and save header 4. - assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 2, header4, header4_hash, &authorities, false).is_ok()); + assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 2, header4, header4_hash, &authorities).is_ok()); // This fails because header 5 is an equivocation of header 4. - assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 3, header5, header5_hash, &authorities, false).is_err()); + assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 3, header5, header5_hash, &authorities).is_err()); // This is ok because we pruned the corresponding header. Shows that we are pruning. - assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 4, header6, header6_hash, &authorities, false).is_ok()); + assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 4, header6, header6_hash, &authorities).is_ok()); } } diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 83ba6ccba2..0e49c45198 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . //! Primitives for BABE. -#![forbid(warnings, unsafe_code, missing_docs)] +#![deny(warnings, unsafe_code, missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use runtime_primitives::ConsensusEngineId; diff --git a/core/consensus/babe/src/digest.rs b/core/consensus/babe/src/digest.rs new file mode 100644 index 0000000000..b26a1508b5 --- /dev/null +++ b/core/consensus/babe/src/digest.rs @@ -0,0 +1,149 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Private mplementation details of BABE digests. +use primitives::sr25519::{Public, Signature}; +use babe_primitives::BABE_ENGINE_ID; +use runtime_primitives::generic::DigestItem; +use std::fmt::Debug; +use parity_codec::{Decode, Encode, Input}; +use log::info; +use schnorrkel::{ + vrf::{VRFProof, VRFOutput, VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}, + PUBLIC_KEY_LENGTH, +}; + +/// A BABE pre-digest. It includes: +/// +/// * The public key of the author. +/// * The VRF proof. +/// * The VRF output. +/// * The slot number. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct BabePreDigest { + pub(super) vrf_output: VRFOutput, + pub(super) proof: VRFProof, + pub(super) author: Public, + pub(super) slot_num: u64, +} + +/// The prefix used by BABE for its VRF keys. +pub const BABE_VRF_PREFIX: &'static [u8] = b"substrate-babe-vrf"; + +type TmpDecode = ( + [u8; VRF_OUTPUT_LENGTH], + [u8; VRF_PROOF_LENGTH], + [u8; PUBLIC_KEY_LENGTH], + u64, +); + +impl Encode for BabePreDigest { + fn encode(&self) -> Vec { + let tmp: TmpDecode = ( + *self.vrf_output.as_bytes(), + self.proof.to_bytes(), + self.author.0, + self.slot_num, + ); + parity_codec::Encode::encode(&tmp) + } +} + +impl Decode for BabePreDigest { + fn decode(i: &mut R) -> Option { + let (output, proof, public_key, slot_num): TmpDecode = Decode::decode(i)?; + Some(BabePreDigest { + proof: VRFProof::from_bytes(&proof).ok()?, + vrf_output: VRFOutput::from_bytes(&output).ok()?, + author: Public(public_key), + slot_num, + }) + } +} + +/// A digest item which is usable with BABE consensus. +pub trait CompatibleDigestItem: Sized { + /// Construct a digest item which contains a BABE pre-digest. + fn babe_pre_digest(seal: BabePreDigest) -> Self; + + /// If this item is an BABE pre-digest, return it. + fn as_babe_pre_digest(&self) -> Option; + + /// Construct a digest item which contains a BABE seal. + fn babe_seal(signature: Signature) -> Self; + + /// If this item is a BABE signature, return the signature. + fn as_babe_seal(&self) -> Option; +} + +impl CompatibleDigestItem for DigestItem> +{ + fn babe_pre_digest(digest: BabePreDigest) -> Self { + DigestItem::PreRuntime(BABE_ENGINE_ID, digest.encode()) + } + + fn as_babe_pre_digest(&self) -> Option { + match self { + DigestItem::PreRuntime(BABE_ENGINE_ID, seal) => { + let decoded = Decode::decode(&mut &seal[..]); + if decoded.is_none() { + info!(target: "babe", "Failed to decode {:?}", seal) + } + decoded + } + _ => { + info!(target: "babe", "Invalid consensus: {:?}!", self); + None + } + } + } + + fn babe_seal(signature: Signature) -> Self { + DigestItem::Seal(BABE_ENGINE_ID, signature.encode()) + } + + fn as_babe_seal(&self) -> Option { + match self { + DigestItem::Seal(BABE_ENGINE_ID, signature) => Decode::decode(&mut &signature[..]), + _ => None, + } + } +} + +impl CompatibleDigestItem for DigestItem +{ + fn babe_pre_digest(digest: BabePreDigest) -> Self { + DigestItem::PreRuntime(BABE_ENGINE_ID, digest.encode()) + } + + fn as_babe_pre_digest(&self) -> Option { + match self { + DigestItem::PreRuntime(BABE_ENGINE_ID, seal) => Decode::decode(&mut &seal[..]), + _ => None, + } + } + + fn babe_seal(signature: Signature) -> Self { + DigestItem::Seal(BABE_ENGINE_ID, signature) + } + + fn as_babe_seal(&self) -> Option { + match self { + DigestItem::Seal(BABE_ENGINE_ID, signature) => Some(signature.clone()), + _ => None, + } + } +} \ No newline at end of file diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 72a4e55a30..2d1afb0187 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -16,7 +16,7 @@ //! # BABE consensus //! -//! BABE (Blind Assignment for Blockchain Extension) consensus in substrate. +//! BABE (Blind Assignment for Blockchain Extension) consensus in Substrate. //! //! # Stability //! @@ -26,32 +26,42 @@ #![forbid(unsafe_code, missing_docs)] #![deny(warnings)] extern crate core; +mod digest; +use digest::CompatibleDigestItem; +pub use digest::{BabePreDigest, BABE_VRF_PREFIX}; pub use babe_primitives::*; pub use consensus_common::SyncOracle; use consensus_common::ExtraVerification; use runtime_primitives::{generic, generic::BlockId, Justification}; use runtime_primitives::traits::{ Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi, AuthorityIdFor, + SimpleBitOps, }; -use std::{sync::Arc, u64, fmt::Debug}; -use parity_codec::{Decode, Encode, Input}; +use std::{sync::Arc, u64, fmt::{Debug, Display}}; +use runtime_support::serde::{Serialize, Deserialize}; +use parity_codec::{Decode, Encode}; use primitives::{ crypto::Pair, - sr25519::{Public, Signature, LocalizedSignature, self}, + sr25519::{Public, Signature, self}, }; use merlin::Transcript; use inherents::{InherentDataProviders, InherentData}; -use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; +use substrate_telemetry::{ + telemetry, + CONSENSUS_TRACE, + CONSENSUS_DEBUG, + CONSENSUS_WARN, + CONSENSUS_INFO, +}; use schnorrkel::{ keys::Keypair, vrf::{ - VRFProof, VRFProofBatchable, VRFInOut, VRFOutput, - VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH, + VRFProof, VRFProofBatchable, VRFInOut, }, - PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH, }; use authorities::AuthoritiesApi; -use consensus_common::{self, Authorities, BlockImport, Environment, Proposer, +use consensus_common::{ + self, Authorities, BlockImport, Environment, Proposer, ForkChoiceStrategy, ImportBlock, BlockOrigin, Error as ConsensusError, }; use srml_babe::{ @@ -74,92 +84,10 @@ use log::{error, warn, debug, info, trace}; use slots::{SlotWorker, SlotInfo, SlotCompatible, slot_now}; -/// A BABE seal. It includes: -/// -/// * The public key -/// * The VRF proof -/// * The signature -/// * The slot number -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct BabeSeal { - vrf_output: VRFOutput, - proof: VRFProof, - signature: LocalizedSignature, - slot_num: u64, -} - -/// The prefix used by BABE for its VRF keys. -pub const BABE_VRF_PREFIX: &'static [u8] = b"substrate-babe-vrf"; - -macro_rules! babe_assert_eq { - ($a: expr, $b: expr) => { - { - let ref a = $a; - let ref b = $b; - if a != b { - error!( - target: "babe", - "Expected {:?} to equal {:?}, but they were not", - stringify!($a), - stringify!($b), - ); - assert_eq!(a, b); - } - } - }; -} - -type TmpDecode = ( - [u8; VRF_OUTPUT_LENGTH], - [u8; VRF_PROOF_LENGTH], - [u8; SIGNATURE_LENGTH], - [u8; PUBLIC_KEY_LENGTH], - u64, -); - -impl Encode for BabeSeal { - fn encode(&self) -> Vec { - let tmp: TmpDecode = ( - *self.vrf_output.as_bytes(), - self.proof.to_bytes(), - self.signature.signature.0, - self.signature.signer.0, - self.slot_num, - ); - let encoded = parity_codec::Encode::encode(&tmp); - if cfg!(any(test, debug_assertions)) { - debug!(target: "babe", "Checking if encoding was correct"); - let decoded_version = Self::decode(&mut &encoded[..]) - .expect("we just encoded this ourselves, so it is correct; qed"); - babe_assert_eq!(decoded_version.proof, self.proof); - babe_assert_eq!(decoded_version.vrf_output, self.vrf_output); - babe_assert_eq!(decoded_version.signature.signature, self.signature.signature); - babe_assert_eq!(decoded_version.signature.signer, self.signature.signer); - babe_assert_eq!(decoded_version.slot_num, self.slot_num); - debug!(target: "babe", "Encoding was correct") - } - encoded - } -} - -impl Decode for BabeSeal { - fn decode(i: &mut R) -> Option { - let (output, proof, sig, public_key, slot_num): TmpDecode = Decode::decode(i)?; - Some(BabeSeal { - proof: VRFProof::from_bytes(&proof).ok()?, - vrf_output: VRFOutput::from_bytes(&output).ok()?, - signature: LocalizedSignature { - signature: Signature(sig), - signer: Public(public_key), - }, - slot_num, - }) - } -} /// A slot duration. Create with `get_or_compute`. // FIXME: Once Rust has higher-kinded types, the duplication between this -// and `super::aura::Config` can be eliminated. +// and `super::babe::Config` can be eliminated. // https://github.com/paritytech/substrate/issues/2434 pub struct Config(slots::SlotDuration); @@ -191,45 +119,6 @@ impl Config { } } -/// A digest item which is usable with BABE consensus. -pub trait CompatibleDigestItem: Sized { - /// Construct a digest item which contains a slot number and a signature - /// on the hash. - fn babe_seal(signature: BabeSeal) -> Self; - - /// If this item is an Babe seal, return the slot number and signature. - fn as_babe_seal(&self) -> Option; -} - -impl CompatibleDigestItem for generic::DigestItem - where T: Debug, Hash: Debug -{ - /// Construct a digest item which contains a slot number and a signature - /// on the hash. - fn babe_seal(signature: BabeSeal) -> Self { - generic::DigestItem::Consensus(BABE_ENGINE_ID, signature.encode()) - } - - /// If this item is an BABE seal, return the slot number and signature. - fn as_babe_seal(&self) -> Option { - match self { - generic::DigestItem::Consensus(BABE_ENGINE_ID, seal) => { - match Decode::decode(&mut &seal[..]) { - s @ Some(_) => s, - s @ None => { - info!(target: "babe", "Failed to decode {:?}", seal); - s - } - } - } - _ => { - info!(target: "babe", "Invalid consensus: {:?}!", self); - None - } - } - } -} - struct BabeSlotCompatible; impl SlotCompatible for BabeSlotCompatible { @@ -280,7 +169,7 @@ pub struct BabeParams { } /// Start the babe worker. The returned future should be run in a tokio runtime. -pub fn start_babe(BabeParams { +pub fn start_babe(BabeParams { config, local_key, client, @@ -295,17 +184,22 @@ pub fn start_babe(BabeParams { impl Future, consensus_common::Error, > where - B: Block, + B: Block, C: ProvideRuntimeApi + ProvideCache, C::Api: AuthoritiesApi, - E: Environment, + SC: SelectChain, + generic::DigestItem: DigestItem, E::Proposer: Proposer, <>::Create as IntoFuture>::Future: Send + 'static, + DigestItemFor: CompatibleDigestItem + DigestItem, + H: Header< + Digest=generic::Digest>, + Hash=B::Hash, + >, + E: Environment, I: BlockImport + Send + Sync + 'static, + Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, - SC: SelectChain, - DigestItemFor: CompatibleDigestItem + DigestItem, - Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, OnExit: Future, { let worker = BabeWorker { @@ -339,15 +233,22 @@ struct BabeWorker { threshold: u64, } -impl SlotWorker for BabeWorker where +impl SlotWorker for BabeWorker where + B: Block, C: ProvideRuntimeApi + ProvideCache, C::Api: AuthoritiesApi, E: Environment, E::Proposer: Proposer, <>::Create as IntoFuture>::Future: Send + 'static, + Hash: Debug + Eq + Copy + SimpleBitOps + Encode + Decode + Serialize + + for<'de> Deserialize<'de> + Debug + Default + AsRef<[u8]> + AsMut<[u8]> + + std::hash::Hash + Display + Send + Sync + 'static, + H: Header< + Digest=generic::Digest>, + Hash=B::Hash, + >, I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Clone, - DigestItemFor: CompatibleDigestItem + DigestItem, Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, { type OnSlot = Box + Send>; @@ -399,7 +300,7 @@ impl SlotWorker for BabeWorker whe // FIXME replace the dummy empty slices with real data // https://github.com/paritytech/substrate/issues/2435 // https://github.com/paritytech/substrate/issues/2436 - let authoring_result = if let Some((inout, proof, _batchable_proof)) = claim_slot( + let proposal_work = if let Some((inout, proof, _batchable_proof)) = claim_slot( &[0u8; 0], slot_info.number, &[0u8; 0], @@ -429,105 +330,133 @@ impl SlotWorker for BabeWorker whe } }; + let inherent_digest = BabePreDigest { + proof, + vrf_output: inout.to_output(), + author: pair.public(), + slot_num, + }; + + // deadline our production to approx. the end of the slot let remaining_duration = slot_info.remaining_duration(); - // deadline our production to approx. the end of the - // slot - (Timeout::new( + Timeout::new( proposer.propose( slot_info.inherent_data, + generic::Digest { + logs: vec![ + generic::DigestItem::babe_pre_digest(inherent_digest.clone()), + ], + }, remaining_duration, ).into_future(), remaining_duration, - ), - inout.to_output(), - proof) + ) } else { return Box::new(future::ok(())); }; - let (proposal_work, vrf_output, proof) = authoring_result; - - Box::new( - proposal_work - .map(move |b| { - // minor hack since we don't have access to the timestamp - // that is actually set by the proposer. - let slot_after_building = slot_now(slot_duration); - if slot_after_building != Some(slot_num) { - info!( - target: "babe", - "Discarding proposal for slot {}; block production took too long", - slot_num - ); - telemetry!(CONSENSUS_INFO; "babe.discarding_proposal_took_too_long"; - "slot" => slot_num - ); - return - } - - let (header, body) = b.deconstruct(); - let header_num = header.number().clone(); - let pre_hash = header.hash(); - let parent_hash = header.parent_hash().clone(); - - // sign the pre-sealed hash of the block and then - // add it to a digest item. - let to_sign = (slot_num, pre_hash, proof.to_bytes()).encode(); - let signature = pair.sign(&to_sign[..]); - let item = as CompatibleDigestItem>::babe_seal(BabeSeal { - proof, - signature: LocalizedSignature { - signature, - signer: pair.public(), - }, - slot_num, - vrf_output, - }); - - let import_block: ImportBlock = ImportBlock { - origin: BlockOrigin::Own, - header, - justification: None, - post_digests: vec![item], - body: Some(body), - finalized: false, - auxiliary: Vec::new(), - fork_choice: ForkChoiceStrategy::LongestChain, - }; - - info!(target: "babe", - "Pre-sealed block for proposal at {}. Hash now {:?}, previously {:?}.", - header_num, - import_block.post_header().hash(), - pre_hash - ); - telemetry!(CONSENSUS_INFO; "babe.pre_sealed_block"; - "header_num" => ?header_num, - "hash_now" => ?import_block.post_header().hash(), - "hash_previously" => ?pre_hash - ); + Box::new(proposal_work.map(move |b| { + // minor hack since we don't have access to the timestamp + // that is actually set by the proposer. + let slot_after_building = slot_now(slot_duration); + if slot_after_building != Some(slot_num) { + info!( + target: "babe", + "Discarding proposal for slot {}; block production took too long", + slot_num + ); + telemetry!(CONSENSUS_INFO; "babe.discarding_proposal_took_too_long"; + "slot" => slot_num + ); + return + } + + let (header, body) = b.deconstruct(); + let pre_digest: Result = find_pre_digest::(&header); + if let Err(e) = pre_digest { + error!(target: "babe", "FATAL ERROR: Invalid pre-digest: {}!", e); + return + } else { + trace!(target: "babe", "Got correct number of seals. Good!") + }; + + let header_num = header.number().clone(); + let parent_hash = header.parent_hash().clone(); + + // sign the pre-sealed hash of the block and then + // add it to a digest item. + let header_hash = header.hash(); + let signature = pair.sign(header_hash.as_ref()); + let signature_digest_item = DigestItemFor::::babe_seal(signature); + + let import_block: ImportBlock = ImportBlock { + origin: BlockOrigin::Own, + header, + justification: None, + post_digests: vec![signature_digest_item], + body: Some(body), + finalized: false, + auxiliary: Vec::new(), + fork_choice: ForkChoiceStrategy::LongestChain, + }; + + info!(target: "babe", + "Pre-sealed block for proposal at {}. Hash now {:?}, previously {:?}.", + header_num, + import_block.post_header().hash(), + header_hash, + ); + telemetry!(CONSENSUS_INFO; "babe.pre_sealed_block"; + "header_num" => ?header_num, + "hash_now" => ?import_block.post_header().hash(), + "hash_previously" => ?header_hash, + ); + + if let Err(e) = block_import.import_block(import_block, Default::default()) { + warn!(target: "babe", "Error with block built on {:?}: {:?}", + parent_hash, e); + telemetry!(CONSENSUS_WARN; "babe.err_with_block_built_on"; + "hash" => ?parent_hash, "err" => ?e + ); + } + }).map_err(|e| { + warn!("Client import failed: {:?}", e); + consensus_common::Error::ClientImport(format!("{:?}", e)).into() + })) + } +} + +macro_rules! babe_err { + ($($i: expr),+) => { + { debug!(target: "babe", $($i),+) + ; format!($($i),+) + } + }; +} - if let Err(e) = block_import.import_block(import_block, Default::default()) { - warn!(target: "babe", "Error with block built on {:?}: {:?}", - parent_hash, e); - telemetry!(CONSENSUS_WARN; "babe.err_with_block_built_on"; - "hash" => ?parent_hash, "err" => ?e - ); - } - }) - .map_err(|e| { - warn!("Client import failed: {:?}", e); - consensus_common::Error::ClientImport(format!("{:?}", e)) - }) - ) +fn find_pre_digest(header: &B::Header) -> Result + where DigestItemFor: CompatibleDigestItem, +{ + let mut pre_digest: Option<_> = None; + for log in header.digest().logs() { + trace!(target: "babe", "Checking log {:?}", log); + match (log.as_babe_pre_digest(), pre_digest.is_some()) { + (Some(_), true) => Err(babe_err!("Multiple BABE pre-runtime headers, rejecting!"))?, + (None, _) => trace!(target: "babe", "Ignoring digest not meant for us"), + (s, false) => pre_digest = s, + } } + pre_digest.ok_or_else(|| babe_err!("No BABE pre-runtime digest found")) } /// check a header has been signed by the right key. If the slot is too far in /// the future, an error will be returned. If successful, returns the pre-header /// and the digest item containing the seal. /// -/// This digest item will always return `Some` when used with `as_babe_seal`. +/// The seal must be the last digest. Otherwise, the whole header is considered +/// unsigned. This is required for security and must not be changed. +/// +/// This digest item will always return `Some` when used with `as_babe_pre_digest`. // // FIXME #1018 needs misbehavior types #[forbid(warnings)] @@ -538,36 +467,31 @@ fn check_header( hash: B::Hash, authorities: &[Public], threshold: u64, -) -> Result>, String> +) -> Result, DigestItemFor)>, String> where DigestItemFor: CompatibleDigestItem, { trace!(target: "babe", "Checking header"); - let digest_item = match header.digest_mut().pop() { + let seal = match header.digest_mut().pop() { Some(x) => x, - None => return Err(format!("Header {:?} is unsealed", hash)), + None => return Err(babe_err!("Header {:?} is unsealed", hash)), }; - let BabeSeal { - slot_num, - signature: LocalizedSignature { signer, signature }, - proof, - vrf_output, - } = digest_item.as_babe_seal().ok_or_else(|| { - debug!(target: "babe", "Header {:?} is unsealed", hash); - format!("Header {:?} is unsealed", hash) + let sig = seal.as_babe_seal().ok_or_else(|| { + babe_err!("Header {:?} has a bad seal", hash) })?; + let pre_digest = find_pre_digest::(&header)?; + let BabePreDigest { slot_num, ref author, ref proof, ref vrf_output } = pre_digest; + if slot_num > slot_now { - header.digest_mut().push(digest_item); + header.digest_mut().push(seal); Ok(CheckedHeader::Deferred(header, slot_num)) - } else if !authorities.contains(&signer) { - debug!(target: "babe", "Slot Author not found"); - Err("Slot Author not found".to_string()) + } else if !authorities.contains(&author) { + Err(babe_err!("Slot author not found")) } else { let pre_hash = header.hash(); - let to_sign = (slot_num, pre_hash, proof.to_bytes()).encode(); - if sr25519::Pair::verify(&signature, &to_sign[..], &signer) { + if sr25519::Pair::verify(&sig, pre_hash, author) { let (inout, _batchable_proof) = { let transcript = make_transcript( Default::default(), @@ -575,41 +499,39 @@ fn check_header( Default::default(), 0, ); - schnorrkel::PublicKey::from_bytes(signer.as_slice()).and_then(|p| { - p.vrf_verify(transcript, &vrf_output, &proof) + schnorrkel::PublicKey::from_bytes(author.as_slice()).and_then(|p| { + p.vrf_verify(transcript, vrf_output, proof) }).map_err(|s| { - debug!(target: "babe", "VRF verification failed: {:?}", s); - format!("VRF verification failed") + babe_err!("VRF verification failed: {:?}", s) })? }; - if check(&inout, threshold) { - match check_equivocation(&client, slot_now, slot_num, header.clone(), signer.clone()) { - Ok(Some(equivocation_proof)) => { - let log_str = format!( - "Slot author {:?} is equivocating at slot {} with headers {:?} and {:?}", - signer, - slot_num, - equivocation_proof.fst_header().hash(), - equivocation_proof.snd_header().hash(), - ); - info!("{}", log_str); - Err(log_str) - }, - Ok(None) => { - Ok(CheckedHeader::Checked(header, digest_item)) - }, - Err(e) => { - Err(e.to_string()) - }, - } - } else { - debug!(target: "babe", "VRF verification failed: threshold {} exceeded", threshold); - Err(format!("Validator {:?} made seal when it wasn’t its turn", signer)) + if !check(&inout, threshold) { + return Err(babe_err!("VRF verification of block by author {:?} failed: \ + threshold {} exceeded", author, threshold)) + } + match check_equivocation(&client, slot_now, slot_num, header.clone(), author.clone()) { + Ok(Some(equivocation_proof)) => { + let log_str = format!( + "Slot author {:?} is equivocating at slot {} with headers {:?} and {:?}", + author, + slot_num, + equivocation_proof.fst_header().hash(), + equivocation_proof.snd_header().hash(), + ); + info!(target: "babe", "{}", log_str); + Err(log_str) + }, + Ok(None) => { + let pre_digest = CompatibleDigestItem::babe_pre_digest(pre_digest); + Ok(CheckedHeader::Checked(header, (pre_digest, seal))) + }, + Err(e) => { + Err(e.to_string()) + }, } } else { - debug!(target: "babe", "Bad signature on {:?}", hash); - Err(format!("Bad signature on {:?}", hash)) + Err(babe_err!("Bad signature on {:?}", hash)) } } } @@ -681,6 +603,8 @@ impl Verifier for BabeVerifier where justification, body, ); + + debug!(target: "babe", "We have {:?} logs in this header", header.digest().logs().len()); let mut inherent_data = self .inherent_data_providers .create_inherent_data() @@ -709,9 +633,9 @@ impl Verifier for BabeVerifier where self.threshold, )?; match checked_header { - CheckedHeader::Checked(pre_header, seal) => { - let BabeSeal { slot_num, .. } = seal.as_babe_seal() - .expect("check_header always returns a seal digest item; qed"); + CheckedHeader::Checked(pre_header, (pre_digest, seal)) => { + let BabePreDigest { slot_num, .. } = pre_digest.as_babe_pre_digest() + .expect("check_header always returns a pre-digest digest item; qed"); // if the body is passed through, we need to use the runtime // to check that the internally-set timestamp in the inherents @@ -738,6 +662,10 @@ impl Verifier for BabeVerifier where extra_verification.into_future().wait()?; + let new_authorities = pre_header.digest() + .log(DigestItem::as_authorities_change) + .map(|digest| digest.to_vec()); + let import_block = ImportBlock { origin, header: pre_header, @@ -750,7 +678,7 @@ impl Verifier for BabeVerifier where }; // FIXME #1019 extract authorities - Ok((import_block, None)) + Ok((import_block, new_authorities)) } CheckedHeader::Deferred(a, b) => { debug!(target: "babe", "Checking {:?} failed; {:?}, {:?}.", hash, a, b); @@ -820,6 +748,7 @@ fn get_keypair(q: &sr25519::Pair) -> &Keypair { q.as_ref() } +#[allow(deprecated)] fn make_transcript( randomness: &[u8], slot_number: u64, @@ -871,7 +800,8 @@ fn claim_slot( #[cfg(test)] #[allow(dead_code, unused_imports, deprecated)] -// FIXME #2532: need to allow deprecated until refactor is done https://github.com/paritytech/substrate/issues/2532 +// FIXME #2532: need to allow deprecated until refactor is done +// https://github.com/paritytech/substrate/issues/2532 mod tests { use super::*; @@ -880,16 +810,18 @@ mod tests { use consensus_common::NoNetwork as DummyOracle; use network::test::*; use network::test::{Block as TestBlock, PeersClient}; - use runtime_primitives::traits::Block as BlockT; + use runtime_primitives::traits::{Block as BlockT, DigestFor}; use network::config::ProtocolConfig; use parking_lot::Mutex; use tokio::runtime::current_thread; use keyring::sr25519::Keyring; + use super::generic::DigestItem; use client::BlockchainEvents; use test_client; use futures::stream::Stream; use log::debug; use std::time::Duration; + type Item = generic::DigestItem; use test_client::AuthorityKeyring; use primitives::hash::H256; use runtime_primitives::testing::{Header as HeaderTest, Digest as DigestTest, Block as RawBlock, ExtrinsicWrapper}; @@ -922,8 +854,8 @@ mod tests { type Error = Error; type Create = Result; - fn propose(&self, _: InherentData, _: Duration) -> Result { - self.1.new_block().unwrap().bake().map_err(|e| e.into()) + fn propose(&self, _: InherentData, digests: DigestFor, _: Duration) -> Result { + self.1.new_block(digests).unwrap().bake().map_err(|e| e.into()) } } @@ -1020,26 +952,30 @@ mod tests { let (inout, proof, _batchable_proof) = get_keypair(&pair).vrf_sign_n_check(transcript, |inout| check(inout, u64::MAX)).unwrap(); let pre_hash: H256 = header.hash(); - let to_sign = (slot_num, pre_hash, proof.to_bytes()).encode(); - let signature = pair.sign(&to_sign[..]); - let item = as CompatibleDigestItem>::babe_seal(BabeSeal { + let pre_digest = BabePreDigest { proof, - signature: LocalizedSignature { - signature, - signer: pair.public(), - }, + author: pair.public(), slot_num, vrf_output: inout.to_output(), - }); - + }; + assert_eq!( + Decode::decode(&mut &pre_digest.encode()[..]).as_ref(), + Some(&pre_digest), + "Pre-digest encoding and decoding did not round-trip", + ); + let item = generic::DigestItem::babe_pre_digest(pre_digest); header.digest_mut().push(item); + + let to_sign = header.hash(); + let signature = pair.sign(&to_sign[..]); + header.digest_mut().push(generic::DigestItem::babe_seal(signature)); (header, pre_hash) } #[test] fn can_serialize_block() { drop(env_logger::try_init()); - assert!(BabeSeal::decode(&mut &b""[..]).is_none()); + assert!(BabePreDigest::decode(&mut &b""[..]).is_none()); } #[test] @@ -1118,26 +1054,28 @@ mod tests { } #[test] - #[allow(deprecated)] - #[should_panic] - fn old_seals_rejected() { + fn wrong_consensus_engine_id_rejected() { drop(env_logger::try_init()); - generic::DigestItem::::Seal(0, Signature([0; 64])).as_babe_seal().unwrap(); + let sig = sr25519::Pair::generate().sign(b""); + let bad_seal: Item = DigestItem::Seal([0; 4], sig); + assert!(bad_seal.as_babe_pre_digest().is_none()); + assert!(bad_seal.as_babe_seal().is_none()) } #[test] - fn wrong_number_rejected() { + fn malformed_pre_digest_rejected() { drop(env_logger::try_init()); - let bad_seal = generic::DigestItem::::Consensus([0; 4], Signature([0; 64]).encode()); - assert!(bad_seal.as_babe_seal().is_none()) + let bad_seal: Item = DigestItem::Seal(BABE_ENGINE_ID, Signature([0; 64])); + assert!(bad_seal.as_babe_pre_digest().is_none()); } #[test] - #[should_panic] - fn bad_seal_rejected() { + fn sig_is_not_pre_digest() { drop(env_logger::try_init()); - let bad_seal = generic::DigestItem::::Consensus(BABE_ENGINE_ID, Signature([0; 64]).encode()); - bad_seal.as_babe_seal().expect("we should not decode this successfully"); + let sig = sr25519::Pair::generate().sign(b""); + let bad_seal: Item = DigestItem::Seal(BABE_ENGINE_ID, sig); + assert!(bad_seal.as_babe_pre_digest().is_none()); + assert!(bad_seal.as_babe_seal().is_some()) } #[test] @@ -1172,6 +1110,7 @@ mod tests { #[test] fn check_header_works_with_equivocation() { + drop(env_logger::try_init()); let client = test_client::new(); let pair = sr25519::Pair::generate(); let public = pair.public(); diff --git a/core/consensus/common/src/import_queue.rs b/core/consensus/common/src/import_queue.rs index 26ae181b51..d44aa0b93a 100644 --- a/core/consensus/common/src/import_queue.rs +++ b/core/consensus/common/src/import_queue.rs @@ -37,7 +37,7 @@ use std::sync::Arc; use std::thread; use runtime_primitives::traits::{ - AuthorityIdFor, Block as BlockT, Header as HeaderT, NumberFor + AuthorityIdFor, Block as BlockT, Header as HeaderT, NumberFor, Digest, }; use runtime_primitives::Justification; @@ -873,6 +873,8 @@ pub fn import_single_block>( }, }; + trace!(target: "sync", "Header {} has {:?} logs", block.hash, header.digest().logs().len()); + let number = header.number().clone(); let hash = header.hash(); let parent = header.parent_hash().clone(); diff --git a/core/consensus/common/src/lib.rs b/core/consensus/common/src/lib.rs index 2d6c53d164..140aa57901 100644 --- a/core/consensus/common/src/lib.rs +++ b/core/consensus/common/src/lib.rs @@ -33,7 +33,7 @@ use std::sync::Arc; use std::time::Duration; use runtime_primitives::generic::BlockId; -use runtime_primitives::traits::{AuthorityIdFor, Block}; +use runtime_primitives::traits::{AuthorityIdFor, Block, DigestFor}; use futures::prelude::*; pub use inherents::InherentData; @@ -87,7 +87,12 @@ pub trait Proposer { /// Future that resolves to a committed proposal. type Create: IntoFuture; /// Create a proposal. - fn propose(&self, inherent_data: InherentData, max_duration: Duration) -> Self::Create; + fn propose( + &self, + inherent_data: InherentData, + inherent_digests: DigestFor, + max_duration: Duration, + ) -> Self::Create; } /// An oracle for when major synchronization work is being undertaken. diff --git a/core/consensus/common/src/select_chain.rs b/core/consensus/common/src/select_chain.rs index 47c65d1fe7..9ab21cba13 100644 --- a/core/consensus/common/src/select_chain.rs +++ b/core/consensus/common/src/select_chain.rs @@ -19,13 +19,13 @@ use runtime_primitives::traits::{Block as BlockT, NumberFor}; /// The SelectChain trait defines the strategy upon which the head is chosen -/// if multiple forks are present for an opaque definition of "best" in the +/// if multiple forks are present for an opaque definition of "best" in the /// specific chain build. /// /// The Strategy can be customised for the two use cases of authoring new blocks /// upon the best chain or which fork to finalise. Unless implemented differently /// by default finalisation methods fall back to use authoring, so as a minimum -/// `_authoring`-functions must be implemented. +/// `_authoring`-functions must be implemented. /// /// Any particular user must make explicit, however, whether they intend to finalise /// or author through the using the right function call, as these might differ in @@ -51,4 +51,4 @@ pub trait SelectChain: Sync + Send + Clone { ) -> Result::Hash>, Error> { Ok(Some(target_hash)) } -} \ No newline at end of file +} diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 44f4ca5983..3d4a11d487 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -30,7 +30,7 @@ pub const MAX_SLOT_CAPACITY: u64 = 1000; /// We prune slots when they reach this number. pub const PRUNING_BOUND: u64 = 2 * MAX_SLOT_CAPACITY; -fn load_decode(backend: Arc, key: &[u8]) -> ClientResult> +fn load_decode(backend: Arc, key: &[u8]) -> ClientResult> where C: AuxStore, T: Decode, diff --git a/core/executor/src/allocator.rs b/core/executor/src/allocator.rs index 4b3f7d3219..bf01dd2e90 100644 --- a/core/executor/src/allocator.rs +++ b/core/executor/src/allocator.rs @@ -163,8 +163,7 @@ impl FreeingBumpHeapAllocator { } fn le_bytes_to_u32(arr: [u8; 4]) -> u32 { - let bytes = [arr[0], arr[1], arr[2], arr[3]]; - unsafe { std::mem::transmute::<[u8; 4], u32>(bytes) }.to_le() + u32::from_le_bytes(arr) } fn write_u32_into_le_bytes(bytes: u32, slice: &mut [u8]) { diff --git a/core/executor/src/wasm_executor.rs b/core/executor/src/wasm_executor.rs index bed60666f7..464531a5a1 100644 --- a/core/executor/src/wasm_executor.rs +++ b/core/executor/src/wasm_executor.rs @@ -483,10 +483,10 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, let key = this.memory.get(data, len as usize).map_err(|_| UserError("Invalid attempt to get key in ext_twox_128"))?; let hashed_key = twox_128(&key); debug_trace!(target: "xxhash", "XXhash: {} -> {}", - if let Ok(_skey) = ::std::str::from_utf8(&key) { - _skey + &if let Ok(_skey) = ::std::str::from_utf8(&key) { + *_skey } else { - &format!("{}", HexDisplay::from(&key)) + format!("{}", HexDisplay::from(&key)) }, HexDisplay::from(&hashed_key) ); diff --git a/core/executor/wasm/Cargo.lock b/core/executor/wasm/Cargo.lock index 8c53b790d8..b2d77765f7 100644 --- a/core/executor/wasm/Cargo.lock +++ b/core/executor/wasm/Cargo.lock @@ -87,12 +87,12 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -201,7 +201,7 @@ dependencies = [ "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", ] @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "uint" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -252,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" +"checksum primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99d5a5fe9d93ddb394e2fb3fc49d0e31acb475fd45a30eeb8f3e76b767ecb7e1" "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" "checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" @@ -264,5 +264,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708" +"checksum uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91bb295c2c53c54742a6b8acb705114f6dfdf3c42becdb146a662cb77fcc0d02" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/core/finality-grandpa/src/finality_proof.rs b/core/finality-grandpa/src/finality_proof.rs index c80b65741b..4ad1844358 100644 --- a/core/finality-grandpa/src/finality_proof.rs +++ b/core/finality-grandpa/src/finality_proof.rs @@ -117,7 +117,7 @@ impl AuthoritySetForFinalityChecker for Arc = Decode::decode(&mut &authorities[..]) diff --git a/core/finality-grandpa/src/import.rs b/core/finality-grandpa/src/import.rs index 6d64ad6778..e397bcf469 100644 --- a/core/finality-grandpa/src/import.rs +++ b/core/finality-grandpa/src/import.rs @@ -317,7 +317,7 @@ where // for the canon block the new authority set should start // with. we use the minimum between the median and the local // best finalized block. - + #[allow(deprecated)] let best_finalized_number = self.inner.backend().blockchain().info() .map_err(|e| ConsensusError::ClientImport(e.to_string()))? diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 455afb865a..5b4fa9155a 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -1067,7 +1067,7 @@ fn allows_reimporting_change_blocks() { let (block_import, ..) = net.make_block_import(client.clone()); let full_client = client.as_full().unwrap(); - let builder = full_client.new_block_at(&BlockId::Number(0)).unwrap(); + let builder = full_client.new_block_at(&BlockId::Number(0), Default::default()).unwrap(); let block = builder.bake().unwrap(); api.scheduled_changes.lock().insert(*block.header.parent_hash(), ScheduledChange { next_authorities: make_ids(peers_b), @@ -1116,7 +1116,7 @@ fn test_bad_justification() { let (block_import, ..) = net.make_block_import(client.clone()); let full_client = client.as_full().expect("only full clients are used in test"); - let builder = full_client.new_block_at(&BlockId::Number(0)).unwrap(); + let builder = full_client.new_block_at(&BlockId::Number(0), Default::default()).unwrap(); let block = builder.bake().unwrap(); api.scheduled_changes.lock().insert(*block.header.parent_hash(), ScheduledChange { next_authorities: make_ids(peers_b), @@ -1480,7 +1480,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ runner_net.lock().add_light_peer(&GrandpaTestNet::default_config()); runner_net.lock().sync_without_disconnects(); - // check block, finalized on light client + // check block, finalized on light client assert_eq!( runner_net.lock().peer(3).client().info().unwrap().chain.finalized_number, if FORCE_CHANGE { 0 } else { 10 }, diff --git a/core/network/src/on_demand.rs b/core/network/src/on_demand.rs index 9ce75c4749..90051e9caf 100644 --- a/core/network/src/on_demand.rs +++ b/core/network/src/on_demand.rs @@ -297,7 +297,7 @@ impl OnDemandCore where self.idle_peers.push_back(peer.clone()); self.best_blocks.insert(peer, best_number); - + self.dispatch(network); } @@ -1010,7 +1010,7 @@ pub mod tests { assert_eq!(result, Some(vec![42])); }); - on_demand.on_remote_read_response(&mut network_interface, + on_demand.on_remote_read_response(&mut network_interface, peer0.clone(), message::RemoteReadResponse { id: 0, proof: vec![vec![2]], diff --git a/core/network/src/test/block_import.rs b/core/network/src/test/block_import.rs index 550d3c75ed..4cf639484f 100644 --- a/core/network/src/test/block_import.rs +++ b/core/network/src/test/block_import.rs @@ -26,9 +26,14 @@ struct TestLink {} impl Link for TestLink {} -fn prepare_good_block() -> (client::Client, Hash, u64, PeerId, IncomingBlock) { +fn prepare_good_block() -> (client::Client< + test_client::Backend, + test_client::Executor, + Block, + test_client::runtime::RuntimeApi, + >, Hash, u64, PeerId, IncomingBlock) { let client = test_client::new(); - let block = client.new_block().unwrap().bake().unwrap(); + let block = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::File, block).unwrap(); let (hash, number) = (client.block_hash(1).unwrap().unwrap(), 1); diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 9e2059fd61..f31a93cf28 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -636,7 +636,8 @@ impl> Peer { let full_client = self.client.as_full().expect("blocks could only be generated by full clients"); let mut at = full_client.header(&at).unwrap().unwrap().hash(); for _ in 0..count { - let builder = full_client.new_block_at(&BlockId::Hash(at)).unwrap(); + let builder = full_client.new_block_at(&BlockId::Hash(at), Default::default() + ).unwrap(); let block = edit_block(builder); let hash = block.header.hash(); trace!( diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index 0875de55b7..ab34cfcd13 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -11,7 +11,7 @@ rustc-hex = { version = "2.0", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } twox-hash = { version = "1.2.0", optional = true } byteorder = { version = "1.3.1", default-features = false } -primitive-types = { version = "0.2", default-features = false, features = ["codec"] } +primitive-types = { version = "0.2.3", default-features = false, features = ["codec"] } impl-serde = { version = "0.1", optional = true } wasmi = { version = "0.4.3", optional = true } hash-db = { version = "0.12", default-features = false } diff --git a/core/rpc/src/chain/tests.rs b/core/rpc/src/chain/tests.rs index 26b7202305..02507442d5 100644 --- a/core/rpc/src/chain/tests.rs +++ b/core/rpc/src/chain/tests.rs @@ -68,7 +68,7 @@ fn should_return_a_block() { subscriptions: Subscriptions::new(remote), }; - let block = api.client.new_block().unwrap().bake().unwrap(); + let block = api.client.new_block(Default::default()).unwrap().bake().unwrap(); let block_hash = block.hash(); api.client.import(BlockOrigin::Own, block).unwrap(); @@ -138,7 +138,7 @@ fn should_return_block_hash() { Ok(None) ); - let block = client.client.new_block().unwrap().bake().unwrap(); + let block = client.client.new_block(Default::default()).unwrap().bake().unwrap(); client.client.import(BlockOrigin::Own, block.clone()).unwrap(); assert_matches!( @@ -172,7 +172,7 @@ fn should_return_finalized_hash() { ); // import new block - let builder = client.client.new_block().unwrap(); + let builder = client.client.new_block(Default::default()).unwrap(); client.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); // no finalization yet assert_matches!( @@ -205,7 +205,7 @@ fn should_notify_about_latest_block() { // assert id assigned assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1)))); - let builder = api.client.new_block().unwrap(); + let builder = api.client.new_block(Default::default()).unwrap(); api.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); } @@ -236,7 +236,7 @@ fn should_notify_about_finalized_block() { // assert id assigned assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1)))); - let builder = api.client.new_block().unwrap(); + let builder = api.client.new_block(Default::default()).unwrap(); api.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); api.client.finalize_block(BlockId::number(1), None, true).unwrap(); } diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 14b6506f29..889c181415 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -99,7 +99,7 @@ fn should_notify_about_storage_changes() { // assert id assigned assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1)))); - let mut builder = api.client.new_block().unwrap(); + let mut builder = api.client.new_block(Default::default()).unwrap(); builder.push_transfer(runtime::Transfer { from: AccountKeyring::Alice.into(), to: AccountKeyring::Ferdie.into(), @@ -134,7 +134,7 @@ fn should_send_initial_storage_changes_and_notifications() { // assert id assigned assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1)))); - let mut builder = api.client.new_block().unwrap(); + let mut builder = api.client.new_block(Default::default()).unwrap(); builder.push_transfer(runtime::Transfer { from: AccountKeyring::Alice.into(), to: AccountKeyring::Ferdie.into(), @@ -168,7 +168,7 @@ fn should_query_storage() { let api = State::new(client.clone(), Subscriptions::new(core.executor())); let add_block = |nonce| { - let mut builder = client.new_block().unwrap(); + let mut builder = client.new_block(Default::default()).unwrap(); builder.push_transfer(runtime::Transfer { from: AccountKeyring::Alice.into(), to: AccountKeyring::Ferdie.into(), diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 238d84b522..0d9d7dcdfc 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -655,7 +655,7 @@ mod tests { pool.submit_one(&BlockId::hash(best.hash()), transaction.clone()).unwrap(); // import the block - let mut builder = client.new_block().unwrap(); + let mut builder = client.new_block(Default::default()).unwrap(); builder.push(transaction.clone()).unwrap(); let block = builder.bake().unwrap(); let id = BlockId::hash(block.header().hash()); diff --git a/core/sr-api-macros/tests/runtime_calls.rs b/core/sr-api-macros/tests/runtime_calls.rs index ca008444e1..ff462d9e2a 100644 --- a/core/sr-api-macros/tests/runtime_calls.rs +++ b/core/sr-api-macros/tests/runtime_calls.rs @@ -171,7 +171,7 @@ fn record_proof_works() { // Build the block and record proof let mut builder = client - .new_block_at_with_proof_recording(&block_id) + .new_block_at_with_proof_recording(&block_id, Default::default()) .expect("Creates block builder"); builder.push(transaction.clone()).unwrap(); let (block, proof) = builder.bake_and_extract_proof().expect("Bake block"); diff --git a/core/sr-api-macros/tests/ui/invalid_api_version_2.rs b/core/sr-api-macros/tests/ui/invalid_api_version_2.rs index 7158630793..b887083800 100644 --- a/core/sr-api-macros/tests/ui/invalid_api_version_2.rs +++ b/core/sr-api-macros/tests/ui/invalid_api_version_2.rs @@ -8,4 +8,3 @@ decl_runtime_apis! { } fn main() {} - diff --git a/core/sr-primitives/src/generic/digest.rs b/core/sr-primitives/src/generic/digest.rs index 265ceb5941..8f7055b843 100644 --- a/core/sr-primitives/src/generic/digest.rs +++ b/core/sr-primitives/src/generic/digest.rs @@ -62,7 +62,6 @@ impl traits::Digest for Digest where /// provide opaque access to other items. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Debug))] -#[allow(deprecated)] pub enum DigestItem { /// System digest item announcing that authorities set has been changed /// in the block. Contains the new set of authorities. @@ -71,14 +70,19 @@ pub enum DigestItem { /// block. It is created for every block iff runtime supports changes /// trie creation. ChangesTrieRoot(Hash), - /// The old way to put a Seal on it. Deprecated. - #[deprecated( - since = "1.0", - note = "New versions of Substrate will never generate this, and it will be rejected on new blockchains.", - )] - Seal(u64, SealSignature), - /// Put a Seal on it + /// A message from the runtime to the consensus engine. This should *never* + /// be generated by the native code of any consensus engine, but this is not + /// checked (yet). Consensus(ConsensusEngineId, Vec), + /// Put a Seal on it. + Seal(ConsensusEngineId, SealSignature), + /// A pre-runtime digest. + /// + /// These are messages from the consensus engine to the runtime, although + /// the consensus engine can (and should) read them itself to avoid + /// code and state duplication. It is erroneous for a runtime to produce + /// these, but this is not (yet) checked. + PreRuntime(ConsensusEngineId, Vec), /// Any 'non-system' digest item, opaque to the native code. Other(Vec), } @@ -97,20 +101,26 @@ impl ::serde::Serializ /// final runtime implementations for encoding/decoding its log items. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Debug))] -#[allow(deprecated)] pub enum DigestItemRef<'a, Hash: 'a, AuthorityId: 'a, SealSignature: 'a> { /// Reference to `DigestItem::AuthoritiesChange`. AuthoritiesChange(&'a [AuthorityId]), /// Reference to `DigestItem::ChangesTrieRoot`. ChangesTrieRoot(&'a Hash), - /// A deprecated sealed signature for testing - #[deprecated] - Seal(&'a u64, &'a SealSignature), - /// A sealed signature for testing - Consensus(&'a ConsensusEngineId, &'a [u8]), + /// A message from the runtime to the consensus engine. This should *never* + /// be generated by the native code of any consensus engine, but this is not + /// checked (yet). + Consensus(&'a ConsensusEngineId, &'a Vec), + /// Put a Seal on it. + Seal(&'a ConsensusEngineId, &'a SealSignature), + /// A pre-runtime digest. + /// + /// These are messages from the consensus engine to the runtime, although + /// the consensus engine can (and should) read them itself to avoid + /// code and state duplication. It is erroneous for a runtime to produce + /// these, but this is not (yet) checked. + PreRuntime(&'a ConsensusEngineId, &'a Vec), /// Any 'non-system' digest item, opaque to the native code. - /// Reference to `DigestItem::Other`. - Other(&'a [u8]), + Other(&'a Vec), } /// Type of the digest item. Used to gain explicit control over `DigestItem` encoding @@ -123,8 +133,9 @@ enum DigestItemType { Other = 0, AuthoritiesChange = 1, ChangesTrieRoot = 2, - Seal = 3, Consensus = 4, + Seal = 5, + PreRuntime = 6, } impl DigestItem { @@ -137,13 +148,13 @@ impl DigestItem(&'a self) -> DigestItemRef<'a, Hash, AuthorityId, SealSignature> { match *self { DigestItem::AuthoritiesChange(ref v) => DigestItemRef::AuthoritiesChange(v), DigestItem::ChangesTrieRoot(ref v) => DigestItemRef::ChangesTrieRoot(v), - DigestItem::Seal(ref v, ref s) => DigestItemRef::Seal(v, s), DigestItem::Consensus(ref v, ref s) => DigestItemRef::Consensus(v, s), + DigestItem::Seal(ref v, ref s) => DigestItemRef::Seal(v, s), + DigestItem::PreRuntime(ref v, ref s) => DigestItemRef::PreRuntime(v, s), DigestItem::Other(ref v) => DigestItemRef::Other(v), } } @@ -164,6 +175,10 @@ impl< fn as_changes_trie_root(&self) -> Option<&Self::Hash> { self.dref().as_changes_trie_root() } + + fn as_pre_runtime(&self) -> Option<(ConsensusEngineId, &[u8])> { + self.dref().as_pre_runtime() + } } impl Encode for DigestItem { @@ -183,14 +198,18 @@ impl Decode for Digest DigestItemType::ChangesTrieRoot => Some(DigestItem::ChangesTrieRoot( Decode::decode(input)?, )), - DigestItemType::Seal => { - let vals: (u64, SealSignature) = Decode::decode(input)?; - Some(DigestItem::Seal(vals.0, vals.1)) - }, DigestItemType::Consensus => { let vals: (ConsensusEngineId, Vec) = Decode::decode(input)?; Some(DigestItem::Consensus(vals.0, vals.1)) } + DigestItemType::Seal => { + let vals: (ConsensusEngineId, SealSignature) = Decode::decode(input)?; + Some(DigestItem::Seal(vals.0, vals.1)) + }, + DigestItemType::PreRuntime => { + let vals: (ConsensusEngineId, Vec) = Decode::decode(input)?; + Some(DigestItem::PreRuntime(vals.0, vals.1)) + }, DigestItemType::Other => Some(DigestItem::Other( Decode::decode(input)?, )), @@ -214,9 +233,16 @@ impl<'a, Hash: Codec + Member, AuthorityId: Codec + Member, SealSignature: Codec _ => None, } } + + /// Cast this digest item into `PreRuntime` + pub fn as_pre_runtime(&self) -> Option<(ConsensusEngineId, &'a [u8])> { + match *self { + DigestItemRef::PreRuntime(consensus_engine_id, ref data) => Some((*consensus_engine_id, data)), + _ => None, + } + } } -#[allow(deprecated)] impl<'a, Hash: Encode, AuthorityId: Encode, SealSignature: Encode> Encode for DigestItemRef<'a, Hash, AuthorityId, SealSignature> { fn encode(&self) -> Vec { let mut v = Vec::new(); @@ -230,13 +256,17 @@ impl<'a, Hash: Encode, AuthorityId: Encode, SealSignature: Encode> Encode for Di DigestItemType::ChangesTrieRoot.encode_to(&mut v); changes_trie_root.encode_to(&mut v); }, + DigestItemRef::Consensus(val, data) => { + DigestItemType::Consensus.encode_to(&mut v); + (val, data).encode_to(&mut v); + }, DigestItemRef::Seal(val, sig) => { DigestItemType::Seal.encode_to(&mut v); (val, sig).encode_to(&mut v); }, - DigestItemRef::Consensus(val, sig) => { - DigestItemType::Consensus.encode_to(&mut v); - (val, sig).encode_to(&mut v); + DigestItemRef::PreRuntime(val, data) => { + DigestItemType::PreRuntime.encode_to(&mut v); + (val, data).encode_to(&mut v); }, DigestItemRef::Other(val) => { DigestItemType::Other.encode_to(&mut v); @@ -254,20 +284,19 @@ mod tests { use substrate_primitives::hash::H512 as Signature; #[test] - #[allow(deprecated)] fn should_serialize_digest() { let digest = Digest { logs: vec![ DigestItem::AuthoritiesChange(vec![1]), DigestItem::ChangesTrieRoot(4), - DigestItem::Seal(1, Signature::from_low_u64_be(15)), DigestItem::Other(vec![1, 2, 3]), + DigestItem::Seal(Default::default(), Signature::default()) ], }; assert_eq!( ::serde_json::to_string(&digest).unwrap(), - r#"{"logs":["0x010401000000","0x0204000000","0x0301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f","0x000c010203"]}"# + "{\"logs\":[\"0x010401000000\",\"0x0204000000\",\"0x000c010203\",\"0x050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"]}", ); } } diff --git a/core/sr-primitives/src/generic/header.rs b/core/sr-primitives/src/generic/header.rs index efcc7614ed..fa94d97c64 100644 --- a/core/sr-primitives/src/generic/header.rs +++ b/core/sr-primitives/src/generic/header.rs @@ -18,9 +18,12 @@ #[cfg(feature = "std")] use serde::Serialize; +#[cfg(feature = "std")] +use log::debug; use crate::codec::{Decode, Encode, Codec, Input, Output, HasCompact, EncodeAsRef}; use crate::traits::{self, Member, SimpleArithmetic, SimpleBitOps, MaybeDisplay, - Hash as HashT, DigestItem as DigestItemT, MaybeSerializeDebug, MaybeSerializeDebugButNotDeserialize}; + Hash as HashT, DigestItem as DigestItemT, MaybeSerializeDebug, + MaybeSerializeDebugButNotDeserialize}; use crate::generic::Digest; /// Abstraction over a block header for a substrate chain. @@ -107,22 +110,29 @@ impl traits::Header for Header &Self::Digest { &self.digest } + + #[cfg(feature = "std")] + fn digest_mut(&mut self) -> &mut Self::Digest { + debug!(target: "header", "Retrieving mutable reference to digest"); + &mut self.digest + } + + #[cfg(not(feature = "std"))] fn digest_mut(&mut self) -> &mut Self::Digest { &mut self.digest } - fn set_digest(&mut self, digest: Self::Digest) { self.digest = digest } fn new( number: Self::Number, extrinsics_root: Self::Hash, state_root: Self::Hash, parent_hash: Self::Hash, - digest: Self::Digest + digest: Self::Digest, ) -> Self { Header { number, extrinsics_root, state_root, parent_hash, - digest + digest, } } } diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index 05938a6a82..e6cf9142ad 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -681,6 +681,10 @@ macro_rules! impl_outer_log { fn as_changes_trie_root(&self) -> Option<&Self::Hash> { self.dref().and_then(|dref| dref.as_changes_trie_root()) } + + fn as_pre_runtime(&self) -> Option<($crate::ConsensusEngineId, &[u8])> { + self.dref().and_then(|dref| dref.as_pre_runtime()) + } } impl From<$crate::generic::DigestItem<$($genarg),*>> for $name { diff --git a/core/sr-primitives/src/testing.rs b/core/sr-primitives/src/testing.rs index e8e5aa20b4..18c65d011e 100644 --- a/core/sr-primitives/src/testing.rs +++ b/core/sr-primitives/src/testing.rs @@ -107,21 +107,20 @@ impl traits::Header for Header { fn digest(&self) -> &Self::Digest { &self.digest } fn digest_mut(&mut self) -> &mut Self::Digest { &mut self.digest } - fn set_digest(&mut self, digest: Self::Digest) { self.digest = digest } fn new( number: Self::Number, extrinsics_root: Self::Hash, state_root: Self::Hash, parent_hash: Self::Hash, - digest: Self::Digest + digest: Self::Digest, ) -> Self { Header { number, - extrinsics_root: extrinsics_root, + extrinsics_root, state_root, parent_hash, - digest + digest, } } } diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index dcfe8ffd24..5963450360 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -641,8 +641,6 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDe fn digest(&self) -> &Self::Digest; /// Get a mutable reference to the digest. fn digest_mut(&mut self) -> &mut Self::Digest; - /// Sets the digest. - fn set_digest(&mut self, digest: Self::Digest); /// Returns the hash of the header. fn hash(&self) -> Self::Hash { @@ -780,11 +778,14 @@ pub trait DigestItem: Codec + Member + MaybeSerializeDebugButNotDeserialize { /// `AuthorityChange` payload. type AuthorityId: Member + MaybeHash + crate::codec::Encode + crate::codec::Decode; - /// Returns Some if the entry is the `AuthoritiesChange` entry. + /// Returns `Some` if the entry is the `AuthoritiesChange` entry. fn as_authorities_change(&self) -> Option<&[Self::AuthorityId]>; - /// Returns Some if the entry is the `ChangesTrieRoot` entry. + /// Returns `Some` if the entry is the `ChangesTrieRoot` entry. fn as_changes_trie_root(&self) -> Option<&Self::Hash>; + + /// Returns `Some` if this entry is the `PreRuntime` entry. + fn as_pre_runtime(&self) -> Option<(super::ConsensusEngineId, &[u8])>; } /// Auxiliary wrapper that holds an api instance and binds it to the given lifetime. diff --git a/core/test-client/src/trait_tests.rs b/core/test-client/src/trait_tests.rs index a6da3b206b..c1df6ffdf8 100644 --- a/core/test-client/src/trait_tests.rs +++ b/core/test-client/src/trait_tests.rs @@ -50,14 +50,14 @@ pub fn test_leaves_for_backend(backend: Arc) where vec![genesis_hash]); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); assert_eq!( blockchain.leaves().unwrap(), vec![a1.hash()]); // A1 -> A2 - let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); + let a2 = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); #[allow(deprecated)] @@ -66,28 +66,28 @@ pub fn test_leaves_for_backend(backend: Arc) where vec![a2.hash()]); // A2 -> A3 - let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); + let a3 = client.new_block_at(&BlockId::Hash(a2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a3.clone()).unwrap(); assert_eq!( blockchain.leaves().unwrap(), vec![a3.hash()]); // A3 -> A4 - let a4 = client.new_block_at(&BlockId::Hash(a3.hash())).unwrap().bake().unwrap(); + let a4 = client.new_block_at(&BlockId::Hash(a3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a4.clone()).unwrap(); assert_eq!( blockchain.leaves().unwrap(), vec![a4.hash()]); // A4 -> A5 - let a5 = client.new_block_at(&BlockId::Hash(a4.hash())).unwrap().bake().unwrap(); + let a5 = client.new_block_at(&BlockId::Hash(a4.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a5.clone()).unwrap(); assert_eq!( blockchain.leaves().unwrap(), vec![a5.hash()]); // A1 -> B2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise B2 has the same hash as A2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -102,21 +102,21 @@ pub fn test_leaves_for_backend(backend: Arc) where vec![a5.hash(), b2.hash()]); // B2 -> B3 - let b3 = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap().bake().unwrap(); + let b3 = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b3.clone()).unwrap(); assert_eq!( blockchain.leaves().unwrap(), vec![a5.hash(), b3.hash()]); // B3 -> B4 - let b4 = client.new_block_at(&BlockId::Hash(b3.hash())).unwrap().bake().unwrap(); + let b4 = client.new_block_at(&BlockId::Hash(b3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b4.clone()).unwrap(); assert_eq!( blockchain.leaves().unwrap(), vec![a5.hash(), b4.hash()]); // // B2 -> C3 - let mut builder = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap(); // this push is required as otherwise C3 has the same hash as B3 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -131,7 +131,7 @@ pub fn test_leaves_for_backend(backend: Arc) where vec![a5.hash(), b4.hash(), c3.hash()]); // A1 -> D2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise D2 has the same hash as B2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -160,27 +160,27 @@ pub fn test_children_for_backend(backend: Arc) where let blockchain = backend.blockchain(); // G -> A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); + let a2 = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); // A2 -> A3 - let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); + let a3 = client.new_block_at(&BlockId::Hash(a2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a3.clone()).unwrap(); // A3 -> A4 - let a4 = client.new_block_at(&BlockId::Hash(a3.hash())).unwrap().bake().unwrap(); + let a4 = client.new_block_at(&BlockId::Hash(a3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a4.clone()).unwrap(); // A4 -> A5 - let a5 = client.new_block_at(&BlockId::Hash(a4.hash())).unwrap().bake().unwrap(); + let a5 = client.new_block_at(&BlockId::Hash(a4.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a5.clone()).unwrap(); // A1 -> B2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise B2 has the same hash as A2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -192,15 +192,15 @@ pub fn test_children_for_backend(backend: Arc) where client.import(BlockOrigin::Own, b2.clone()).unwrap(); // B2 -> B3 - let b3 = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap().bake().unwrap(); + let b3 = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b3.clone()).unwrap(); // B3 -> B4 - let b4 = client.new_block_at(&BlockId::Hash(b3.hash())).unwrap().bake().unwrap(); + let b4 = client.new_block_at(&BlockId::Hash(b3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b4.clone()).unwrap(); // // B2 -> C3 - let mut builder = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap(); // this push is required as otherwise C3 has the same hash as B3 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -212,7 +212,7 @@ pub fn test_children_for_backend(backend: Arc) where client.import(BlockOrigin::Own, c3.clone()).unwrap(); // A1 -> D2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise D2 has the same hash as B2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -250,27 +250,27 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc A1 - let a1 = client.new_block().unwrap().bake().unwrap(); + let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a1.clone()).unwrap(); // A1 -> A2 - let a2 = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap().bake().unwrap(); + let a2 = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); // A2 -> A3 - let a3 = client.new_block_at(&BlockId::Hash(a2.hash())).unwrap().bake().unwrap(); + let a3 = client.new_block_at(&BlockId::Hash(a2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a3.clone()).unwrap(); // A3 -> A4 - let a4 = client.new_block_at(&BlockId::Hash(a3.hash())).unwrap().bake().unwrap(); + let a4 = client.new_block_at(&BlockId::Hash(a3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a4.clone()).unwrap(); // A4 -> A5 - let a5 = client.new_block_at(&BlockId::Hash(a4.hash())).unwrap().bake().unwrap(); + let a5 = client.new_block_at(&BlockId::Hash(a4.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a5.clone()).unwrap(); // A1 -> B2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise B2 has the same hash as A2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -282,15 +282,15 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc B3 - let b3 = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap().bake().unwrap(); + let b3 = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b3.clone()).unwrap(); // B3 -> B4 - let b4 = client.new_block_at(&BlockId::Hash(b3.hash())).unwrap().bake().unwrap(); + let b4 = client.new_block_at(&BlockId::Hash(b3.hash()), Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, b4.clone()).unwrap(); // // B2 -> C3 - let mut builder = client.new_block_at(&BlockId::Hash(b2.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(b2.hash()), Default::default()).unwrap(); // this push is required as otherwise C3 has the same hash as B3 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), @@ -302,7 +302,7 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc D2 - let mut builder = client.new_block_at(&BlockId::Hash(a1.hash())).unwrap(); + let mut builder = client.new_block_at(&BlockId::Hash(a1.hash()), Default::default()).unwrap(); // this push is required as otherwise D2 has the same hash as B2 and won't get imported builder.push_transfer(Transfer { from: AccountKeyring::Alice.into(), diff --git a/core/test-runtime/src/system.rs b/core/test-runtime/src/system.rs index 804d5411d6..d7dccd33be 100644 --- a/core/test-runtime/src/system.rs +++ b/core/test-runtime/src/system.rs @@ -21,7 +21,7 @@ use rstd::prelude::*; use runtime_io::{storage_root, enumerated_trie_root, storage_changes_root, twox_128, blake2_256}; use runtime_support::storage::{self, StorageValue, StorageMap}; use runtime_support::storage_items; -use runtime_primitives::traits::{Hash as HashT, BlakeTwo256, Digest as DigestT}; +use runtime_primitives::traits::{Hash as HashT, BlakeTwo256, Digest as DigestT, Header as _}; use runtime_primitives::generic; use runtime_primitives::{ApplyError, ApplyOutcome, ApplyResult, transaction_validity::TransactionValidity}; use parity_codec::{KeyedVec, Encode}; @@ -38,6 +38,7 @@ storage_items! { Number: b"sys:num" => BlockNumber; ParentHash: b"sys:pha" => required Hash; NewAuthorities: b"sys:new_auth" => Vec; + StorageDigest: b"sys:digest" => Digest; } pub fn balance_of_key(who: AccountId) -> Vec { @@ -67,6 +68,7 @@ pub fn initialize_block(header: &Header) { // populate environment. ::put(&header.number); ::put(&header.parent_hash); + ::put(header.digest()); storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32); } @@ -99,18 +101,17 @@ pub fn polish_block(block: &mut Block) { header.state_root = storage_root().into(); // check digest - let mut digest = Digest::default(); + let digest = &mut header.digest; if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into()) { digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root.into())); } if let Some(new_authorities) = ::take() { digest.push(generic::DigestItem::AuthoritiesChange(new_authorities)); } - header.digest = digest; } -pub fn execute_block(block: Block) { - let ref header = block.header; +pub fn execute_block(mut block: Block) { + let header = &mut block.header; // check transaction trie root represents the transactions. let txs = block.extrinsics.iter().map(Encode::encode).collect::>(); @@ -132,14 +133,13 @@ pub fn execute_block(block: Block) { assert!(storage_root == header.state_root, "Storage root must match that calculated."); // check digest - let mut digest = Digest::default(); + let digest = &mut header.digest; if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into()) { digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root.into())); } if let Some(new_authorities) = ::take() { digest.push(generic::DigestItem::AuthoritiesChange(new_authorities)); } - assert!(digest == header.digest, "Header digest items must match that calculated."); } /// The block executor. @@ -209,13 +209,16 @@ pub fn finalize_block() -> Header { let txs: Vec<_> = (0..extrinsic_index).map(ExtrinsicData::take).collect(); let txs = txs.iter().map(Vec::as_slice).collect::>(); let extrinsics_root = enumerated_trie_root::(&txs).into(); - + // let mut digest = Digest::default(); let number = ::take().expect("Number is set by `initialize_block`"); let parent_hash = ::take(); + let mut digest = ::take().expect("StorageDigest is set by `initialize_block`"); + + // This MUST come after all changes to storage are done. Otherwise we will fail the + // “Storage root does not match that calculated” assertion. let storage_root = BlakeTwo256::storage_root(); let storage_changes_root = BlakeTwo256::storage_changes_root(parent_hash); - let mut digest = Digest::default(); if let Some(storage_changes_root) = storage_changes_root { digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root)); } diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index eaa9acbd45..8439721da3 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -1615,13 +1615,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "primitive-types" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2492,7 +2492,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2937,7 +2937,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3409,7 +3409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" +"checksum primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99d5a5fe9d93ddb394e2fb3fc49d0e31acb475fd45a30eeb8f3e76b767ecb7e1" "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" "checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" @@ -3508,7 +3508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708" +"checksum uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91bb295c2c53c54742a6b8acb705114f6dfdf3c42becdb146a662cb77fcc0d02" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index 5f46b360e4..c0d57e3fd9 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -1649,13 +1649,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "primitive-types" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2619,7 +2619,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3030,7 +3030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3502,7 +3502,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" +"checksum primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99d5a5fe9d93ddb394e2fb3fc49d0e31acb475fd45a30eeb8f3e76b767ecb7e1" "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" "checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" @@ -3601,7 +3601,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708" +"checksum uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91bb295c2c53c54742a6b8acb705114f6dfdf3c42becdb146a662cb77fcc0d02" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index 8813850bbd..6c4b93b2ad 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -38,13 +38,13 @@ mod tests { NativeOrEncoded}; use node_primitives::{Hash, BlockNumber, AccountId}; use runtime_primitives::traits::{Header as HeaderT, Hash as HashT, Digest, DigestItem}; - use runtime_primitives::{generic::Era, ApplyOutcome, ApplyError, ApplyResult, Perbill}; + use runtime_primitives::{generic::{self, Era}, ApplyOutcome, ApplyError, ApplyResult, Perbill}; use {balances, indices, session, system, staking, consensus, timestamp, treasury, contract}; use contract::ContractAddressFor; use system::{EventRecord, Phase}; use node_runtime::{Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances, BuildStorage, GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, System, - SystemConfig, GrandpaConfig, IndicesConfig, Event}; + SystemConfig, GrandpaConfig, IndicesConfig, Event, Log}; use wabt; use primitives::map; diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index bb066b1b98..03b3f1caad 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 82, - impl_version: 82, + spec_version: 86, + impl_version: 87, apis: RUNTIME_API_VERSIONS, }; diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index 846857caa2..f564b3eca2 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -801,6 +801,14 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "impl-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "integer-sqrt" version = "0.1.2" @@ -1671,13 +1679,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "primitive-types" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2674,6 +2682,7 @@ dependencies = [ "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -2764,8 +2773,9 @@ dependencies = [ "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2793,6 +2803,7 @@ version = "2.0.0" dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", @@ -3176,7 +3187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3584,6 +3595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56" +"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" @@ -3657,7 +3669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" +"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" "checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" @@ -3757,7 +3769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7780bb27fd8a22295e0d9d53ae3be253f715a0dccb1808527f478f1c2603708" +"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" diff --git a/scripts/flamingfir-deploy.sh b/scripts/flamingfir-deploy.sh index ffd3cab9d8..13be56dfbd 100755 --- a/scripts/flamingfir-deploy.sh +++ b/scripts/flamingfir-deploy.sh @@ -13,12 +13,12 @@ JOB_ID=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" --header "Conte echo "Launched job: $JOB_ID" -while [ ${RETRY_ATTEMPT} -le ${RETRY_COUNT} ] ; do +while [ ${RETRY_ATTEMPT} -le ${RETRY_COUNT} ] ; do export RETRY_RESULT=$(wget -O - --header "Authorization: Bearer ${AWX_TOKEN}" https://ansible-awx.parity.io/api/v2/jobs/${JOB_ID}/ | jq .status) RETRY_ATTEMPT=$(( $RETRY_ATTEMPT +1 )) - sleep $SLEEP_TIME + sleep $SLEEP_TIME if [ $(echo $RETRY_RESULT | egrep -e successful -e failed) ] ; then - break + break fi done diff --git a/srml/aura/src/tests.rs b/srml/aura/src/tests.rs index e74c7dace2..3e20613c48 100644 --- a/srml/aura/src/tests.rs +++ b/srml/aura/src/tests.rs @@ -73,7 +73,7 @@ fn aura_reports_offline() { } with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); let slot_duration = Aura::slot_duration(); Aura::on_timestamp_set::(5 * slot_duration, slot_duration); @@ -82,7 +82,7 @@ fn aura_reports_offline() { // no slashing when last step was 0. assert_eq!(SLASH_COUNTS.lock().as_slice(), &[0, 0, 0, 0]); - System::initialize(&2, &header.hash(), &Default::default()); + System::initialize(&2, &header.hash(), &Default::default(), &Default::default()); Aura::on_timestamp_set::(8 * slot_duration, slot_duration); let _header = System::finalize(); diff --git a/srml/consensus/src/tests.rs b/srml/consensus/src/tests.rs index bf8b3a09f3..471cdf4979 100644 --- a/srml/consensus/src/tests.rs +++ b/srml/consensus/src/tests.rs @@ -26,7 +26,7 @@ use inherents::{InherentData, ProvideInherent}; #[test] fn authorities_change_logged() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Consensus::set_authorities(&[UintAuthorityId(4), UintAuthorityId(5), UintAuthorityId(6)]); Consensus::on_finalize(1); let header = System::finalize(); @@ -47,7 +47,7 @@ fn authorities_change_logged() { #[test] fn partial_authorities_change_logged() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialize(&2, &Default::default(), &Default::default()); + System::initialize(&2, &Default::default(), &Default::default(), &Default::default()); Consensus::set_authorities(&[UintAuthorityId(2), UintAuthorityId(4), UintAuthorityId(5)]); Consensus::on_finalize(2); let header = System::finalize(); @@ -68,7 +68,7 @@ fn partial_authorities_change_logged() { #[test] fn authorities_change_is_not_logged_when_not_changed() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Consensus::on_finalize(1); let header = System::finalize(); assert_eq!(header.digest, testing::Digest { @@ -80,7 +80,7 @@ fn authorities_change_is_not_logged_when_not_changed() { #[test] fn authorities_change_is_not_logged_when_changed_back_to_original() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Consensus::set_authorities(&[UintAuthorityId(4), UintAuthorityId(5), UintAuthorityId(6)]); Consensus::set_authorities(&[UintAuthorityId(1), UintAuthorityId(2), UintAuthorityId(3)]); Consensus::on_finalize(1); @@ -94,7 +94,7 @@ fn authorities_change_is_not_logged_when_changed_back_to_original() { #[test] fn offline_report_can_be_excluded() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); assert!(Consensus::create_inherent(&InherentData::new()).is_none()); let offline_report: Vec = vec![0]; @@ -110,7 +110,7 @@ fn set_and_kill_storage_work() { use srml_support::storage; with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); let item = (vec![42u8], vec![42u8]); diff --git a/srml/contract/src/tests.rs b/srml/contract/src/tests.rs index aeadc99353..29fc1d3a6d 100644 --- a/srml/contract/src/tests.rs +++ b/srml/contract/src/tests.rs @@ -736,7 +736,7 @@ fn deduct_blocks() { assert_eq!(bob_contract.rent_allowance, 1_000); // Advance 4 blocks - System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); @@ -751,7 +751,7 @@ fn deduct_blocks() { assert_eq!(Balances::free_balance(BOB), 30_000 - rent); // Advance 7 blocks more - System::initialize(&12, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&12, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); @@ -825,7 +825,7 @@ fn claim_surcharge(blocks: u64, trigger_call: impl Fn() -> bool, removes: bool) )); // Advance blocks - System::initialize(&blocks, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&blocks, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert!(trigger_call()); @@ -865,14 +865,14 @@ fn removals(trigger_call: impl Fn() -> bool) { assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); // Advance blocks - System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert!(trigger_call()); assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); // Advance blocks - System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent must have no effect assert!(trigger_call()); @@ -899,14 +899,14 @@ fn removals(trigger_call: impl Fn() -> bool) { assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 100); // Advance blocks - System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert!(trigger_call()); assert!(ContractInfoOf::::get(BOB).unwrap().get_tombstone().is_some()); // Advance blocks - System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent must have no effect assert!(trigger_call()); @@ -937,14 +937,14 @@ fn removals(trigger_call: impl Fn() -> bool) { assert_eq!(ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap().rent_allowance, 1_000); // Advance blocks - System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert!(trigger_call()); assert!(ContractInfoOf::::get(BOB).is_none()); // Advance blocks - System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent must have no effect assert!(trigger_call()); @@ -1027,7 +1027,7 @@ fn default_rent_allowance_on_create() { assert_eq!(bob_contract.rent_allowance, >::max_value()); // Advance blocks - System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); @@ -1179,7 +1179,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage: } // Advance 4 blocks - System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); // Trigger rent through call assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null())); @@ -1198,7 +1198,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage: if !test_restore_to_with_dirty_storage { // Advance 1 blocks - System::initialize(&6, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&6, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); } assert_ok!(Contract::call( diff --git a/srml/executive/src/lib.rs b/srml/executive/src/lib.rs index 33d26ce42f..70285f7dfa 100644 --- a/srml/executive/src/lib.rs +++ b/srml/executive/src/lib.rs @@ -80,7 +80,7 @@ use rstd::result; use primitives::traits::{ self, Header, Zero, One, Checkable, Applyable, CheckEqual, OnFinalize, OnInitialize, Digest, NumberFor, Block as BlockT, OffchainWorker, - ValidateUnsigned, + ValidateUnsigned, DigestItem, }; use srml_support::{Dispatchable, traits::MakePayment}; use parity_codec::{Codec, Encode}; @@ -152,11 +152,13 @@ where { /// Start the execution of a particular block. pub fn initialize_block(header: &System::Header) { - Self::initialize_block_impl(header.number(), header.parent_hash(), header.extrinsics_root()); + let mut digests = System::Digest::default(); + header.digest().logs().iter().for_each(|d| if d.as_pre_runtime().is_some() { digests.push(d.clone()) }); + Self::initialize_block_impl(header.number(), header.parent_hash(), header.extrinsics_root(), &digests); } - fn initialize_block_impl(block_number: &System::BlockNumber, parent_hash: &System::Hash, extrinsics_root: &System::Hash) { - >::initialize(block_number, parent_hash, extrinsics_root); + fn initialize_block_impl(block_number: &System::BlockNumber, parent_hash: &System::Hash, extrinsics_root: &System::Hash, digest: &System::Digest) { + >::initialize(block_number, parent_hash, extrinsics_root, digest); >::on_initialize(*block_number); } @@ -262,7 +264,8 @@ where Payment::make_payment(sender, encoded_len).map_err(|_| internal::ApplyError::CantPay)?; // AUDIT: Under no circumstances may this function panic from here onwards. - + // FIXME: ensure this at compile-time (such as by not defining a panic function, forcing + // a linker error unless the compiler can prove it cannot be called). // increment nonce in storage >::inc_account_nonce(sender); } diff --git a/srml/finality-tracker/src/lib.rs b/srml/finality-tracker/src/lib.rs index 2276ad3155..9e83198502 100644 --- a/srml/finality-tracker/src/lib.rs +++ b/srml/finality-tracker/src/lib.rs @@ -344,7 +344,7 @@ mod tests { with_externalities(&mut TestExternalities::new(t), || { let mut parent_hash = System::parent_hash(); for i in 2..106 { - System::initialize(&i, &parent_hash, &Default::default()); + System::initialize(&i, &parent_hash, &Default::default(), &Default::default()); FinalityTracker::on_finalize(i); let hdr = System::finalize(); parent_hash = hdr.hash(); @@ -369,7 +369,7 @@ mod tests { with_externalities(&mut TestExternalities::new(t), || { let mut parent_hash = System::parent_hash(); for i in 2..106 { - System::initialize(&i, &parent_hash, &Default::default()); + System::initialize(&i, &parent_hash, &Default::default(), &Default::default()); assert_ok!(FinalityTracker::dispatch( Call::final_hint(i-1), Origin::NONE, diff --git a/srml/grandpa/src/tests.rs b/srml/grandpa/src/tests.rs index 560766f8c6..d19c5c25b6 100644 --- a/srml/grandpa/src/tests.rs +++ b/srml/grandpa/src/tests.rs @@ -30,7 +30,7 @@ use super::*; #[test] fn authorities_change_logged() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Grandpa::schedule_change(vec![(4, 1), (5, 1), (6, 1)], 0, None).unwrap(); System::note_finished_extrinsics(); @@ -56,7 +56,7 @@ fn authorities_change_logged() { #[test] fn authorities_change_logged_after_delay() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Grandpa::schedule_change(vec![(4, 1), (5, 1), (6, 1)], 1, None).unwrap(); Grandpa::on_finalize(1); let header = System::finalize(); @@ -69,7 +69,7 @@ fn authorities_change_logged_after_delay() { // no change at this height. assert_eq!(System::events(), vec![]); - System::initialize(&2, &header.hash(), &Default::default()); + System::initialize(&2, &header.hash(), &Default::default(), &Default::default()); System::note_finished_extrinsics(); Grandpa::on_finalize(2); @@ -87,7 +87,7 @@ fn authorities_change_logged_after_delay() { #[test] fn cannot_schedule_change_when_one_pending() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Grandpa::schedule_change(vec![(4, 1), (5, 1), (6, 1)], 1, None).unwrap(); assert!(Grandpa::pending_change().is_some()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); @@ -95,14 +95,14 @@ fn cannot_schedule_change_when_one_pending() { Grandpa::on_finalize(1); let header = System::finalize(); - System::initialize(&2, &header.hash(), &Default::default()); + System::initialize(&2, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().is_some()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); Grandpa::on_finalize(2); let header = System::finalize(); - System::initialize(&3, &header.hash(), &Default::default()); + System::initialize(&3, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_ok()); @@ -130,7 +130,7 @@ fn new_decodes_from_old() { #[test] fn dispatch_forced_change() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialize(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); Grandpa::schedule_change( vec![(4, 1), (5, 1), (6, 1)], 5, @@ -144,7 +144,7 @@ fn dispatch_forced_change() { let mut header = System::finalize(); for i in 2..7 { - System::initialize(&i, &header.hash(), &Default::default()); + System::initialize(&i, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().unwrap().forced.is_some()); assert_eq!(Grandpa::next_forced(), Some(11)); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); @@ -157,7 +157,7 @@ fn dispatch_forced_change() { // change has been applied at the end of block 6. // add a normal change. { - System::initialize(&7, &header.hash(), &Default::default()); + System::initialize(&7, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert_eq!(Grandpa::grandpa_authorities(), vec![(4, 1), (5, 1), (6, 1)]); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_ok()); @@ -167,7 +167,7 @@ fn dispatch_forced_change() { // run the normal change. { - System::initialize(&8, &header.hash(), &Default::default()); + System::initialize(&8, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().is_some()); assert_eq!(Grandpa::grandpa_authorities(), vec![(4, 1), (5, 1), (6, 1)]); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); @@ -178,7 +178,7 @@ fn dispatch_forced_change() { // normal change applied. but we can't apply a new forced change for some // time. for i in 9..11 { - System::initialize(&i, &header.hash(), &Default::default()); + System::initialize(&i, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert_eq!(Grandpa::grandpa_authorities(), vec![(5, 1)]); assert_eq!(Grandpa::next_forced(), Some(11)); @@ -188,7 +188,7 @@ fn dispatch_forced_change() { } { - System::initialize(&11, &header.hash(), &Default::default()); + System::initialize(&11, &header.hash(), &Default::default(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert!(Grandpa::schedule_change(vec![(5, 1), (6, 1), (7, 1)], 5, Some(0)).is_ok()); assert_eq!(Grandpa::next_forced(), Some(21)); diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index cf5f473bdc..7c4a95a30f 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -465,10 +465,16 @@ impl Module { } /// Start the execution of a particular block. - pub fn initialize(number: &T::BlockNumber, parent_hash: &T::Hash, txs_root: &T::Hash) { + pub fn initialize( + number: &T::BlockNumber, + parent_hash: &T::Hash, + txs_root: &T::Hash, + digest: &T::Digest, + ) { // populate environment storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32); >::put(number); + >::put(digest); >::put(parent_hash); >::insert(*number - One::one(), parent_hash); >::put(txs_root); @@ -553,38 +559,51 @@ impl Module { /// Get the basic random seed. /// - /// In general you won't want to use this, but rather `Self::random` which allows you to give a subject for the - /// random result and whose value will be independently low-influence random from any other such seeds. + /// In general you won't want to use this, but rather `Self::random` which + /// allows you to give a subject for the random result and whose value will + /// be independently low-influence random from any other such seeds. pub fn random_seed() -> T::Hash { Self::random(&[][..]) } /// Get a low-influence "random" value. /// - /// Being a deterministic block chain, real randomness is difficult to come by. This gives you something that - /// approximates it. `subject` is a context identifier and allows you to get a different result to other callers - /// of this function; use it like `random(&b"my context"[..])`. + /// Being a deterministic block chain, real randomness is difficult to come + /// by. This gives you something that approximates it. `subject` is a + /// context identifier and allows you to get a different result to other + /// callers of this function; use it like `random(&b"my context"[..])`. /// - /// This is initially implemented through a low-influence "triplet mix" convolution of previous block hash values. - /// In the future it will be generated from a secure "VRF". + /// This is initially implemented through a low-influence "triplet mix" + /// convolution of previous block hash values. In the future it will be + /// generated from a secure verifiable random function (VRF). /// /// ### Security Notes - /// This randomness uses a low-influence function, drawing upon the block hashes from the previous 81 blocks. Its - /// result for any given subject will be known in advance by the block producer of this block (and, indeed, anyone - /// who knows the block's `parent_hash`). However, it is mostly impossible for the producer of this block *alone* - /// to influence the value of this hash. A sizable minority of dishonest and coordinating block producers would be - /// required in order to affect this value. If that is an insufficient security guarantee then two things can be - /// used to improve this randomness: - /// - Name, in advance, the block number whose random value will be used; ensure your module retains a buffer of - /// previous random values for its subject and then index into these in order to obviate the ability of your user - /// to look up the parent hash and choose when to transact based upon it. - /// - Require your user to first commit to an additional value by first posting its hash. Require them to reveal - /// the value to determine the final result, hashing it with the output of this random function. This reduces the - /// ability of a cabal of block producers from conspiring against individuals. /// - /// WARNING: Hashing the result of this function will remove any low-infleunce properties it has and mean that - /// all bits of the resulting value are entirely manipulatable by the author of the parent block, who can determine - /// the value of `parent_hash`. + /// This randomness uses a low-influence function, drawing upon the block + /// hashes from the previous 81 blocks. Its result for any given subject + /// will be known in advance by the block producer of this block (and, + /// indeed, anyone who knows the block's `parent_hash`). However, it is + /// mostly impossible for the producer of this block *alone* to influence + /// the value of this hash. A sizable minority of dishonest and coordinating + /// block producers would be required in order to affect this value. If that + /// is an insufficient security guarantee then two things can be used to + /// improve this randomness: + /// + /// - Name, in advance, the block number whose random value will be used; + /// ensure your module retains a buffer of previous random values for its + /// subject and then index into these in order to obviate the ability of + /// your user to look up the parent hash and choose when to transact based + /// upon it. + /// - Require your user to first commit to an additional value by first + /// posting its hash. Require them to reveal the value to determine the + /// final result, hashing it with the output of this random function. This + /// reduces the ability of a cabal of block producers from conspiring + /// against individuals. + /// + /// WARNING: Hashing the result of this function will remove any + /// low-influnce properties it has and mean that all bits of the resulting + /// value are entirely manipulatable by the author of the parent block, who + /// can determine the value of `parent_hash`. pub fn random(subject: &[u8]) -> T::Hash { let (index, hash_series) = >::get(); if hash_series.len() > 0 { @@ -606,8 +625,9 @@ impl Module { >::insert(who, Self::account_nonce(who) + T::Index::one()); } - /// Note what the extrinsic data of the current extrinsic index is. If this is called, then - /// ensure `derive_extrinsics` is also called before block-building is completed. + /// Note what the extrinsic data of the current extrinsic index is. If this + /// is called, then ensure `derive_extrinsics` is also called before + /// block-building is completed. /// /// NOTE: This function is called only when the block is being constructed locally. /// `execute_block` doesn't note any extrinsics. @@ -722,7 +742,7 @@ mod tests { #[test] fn deposit_event_should_work() { with_externalities(&mut new_test_ext(), || { - System::initialize(&1, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&1, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); System::note_finished_extrinsics(); System::deposit_event(1u16); System::finalize(); @@ -737,7 +757,7 @@ mod tests { ] ); - System::initialize(&2, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&2, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); System::deposit_event(42u16); System::note_applied_extrinsic(&Ok(()), 0); System::note_applied_extrinsic(&Err(""), 0); @@ -758,7 +778,7 @@ mod tests { with_externalities(&mut new_test_ext(), || { const BLOCK_NUMBER: u64 = 1; - System::initialize(&BLOCK_NUMBER, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&BLOCK_NUMBER, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); System::note_finished_extrinsics(); let topics = vec![ diff --git a/test-utils/transaction-factory/src/lib.rs b/test-utils/transaction-factory/src/lib.rs index b046cf74c9..8f292f3a02 100644 --- a/test-utils/transaction-factory/src/lib.rs +++ b/test-utils/transaction-factory/src/lib.rs @@ -148,7 +148,7 @@ where as ProvideRuntimeApi>::Api: BlockBuilder>, RA: RuntimeAdapter, { - let mut block = client.new_block().expect("Failed to create new block"); + let mut block = client.new_block(Default::default()).expect("Failed to create new block"); block.push( Decode::decode(&mut &transfer.encode()[..]) .expect("Failed to decode transfer extrinsic") diff --git a/test-utils/transaction-factory/src/modes.rs b/test-utils/transaction-factory/src/modes.rs index f3d278bbbf..a212d6aed8 100644 --- a/test-utils/transaction-factory/src/modes.rs +++ b/test-utils/transaction-factory/src/modes.rs @@ -38,4 +38,3 @@ impl FromStr for Mode { } } } - -- GitLab From 4ae2596928ba1dfebb3b7bca0b985bdefda196cc Mon Sep 17 00:00:00 2001 From: thiolliere Date: Wed, 29 May 2019 14:16:37 +0200 Subject: [PATCH 053/113] derive codec for inherent data (#2714) * derive codec for inherent data * increase spec version --- core/inherents/src/lib.rs | 29 +---------------------------- node/runtime/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/core/inherents/src/lib.rs b/core/inherents/src/lib.rs index 62b6f655cf..e851959ee0 100644 --- a/core/inherents/src/lib.rs +++ b/core/inherents/src/lib.rs @@ -53,7 +53,7 @@ pub use runtime_primitives::RuntimeString; pub type InherentIdentifier = [u8; 8]; /// Inherent data to include in a block. -#[derive(Clone, Default)] +#[derive(Clone, Default, Encode, Decode)] pub struct InherentData { /// All inherent data encoded with parity-codec and an identifier. data: BTreeMap> @@ -123,33 +123,6 @@ impl InherentData { } } -impl codec::Encode for InherentData { - fn encode(&self) -> Vec { - let keys = self.data.keys().collect::>(); - let values = self.data.values().collect::>(); - - let mut encoded = keys.encode(); - encoded.extend(values.encode()); - encoded - } -} - -impl codec::Decode for InherentData { - fn decode(value: &mut I) -> Option { - Vec::::decode(value) - .and_then(|i| Vec::>::decode(value).map(|v| (i, v))) - .and_then(|(i, v)| { - if i.len() == v.len() { - Some(Self { - data: i.into_iter().zip(v.into_iter()).collect() - }) - } else { - None - } - }) - } -} - /// The result of checking inherents. /// /// It either returns okay for all checks, stores all occurred errors or just one fatal error. diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 03b3f1caad..917e979d9f 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,7 +58,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 86, + spec_version: 87, impl_version: 87, apis: RUNTIME_API_VERSIONS, }; -- GitLab From b1a951c712c5ca335fa40f1f9f3c42c1ef8252f5 Mon Sep 17 00:00:00 2001 From: Kian Peymani Date: Wed, 29 May 2019 14:17:58 +0200 Subject: [PATCH 054/113] Limited Unbonding Chunks. (#2700) * Limit number of unlocking chunks. * Bump. --- node/runtime/src/lib.rs | 4 ++-- srml/staking/src/lib.rs | 17 +++++++++++++++-- srml/staking/src/tests.rs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 917e979d9f..97d1b88cc2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 87, - impl_version: 87, + spec_version: 88, + impl_version: 88, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 6a9846e07f..f84bf0a9ce 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -214,6 +214,11 @@ //! removed. Once the `BondingDuration` is over, the [`withdraw_unbonded`](./enum.Call.html#variant.withdraw_unbonded) call can be used //! to actually withdraw the funds. //! +//! Note that there is a limitation to the number of fund-chunks that can be scheduled to be unlocked in the future +//! via [`unbond`](enum.Call.html#variant.unbond). +//! In case this maximum (`MAX_UNLOCKING_CHUNKS`) is reached, the bonded account _must_ first wait until a successful +//! call to `withdraw_unbonded` to remove some of the chunks. +//! //! ### Election Algorithm //! //! The current election algorithm is implemented based on Phragmén. @@ -266,6 +271,8 @@ const RECENT_OFFLINE_COUNT: usize = 32; const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4; const MAX_NOMINATIONS: usize = 16; const MAX_UNSTAKE_THRESHOLD: u32 = 10; +const MAX_UNLOCKING_CHUNKS: usize = 32; +const STAKING_ID: LockIdentifier = *b"staking "; /// Indicates the initial status of the staker. #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] @@ -426,8 +433,6 @@ pub trait Trait: system::Trait + session::Trait { type Reward: OnUnbalanced>; } -const STAKING_ID: LockIdentifier = *b"staking "; - decl_storage! { trait Store for Module as Staking { @@ -605,12 +610,20 @@ decl_module! { /// Once the unlock period is done, you can call `withdraw_unbonded` to actually move /// the funds out of management ready for transfer. /// + /// No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) + /// can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need + /// to be called first to remove some of the chunks (if possible). + /// /// The dispatch origin for this call must be _Signed_ by the controller, not the stash. /// /// See also [`Call::withdraw_unbonded`]. fn unbond(origin, #[compact] value: BalanceOf) { let controller = ensure_signed(origin)?; let mut ledger = Self::ledger(&controller).ok_or("not a controller")?; + ensure!( + ledger.unlocking.len() < MAX_UNLOCKING_CHUNKS, + "can not schedule more unlock chunks" + ); let mut value = value.min(ledger.active); diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 17885dc251..fecd38bb01 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1237,6 +1237,38 @@ fn bond_extra_and_withdraw_unbonded_works() { }) } +#[test] +fn too_many_unbond_calls_should_not_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + // locked at era 0 until 3 + for _ in 0..MAX_UNLOCKING_CHUNKS-1 { + assert_ok!(Staking::unbond(Origin::signed(10), 1)); + } + + System::set_block_number(1); + Session::check_rotate_session(System::block_number()); + + // locked ar era 1 until 4 + assert_ok!(Staking::unbond(Origin::signed(10), 1)); + // can't do more. + assert_noop!(Staking::unbond(Origin::signed(10), 1), "can not schedule more unlock chunks"); + + System::set_block_number(2); + Session::check_rotate_session(System::block_number()); + + System::set_block_number(3); + Session::check_rotate_session(System::block_number()); + + assert_noop!(Staking::unbond(Origin::signed(10), 1), "can not schedule more unlock chunks"); + // free up. + assert_ok!(Staking::withdraw_unbonded(Origin::signed(10))); + + // Can add again. + assert_ok!(Staking::unbond(Origin::signed(10), 1)); + assert_eq!(Staking::ledger(&10).unwrap().unlocking.len(), 2); + }) +} + #[test] fn slot_stake_is_least_staked_validator_and_exposure_defines_maximum_punishment() { // Test that slot_stake is determined by the least staked validator -- GitLab From d9e7d7ce3b80a3c504c10f898ad2053dd1cc1c36 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 29 May 2019 15:15:10 +0200 Subject: [PATCH 055/113] Maps are appendable too (#2716) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Maps are appendable too * Update srml/support/src/storage/hashed/generator.rs Co-Authored-By: Tomasz Drwięga * Update srml/support/src/storage/mod.rs Co-Authored-By: Tomasz Drwięga * Fix docs * Make Appendable public * Bump runtime version --- node/runtime/src/lib.rs | 2 +- srml/support/procedural/src/storage/impls.rs | 5 ++- srml/support/src/lib.rs | 4 +- srml/support/src/storage/child.rs | 0 srml/support/src/storage/hashed/generator.rs | 22 +++++++++- srml/support/src/storage/mod.rs | 23 ++++++++++- srml/support/src/storage/storage_items.rs | 43 ++++++++++++++++++++ 7 files changed, 94 insertions(+), 5 deletions(-) delete mode 100644 srml/support/src/storage/child.rs diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 97d1b88cc2..6bc118bdc0 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 88, - impl_version: 88, + impl_version: 89, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/support/procedural/src/storage/impls.rs b/srml/support/procedural/src/storage/impls.rs index 720ed21c24..0e9e30e2a4 100644 --- a/srml/support/procedural/src/storage/impls.rs +++ b/srml/support/procedural/src/storage/impls.rs @@ -225,8 +225,11 @@ impl<'a, I: Iterator> Impls<'a, I> { #mutate_impl ; ret } - } + + impl<#traitinstance: 'static + #traittype, #instance #bound_instantiable> + #scrate::storage::hashed::generator::AppendableStorageMap<#kty, #typ> for #name<#traitinstance, #instance> + {} } } diff --git a/srml/support/src/lib.rs b/srml/support/src/lib.rs index 4f749d4c89..0931e4c5a3 100644 --- a/srml/support/src/lib.rs +++ b/srml/support/src/lib.rs @@ -57,7 +57,9 @@ pub mod unsigned; mod double_map; pub mod traits; -pub use self::storage::{StorageList, StorageValue, StorageMap, EnumerableStorageMap, StorageDoubleMap}; +pub use self::storage::{ + StorageList, StorageValue, StorageMap, EnumerableStorageMap, StorageDoubleMap, AppendableStorageMap +}; pub use self::hashable::Hashable; pub use self::dispatch::{Parameter, Dispatchable, Callable, IsSubType}; pub use self::double_map::StorageDoubleMapWithHasher; diff --git a/srml/support/src/storage/child.rs b/srml/support/src/storage/child.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/srml/support/src/storage/hashed/generator.rs b/srml/support/src/storage/hashed/generator.rs index fb876a2adb..1cc62c69f7 100644 --- a/srml/support/src/storage/hashed/generator.rs +++ b/srml/support/src/storage/hashed/generator.rs @@ -281,5 +281,25 @@ pub trait EnumerableStorageMap: StorageMap>(storage: &S) -> Option; /// Enumerate all elements in the map. - fn enumerate<'a, S: HashedStorage>(storage: &'a S) -> Box + 'a> where K: 'a, V: 'a; + fn enumerate<'a, S: HashedStorage>( + storage: &'a S + ) -> Box + 'a> where K: 'a, V: 'a; +} + +/// A `StorageMap` with appendable entries. +pub trait AppendableStorageMap: StorageMap { + /// Append the given items to the value in the storage. + /// + /// `T` is required to implement `codec::EncodeAppend`. + fn append, I: codec::Encode>( + key : &K, items: &[I], storage: &mut S + ) -> Result<(), &'static str> where V: codec::EncodeAppend { + let k = Self::key_for(key); + let new_val = ::append( + storage.get_raw(&k[..]).unwrap_or_default(), + items, + ).ok_or_else(|| "Could not append given item")?; + storage.put_raw(&k[..], &new_val); + Ok(()) + } } diff --git a/srml/support/src/storage/mod.rs b/srml/support/src/storage/mod.rs index 635572c991..41ea4cfdbc 100644 --- a/srml/support/src/storage/mod.rs +++ b/srml/support/src/storage/mod.rs @@ -330,6 +330,25 @@ impl StorageMap for U where U: hashed::generator::S } } +/// A storage map with values that can be appended to. +pub trait AppendableStorageMap: StorageMap { + /// Append the given item to the value in the storage. + /// + /// `T` is required to implement `codec::EncodeAppend`. + fn append, I: Encode>(key: KeyArg, items: &[I]) -> Result<(), &'static str> + where V: EncodeAppend; +} + +impl AppendableStorageMap for U + where U: hashed::generator::AppendableStorageMap +{ + fn append, I: Encode>(key: KeyArg, items: &[I]) -> Result<(), &'static str> + where V: EncodeAppend + { + U::append(key.borrow(), items, &mut RuntimeStorage) + } +} + /// A storage map that can be enumerated. /// /// Primarily useful for off-chain computations. @@ -342,7 +361,9 @@ pub trait EnumerableStorageMap: StorageMap { fn enumerate() -> Box> where K: 'static, V: 'static; } -impl EnumerableStorageMap for U where U: hashed::generator::EnumerableStorageMap { +impl EnumerableStorageMap for U + where U: hashed::generator::EnumerableStorageMap +{ fn head() -> Option { >::head(&RuntimeStorage) } diff --git a/srml/support/src/storage/storage_items.rs b/srml/support/src/storage/storage_items.rs index 802965fc27..2e7a8d4bb4 100644 --- a/srml/support/src/storage/storage_items.rs +++ b/srml/support/src/storage/storage_items.rs @@ -900,3 +900,46 @@ mod test3 { type BlockNumber = u32; } } + +#[cfg(test)] +#[allow(dead_code)] +mod test_map_vec_append { + pub trait Trait { + type Origin; + type BlockNumber; + } + decl_module! { + pub struct Module for enum Call where origin: T::Origin {} + } + crate::decl_storage! { + trait Store for Module as Test { + JustVec: Vec; + MapVec: map u32 => Vec; + } + } + + struct Test {} + + impl Trait for Test { + type Origin = u32; + type BlockNumber = u32; + } + + #[test] + fn append_works() { + use crate::storage::{AppendableStorageMap, StorageMap, StorageValue}; + use runtime_io::{with_externalities, TestExternalities}; + + with_externalities(&mut TestExternalities::default(), || { + let _ = >::append(1, &[1, 2, 3]); + let _ = >::append(1, &[4, 5]); + assert_eq!(>::get(1), vec![1, 2, 3, 4, 5]); + + let _ = >::append(&[1, 2, 3]); + let _ = >::append(&[4, 5]); + assert_eq!(>::get(), vec![1, 2, 3, 4, 5]); + }); + } +} + + -- GitLab From 51b577fbede36b2dbee2fad1214f6a59887eaa21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Wed, 29 May 2019 15:25:02 +0200 Subject: [PATCH 056/113] core: import equivocated aura and babe blocks (#2709) * core: import equivocated aura and babe blocks * core: cleanup check_equivocation handling * fix: use map_err on Aura * core: slots: remove unneeded Arc and minimize cloning * core: fix slots equivocation tests * core: slots: remove unused import * core: remove unnecessary comments --- Cargo.lock | 1 + core/consensus/aura/src/lib.rs | 90 +++-------------- core/consensus/babe/src/lib.rs | 123 ++++------------------- core/consensus/slots/Cargo.toml | 3 + core/consensus/slots/src/aux_schema.rs | 134 +++++++++++++++++++++++-- 5 files changed, 161 insertions(+), 190 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83a85c4d69..d585910b14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4061,6 +4061,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", + "substrate-test-client 2.0.0", "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index e3ab9e31cf..36c51c8cff 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -395,7 +395,7 @@ fn find_pre_digest(header: &B::Header) -> Result // // FIXME #1018 needs misbehavior types fn check_header( - client: &Arc, + client: &C, slot_now: u64, mut header: B::Header, hash: B::Hash, @@ -431,26 +431,22 @@ fn check_header( let pre_hash = header.hash(); if P::verify(&sig, pre_hash.as_ref(), expected_author) { - match check_equivocation::<_, _,

::Public>( + if let Some(equivocation_proof) = check_equivocation( client, slot_now, slot_num, - header.clone(), - expected_author.clone(), - ) { - Ok(Some(equivocation_proof)) => { - let log_str = format!( - "Slot author is equivocating at slot {} with headers {:?} and {:?}", - slot_num, - equivocation_proof.fst_header().hash(), - equivocation_proof.snd_header().hash(), - ); - info!("{}", log_str); - Err(log_str) - }, - Ok(None) => Ok(CheckedHeader::Checked(header, (slot_num, seal))), - Err(e) => Err(e.to_string()), + &header, + expected_author, + ).map_err(|e| e.to_string())? { + info!( + "Slot author is equivocating at slot {} with headers {:?} and {:?}", + slot_num, + equivocation_proof.fst_header().hash(), + equivocation_proof.snd_header().hash(), + ); } + + Ok(CheckedHeader::Checked(header, (slot_num, seal))) } else { Err(format!("Bad signature on {:?}", hash)) } @@ -766,9 +762,6 @@ mod tests { use primitives::sr25519; use client::{LongestChain, BlockchainEvents}; use test_client; - use primitives::hash::H256; - use runtime_primitives::testing::{Header as HeaderTest, Digest as DigestTest, Block as RawBlock, ExtrinsicWrapper}; - use slots::{MAX_SLOT_CAPACITY, PRUNING_BOUND}; type Error = client::error::Error; @@ -873,24 +866,6 @@ mod tests { } } - fn create_header(slot_num: u64, number: u64, pair: &sr25519::Pair) -> (HeaderTest, H256) { - let mut header = HeaderTest { - parent_hash: Default::default(), - number, - state_root: Default::default(), - extrinsics_root: Default::default(), - digest: DigestTest { logs: vec![], }, - }; - let item = as CompatibleDigestItem>::aura_pre_digest(slot_num); - header.digest_mut().push(item); - let header_hash: H256 = header.hash(); - let signature = pair.sign(&header_hash[..]); - - let item = CompatibleDigestItem::::aura_seal(signature); - header.digest_mut().push(item); - (header, header_hash) - } - #[test] #[allow(deprecated)] fn authoring_blocks() { @@ -975,43 +950,4 @@ mod tests { Keyring::Charlie.into() ]); } - - #[test] - fn check_header_works_with_equivocation() { - let client = test_client::new(); - let pair = sr25519::Pair::generate(); - let public = pair.public(); - let authorities = vec![public.clone(), sr25519::Pair::generate().public()]; - - let (header1, header1_hash) = create_header(2, 1, &pair); - let (header2, header2_hash) = create_header(2, 2, &pair); - let (header3, header3_hash) = create_header(4, 2, &pair); - let (header4, header4_hash) = create_header(MAX_SLOT_CAPACITY + 4, 3, &pair); - let (header5, header5_hash) = create_header(MAX_SLOT_CAPACITY + 4, 4, &pair); - let (header6, header6_hash) = create_header(4, 3, &pair); - - type B = RawBlock>; - type P = sr25519::Pair; - - let c = Arc::new(client); - - // It's ok to sign same headers. - check_header::<_, B, P>(&c, 2, header1.clone(), header1_hash, &authorities).unwrap(); - assert!(check_header::<_, B, P>(&c, 3, header1, header1_hash, &authorities).is_ok()); - - // But not two different headers at the same slot. - assert!(check_header::<_, B, P>(&c, 4, header2, header2_hash, &authorities).is_err()); - - // Different slot is ok. - assert!(check_header::<_, B, P>(&c, 5, header3, header3_hash, &authorities).is_ok()); - - // Here we trigger pruning and save header 4. - assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 2, header4, header4_hash, &authorities).is_ok()); - - // This fails because header 5 is an equivocation of header 4. - assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 3, header5, header5_hash, &authorities).is_err()); - - // This is ok because we pruned the corresponding header. Shows that we are pruning. - assert!(check_header::<_, B, P>(&c, PRUNING_BOUND + 4, header6, header6_hash, &authorities).is_ok()); - } } diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 2d1afb0187..81b4be4137 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -461,7 +461,7 @@ fn find_pre_digest(header: &B::Header) -> Result( - client: &Arc, + client: &C, slot_now: u64, mut header: B::Header, hash: B::Hash, @@ -508,28 +508,27 @@ fn check_header( if !check(&inout, threshold) { return Err(babe_err!("VRF verification of block by author {:?} failed: \ - threshold {} exceeded", author, threshold)) + threshold {} exceeded", author, threshold)); } - match check_equivocation(&client, slot_now, slot_num, header.clone(), author.clone()) { - Ok(Some(equivocation_proof)) => { - let log_str = format!( - "Slot author {:?} is equivocating at slot {} with headers {:?} and {:?}", - author, - slot_num, - equivocation_proof.fst_header().hash(), - equivocation_proof.snd_header().hash(), - ); - info!(target: "babe", "{}", log_str); - Err(log_str) - }, - Ok(None) => { - let pre_digest = CompatibleDigestItem::babe_pre_digest(pre_digest); - Ok(CheckedHeader::Checked(header, (pre_digest, seal))) - }, - Err(e) => { - Err(e.to_string()) - }, + + if let Some(equivocation_proof) = check_equivocation( + client, + slot_now, + slot_num, + &header, + author, + ).map_err(|e| e.to_string())? { + info!( + "Slot author {:?} is equivocating at slot {} with headers {:?} and {:?}", + author, + slot_num, + equivocation_proof.fst_header().hash(), + equivocation_proof.snd_header().hash(), + ); } + + let pre_digest = CompatibleDigestItem::babe_pre_digest(pre_digest); + Ok(CheckedHeader::Checked(header, (pre_digest, seal))) } else { Err(babe_err!("Bad signature on {:?}", hash)) } @@ -823,9 +822,6 @@ mod tests { use std::time::Duration; type Item = generic::DigestItem; use test_client::AuthorityKeyring; - use primitives::hash::H256; - use runtime_primitives::testing::{Header as HeaderTest, Digest as DigestTest, Block as RawBlock, ExtrinsicWrapper}; - use slots::{MAX_SLOT_CAPACITY, PRUNING_BOUND}; type Error = client::error::Error; @@ -934,44 +930,6 @@ mod tests { } } - fn create_header(slot_num: u64, number: u64, pair: &sr25519::Pair) -> (HeaderTest, H256) { - let mut header = HeaderTest { - parent_hash: Default::default(), - number, - state_root: Default::default(), - extrinsics_root: Default::default(), - digest: DigestTest { logs: vec![], }, - }; - - let transcript = make_transcript( - Default::default(), - slot_num, - Default::default(), - 0, - ); - - let (inout, proof, _batchable_proof) = get_keypair(&pair).vrf_sign_n_check(transcript, |inout| check(inout, u64::MAX)).unwrap(); - let pre_hash: H256 = header.hash(); - let pre_digest = BabePreDigest { - proof, - author: pair.public(), - slot_num, - vrf_output: inout.to_output(), - }; - assert_eq!( - Decode::decode(&mut &pre_digest.encode()[..]).as_ref(), - Some(&pre_digest), - "Pre-digest encoding and decoding did not round-trip", - ); - let item = generic::DigestItem::babe_pre_digest(pre_digest); - header.digest_mut().push(item); - - let to_sign = header.hash(); - let signature = pair.sign(&to_sign[..]); - header.digest_mut().push(generic::DigestItem::babe_seal(signature)); - (header, pre_hash) - } - #[test] fn can_serialize_block() { drop(env_logger::try_init()); @@ -1107,45 +1065,4 @@ mod tests { Keyring::Charlie.into() ]); } - - #[test] - fn check_header_works_with_equivocation() { - drop(env_logger::try_init()); - let client = test_client::new(); - let pair = sr25519::Pair::generate(); - let public = pair.public(); - let authorities = vec![public.clone(), sr25519::Pair::generate().public()]; - - let (header1, header1_hash) = create_header(2, 1, &pair); - let (header2, header2_hash) = create_header(2, 2, &pair); - let (header3, header3_hash) = create_header(4, 2, &pair); - let (header4, header4_hash) = create_header(MAX_SLOT_CAPACITY + 4, 3, &pair); - let (header5, header5_hash) = create_header(MAX_SLOT_CAPACITY + 4, 4, &pair); - let (header6, header6_hash) = create_header(4, 3, &pair); - - let c = Arc::new(client); - let max = u64::MAX; - - type B = RawBlock>; - type P = sr25519::Pair; - - // It's ok to sign same headers. - assert!(check_header::(&c, 2, header1.clone(), header1_hash, &authorities, max).is_ok()); - assert!(check_header::(&c, 3, header1, header1_hash, &authorities, max).is_ok()); - - // But not two different headers at the same slot. - assert!(check_header::(&c, 4, header2, header2_hash, &authorities, max).is_err()); - - // Different slot is ok. - assert!(check_header::(&c, 5, header3, header3_hash, &authorities, max).is_ok()); - - // Here we trigger pruning and save header 4. - assert!(check_header::(&c, PRUNING_BOUND + 2, header4, header4_hash, &authorities, max).is_ok()); - - // This fails because header 5 is an equivocation of header 4. - assert!(check_header::(&c, PRUNING_BOUND + 3, header5, header5_hash, &authorities, max).is_err()); - - // This is ok because we pruned the corresponding header. Shows that we are pruning. - assert!(check_header::(&c, PRUNING_BOUND + 4, header6, header6_hash, &authorities, max).is_ok()); - } } diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index ee3571bcdc..2be9133d54 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -16,3 +16,6 @@ futures = "0.1.17" tokio = "0.1.7" parking_lot = "0.7.1" log = "0.4" + +[dev-dependencies] +test_client = { package = "substrate-test-client", path = "../../test-client" } diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 3d4a11d487..ed96bf2e22 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -16,7 +16,6 @@ //! Schema for slots in the aux-db. -use std::sync::Arc; use codec::{Encode, Decode}; use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; @@ -30,7 +29,7 @@ pub const MAX_SLOT_CAPACITY: u64 = 1000; /// We prune slots when they reach this number. pub const PRUNING_BOUND: u64 = 2 * MAX_SLOT_CAPACITY; -fn load_decode(backend: Arc, key: &[u8]) -> ClientResult> +fn load_decode(backend: &C, key: &[u8]) -> ClientResult> where C: AuxStore, T: Decode, @@ -74,16 +73,16 @@ impl EquivocationProof { /// /// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY. pub fn check_equivocation( - backend: &Arc, + backend: &C, slot_now: u64, slot: u64, - header: H, - signer: P, + header: &H, + signer: &P, ) -> ClientResult>> where H: Header, C: AuxStore, - P: Encode + Decode + PartialEq, + P: Clone + Encode + Decode + PartialEq, { // We don't check equivocations for old headers out of our capacity. if slot_now - slot > MAX_SLOT_CAPACITY { @@ -95,18 +94,18 @@ pub fn check_equivocation( slot.using_encoded(|s| curr_slot_key.extend(s)); // Get headers of this slot. - let mut headers_with_sig = load_decode::<_, Vec<(H, P)>>(backend.clone(), &curr_slot_key[..])? + let mut headers_with_sig = load_decode::<_, Vec<(H, P)>>(backend, &curr_slot_key[..])? .unwrap_or_else(Vec::new); // Get first slot saved. let slot_header_start = SLOT_HEADER_START.to_vec(); - let first_saved_slot = load_decode::<_, u64>(backend.clone(), &slot_header_start[..])? + let first_saved_slot = load_decode::<_, u64>(backend, &slot_header_start[..])? .unwrap_or(slot); for (prev_header, prev_signer) in headers_with_sig.iter() { // A proof of equivocation consists of two headers: // 1) signed by the same voter, - if *prev_signer == signer { + if prev_signer == signer { // 2) with different hash if header.hash() != prev_header.hash() { return Ok(Some(EquivocationProof { @@ -137,7 +136,7 @@ pub fn check_equivocation( } } - headers_with_sig.push((header, signer)); + headers_with_sig.push((header.clone(), signer.clone())); backend.insert_aux( &[ @@ -149,3 +148,118 @@ pub fn check_equivocation( Ok(None) } + +#[cfg(test)] +mod test { + use primitives::{sr25519, Pair}; + use primitives::hash::H256; + use runtime_primitives::testing::{Header as HeaderTest, Digest as DigestTest}; + use test_client; + + use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation}; + + fn create_header(number: u64) -> HeaderTest { + // so that different headers for the same number get different hashes + let parent_hash = H256::random(); + + let header = HeaderTest { + parent_hash, + number, + state_root: Default::default(), + extrinsics_root: Default::default(), + digest: DigestTest { logs: vec![], }, + }; + + header + } + + #[test] + fn check_equivocation_works() { + let client = test_client::new(); + let pair = sr25519::Pair::generate(); + let public = pair.public(); + + let header1 = create_header(1); // @ slot 2 + let header2 = create_header(2); // @ slot 2 + let header3 = create_header(2); // @ slot 4 + let header4 = create_header(3); // @ slot MAX_SLOT_CAPACITY + 4 + let header5 = create_header(4); // @ slot MAX_SLOT_CAPACITY + 4 + let header6 = create_header(3); // @ slot 4 + + // It's ok to sign same headers. + assert!( + check_equivocation( + &client, + 2, + 2, + &header1, + &public, + ).unwrap().is_none(), + ); + + assert!( + check_equivocation( + &client, + 3, + 2, + &header1, + &public, + ).unwrap().is_none(), + ); + + // But not two different headers at the same slot. + assert!( + check_equivocation( + &client, + 4, + 2, + &header2, + &public, + ).unwrap().is_some(), + ); + + // Different slot is ok. + assert!( + check_equivocation( + &client, + 5, + 4, + &header3, + &public, + ).unwrap().is_none(), + ); + + // Here we trigger pruning and save header 4. + assert!( + check_equivocation( + &client, + PRUNING_BOUND + 2, + MAX_SLOT_CAPACITY + 4, + &header4, + &public, + ).unwrap().is_none(), + ); + + // This fails because header 5 is an equivocation of header 4. + assert!( + check_equivocation( + &client, + PRUNING_BOUND + 3, + MAX_SLOT_CAPACITY + 4, + &header5, + &public, + ).unwrap().is_some(), + ); + + // This is ok because we pruned the corresponding header. Shows that we are pruning. + assert!( + check_equivocation( + &client, + PRUNING_BOUND + 4, + 4, + &header6, + &public, + ).unwrap().is_none(), + ); + } +} -- GitLab From 090fc1c039bf4ae052ab5219fc6ce75d99773b9e Mon Sep 17 00:00:00 2001 From: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> Date: Wed, 29 May 2019 09:35:31 -0400 Subject: [PATCH 057/113] Update dependencies (#2718) I am taking charge of ~monthly dependency updates, as per a suggestion from @rphmeier. --- Cargo.lock | 1117 ++++++++++++++++++++++++++-------------------------- 1 file changed, 563 insertions(+), 554 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d585910b14..978af7a4ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,13 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "MacTypes-sys" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "aes-ctr" version = "0.3.0" @@ -52,7 +44,7 @@ name = "aio-limited" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -106,7 +98,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -119,27 +111,26 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -147,8 +138,8 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -194,7 +185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +193,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -281,7 +272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bstr" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -289,7 +280,7 @@ dependencies = [ [[package]] name = "bumpalo" -version = "2.4.1" +version = "2.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -318,6 +309,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -333,7 +325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.26" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -349,7 +341,7 @@ dependencies = [ [[package]] name = "cfg-if" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -367,8 +359,8 @@ name = "chrono" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -378,7 +370,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -402,7 +394,7 @@ name = "clear_on_drop" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -415,10 +407,10 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.35" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -428,20 +420,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "core-foundation" -version = "0.5.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "core-foundation-sys" -version = "0.5.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "criterion" @@ -455,17 +444,17 @@ dependencies = [ "csv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "tinytemplate 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -484,7 +473,7 @@ name = "crossbeam" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -536,7 +525,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -550,7 +539,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -570,7 +559,7 @@ name = "crossbeam-utils" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -578,7 +567,7 @@ name = "crossbeam-utils" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -589,7 +578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crunchy" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -616,9 +605,9 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -635,7 +624,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -667,7 +656,7 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -684,13 +673,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "derive_more" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -734,7 +723,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -775,15 +764,16 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "error-chain" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -791,7 +781,7 @@ name = "exit-future" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -800,7 +790,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -809,10 +799,10 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -825,7 +815,7 @@ name = "fdlimit" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -833,10 +823,10 @@ name = "finality-grandpa" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -849,7 +839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -886,7 +876,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -912,7 +902,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -920,7 +910,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -953,7 +943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -963,7 +953,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -982,7 +972,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "bstr 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -990,13 +980,13 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1015,7 +1005,7 @@ name = "hash256-std-hasher" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1045,7 +1035,7 @@ name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1068,7 +1058,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hex-literal-impl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1084,7 +1074,7 @@ name = "hex-literal-impl" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1123,7 +1113,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "http-body" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1141,7 +1142,7 @@ dependencies = [ [[package]] name = "hyper" -version = "0.10.15" +version = "0.10.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1159,22 +1160,24 @@ dependencies = [ [[package]] name = "hyper" -version = "0.12.27" +version = "0.12.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1208,7 +1211,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1216,7 +1219,7 @@ name = "impl-serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1239,7 +1242,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1253,15 +1256,15 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1269,10 +1272,10 @@ name = "jsonrpc-core" version = "10.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1281,9 +1284,9 @@ name = "jsonrpc-derive" version = "10.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1291,12 +1294,12 @@ name = "jsonrpc-http-server" version = "10.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hyper 0.12.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-server-utils 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1307,7 +1310,7 @@ dependencies = [ "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1321,9 +1324,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1331,7 +1334,7 @@ name = "jsonrpc-ws-server" version = "10.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-server-utils 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1415,7 +1418,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.51" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1423,7 +1426,7 @@ name = "libloading" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1433,7 +1436,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1453,7 +1456,7 @@ dependencies = [ "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1474,19 +1477,19 @@ dependencies = [ "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1504,7 +1507,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1512,7 +1515,7 @@ name = "libp2p-dns" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1528,9 +1531,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1545,12 +1548,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1570,13 +1573,13 @@ dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1593,11 +1596,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1614,7 +1617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1629,12 +1632,12 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1650,10 +1653,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1667,7 +1670,7 @@ name = "libp2p-plaintext" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1679,7 +1682,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1695,24 +1698,24 @@ dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1721,7 +1724,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1735,7 +1738,7 @@ name = "libp2p-uds" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1746,13 +1749,13 @@ name = "libp2p-wasm-ext" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1761,14 +1764,14 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "websocket 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1776,22 +1779,22 @@ name = "libp2p-yamux" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "librocksdb-sys" -version = "5.17.2" +version = "5.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1842,7 +1845,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1863,7 +1866,7 @@ name = "memchr" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1888,7 +1891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "merlin" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1907,15 +1910,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.16" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1930,7 +1932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1940,8 +1942,8 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1961,7 +1963,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1979,19 +1981,19 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1999,8 +2001,8 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2010,9 +2012,9 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2021,7 +2023,7 @@ name = "node-cli" version = "2.0.0" dependencies = [ "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", @@ -2049,7 +2051,7 @@ dependencies = [ "substrate-service-test 2.0.0", "substrate-telemetry 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-factory 0.0.1", ] @@ -2088,7 +2090,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2104,7 +2106,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -2138,9 +2140,9 @@ name = "node-template" version = "2.0.0" dependencies = [ "ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "node-template-runtime 2.0.0", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2156,7 +2158,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2167,7 +2169,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2209,23 +2211,27 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.39" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2257,15 +2263,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.10.20" +version = "0.10.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2275,13 +2281,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.43" +version = "0.9.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2321,7 +2327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2329,15 +2335,15 @@ name = "parity-codec-derive" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multiaddr" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2346,8 +2352,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2359,7 +2366,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2385,7 +2392,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2425,7 +2432,7 @@ name = "parking_lot_core" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2436,7 +2443,7 @@ name = "parking_lot_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2448,7 +2455,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2461,7 +2468,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2469,10 +2476,10 @@ name = "paste-impl" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2533,10 +2540,10 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2549,12 +2556,12 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2564,7 +2571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.28" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2572,7 +2579,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2600,7 +2607,7 @@ name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2608,7 +2615,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2618,7 +2625,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2631,7 +2638,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2641,13 +2648,13 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2659,7 +2666,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2694,10 +2701,10 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2709,7 +2716,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2720,7 +2727,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2758,7 +2765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2821,8 +2828,8 @@ name = "rhododendron" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2833,9 +2840,9 @@ name = "ring" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2846,8 +2853,8 @@ name = "rocksdb" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "librocksdb-sys 5.17.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2856,7 +2863,7 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2880,17 +2887,17 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2929,14 +2936,14 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2947,23 +2954,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "security-framework" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "security-framework-sys" -version = "0.2.3" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2986,20 +2991,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3007,9 +3012,9 @@ name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3053,7 +3058,7 @@ dependencies = [ [[package]] name = "sha3" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3102,7 +3107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3122,9 +3127,9 @@ name = "slog_derive" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3166,8 +3171,8 @@ dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-version 2.0.0", @@ -3176,7 +3181,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-test-client 2.0.0", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3202,10 +3207,10 @@ version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", @@ -3238,7 +3243,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -3248,7 +3253,7 @@ name = "srml-assets" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3264,7 +3269,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3286,7 +3291,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3307,7 +3312,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3322,7 +3327,7 @@ name = "srml-consensus" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3342,7 +3347,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-sandbox 2.0.0", @@ -3364,7 +3369,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3381,7 +3386,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3396,7 +3401,7 @@ name = "srml-example" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "srml-balances 2.0.0", @@ -3411,7 +3416,7 @@ version = "2.0.0" dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3429,7 +3434,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3444,7 +3449,7 @@ name = "srml-grandpa" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3464,7 +3469,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3479,7 +3484,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -3491,7 +3496,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3508,7 +3513,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3527,7 +3532,7 @@ name = "srml-sudo" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3546,7 +3551,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3560,31 +3565,31 @@ dependencies = [ name = "srml-support-procedural" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools" version = "2.0.0" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools-derive" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3592,7 +3597,7 @@ name = "srml-support-test" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "srml-support 2.0.0", "substrate-inherents 2.0.0", @@ -3607,7 +3612,7 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3620,7 +3625,7 @@ name = "srml-timestamp" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3635,7 +3640,7 @@ name = "srml-treasury" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3662,7 +3667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "stdweb" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3670,7 +3675,7 @@ dependencies = [ "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3678,11 +3683,11 @@ name = "stdweb-derive" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3691,13 +3696,13 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3738,9 +3743,9 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3754,9 +3759,9 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3783,7 +3788,7 @@ name = "substrate" version = "2.0.0" dependencies = [ "ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "node-cli 2.0.0", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3824,11 +3829,11 @@ dependencies = [ "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3845,19 +3850,19 @@ dependencies = [ "substrate-service 2.0.0", "substrate-state-machine 2.0.0", "substrate-telemetry 2.0.0", - "sysinfo 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sysinfo 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-client" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", @@ -3910,7 +3915,7 @@ name = "substrate-consensus-aura" version = "2.0.0" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3933,7 +3938,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3963,9 +3968,9 @@ name = "substrate-consensus-babe" version = "2.0.0" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3990,7 +3995,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4008,8 +4013,8 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4027,9 +4032,9 @@ dependencies = [ name = "substrate-consensus-rhd" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4045,14 +4050,14 @@ dependencies = [ "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-consensus-slots" version = "2.0.0" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4062,7 +4067,7 @@ dependencies = [ "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4071,7 +4076,7 @@ version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4097,7 +4102,7 @@ dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "finality-grandpa 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4115,7 +4120,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4154,7 +4159,7 @@ dependencies = [ name = "substrate-keystore" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4168,10 +4173,10 @@ name = "substrate-network" version = "2.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4188,7 +4193,7 @@ dependencies = [ "substrate-peerset 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4201,20 +4206,20 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-peerset 2.0.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4227,7 +4232,7 @@ name = "substrate-offchain" version = "2.0.0" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4238,7 +4243,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4253,7 +4258,7 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4261,14 +4266,14 @@ dependencies = [ name = "substrate-peerset" version = "2.0.0" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4285,7 +4290,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4293,13 +4298,13 @@ dependencies = [ "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)", "substrate-serializer 2.0.0", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4308,8 +4313,8 @@ name = "substrate-rpc" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-derive 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-pubsub 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4317,7 +4322,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4331,7 +4336,7 @@ dependencies = [ "substrate-test-client 2.0.0", "substrate-test-runtime 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4342,7 +4347,7 @@ dependencies = [ "jsonrpc-pubsub 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-ws-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-rpc 2.0.0", ] @@ -4351,7 +4356,7 @@ dependencies = [ name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4359,9 +4364,9 @@ dependencies = [ name = "substrate-service" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", @@ -4369,7 +4374,7 @@ dependencies = [ "node-runtime 2.0.0", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4389,7 +4394,7 @@ dependencies = [ "substrate-test-client 2.0.0", "substrate-transaction-pool 2.0.0", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4398,7 +4403,7 @@ version = "2.0.0" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -4407,7 +4412,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4428,7 +4433,7 @@ dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", @@ -4446,7 +4451,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4459,7 +4464,7 @@ dependencies = [ name = "substrate-test-client" version = "2.0.0" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -4476,11 +4481,11 @@ dependencies = [ name = "substrate-test-runtime" version = "2.0.0" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4506,13 +4511,13 @@ name = "substrate-transaction-graph" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime 2.0.0", @@ -4522,8 +4527,8 @@ dependencies = [ name = "substrate-transaction-pool" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4550,7 +4555,7 @@ dependencies = [ "trie-bench 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-standardmap 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4565,32 +4570,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.32" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sysinfo" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4616,11 +4621,11 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.0.7" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4640,7 +4645,7 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4667,7 +4672,7 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4696,10 +4701,10 @@ dependencies = [ [[package]] name = "tinytemplate" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4708,20 +4713,20 @@ name = "tk-listen" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4738,13 +4743,23 @@ dependencies = [ "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-buf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-codec" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4753,7 +4768,7 @@ name = "tokio-current-thread" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4762,10 +4777,10 @@ name = "tokio-dns-unofficial" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4774,7 +4789,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4782,7 +4797,7 @@ name = "tokio-fs" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4793,7 +4808,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4803,10 +4818,10 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4821,7 +4836,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4830,9 +4845,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4845,7 +4860,7 @@ dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4859,7 +4874,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4869,8 +4884,8 @@ name = "tokio-tls" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4888,9 +4903,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4902,11 +4917,11 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4915,18 +4930,10 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "toml" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4960,7 +4967,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-standardmap 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4985,10 +4992,9 @@ dependencies = [ [[package]] name = "trie-standardmap" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5005,10 +5011,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5023,10 +5029,10 @@ dependencies = [ [[package]] name = "twox-hash" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5050,7 +5056,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5065,7 +5071,7 @@ dependencies = [ [[package]] name = "unicase" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5089,7 +5095,7 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -5166,8 +5172,8 @@ name = "wabt" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5177,8 +5183,8 @@ name = "wabt-sys" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5197,82 +5203,82 @@ name = "want" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-futures" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5280,11 +5286,11 @@ name = "wasm-timer" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5308,32 +5314,35 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "websocket" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5341,7 +5350,7 @@ dependencies = [ [[package]] name = "weedle" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5353,7 +5362,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5411,9 +5420,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5435,7 +5444,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5451,11 +5460,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "yamux" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5483,13 +5492,12 @@ name = "zeroize_derive" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" @@ -5503,8 +5511,8 @@ dependencies = [ "checksum asn1_der_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7f92edafad155aff997fa5b727c6429b91e996b5a5d62a2b0adbae1306b5fe" "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" @@ -5521,8 +5529,8 @@ dependencies = [ "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" -"checksum bstr 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6c8203ca06c502958719dae5f653a79e0cc6ba808ed02beffbf27d09610f2143" -"checksum bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4639720be048090544634e0402490838995ccdc9d2fe648f528f30d3c33ae71f" +"checksum bstr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "59604ece62a407dc9164732e5adea02467898954c3a5811fd2dc140af14ef15b" +"checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" @@ -5530,18 +5538,18 @@ dependencies = [ "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" -"checksum cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "389803e36973d242e7fecb092b2de44a3d35ac62524b3b9339e51d577d668e02" +"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7fa24eb00d5ffab90eaeaf1092ac85c04c64aaf358ea6f84505b8116d24c6af" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a" +"checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" -"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa" +"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" "checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" @@ -5555,7 +5563,7 @@ dependencies = [ "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" +"checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" "checksum crypto-mac 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "779015233ac67d65098614aec748ac1c756ab6677fa2e14cf8b37c08dfed1198" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum csv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9044e25afb0924b5a5fc5511689b0918629e85d68ea591e5e87fbf1e85ea1b3b" @@ -5564,9 +5572,9 @@ dependencies = [ "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5531b7f0698d9220b4729f8811931dbe0e91a05be2f7b3245fdc50dd856bae26" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1f8a6fc0376eb52dc18af94915cc04dfdf8353746c0e8c550ae683a0815e5c1" +"checksum curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "750226d75fc2f5a8daec6e7477624e258674023eb73d8d647f63b943ca182a4a" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" -"checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" @@ -5578,7 +5586,7 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" "checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" -"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" +"checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d8013f441e38e31c670e7f34ec8f1d5d3a2bd9d303c1ff83976ca886005e8f48" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" @@ -5593,7 +5601,7 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981" +"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" @@ -5603,7 +5611,7 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4feaabe24a0a658fd9cf4a9acf6ed284f045c77df0f49020ba3245cfb7b454" -"checksum h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "85ab6286db06040ddefb71641b50017c06874614001a134b423783e2db2920bd" +"checksum h2 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "2b53def7bb0253af7718036fe9338c15defd209136819464384f3a553e07481b" "checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" "checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" @@ -5619,10 +5627,11 @@ dependencies = [ "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" +"checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" -"checksum hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)" = "df0caae6b71d266b91b4a83111a61d2b94ed2e2bea024c532b933dcff867e58c" -"checksum hyper 0.12.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4f2777434f26af6e4ce4fdcdccd3bed9d861d11e87bcbe72c0f51ddaca8ff848" +"checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" +"checksum hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)" = "e2cd6adf83b3347d36e271f030621a8cf95fd1fd0760546b9fc5a24a0f1447c7" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56" @@ -5632,8 +5641,8 @@ dependencies = [ "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3c994fd445b81741d77f6bcd227d6ed645b95b35a2ecfd2050767450ff1c0b6d" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc15eef5f8b6bef5ac5f7440a957ff95d036e2f98706947741bfc93d1976db4c" "checksum jsonrpc-derive 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c2dae61ca8a3b047fb11309b00661bc56837085bd07e46f907b9c562c0b03e68" "checksum jsonrpc-http-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d2a00824306155b8ef57fe957f31b8cd8ad24262f15cf911d84dcf9a3f206d" @@ -5649,7 +5658,7 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" +"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" "checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" @@ -5670,7 +5679,7 @@ dependencies = [ "checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" "checksum libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04451aa166aa2040293f44c1c27144b65500e4a2ebbb723dfe732f39436eccbd" "checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" -"checksum librocksdb-sys 5.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7dfb546562f9b450237bb8df7a31961849ee9fb1186d9e356db1d7a6b7609ff2" +"checksum librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c" @@ -5683,37 +5692,37 @@ dependencies = [ "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "83c2dda19c01176e8e7148f7bdb88bbdf215a8db0641f89fc40e4b81736aeda5" +"checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" -"checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" +"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f989d40aab0ed0d83c1cdb4856b5790e980b96548d1a921f280e985eb049f38d" "checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" -"checksum native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8e08de0070bbf4c31f452ea2a70db092f36f6f2e4d897adf5674477d488fb2" +"checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d138afcce92d219ccb6eb53d9b1e8a96ac0d633cfd3c53cd9856d96d1741bb8" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)" = "5a0d6b781aac4ac1bd6cafe2a2f0ad8c16ae8e1dd5184822a16c50139f8838d9" +"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)" = "33c86834957dd5b915623e94f2f4ab2c70dd8f6b70679824155d5ae21dbd495d" +"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a130a727008cfcd1068a28439fe939897ccad28664422aeca65b384d6de6d0" +"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" @@ -5733,12 +5742,12 @@ dependencies = [ "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" "checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" -"checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" +"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" -"checksum proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6a9bed9ebc40cf53e3a76d7486c54d05002eae6485b2711ab9104476fb2eb8bc" +"checksum proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1dd4172a1e1f96f709341418f49b11ea6c2d95d53dca08c0f74cbd332d9cf3" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" -"checksum proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)" = "ba92c84f814b3f9a44c5cfca7d2ad77fa10710867d2bbb1b3d175ab5f47daa12" -"checksum protobuf 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3959be8d6250192f80ef056c0a4aaaeaff8a25e904e6e7a0f5285cb1a061835f" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a151c11a92df0059d6ab446fafa3b21a1210aad4bc2293e1c946e8132b10db01" "checksum pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "efb0dcbddbb600f47a7098d33762a00552c671992171637f5bb310b37fe1f0e4" "checksum quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb6ccf8db7bbcb9c2eae558db5ab4f3da1c2a87e4e597ed394726bc8ea6ca1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -5752,7 +5761,7 @@ dependencies = [ "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" @@ -5773,27 +5782,27 @@ dependencies = [ "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d548a40fe17c3a77d54b82457b79fcc9b8a288d509ca20fbf5aa1dac386d22d6" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" +"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05" -"checksum security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6696852716b589dff9e886ff83778bb635150168e83afa8ac6b8a78cb82abc" +"checksum security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eee63d0f4a9ec776eeb30e220f0bc1e092c3ad744b2a379e3993070364d3adc2" +"checksum security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9636f8989cbf61385ae4824b98c1aaa54c994d7d8b41f11c601ed799f0549a56" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" -"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" +"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -"checksum sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34a5e54083ce2b934bf059fdf38e7330a154177e029ab6c4e18638f2f624053a" +"checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" @@ -5808,7 +5817,7 @@ dependencies = [ "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" -"checksum stdweb 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c1d5ac2f828b2877a6be60a51b8e3ebb57b56862b10be1a72676ca8900b69d" +"checksum stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c34362bb10ac1a9439674795cc0e1bdcb0c46444c8fd4874ef39a01d9a8a8f24" "checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" "checksum stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e68f7d08b76979a43e93fe043b66d2626e35d41d68b0b85519202c6dd8ac59fa" "checksum stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d52317523542cc0af5b7e31017ad0f7d1e78da50455e38d5657cd17754f617da" @@ -5822,13 +5831,13 @@ dependencies = [ "checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" -"checksum syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)" = "846620ec526c1599c070eff393bfeeeb88a93afa2513fc3b49f1fea84cf7b0ed" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum sysinfo 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a0cb7899e248ed0baa6ef6f8406352523c2f99bc7c4b1800f4cd6d5dde99eb" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" +"checksum sysinfo 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65f0e28a49b7bf142cee89befd7077b40627d7cc70aa8a8acfe03afc26016c33" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -"checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" +"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" @@ -5836,9 +5845,10 @@ dependencies = [ "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" -"checksum tinytemplate 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7655088894274afb52b807bd3c87072daa1fedd155068b8705cabfd628956115" +"checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" -"checksum tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cec6c34409089be085de9403ba2010b80e36938c9ca992c4f67f407bb13db0b1" +"checksum tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "94a1f9396aec29d31bb16c24d155cfa144d1af91c40740125db3131bdaf76da8" +"checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" @@ -5854,26 +5864,25 @@ dependencies = [ "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "87c5890a989fa47ecdc7bcb4c63a77a82c18f306714104b1decfd722db17b39e" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum trie-bench 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba20f7d9865497ea46511860b43e05a44f4ac9a76ee089d34cd80a839a690264" "checksum trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba73747fd3a64ab531274c04cb588dfa9d30d972d62990831e63fbce2cfec59" "checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9" -"checksum trie-standardmap 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4e24277af05f38f3aaf03ac78e3a154be83f13db9c8ef0cb95bb1aa764a477b" +"checksum trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ebaa4b340046196efad8872b2dffe585b5ea330230dc44ee14e399f77da29f51" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0b0df728de48978b759da185ed7ef76676ef0c878ae4800c9e90024c998dc75b" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" +"checksum twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7bcecad121018bdcd6b709fa2325b004878fcb3d3067934ce90749f0faff9a" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -"checksum unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41d17211f887da8e4a70a45b9536f26fc5de166b81e2d5d80de4a17fd22553bd" +"checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" @@ -5889,19 +5898,19 @@ dependencies = [ "checksum wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a6265b25719e82598d104b3717375e37661d41753e2c84cde3f51050c7ed7e3c" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" -"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4" -"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1" -"checksum wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad171fc1f6e43f97d155d27f4ee5657bd8aa5cce7c497ef3a0a0c5b44618b2d" -"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71" -"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" -"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" -"checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" +"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" +"checksum wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fa1af11c73eca3dc8c51c76ea475a4416e912da6402064a49fc6c0214701866d" +"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047" +"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6" +"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6" +"checksum wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1f42ff7adb8102bf5ad8adbc45b1635c520c8175f9fdf6eb2c54479d485d435a" "checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" "checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" -"checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" -"checksum websocket 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cc2d74d89f9df981ab41ae624e33cf302fdf456b93455c6a31911a99c9f0bb8" -"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" +"checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0adcd2a64c5746c9702b354a1b992802b0c363df1dfa324a74cb7aebe10e0cbf" +"checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" @@ -5915,7 +5924,7 @@ dependencies = [ "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" -"checksum yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9073f5dbc901abb0b2ec4f866e726fed2f54953bdf81f8a5fde7762b7cc3b3" +"checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" "checksum zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e68403b858b6af538b11614e62dfe9ab2facba9f13a0cafb974855cfb495ec95" "checksum zeroize_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3f07490820219949839d0027b965ffdd659d75be9220c00798762e36c6cd281" -- GitLab From 1ba2440b28f001855253028e40ce8f4080782060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 29 May 2019 16:06:49 +0200 Subject: [PATCH 058/113] Remove InherentsPool and introduce non-propagateable transactions. (#2695) * Remove InherentsPool. * Introduce transactions that are not propagated over the network. * Bump spec version. * Use separate flag for propagation. * Fix tests. --- Cargo.lock | 2 - core/basic-authorship/src/basic_authorship.rs | 46 +---------- core/inherents/src/lib.rs | 3 - core/inherents/src/pool.rs | 75 ------------------ core/offchain/Cargo.toml | 1 - core/offchain/src/api.rs | 9 +-- core/offchain/src/lib.rs | 16 ++-- core/service/Cargo.toml | 1 - core/service/src/components.rs | 2 +- core/service/src/lib.rs | 78 +++++++++++++++---- .../sr-primitives/src/transaction_validity.rs | 69 +++++++++++++++- core/test-runtime/src/lib.rs | 31 +++++++- core/test-runtime/src/system.rs | 1 + core/transaction-pool/graph/src/base_pool.rs | 69 +++++++++++++++- core/transaction-pool/graph/src/pool.rs | 4 +- core/transaction-pool/graph/src/ready.rs | 2 + core/transaction-pool/graph/src/rotator.rs | 2 + core/transaction-pool/src/tests.rs | 1 + node-template/src/service.rs | 1 - node/cli/src/service.rs | 1 - node/runtime/src/lib.rs | 2 +- srml/executive/src/lib.rs | 5 +- 22 files changed, 250 insertions(+), 171 deletions(-) delete mode 100644 core/inherents/src/pool.rs diff --git a/Cargo.lock b/Cargo.lock index 978af7a4ab..abd2e63f1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4238,7 +4238,6 @@ dependencies = [ "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", - "substrate-inherents 2.0.0", "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", @@ -4384,7 +4383,6 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-executor 2.0.0", "substrate-finality-grandpa 2.0.0", - "substrate-inherents 2.0.0", "substrate-keystore 2.0.0", "substrate-network 2.0.0", "substrate-offchain 2.0.0", diff --git a/core/basic-authorship/src/basic_authorship.rs b/core/basic-authorship/src/basic_authorship.rs index 62aad4c9c7..87d0b8f92b 100644 --- a/core/basic-authorship/src/basic_authorship.rs +++ b/core/basic-authorship/src/basic_authorship.rs @@ -20,7 +20,7 @@ // use std::{self, time, sync::Arc}; -use log::{info, debug, warn, trace}; +use log::{info, debug, trace}; use client::{ self, error, Client as SubstrateClient, CallExecutor, @@ -36,7 +36,7 @@ use runtime_primitives::traits::{ use runtime_primitives::generic::BlockId; use runtime_primitives::ApplyError; use transaction_pool::txpool::{self, Pool as TransactionPool}; -use inherents::{InherentData, pool::InherentsPool}; +use inherents::InherentData; use substrate_telemetry::{telemetry, CONSENSUS_INFO}; /// Build new blocks. @@ -119,8 +119,6 @@ pub struct ProposerFactory where A: txpool::ChainApi { pub client: Arc, /// The transaction pool. pub transaction_pool: Arc>, - /// The inherents pool - pub inherents_pool: Arc::Extrinsic>>, } impl consensus_common::Environment<::Block> for ProposerFactory where @@ -150,7 +148,6 @@ impl consensus_common::Environment<::Block> for Propose parent_id: id, parent_number: *parent_header.number(), transaction_pool: self.transaction_pool.clone(), - inherents_pool: self.inherents_pool.clone(), now: Box::new(time::Instant::now), }; @@ -165,7 +162,6 @@ pub struct Proposer { parent_id: BlockId, parent_number: <::Header as HeaderT>::Number, transaction_pool: Arc>, - inherents_pool: Arc::Extrinsic>>, now: Box time::Instant>, } @@ -218,14 +214,6 @@ impl Proposer where inherent_data, inherent_digests.clone(), |block_builder| { - // Add inherents from the internal pool - let inherents = self.inherents_pool.drain(); - debug!("Pushing {} queued inherent extrinsics.", inherents.len()); - for i in inherents { - if let Err(e) = block_builder.push_extrinsic(i) { - warn!("Error while pushing inherent extrinsic from the pool: {:?}", e); - } - } // proceed with transactions let mut is_first = true; let mut skipped = 0; @@ -328,7 +316,6 @@ mod tests { let proposer_factory = ProposerFactory { client: client.clone(), transaction_pool: txpool.clone(), - inherents_pool: Default::default(), }; let mut proposer = proposer_factory.init( @@ -350,33 +337,4 @@ mod tests { assert_eq!(block.extrinsics().len(), 1); assert_eq!(txpool.ready().count(), 2); } - - #[test] - fn should_include_inherents_from_the_pool() { - // given - let client = Arc::new(test_client::new()); - let chain_api = transaction_pool::ChainApi::new(client.clone()); - let txpool = Arc::new(TransactionPool::new(Default::default(), chain_api)); - let inpool = Arc::new(InherentsPool::default()); - - let proposer_factory = ProposerFactory { - client: client.clone(), - transaction_pool: txpool.clone(), - inherents_pool: inpool.clone(), - }; - - inpool.add(extrinsic(0)); - - let proposer = proposer_factory.init( - &client.header(&BlockId::number(0)).unwrap().unwrap(), - &[] - ).unwrap(); - - // when - let deadline = time::Duration::from_secs(3); - let block = proposer.propose(Default::default(), Default::default(), deadline).unwrap(); - - // then - assert_eq!(block.extrinsics().len(), 1); - } } diff --git a/core/inherents/src/lib.rs b/core/inherents/src/lib.rs index e851959ee0..7b99c7ba52 100644 --- a/core/inherents/src/lib.rs +++ b/core/inherents/src/lib.rs @@ -44,9 +44,6 @@ use parking_lot::RwLock; #[cfg(feature = "std")] use std::{sync::Arc, format}; -#[cfg(feature = "std")] -pub mod pool; - pub use runtime_primitives::RuntimeString; /// An identifier for an inherent. diff --git a/core/inherents/src/pool.rs b/core/inherents/src/pool.rs deleted file mode 100644 index 2c7e953696..0000000000 --- a/core/inherents/src/pool.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Inherents Pool - -use std::{fmt, mem, vec}; -use parking_lot::Mutex; - -/// Inherents Pool -/// -/// The pool is responsible to collect inherents asynchronously generated -/// by some other parts of the code and make them ready for the next block production. -pub struct InherentsPool { - data: Mutex>, -} - -impl Default for InherentsPool { - fn default() -> Self { - InherentsPool { - data: Default::default(), - } - } -} - -impl fmt::Debug for InherentsPool { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let mut builder = fmt.debug_struct("InherentsPool"); - if let Some(data) = self.data.try_lock() { - builder.field("data", &*data); - } - builder.finish() - } -} - -impl InherentsPool { - /// Add inherent extrinsic to the pool. - /// - /// This inherent will be appended to the next produced block. - pub fn add(&self, extrinsic: T) { - self.data.lock().push(extrinsic); - } - - /// Drain all currently queued inherents. - pub fn drain(&self) -> Vec { - mem::replace(&mut *self.data.lock(), vec![]) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn should_drain_inherents_to_given_data() { - let pool = InherentsPool::default(); - pool.add(5); - pool.add(7); - - assert_eq!(pool.drain(), vec![5, 7]); - assert_eq!(pool.drain(), vec![]); - } -} diff --git a/core/offchain/Cargo.toml b/core/offchain/Cargo.toml index 241edfea9f..14341e2458 100644 --- a/core/offchain/Cargo.toml +++ b/core/offchain/Cargo.toml @@ -10,7 +10,6 @@ edition = "2018" client = { package = "substrate-client", path = "../../core/client" } consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common" } futures = "0.1.25" -inherents = { package = "substrate-inherents", path = "../../core/inherents" } log = "0.4" offchain-primitives = { package = "substrate-offchain-primitives", path = "./primitives" } parity-codec = { version = "3.3", features = ["derive"] } diff --git a/core/offchain/src/api.rs b/core/offchain/src/api.rs index 5d2a636be3..25a8a2ebaa 100644 --- a/core/offchain/src/api.rs +++ b/core/offchain/src/api.rs @@ -16,7 +16,6 @@ use std::sync::Arc; use futures::{Stream, Future, sync::mpsc}; -use inherents::pool::InherentsPool; use log::{info, debug, warn}; use parity_codec::Decode; use primitives::OffchainExt; @@ -46,21 +45,18 @@ impl OffchainExt for AsyncApi { pub(crate) struct Api { receiver: Option>, transaction_pool: Arc>, - inherents_pool: Arc::Extrinsic>>, at: BlockId, } impl Api { pub fn new( transaction_pool: Arc>, - inherents_pool: Arc::Extrinsic>>, at: BlockId, ) -> (AsyncApi, Self) { let (tx, rx) = mpsc::unbounded(); let api = Self { receiver: Some(rx), transaction_pool, - inherents_pool, at, }; (AsyncApi(tx), api) @@ -90,9 +86,8 @@ impl Api { info!("Submitting to the pool: {:?} (isSigned: {:?})", xt, xt.is_signed()); match self.transaction_pool.submit_one(&self.at, xt.clone()) { Ok(hash) => debug!("[{:?}] Offchain transaction added to the pool.", hash), - Err(_) => { - debug!("Offchain inherent added to the pool."); - self.inherents_pool.add(xt); + Err(e) => { + debug!("Couldn't submit transaction: {:?}", e); }, } } diff --git a/core/offchain/src/lib.rs b/core/offchain/src/lib.rs index cac960f250..f176fadd0d 100644 --- a/core/offchain/src/lib.rs +++ b/core/offchain/src/lib.rs @@ -19,8 +19,8 @@ //! The offchain workers is a special function of the runtime that //! gets executed after block is imported. During execution //! it's able to asynchronously submit extrinsics that will either -//! be propagated to other nodes (transactions) or will be -//! added to the next block produced by the node as inherents. +//! be propagated to other nodes added to the next block +//! produced by the node as unsigned transactions. //! //! Offchain workers can be used for computation-heavy tasks //! that are not feasible for execution during regular block processing. @@ -39,7 +39,6 @@ use std::{ }; use client::runtime_api::ApiExt; -use inherents::pool::InherentsPool; use log::{debug, warn}; use primitives::ExecutionContext; use runtime_primitives::{ @@ -57,7 +56,6 @@ pub use offchain_primitives::OffchainWorkerApi; #[derive(Debug)] pub struct OffchainWorkers { client: Arc, - inherents_pool: Arc::Extrinsic>>, executor: TaskExecutor, _block: PhantomData, } @@ -66,12 +64,10 @@ impl OffchainWorkers { /// Creates new `OffchainWorkers`. pub fn new( client: Arc, - inherents_pool: Arc::Extrinsic>>, executor: TaskExecutor, ) -> Self { Self { client, - inherents_pool, executor, _block: PhantomData, } @@ -97,7 +93,7 @@ impl OffchainWorkers where debug!("Checking offchain workers at {:?}: {:?}", at, has_api); if has_api.unwrap_or(false) { - let (api, runner) = api::Api::new(pool.clone(), self.inherents_pool.clone(), at.clone()); + let (api, runner) = api::Api::new(pool.clone(), at.clone()); self.executor.spawn(runner.process()); debug!("Running offchain workers at {:?}", at); @@ -119,14 +115,14 @@ mod tests { let runtime = tokio::runtime::Runtime::new().unwrap(); let client = Arc::new(test_client::new()); let pool = Arc::new(Pool::new(Default::default(), ::transaction_pool::ChainApi::new(client.clone()))); - let inherents = Arc::new(InherentsPool::default()); // when - let offchain = OffchainWorkers::new(client, inherents.clone(), runtime.executor()); + let offchain = OffchainWorkers::new(client, runtime.executor()); offchain.on_block_imported(&0u64, &pool); // then runtime.shutdown_on_idle().wait().unwrap(); - assert_eq!(inherents.drain().len(), 1); + assert_eq!(pool.status().ready, 1); + assert_eq!(pool.ready().next().unwrap().is_propagateable(), false); } } diff --git a/core/service/Cargo.toml b/core/service/Cargo.toml index bf13a51fac..89804166d6 100644 --- a/core/service/Cargo.toml +++ b/core/service/Cargo.toml @@ -16,7 +16,6 @@ exit-future = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" target_info = "0.1" -inherents = { package = "substrate-inherents", path = "../../core/inherents" } keystore = { package = "substrate-keystore", path = "../../core/keystore" } sr-io = { path = "../../core/sr-io" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 0d9d7dcdfc..3876279cc7 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -635,7 +635,7 @@ mod tests { use super::*; use consensus_common::BlockOrigin; use client::LongestChain; - use substrate_test_client::{self, TestClient, AccountKeyring, runtime::Transfer}; + use substrate_test_client::{TestClient, AccountKeyring, runtime::Transfer}; #[test] fn should_remove_transactions_from_the_pool() { diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 1eb59872ce..cb65ece34e 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -34,7 +34,6 @@ use parking_lot::Mutex; use client::BlockchainEvents; use exit_future::Signal; use futures::prelude::*; -use inherents::pool::InherentsPool; use keystore::Store as Keystore; use log::{info, warn, debug}; use parity_codec::{Encode, Decode}; @@ -76,7 +75,6 @@ pub struct Service { select_chain: Option<::SelectChain>, network: Option>>, transaction_pool: Arc>, - inherents_pool: Arc>>, keystore: Keystore, exit: ::exit_future::Exit, signal: Option, @@ -211,11 +209,9 @@ impl Service { .select(exit.clone()) .then(|_| Ok(()))); - let inherents_pool = Arc::new(InherentsPool::default()); let offchain_workers = if config.offchain_worker { Some(Arc::new(offchain::OffchainWorkers::new( client.clone(), - inherents_pool.clone(), task_executor.clone(), ))) } else { @@ -381,7 +377,6 @@ impl Service { network: Some(network), select_chain, transaction_pool, - inherents_pool, signal: Some(signal), keystore, config, @@ -433,11 +428,6 @@ impl Service where Components: components::Components { self.transaction_pool.clone() } - /// Get shared inherents pool instance. - pub fn inherents_pool(&self) -> Arc>> { - self.inherents_pool.clone() - } - /// Get shared keystore. pub fn keystore(&self) -> &Keystore { &self.keystore @@ -498,17 +488,32 @@ impl TransactionPoolAdapter { } } +/// Get transactions for propagation. +/// +/// Function extracted to simplify the test and prevent creating `ServiceFactory`. +fn transactions_to_propagate(pool: &TransactionPool) + -> Vec<(H, B::Extrinsic)> +where + PoolApi: ChainApi, + B: BlockT, + H: std::hash::Hash + Eq + runtime_primitives::traits::Member + serde::Serialize, + E: txpool::error::IntoPoolError + From, +{ + pool.ready() + .filter(|t| t.is_propagateable()) + .map(|t| { + let hash = t.hash.clone(); + let ex: B::Extrinsic = t.data.clone(); + (hash, ex) + }) + .collect() +} + impl network::TransactionPool, ComponentBlock> for TransactionPoolAdapter where ::RuntimeApi: Send + Sync { fn transactions(&self) -> Vec<(ComponentExHash, ComponentExtrinsic)> { - self.pool.ready() - .map(|t| { - let hash = t.hash.clone(); - let ex: ComponentExtrinsic = t.data.clone(); - (hash, ex) - }) - .collect() + transactions_to_propagate(&self.pool) } fn import(&self, transaction: &ComponentExtrinsic) -> Option> { @@ -745,3 +750,42 @@ macro_rules! construct_service_factory { } } } + +#[cfg(test)] +mod tests { + use super::*; + use client::LongestChain; + use consensus_common::SelectChain; + use runtime_primitives::traits::BlindCheckable; + use substrate_test_client::{AccountKeyring, runtime::{Extrinsic, Transfer}}; + + #[test] + fn should_not_propagate_transactions_that_are_marked_as_such() { + // given + let client = Arc::new(substrate_test_client::new()); + let pool = Arc::new(TransactionPool::new( + Default::default(), + transaction_pool::ChainApi::new(client.clone()) + )); + let best = LongestChain::new(client.backend().clone(), client.import_lock()) + .best_chain().unwrap(); + let transaction = Transfer { + amount: 5, + nonce: 0, + from: AccountKeyring::Alice.into(), + to: Default::default(), + }.into_signed_tx(); + pool.submit_one(&BlockId::hash(best.hash()), transaction.clone()).unwrap(); + pool.submit_one(&BlockId::hash(best.hash()), Extrinsic::IncludeData(vec![1])).unwrap(); + assert_eq!(pool.status().ready, 2); + + // when + let transactions = transactions_to_propagate(&pool); + + // then + assert_eq!(transactions.len(), 1); + assert!(transactions[0].1.clone().check().is_ok()); + // this should not panic + let _ = transactions[0].1.transfer(); + } +} diff --git a/core/sr-primitives/src/transaction_validity.rs b/core/sr-primitives/src/transaction_validity.rs index 29d2a82a24..f36599b67b 100644 --- a/core/sr-primitives/src/transaction_validity.rs +++ b/core/sr-primitives/src/transaction_validity.rs @@ -30,7 +30,7 @@ pub type TransactionLongevity = u64; pub type TransactionTag = Vec; /// Information on a transaction's validity and, if valid, on how it relates to other transactions. -#[derive(Clone, PartialEq, Eq, Encode, Decode)] +#[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Debug))] pub enum TransactionValidity { /// Transaction is invalid. Details are described by the error code. @@ -59,7 +59,74 @@ pub enum TransactionValidity { /// Longevity describes minimum number of blocks the validity is correct. /// After this period transaction should be removed from the pool or revalidated. longevity: TransactionLongevity, + /// A flag indicating if the transaction should be propagated to other peers. + /// + /// By setting `false` here the transaction will still be considered for + /// including in blocks that are authored on the current node, but will + /// never be sent to other peers. + propagate: bool, }, /// Transaction validity can't be determined. Unknown(i8), } + +impl Decode for TransactionValidity { + fn decode(value: &mut I) -> Option { + match value.read_byte()? { + 0 => Some(TransactionValidity::Invalid(i8::decode(value)?)), + 1 => { + let priority = TransactionPriority::decode(value)?; + let requires = Vec::decode(value)?; + let provides = Vec::decode(value)?; + let longevity = TransactionLongevity::decode(value)?; + let propagate = bool::decode(value).unwrap_or(true); + + Some(TransactionValidity::Valid { + priority, requires, provides, longevity, propagate, + }) + }, + 2 => Some(TransactionValidity::Unknown(i8::decode(value)?)), + _ => None, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn should_decode_with_backward_compat() { + let old_encoding = vec![ + 1, 5, 0, 0, 0, 0, 0, 0, 0, 4, 16, 1, 2, 3, 4, 4, 12, 4, 5, 6, 42, 0, 0, 0, 0, 0, 0, 0 + ]; + + assert_eq!(TransactionValidity::decode(&mut &*old_encoding), Some(TransactionValidity::Valid { + priority: 5, + requires: vec![vec![1, 2, 3, 4]], + provides: vec![vec![4, 5, 6]], + longevity: 42, + propagate: true, + })); + } + + #[test] + fn should_encode_and_decode() { + let v = TransactionValidity::Valid { + priority: 5, + requires: vec![vec![1, 2, 3, 4]], + provides: vec![vec![4, 5, 6]], + longevity: 42, + propagate: false, + }; + + let encoded = v.encode(); + assert_eq!( + encoded, + vec![1, 5, 0, 0, 0, 0, 0, 0, 0, 4, 16, 1, 2, 3, 4, 4, 12, 4, 5, 6, 42, 0, 0, 0, 0, 0, 0, 0, 0] + ); + + // decode back + assert_eq!(TransactionValidity::decode(&mut &*encoded), Some(v)); + } +} diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index e7c6348495..980ce810e4 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -34,8 +34,9 @@ use substrate_client::{ impl_runtime_apis, }; use runtime_primitives::{ - ApplyResult, transaction_validity::TransactionValidity, + ApplyResult, create_runtime_str, + transaction_validity::TransactionValidity, traits::{ BlindCheckable, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, GetNodeBlockType, GetRuntimeBlockType, AuthorityIdFor, Verify, @@ -121,14 +122,18 @@ impl BlindCheckable for Extrinsic { Err(runtime_primitives::BAD_SIGNATURE) } }, - Extrinsic::IncludeData(data) => Ok(Extrinsic::IncludeData(data)), + Extrinsic::IncludeData(_) => Err(runtime_primitives::BAD_SIGNATURE), } } } impl ExtrinsicT for Extrinsic { fn is_signed(&self) -> Option { - Some(true) + if let Extrinsic::IncludeData(_) = *self { + Some(false) + } else { + Some(true) + } } } @@ -361,6 +366,16 @@ cfg_if! { impl client_api::TaggedTransactionQueue for Runtime { fn validate_transaction(utx: ::Extrinsic) -> TransactionValidity { + if let Extrinsic::IncludeData(data) = utx { + return TransactionValidity::Valid { + priority: data.len() as u64, + requires: vec![], + provides: vec![data], + longevity: 1, + propagate: false, + }; + } + system::validate_transaction(utx) } } @@ -499,6 +514,16 @@ cfg_if! { impl client_api::TaggedTransactionQueue for Runtime { fn validate_transaction(utx: ::Extrinsic) -> TransactionValidity { + if let Extrinsic::IncludeData(data) = utx { + return TransactionValidity::Valid { + priority: data.len() as u64, + requires: vec![], + provides: vec![data], + longevity: 1, + propagate: false, + }; + } + system::validate_transaction(utx) } } diff --git a/core/test-runtime/src/system.rs b/core/test-runtime/src/system.rs index d7dccd33be..491ca0db36 100644 --- a/core/test-runtime/src/system.rs +++ b/core/test-runtime/src/system.rs @@ -190,6 +190,7 @@ pub fn validate_transaction(utx: Extrinsic) -> TransactionValidity { requires, provides, longevity: 64, + propagate: true, } } diff --git a/core/transaction-pool/graph/src/base_pool.rs b/core/transaction-pool/graph/src/base_pool.rs index 74e499674a..b3a2cf0e54 100644 --- a/core/transaction-pool/graph/src/base_pool.rs +++ b/core/transaction-pool/graph/src/base_pool.rs @@ -100,6 +100,15 @@ pub struct Transaction { pub requires: Vec, /// Tags that this transaction provides. pub provides: Vec, + /// Should that transaction be propagated. + pub propagate: bool, +} + +impl Transaction { + /// Returns `true` if the transaction should be propagated to other peers. + pub fn is_propagateable(&self) -> bool { + self.propagate + } } impl fmt::Debug for Transaction where @@ -123,6 +132,7 @@ impl fmt::Debug for Transaction where write!(fmt, "priority: {:?}, ", &self.priority)?; write!(fmt, "valid_till: {:?}, ", &self.valid_till)?; write!(fmt, "bytes: {:?}, ", &self.bytes)?; + write!(fmt, "propagate: {:?}, ", &self.propagate)?; write!(fmt, "requires: [")?; print_tags(fmt, &self.requires)?; write!(fmt, "], provides: [")?; @@ -473,6 +483,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![1]], + propagate: true, }).unwrap(); // then @@ -494,6 +505,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![1]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![1u8], @@ -503,6 +515,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![1]], + propagate: true, }).unwrap_err(); // then @@ -525,6 +538,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![0]], provides: vec![vec![1]], + propagate: true, }).unwrap(); assert_eq!(pool.ready().count(), 0); assert_eq!(pool.ready.len(), 0); @@ -536,6 +550,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![0]], + propagate: true, }).unwrap(); // then @@ -557,6 +572,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![0]], provides: vec![vec![1]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![3u8], @@ -566,6 +582,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![2]], provides: vec![], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![2u8], @@ -575,6 +592,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![1]], provides: vec![vec![3], vec![2]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![4u8], @@ -584,6 +602,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![3], vec![4]], provides: vec![], + propagate: true, }).unwrap(); assert_eq!(pool.ready().count(), 0); assert_eq!(pool.ready.len(), 0); @@ -596,6 +615,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![0], vec![4]], + propagate: true, }).unwrap(); // then @@ -627,6 +647,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![0]], provides: vec![vec![1]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![3u8], @@ -636,6 +657,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![1]], provides: vec![vec![2]], + propagate: true, }).unwrap(); assert_eq!(pool.ready().count(), 0); assert_eq!(pool.ready.len(), 0); @@ -649,6 +671,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![2]], provides: vec![vec![0]], + propagate: true, }).unwrap(); // then @@ -668,6 +691,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![0]], + propagate: true, }).unwrap(); let mut it = pool.ready().into_iter().map(|tx| tx.data[0]); assert_eq!(it.next(), Some(4)); @@ -695,6 +719,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![0]], provides: vec![vec![1]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![3u8], @@ -704,6 +729,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![1]], provides: vec![vec![2]], + propagate: true, }).unwrap(); assert_eq!(pool.ready().count(), 0); assert_eq!(pool.ready.len(), 0); @@ -717,6 +743,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![2]], provides: vec![vec![0]], + propagate: true, }).unwrap(); // then @@ -736,6 +763,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![0]], + propagate: true, }).unwrap_err(); let mut it = pool.ready().into_iter().map(|tx| tx.data[0]); assert_eq!(it.next(), None); @@ -759,6 +787,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![0], vec![4]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![1u8], @@ -768,6 +797,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![0]], provides: vec![vec![1]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![3u8], @@ -777,6 +807,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![2]], provides: vec![], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![2u8], @@ -786,6 +817,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![1]], provides: vec![vec![3], vec![2]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![4u8], @@ -795,6 +827,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![3], vec![4]], provides: vec![], + propagate: true, }).unwrap(); // future pool.import(Transaction { @@ -805,6 +838,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![11]], provides: vec![], + propagate: true, }).unwrap(); assert_eq!(pool.ready().count(), 5); assert_eq!(pool.future.len(), 1); @@ -830,6 +864,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![0]], provides: vec![vec![100]], + propagate: true, }).unwrap(); // ready pool.import(Transaction { @@ -840,6 +875,7 @@ mod tests { valid_till: 64u64, requires: vec![], provides: vec![vec![1]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![2u8], @@ -849,6 +885,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![2]], provides: vec![vec![3]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![3u8], @@ -858,6 +895,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![1]], provides: vec![vec![2]], + propagate: true, }).unwrap(); pool.import(Transaction { data: vec![4u8], @@ -867,6 +905,7 @@ mod tests { valid_till: 64u64, requires: vec![vec![3], vec![2]], provides: vec![vec![4]], + propagate: true, }).unwrap(); assert_eq!(pool.ready().count(), 4); @@ -901,8 +940,36 @@ mod tests { valid_till: 64u64, requires: vec![vec![3], vec![2]], provides: vec![vec![4]], + propagate: true, }), - r#"Transaction { hash: 4, priority: 1000, valid_till: 64, bytes: 1, requires: [03,02], provides: [04], data: [4]}"#.to_owned() + "Transaction { \ +hash: 4, priority: 1000, valid_till: 64, bytes: 1, propagate: true, \ +requires: [03,02], provides: [04], data: [4]}".to_owned() ); } + + #[test] + fn transaction_propagation() { + assert_eq!(Transaction { + data: vec![4u8], + bytes: 1, + hash: 4, + priority: 1_000u64, + valid_till: 64u64, + requires: vec![vec![3], vec![2]], + provides: vec![vec![4]], + propagate: true, + }.is_propagateable(), true); + + assert_eq!(Transaction { + data: vec![4u8], + bytes: 1, + hash: 4, + priority: 1_000u64, + valid_till: 64u64, + requires: vec![vec![3], vec![2]], + provides: vec![vec![4]], + propagate: false, + }.is_propagateable(), false); + } } diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index a5b7a3d2aa..61e234f156 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -129,7 +129,7 @@ impl Pool { } match self.api.validate_transaction(at, xt.clone())? { - TransactionValidity::Valid { priority, requires, provides, longevity } => { + TransactionValidity::Valid { priority, requires, provides, longevity, propagate } => { Ok(base::Transaction { data: xt, bytes, @@ -137,6 +137,7 @@ impl Pool { priority, requires, provides, + propagate, valid_till: block_number .saturated_into::() .saturating_add(longevity), @@ -491,6 +492,7 @@ mod tests { requires: if nonce > block_number { vec![vec![nonce as u8 - 1]] } else { vec![] }, provides: vec![vec![nonce as u8]], longevity: 3, + propagate: true, }) } } diff --git a/core/transaction-pool/graph/src/ready.rs b/core/transaction-pool/graph/src/ready.rs index ca3d7322cc..3497c1bc4b 100644 --- a/core/transaction-pool/graph/src/ready.rs +++ b/core/transaction-pool/graph/src/ready.rs @@ -499,6 +499,7 @@ mod tests { valid_till: 2, requires: vec![vec![1], vec![2]], provides: vec![vec![3], vec![4]], + propagate: true, } } @@ -558,6 +559,7 @@ mod tests { valid_till: u64::max_value(), // use the max_value() here for testing. requires: vec![tx1.provides[0].clone()], provides: vec![], + propagate: true, }; // when diff --git a/core/transaction-pool/graph/src/rotator.rs b/core/transaction-pool/graph/src/rotator.rs index 2ca51ef74e..41c1b5842a 100644 --- a/core/transaction-pool/graph/src/rotator.rs +++ b/core/transaction-pool/graph/src/rotator.rs @@ -120,6 +120,7 @@ mod tests { valid_till: 1, requires: vec![], provides: vec![], + propagate: true, }; (hash, tx) @@ -185,6 +186,7 @@ mod tests { valid_till, requires: vec![], provides: vec![], + propagate: true, } } diff --git a/core/transaction-pool/src/tests.rs b/core/transaction-pool/src/tests.rs index cab44f49cc..a1ee4a50df 100644 --- a/core/transaction-pool/src/tests.rs +++ b/core/transaction-pool/src/tests.rs @@ -53,6 +53,7 @@ impl txpool::ChainApi for TestApi { requires, provides, longevity: 64, + propagate: true, }) } diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 48e26d1ca5..934cf87b9c 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -71,7 +71,6 @@ construct_service_factory! { let proposer = Arc::new(ProposerFactory { client: service.client(), transaction_pool: service.transaction_pool(), - inherents_pool: service.inherents_pool(), }); let client = service.client(); let select_chain = service.select_chain() diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index bb1c257155..e717166cd6 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -87,7 +87,6 @@ construct_service_factory! { let proposer = Arc::new(substrate_basic_authorship::ProposerFactory { client: service.client(), transaction_pool: service.transaction_pool(), - inherents_pool: service.inherents_pool(), }); let client = service.client(); diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 6bc118bdc0..86c73307b8 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 88, - impl_version: 89, + impl_version: 90, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/executive/src/lib.rs b/srml/executive/src/lib.rs index 70285f7dfa..d1c22fcb6a 100644 --- a/srml/executive/src/lib.rs +++ b/srml/executive/src/lib.rs @@ -358,6 +358,7 @@ where requires, provides, longevity: TransactionLongevity::max_value(), + propagate: true, } }, (None, None) => UnsignedValidator::validate_unsigned(&xt.deconstruct().0), @@ -432,6 +433,7 @@ mod tests { requires: vec![], provides: vec![], longevity: std::u64::MAX, + propagate: false, }, _ => TransactionValidity::Invalid(0), } @@ -569,7 +571,8 @@ mod tests { priority: 0, requires: vec![], provides: vec![], - longevity: 18446744073709551615 + longevity: 18446744073709551615, + propagate: false, }; let mut t = new_test_ext(); -- GitLab From 58c3bbc40c2fb62b470cef2d2318d348f522dfad Mon Sep 17 00:00:00 2001 From: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> Date: Wed, 29 May 2019 10:07:01 -0400 Subject: [PATCH 059/113] Update runtime dependencies (#2721) --- core/executor/wasm/Cargo.lock | 94 +-- core/test-runtime/wasm/Cargo.lock | 964 +++++++++++++------------ node-template/runtime/wasm/Cargo.lock | 980 +++++++++++++------------- node/runtime/wasm/Cargo.lock | 967 ++++++++++++------------- 4 files changed, 1543 insertions(+), 1462 deletions(-) diff --git a/core/executor/wasm/Cargo.lock b/core/executor/wasm/Cargo.lock index b2d77765f7..34cd17116c 100644 --- a/core/executor/wasm/Cargo.lock +++ b/core/executor/wasm/Cargo.lock @@ -2,10 +2,10 @@ # It is not intended for manual editing. [[package]] name = "arrayvec" -version = "0.4.7" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -20,12 +20,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crunchy" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -33,15 +33,15 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -54,7 +54,7 @@ dependencies = [ [[package]] name = "nodrop" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -70,7 +70,7 @@ name = "parity-codec" version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -79,33 +79,33 @@ name = "parity-codec-derive" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primitive-types" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro-crate" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro2" -version = "0.4.19" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -113,10 +113,10 @@ dependencies = [ [[package]] name = "quote" -version = "0.6.8" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -156,14 +156,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.79" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "sr-io" version = "2.0.0" dependencies = [ - "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", @@ -197,40 +197,40 @@ name = "substrate-primitives" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", ] [[package]] name = "syn" -version = "0.15.26" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "toml" -version = "0.4.10" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uint" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -240,29 +240,29 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" -"checksum fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a557e80084b05c32b455963ff565a9de6f2866da023d6671705c6aff6f65e01c" -"checksum hash-db 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07463834729d0ce8d475e7dd6d302e407093ad9a9c02d77eb07fb74b5373829d" -"checksum hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1224388a21c88a80ae7087a2a245ca6d80acc97a9186b75789fb3eeefd0609af" +"checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +"checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" +"checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" +"checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" -"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99d5a5fe9d93ddb394e2fb3fc49d0e31acb475fd45a30eeb8f3e76b767ecb7e1" -"checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" -"checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" -"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" +"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" +"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91bb295c2c53c54742a6b8acb705114f6dfdf3c42becdb146a662cb77fcc0d02" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" +"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index 8439721da3..2f05852a50 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -33,7 +33,7 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.6.10" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -44,12 +44,12 @@ name = "aio-limited" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -79,7 +79,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -87,27 +87,26 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.14" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -115,8 +114,8 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -174,10 +173,10 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -193,7 +192,7 @@ dependencies = [ [[package]] name = "block-padding" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,7 +205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bumpalo" -version = "2.4.1" +version = "2.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -245,12 +244,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.30" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -258,8 +257,8 @@ name = "chrono" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -268,7 +267,7 @@ name = "clear_on_drop" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -289,7 +288,7 @@ name = "crossbeam" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -341,7 +340,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -355,7 +354,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -375,7 +374,7 @@ name = "crossbeam-utils" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -383,7 +382,7 @@ name = "crossbeam-utils" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -394,7 +393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crunchy" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -435,14 +434,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -452,13 +451,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "derive_more" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -492,7 +491,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -500,7 +499,7 @@ dependencies = [ [[package]] name = "either" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -519,7 +518,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -533,7 +532,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -541,7 +540,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -550,10 +549,10 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -563,12 +562,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -613,7 +612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.25" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -621,7 +620,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -654,7 +653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -664,7 +663,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -674,10 +673,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -699,7 +698,7 @@ name = "heapsize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -707,7 +706,7 @@ name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -717,16 +716,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hex-literal" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hex-literal-impl" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -798,7 +797,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "impl-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -811,21 +818,21 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -863,7 +870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.50" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -872,7 +879,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -886,17 +893,17 @@ dependencies = [ "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -912,22 +919,22 @@ dependencies = [ "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -942,7 +949,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -950,7 +957,7 @@ name = "libp2p-dns" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -966,9 +973,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -983,12 +990,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1008,13 +1015,13 @@ dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1031,11 +1038,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1052,7 +1059,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1067,17 +1074,17 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1088,10 +1095,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1105,7 +1112,7 @@ name = "libp2p-plaintext" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1117,40 +1124,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-secio" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1159,7 +1166,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1173,7 +1180,7 @@ name = "libp2p-uds" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1181,16 +1188,16 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1198,11 +1205,11 @@ name = "libp2p-yamux" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1232,7 +1239,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1267,7 +1274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "merlin" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1278,15 +1285,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.16" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1301,7 +1307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1311,8 +1317,8 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1332,7 +1338,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1345,9 +1351,9 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1371,23 +1377,27 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.39" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1410,26 +1420,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.10.19" +version = "0.10.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.9.42" +version = "0.9.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1461,7 +1471,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1469,15 +1479,15 @@ name = "parity-codec-derive" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multiaddr" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1485,24 +1495,30 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multihash" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-send-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "parity-wasm" version = "0.31.3" @@ -1543,10 +1559,10 @@ name = "parking_lot_core" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1554,11 +1570,11 @@ name = "parking_lot_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1566,31 +1582,31 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "paste" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "paste-impl" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1615,21 +1631,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "primitive-types" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro-crate" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1642,12 +1658,12 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1657,7 +1673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.27" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1665,7 +1681,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.4.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1683,7 +1699,7 @@ name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1691,7 +1707,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1701,10 +1717,10 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1714,9 +1730,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1724,17 +1740,17 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1742,7 +1758,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1777,12 +1793,12 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1792,10 +1808,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1803,7 +1819,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1821,7 +1837,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1832,7 +1848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1846,7 +1862,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.51" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1854,24 +1870,24 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1882,17 +1898,17 @@ name = "ring" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1910,17 +1926,17 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1933,36 +1949,19 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.0.0" -source = "git+https://github.com/w3f/schnorrkel#3179838da9dd4896c12bb910e7c42477a3250641" -dependencies = [ - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "schnorrkel" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1990,20 +1989,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2011,9 +2010,20 @@ name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sha-1" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2038,7 +2048,7 @@ name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2046,10 +2056,10 @@ dependencies = [ [[package]] name = "sha3" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2086,7 +2096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2120,7 +2130,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2138,10 +2148,10 @@ name = "sr-api-macros" version = "2.0.0" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2166,9 +2176,9 @@ version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2187,7 +2197,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -2197,7 +2207,7 @@ name = "srml-executive" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2210,7 +2220,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -2222,8 +2232,8 @@ dependencies = [ "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2236,31 +2246,31 @@ dependencies = [ name = "srml-support-procedural" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools" version = "2.0.0" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools-derive" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2269,7 +2279,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2311,19 +2321,19 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-bip39" -version = "0.2.0" -source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" +version = "0.2.1" +source = "git+https://github.com/paritytech/substrate-bip39#44307fda4ea17fe97aeb93af317fbc8f6ed34193" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2331,11 +2341,11 @@ dependencies = [ name = "substrate-client" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2391,24 +2401,25 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-consensus-slots" version = "2.0.0" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2417,7 +2428,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2425,7 +2436,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2439,7 +2450,7 @@ dependencies = [ "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2475,7 +2486,7 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2488,29 +2499,30 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", - "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", + "substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2520,6 +2532,7 @@ version = "2.0.0" dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", @@ -2537,7 +2550,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2550,11 +2563,11 @@ dependencies = [ name = "substrate-test-runtime" version = "2.0.0" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2600,27 +2613,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.33" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2642,9 +2655,9 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2661,9 +2674,9 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2693,31 +2706,32 @@ name = "tk-listen" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.16" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2728,17 +2742,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-current-thread" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2746,19 +2760,19 @@ name = "tokio-dns-unofficial" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2766,9 +2780,9 @@ name = "tokio-fs" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2777,7 +2791,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2787,25 +2801,25 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-sync" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2814,38 +2828,46 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-threadpool" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-timer" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-trace-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2854,9 +2876,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2868,11 +2890,11 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2881,10 +2903,10 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.10" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2919,7 +2941,7 @@ dependencies = [ [[package]] name = "twox-hash" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2937,11 +2959,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2964,7 +2986,7 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3018,75 +3040,75 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-futures" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3094,39 +3116,47 @@ name = "wasm-timer" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasmi" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasmi-validation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "weedle" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3139,7 +3169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3161,7 +3191,7 @@ name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3174,7 +3204,7 @@ name = "wincolor" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3187,9 +3217,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.19 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3207,21 +3237,21 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "yamux" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3240,15 +3270,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" +"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f10b352bc3fc08ae24dc5d2d3ddcac153678533986122dc283d747b12071000" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9893d63fc3b1c44231e667da6836a33f27d8b6b3bdc82f83da5dfd579d1b6528" "checksum asn1_der_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7f92edafad155aff997fa5b727c6429b91e996b5a5d62a2b0adbae1306b5fe" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" @@ -3257,19 +3287,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" -"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d" +"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -"checksum block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d75255892aeb580d3c566f213a2b6fdc1c66667839f45719ee1d30ebf2aea591" +"checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" -"checksum bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4639720be048090544634e0402490838995ccdc9d2fe648f528f30d3c33ae71f" +"checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" -"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" +"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -3285,19 +3315,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" +"checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" "checksum crypto-mac 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "779015233ac67d65098614aec748ac1c756ab6677fa2e14cf8b37c08dfed1198" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1f8a6fc0376eb52dc18af94915cc04dfdf8353746c0e8c550ae683a0815e5c1" +"checksum curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "750226d75fc2f5a8daec6e7477624e258674023eb73d8d647f63b943ca182a4a" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" -"checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" -"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" +"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" @@ -3305,14 +3335,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a557e80084b05c32b455963ff565a9de6f2866da023d6671705c6aff6f65e01c" +"checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" +"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" @@ -3320,14 +3350,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" "checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" -"checksum hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1224388a21c88a80ae7087a2a245ca6d80acc97a9186b75789fb3eeefd0609af" +"checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -"checksum hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "27455ce8b4a6666c87220e4b59c9a83995476bdadc10197905e61dbe906e36fa" -"checksum hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d340b6514f232f6db1bd16db65302a5278a04fef9ce867cb932e7e5fa21130a" +"checksum hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc2928beef125e519d69ae1baa8c37ea2e0d3848545217f6db0179c5eb1d639" +"checksum hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" @@ -3336,16 +3366,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56" +"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3c994fd445b81741d77f6bcd227d6ed645b95b35a2ecfd2050767450ff1c0b6d" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" +"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" "checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" "checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" @@ -3359,10 +3390,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" "checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" "checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" "checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" "checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" "checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" @@ -3372,8 +3403,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "83c2dda19c01176e8e7148f7bdb88bbdf215a8db0641f89fc40e4b81736aeda5" -"checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" +"checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" +"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -3382,21 +3413,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d138afcce92d219ccb6eb53d9b1e8a96ac0d633cfd3c53cd9856d96d1741bb8" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.19 (registry+https://github.com/rust-lang/crates.io-index)" = "84321fb9004c3bce5611188a644d6171f895fa2889d155927d528782edb21c5d" -"checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" +"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" +"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a130a727008cfcd1068a28439fe939897ccad28664422aeca65b384d6de6d0" -"checksum parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e8eab0287ccde7821e337a124dc5a4f1d6e4c25d10cc91e3f9361615dd95076" +"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" +"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" @@ -3404,18 +3436,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f50392d1265092fbee9273414cc40eb6d47d307bd66222c477bb8450c8504f9d" -"checksum paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3cd512fe3a55e8933b2dcad913e365639db86d512e4004c3084b86864d9467a" +"checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" +"checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99d5a5fe9d93ddb394e2fb3fc49d0e31acb475fd45a30eeb8f3e76b767ecb7e1" -"checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" +"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" +"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" -"checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" +"checksum proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1dd4172a1e1f96f709341418f49b11ea6c2d95d53dca08c0f74cbd332d9cf3" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -"checksum protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24d5d73d2b88fddb8b8141f2730d950d88772c940ac4f8f3e93230b9a99d92df" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a151c11a92df0059d6ab446fafa3b21a1210aad4bc2293e1c946e8132b10db01" "checksum quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb6ccf8db7bbcb9c2eae558db5ab4f3da1c2a87e4e597ed394726bc8ea6ca1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" @@ -3428,37 +3460,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" +"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" -"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" +"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" +"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d548a40fe17c3a77d54b82457b79fcc9b8a288d509ca20fbf5aa1dac386d22d6" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" +"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" -"checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" +"checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" -"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" +"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -"checksum sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34a5e54083ce2b934bf059fdf38e7330a154177e029ab6c4e18638f2f624053a" +"checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" @@ -3474,11 +3506,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" -"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" +"checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" -"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" @@ -3487,31 +3519,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" -"checksum tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fcaabb3cec70485d0df6e9454fe514393ad1c4070dee8915f11041e95630b230" +"checksum tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "94a1f9396aec29d31bb16c24d155cfa144d1af91c40740125db3131bdaf76da8" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" -"checksum tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c756b04680eea21902a46fca4e9f410a2332c04995af590e07ff262e2193a9a3" +"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" -"checksum tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30c6dbf2d1ad1de300b393910e8a3aa272b724a400b6531da03eed99e329fbf0" +"checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" -"checksum tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1bf2b9dac2a0509b5cfd1df5aa25eafacb616a42a491a13604d6bbeab4486363" +"checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "742e511f6ce2298aeb86fc9ea0d8df81c2388c6ebae3dc8a7316e8c9df0df801" -"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" +"checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" +"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +"checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba73747fd3a64ab531274c04cb588dfa9d30d972d62990831e63fbce2cfec59" "checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" +"checksum twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7bcecad121018bdcd6b709fa2325b004878fcb3d3067934ce90749f0faff9a" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91bb295c2c53c54742a6b8acb705114f6dfdf3c42becdb146a662cb77fcc0d02" +"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" @@ -3520,19 +3553,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4" -"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1" -"checksum wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad171fc1f6e43f97d155d27f4ee5657bd8aa5cce7c497ef3a0a0c5b44618b2d" -"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71" -"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" -"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" -"checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" +"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" +"checksum wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fa1af11c73eca3dc8c51c76ea475a4416e912da6402064a49fc6c0214701866d" +"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047" +"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6" +"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6" +"checksum wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1f42ff7adb8102bf5ad8adbc45b1635c520c8175f9fdf6eb2c54479d485d435a" "checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" -"checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d" -"checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" -"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" +"checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" +"checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" +"checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" @@ -3540,6 +3574,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -"checksum x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4aca1ba6bec2719576bd20dfe5b24d9359552e616d10bff257e50cd85f745d17" -"checksum yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9073f5dbc901abb0b2ec4f866e726fed2f54953bdf81f8a5fde7762b7cc3b3" +"checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" +"checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index c0d57e3fd9..2473762307 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -33,7 +33,7 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.6.10" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -44,12 +44,12 @@ name = "aio-limited" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -79,7 +79,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -87,27 +87,26 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.14" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -115,8 +114,8 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -174,10 +173,10 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -193,7 +192,7 @@ dependencies = [ [[package]] name = "block-padding" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,7 +205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bumpalo" -version = "2.4.1" +version = "2.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -245,12 +244,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.31" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -258,8 +257,8 @@ name = "chrono" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -268,7 +267,7 @@ name = "clear_on_drop" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -289,7 +288,7 @@ name = "crossbeam" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -341,7 +340,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -355,7 +354,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -375,7 +374,7 @@ name = "crossbeam-utils" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -383,7 +382,7 @@ name = "crossbeam-utils" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -394,7 +393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crunchy" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -435,14 +434,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -452,13 +451,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "derive_more" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -492,7 +491,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -500,7 +499,7 @@ dependencies = [ [[package]] name = "either" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -519,7 +518,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -533,7 +532,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -541,7 +540,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -550,10 +549,10 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -563,12 +562,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -613,7 +612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.25" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -621,7 +620,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -654,7 +653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -664,7 +663,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -674,10 +673,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -699,7 +698,7 @@ name = "heapsize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -707,7 +706,7 @@ name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -717,16 +716,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hex-literal" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hex-literal-impl" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -798,7 +797,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "impl-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -811,21 +818,21 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -863,7 +870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.50" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -872,7 +879,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -886,17 +893,17 @@ dependencies = [ "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -912,22 +919,22 @@ dependencies = [ "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -942,7 +949,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -950,7 +957,7 @@ name = "libp2p-dns" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -966,9 +973,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -983,12 +990,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1008,13 +1015,13 @@ dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1031,11 +1038,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1052,7 +1059,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1067,17 +1074,17 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1088,10 +1095,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1105,7 +1112,7 @@ name = "libp2p-plaintext" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1117,40 +1124,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-secio" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1159,7 +1166,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1173,7 +1180,7 @@ name = "libp2p-uds" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1181,16 +1188,16 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1198,11 +1205,11 @@ name = "libp2p-yamux" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1232,7 +1239,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1267,7 +1274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "merlin" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1278,15 +1285,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.16" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1301,7 +1307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1311,8 +1317,8 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1332,7 +1338,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1345,9 +1351,9 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1356,7 +1362,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -1405,23 +1411,27 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.39" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1444,26 +1454,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.10.19" +version = "0.10.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.9.42" +version = "0.9.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1495,7 +1505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1503,15 +1513,15 @@ name = "parity-codec-derive" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multiaddr" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1519,24 +1529,30 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multihash" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-send-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "parity-wasm" version = "0.31.3" @@ -1577,10 +1593,10 @@ name = "parking_lot_core" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1588,11 +1604,11 @@ name = "parking_lot_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1600,31 +1616,31 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "paste" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "paste-impl" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1649,21 +1665,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "primitive-types" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro-crate" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1676,12 +1692,12 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1691,7 +1707,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.27" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1699,7 +1715,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.4.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1717,7 +1733,7 @@ name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1725,7 +1741,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1735,10 +1751,10 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1748,9 +1764,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1758,17 +1774,17 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1776,7 +1792,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1811,12 +1827,12 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1826,10 +1842,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1837,7 +1853,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1855,7 +1871,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1866,7 +1882,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1880,7 +1896,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.51" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1888,24 +1904,24 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1916,17 +1932,17 @@ name = "ring" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1944,17 +1960,17 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1967,36 +1983,19 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.0.0" -source = "git+https://github.com/w3f/schnorrkel#0a0de4294b475ef6abdeebb50067f213ca79b3c7" -dependencies = [ - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "schnorrkel" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2024,20 +2023,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2045,9 +2044,20 @@ name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sha-1" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2072,7 +2082,7 @@ name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2080,10 +2090,10 @@ dependencies = [ [[package]] name = "sha3" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2120,7 +2130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2154,7 +2164,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2172,10 +2182,10 @@ name = "sr-api-macros" version = "2.0.0" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2200,9 +2210,9 @@ version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2221,7 +2231,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -2231,7 +2241,7 @@ name = "srml-aura" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", @@ -2248,7 +2258,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2261,7 +2271,7 @@ name = "srml-consensus" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2275,7 +2285,7 @@ name = "srml-executive" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2289,7 +2299,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2304,7 +2314,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -2315,7 +2325,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-consensus 2.0.0", @@ -2330,7 +2340,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2346,7 +2356,7 @@ name = "srml-sudo" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2362,8 +2372,8 @@ dependencies = [ "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2376,31 +2386,31 @@ dependencies = [ name = "srml-support-procedural" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools" version = "2.0.0" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools-derive" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2409,7 +2419,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2422,7 +2432,7 @@ name = "srml-timestamp" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2464,19 +2474,19 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-bip39" -version = "0.2.0" -source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" +version = "0.2.1" +source = "git+https://github.com/paritytech/substrate-bip39#44307fda4ea17fe97aeb93af317fbc8f6ed34193" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2484,11 +2494,11 @@ dependencies = [ name = "substrate-client" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2534,17 +2544,18 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2552,7 +2563,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2566,7 +2577,7 @@ dependencies = [ "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2602,7 +2613,7 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2615,29 +2626,30 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", - "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", - "tiny-bip39 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)", + "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2647,6 +2659,7 @@ version = "2.0.0" dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", @@ -2664,7 +2677,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2693,27 +2706,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.33" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2735,9 +2748,9 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2754,14 +2767,14 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tiny-bip39" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2786,31 +2799,32 @@ name = "tk-listen" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.16" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2821,17 +2835,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-current-thread" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2839,19 +2853,19 @@ name = "tokio-dns-unofficial" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2859,9 +2873,9 @@ name = "tokio-fs" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2870,7 +2884,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2880,25 +2894,25 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-sync" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2907,38 +2921,46 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-threadpool" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-timer" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-trace-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2947,9 +2969,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2961,11 +2983,11 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2974,10 +2996,10 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.10" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3012,7 +3034,7 @@ dependencies = [ [[package]] name = "twox-hash" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3030,11 +3052,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3057,7 +3079,7 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3111,75 +3133,75 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-futures" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3187,39 +3209,47 @@ name = "wasm-timer" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasmi" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasmi-validation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "weedle" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3232,7 +3262,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3254,7 +3284,7 @@ name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3267,7 +3297,7 @@ name = "wincolor" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3280,9 +3310,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.19 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3300,21 +3330,21 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "yamux" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3333,15 +3363,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" +"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f10b352bc3fc08ae24dc5d2d3ddcac153678533986122dc283d747b12071000" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9893d63fc3b1c44231e667da6836a33f27d8b6b3bdc82f83da5dfd579d1b6528" "checksum asn1_der_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7f92edafad155aff997fa5b727c6429b91e996b5a5d62a2b0adbae1306b5fe" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" @@ -3350,19 +3380,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" -"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d" +"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -"checksum block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d75255892aeb580d3c566f213a2b6fdc1c66667839f45719ee1d30ebf2aea591" +"checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" -"checksum bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4639720be048090544634e0402490838995ccdc9d2fe648f528f30d3c33ae71f" +"checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" -"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" +"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -3378,19 +3408,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" +"checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" "checksum crypto-mac 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "779015233ac67d65098614aec748ac1c756ab6677fa2e14cf8b37c08dfed1198" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1f8a6fc0376eb52dc18af94915cc04dfdf8353746c0e8c550ae683a0815e5c1" +"checksum curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "750226d75fc2f5a8daec6e7477624e258674023eb73d8d647f63b943ca182a4a" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" -"checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" -"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" +"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" @@ -3398,14 +3428,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a557e80084b05c32b455963ff565a9de6f2866da023d6671705c6aff6f65e01c" +"checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" +"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" @@ -3413,14 +3443,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" "checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" -"checksum hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1224388a21c88a80ae7087a2a245ca6d80acc97a9186b75789fb3eeefd0609af" +"checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -"checksum hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "27455ce8b4a6666c87220e4b59c9a83995476bdadc10197905e61dbe906e36fa" -"checksum hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d340b6514f232f6db1bd16db65302a5278a04fef9ce867cb932e7e5fa21130a" +"checksum hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc2928beef125e519d69ae1baa8c37ea2e0d3848545217f6db0179c5eb1d639" +"checksum hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" @@ -3429,16 +3459,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56" +"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3c994fd445b81741d77f6bcd227d6ed645b95b35a2ecfd2050767450ff1c0b6d" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" +"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" "checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" "checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" @@ -3452,10 +3483,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" "checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" "checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" "checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" "checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" "checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" @@ -3465,8 +3496,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "83c2dda19c01176e8e7148f7bdb88bbdf215a8db0641f89fc40e4b81736aeda5" -"checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" +"checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" +"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -3475,21 +3506,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d138afcce92d219ccb6eb53d9b1e8a96ac0d633cfd3c53cd9856d96d1741bb8" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.19 (registry+https://github.com/rust-lang/crates.io-index)" = "84321fb9004c3bce5611188a644d6171f895fa2889d155927d528782edb21c5d" -"checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" +"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" +"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a130a727008cfcd1068a28439fe939897ccad28664422aeca65b384d6de6d0" -"checksum parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e8eab0287ccde7821e337a124dc5a4f1d6e4c25d10cc91e3f9361615dd95076" +"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" +"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" @@ -3497,18 +3529,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f50392d1265092fbee9273414cc40eb6d47d307bd66222c477bb8450c8504f9d" -"checksum paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3cd512fe3a55e8933b2dcad913e365639db86d512e4004c3084b86864d9467a" +"checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" +"checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum primitive-types 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99d5a5fe9d93ddb394e2fb3fc49d0e31acb475fd45a30eeb8f3e76b767ecb7e1" -"checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" +"checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" +"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" -"checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" +"checksum proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1dd4172a1e1f96f709341418f49b11ea6c2d95d53dca08c0f74cbd332d9cf3" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -"checksum protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24d5d73d2b88fddb8b8141f2730d950d88772c940ac4f8f3e93230b9a99d92df" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a151c11a92df0059d6ab446fafa3b21a1210aad4bc2293e1c946e8132b10db01" "checksum quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb6ccf8db7bbcb9c2eae558db5ab4f3da1c2a87e4e597ed394726bc8ea6ca1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" @@ -3521,37 +3553,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" +"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" -"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" +"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" +"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d548a40fe17c3a77d54b82457b79fcc9b8a288d509ca20fbf5aa1dac386d22d6" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" +"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" -"checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" +"checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" -"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" +"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -"checksum sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34a5e54083ce2b934bf059fdf38e7330a154177e029ab6c4e18638f2f624053a" +"checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" @@ -3567,44 +3599,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" -"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" +"checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" -"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tiny-bip39 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5388a470627f97a01a6e13389ced797a42b1611f9de7e0f6ca705675ac55297" +"checksum tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" -"checksum tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fcaabb3cec70485d0df6e9454fe514393ad1c4070dee8915f11041e95630b230" +"checksum tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "94a1f9396aec29d31bb16c24d155cfa144d1af91c40740125db3131bdaf76da8" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" -"checksum tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c756b04680eea21902a46fca4e9f410a2332c04995af590e07ff262e2193a9a3" +"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" -"checksum tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30c6dbf2d1ad1de300b393910e8a3aa272b724a400b6531da03eed99e329fbf0" +"checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" -"checksum tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1bf2b9dac2a0509b5cfd1df5aa25eafacb616a42a491a13604d6bbeab4486363" +"checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "742e511f6ce2298aeb86fc9ea0d8df81c2388c6ebae3dc8a7316e8c9df0df801" -"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" +"checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" +"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +"checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba73747fd3a64ab531274c04cb588dfa9d30d972d62990831e63fbce2cfec59" "checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" +"checksum twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7bcecad121018bdcd6b709fa2325b004878fcb3d3067934ce90749f0faff9a" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum uint 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91bb295c2c53c54742a6b8acb705114f6dfdf3c42becdb146a662cb77fcc0d02" +"checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" @@ -3613,19 +3646,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4" -"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1" -"checksum wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad171fc1f6e43f97d155d27f4ee5657bd8aa5cce7c497ef3a0a0c5b44618b2d" -"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71" -"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" -"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" -"checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" +"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" +"checksum wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fa1af11c73eca3dc8c51c76ea475a4416e912da6402064a49fc6c0214701866d" +"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047" +"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6" +"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6" +"checksum wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1f42ff7adb8102bf5ad8adbc45b1635c520c8175f9fdf6eb2c54479d485d435a" "checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" -"checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d" -"checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" -"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" +"checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" +"checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" +"checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" @@ -3633,6 +3667,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -"checksum x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4aca1ba6bec2719576bd20dfe5b24d9359552e616d10bff257e50cd85f745d17" -"checksum yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9073f5dbc901abb0b2ec4f866e726fed2f54953bdf81f8a5fde7762b7cc3b3" +"checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" +"checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index f564b3eca2..58b59ba4fc 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -33,7 +33,7 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.6.10" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -44,12 +44,12 @@ name = "aio-limited" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -79,7 +79,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -87,27 +87,26 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.14" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -115,8 +114,8 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -174,10 +173,10 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -193,7 +192,7 @@ dependencies = [ [[package]] name = "block-padding" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,7 +205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bumpalo" -version = "2.4.1" +version = "2.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -245,12 +244,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.30" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -258,8 +257,8 @@ name = "chrono" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -268,7 +267,7 @@ name = "clear_on_drop" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -289,7 +288,7 @@ name = "crossbeam" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -341,7 +340,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -355,7 +354,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -375,7 +374,7 @@ name = "crossbeam-utils" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -383,7 +382,7 @@ name = "crossbeam-utils" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -394,7 +393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crunchy" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -435,14 +434,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -452,13 +451,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "derive_more" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -492,7 +491,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -500,7 +499,7 @@ dependencies = [ [[package]] name = "either" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -519,7 +518,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -533,7 +532,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -541,7 +540,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -550,10 +549,10 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -563,12 +562,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -613,7 +612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.25" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -621,7 +620,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -654,7 +653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -664,7 +663,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -674,10 +673,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -699,7 +698,7 @@ name = "heapsize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -707,7 +706,7 @@ name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -717,16 +716,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hex-literal" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hex-literal-impl" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -798,7 +797,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -806,7 +805,7 @@ name = "impl-serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -819,21 +818,21 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -871,7 +870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.50" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -880,7 +879,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -894,17 +893,17 @@ dependencies = [ "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -920,22 +919,22 @@ dependencies = [ "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -950,7 +949,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -958,7 +957,7 @@ name = "libp2p-dns" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -974,9 +973,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -991,12 +990,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,13 +1015,13 @@ dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1039,11 +1038,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1060,7 +1059,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1075,17 +1074,17 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1096,10 +1095,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1113,7 +1112,7 @@ name = "libp2p-plaintext" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1125,40 +1124,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-secio" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1167,7 +1166,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1181,7 +1180,7 @@ name = "libp2p-uds" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1189,16 +1188,16 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1206,11 +1205,11 @@ name = "libp2p-yamux" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1240,7 +1239,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1275,7 +1274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "merlin" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1286,15 +1285,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.16" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1309,7 +1307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1319,8 +1317,8 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1340,7 +1338,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1353,9 +1351,9 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1363,7 +1361,7 @@ name = "node-primitives" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -1378,7 +1376,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -1435,23 +1433,27 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.39" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1474,26 +1476,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.10.19" +version = "0.10.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.9.42" +version = "0.9.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1525,7 +1527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1533,15 +1535,15 @@ name = "parity-codec-derive" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multiaddr" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1549,24 +1551,30 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-multihash" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-send-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "parity-wasm" version = "0.31.3" @@ -1607,10 +1615,10 @@ name = "parking_lot_core" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1618,11 +1626,11 @@ name = "parking_lot_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1630,31 +1638,31 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "paste" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "paste-impl" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1682,7 +1690,7 @@ name = "primitive-types" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1690,10 +1698,10 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1706,12 +1714,12 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1721,7 +1729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.27" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1729,7 +1737,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.4.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1757,7 +1765,7 @@ name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1765,7 +1773,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1775,10 +1783,10 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1788,9 +1796,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1798,17 +1806,17 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1816,7 +1824,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1851,12 +1859,12 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1866,10 +1874,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1877,7 +1885,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1895,7 +1903,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1906,7 +1914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1920,7 +1928,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.51" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1928,24 +1936,24 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1956,17 +1964,17 @@ name = "ring" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1984,17 +1992,17 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2007,36 +2015,19 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.0.0" -source = "git+https://github.com/w3f/schnorrkel#3179838da9dd4896c12bb910e7c42477a3250641" -dependencies = [ - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "schnorrkel" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2064,20 +2055,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2085,9 +2076,20 @@ name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sha-1" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2112,7 +2114,7 @@ name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2120,10 +2122,10 @@ dependencies = [ [[package]] name = "sha3" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2160,7 +2162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2194,7 +2196,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2212,10 +2214,10 @@ name = "sr-api-macros" version = "2.0.0" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2240,9 +2242,9 @@ version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2256,7 +2258,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2272,7 +2274,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -2282,7 +2284,7 @@ name = "srml-aura" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", @@ -2299,7 +2301,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2312,7 +2314,7 @@ name = "srml-consensus" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2328,7 +2330,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-sandbox 2.0.0", @@ -2346,7 +2348,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2362,7 +2364,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2375,7 +2377,7 @@ name = "srml-executive" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2388,7 +2390,7 @@ name = "srml-finality-tracker" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2401,7 +2403,7 @@ name = "srml-grandpa" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-consensus 2.0.0", @@ -2419,7 +2421,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2434,7 +2436,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -2445,7 +2447,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-consensus 2.0.0", @@ -2460,7 +2462,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2476,7 +2478,7 @@ name = "srml-sudo" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2492,8 +2494,8 @@ dependencies = [ "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2506,31 +2508,31 @@ dependencies = [ name = "srml-support-procedural" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools" version = "2.0.0" dependencies = [ - "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "srml-support-procedural-tools-derive" version = "2.0.0" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2539,7 +2541,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2552,7 +2554,7 @@ name = "srml-timestamp" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", @@ -2565,7 +2567,7 @@ name = "srml-treasury" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-balances 2.0.0", @@ -2607,19 +2609,19 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-bip39" -version = "0.2.0" -source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" +version = "0.2.1" +source = "git+https://github.com/paritytech/substrate-bip39#44307fda4ea17fe97aeb93af317fbc8f6ed34193" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2627,11 +2629,11 @@ dependencies = [ name = "substrate-client" version = "2.0.0" dependencies = [ - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2677,8 +2679,8 @@ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2688,7 +2690,7 @@ dependencies = [ "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2696,7 +2698,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2710,7 +2712,7 @@ dependencies = [ "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2757,7 +2759,7 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2770,30 +2772,30 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", - "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", - "tiny-bip39 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)", + "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2803,7 +2805,7 @@ version = "2.0.0" dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", @@ -2821,7 +2823,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2850,27 +2852,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.33" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2892,9 +2894,9 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2911,14 +2913,14 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tiny-bip39" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2943,31 +2945,32 @@ name = "tk-listen" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.16" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2978,17 +2981,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-current-thread" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2996,19 +2999,19 @@ name = "tokio-dns-unofficial" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3016,9 +3019,9 @@ name = "tokio-fs" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3027,7 +3030,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3037,25 +3040,25 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-sync" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3064,38 +3067,46 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-threadpool" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-timer" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-trace-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3104,9 +3115,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3118,11 +3129,11 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3131,10 +3142,10 @@ dependencies = [ [[package]] name = "toml" -version = "0.4.10" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3169,7 +3180,7 @@ dependencies = [ [[package]] name = "twox-hash" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3191,7 +3202,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3214,7 +3225,7 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3268,75 +3279,75 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-futures" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.42" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3344,21 +3355,21 @@ name = "wasm-timer" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasmi" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3372,20 +3383,20 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "weedle" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3398,7 +3409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3420,7 +3431,7 @@ name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3433,7 +3444,7 @@ name = "wincolor" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3446,9 +3457,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.19 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3466,21 +3477,21 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "yamux" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3499,15 +3510,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" +"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f10b352bc3fc08ae24dc5d2d3ddcac153678533986122dc283d747b12071000" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9893d63fc3b1c44231e667da6836a33f27d8b6b3bdc82f83da5dfd579d1b6528" "checksum asn1_der_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7f92edafad155aff997fa5b727c6429b91e996b5a5d62a2b0adbae1306b5fe" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" @@ -3516,19 +3527,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814" -"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d" +"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -"checksum block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d75255892aeb580d3c566f213a2b6fdc1c66667839f45719ee1d30ebf2aea591" +"checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" -"checksum bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4639720be048090544634e0402490838995ccdc9d2fe648f528f30d3c33ae71f" +"checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" -"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" +"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -3544,19 +3555,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" +"checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" "checksum crypto-mac 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "779015233ac67d65098614aec748ac1c756ab6677fa2e14cf8b37c08dfed1198" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1f8a6fc0376eb52dc18af94915cc04dfdf8353746c0e8c550ae683a0815e5c1" +"checksum curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "750226d75fc2f5a8daec6e7477624e258674023eb73d8d647f63b943ca182a4a" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" -"checksum derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe9f11be34f800b3ecaaed0ec9ec2e015d1d0ba0c8644c1310f73d6e8994615" +"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" -"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" +"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c7464757b80de8930c91c9afe77ddce501826bf9d134a87db2c67d9dc177e2c" @@ -3564,14 +3575,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum fixed-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a557e80084b05c32b455963ff565a9de6f2866da023d6671705c6aff6f65e01c" +"checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" +"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" @@ -3579,14 +3590,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" "checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" -"checksum hash256-std-hasher 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1224388a21c88a80ae7087a2a245ca6d80acc97a9186b75789fb3eeefd0609af" +"checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -"checksum hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "27455ce8b4a6666c87220e4b59c9a83995476bdadc10197905e61dbe906e36fa" -"checksum hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d340b6514f232f6db1bd16db65302a5278a04fef9ce867cb932e7e5fa21130a" +"checksum hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc2928beef125e519d69ae1baa8c37ea2e0d3848545217f6db0179c5eb1d639" +"checksum hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda" "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" @@ -3598,14 +3609,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum js-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3c994fd445b81741d77f6bcd227d6ed645b95b35a2ecfd2050767450ff1c0b6d" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" +"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" "checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" "checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" @@ -3619,10 +3630,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" "checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" "checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9bff57806e0f71832cc02b5dea1010e5f1a9d16393fd104a4b64e4aaae40d885" +"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" "checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" "checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dff6c81d0f46261a6327219349753aefd3a92021a1e6102185fa112cfcddca97" +"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" "checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" @@ -3632,8 +3643,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "83c2dda19c01176e8e7148f7bdb88bbdf215a8db0641f89fc40e4b81736aeda5" -"checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" +"checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" +"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -3642,21 +3653,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d138afcce92d219ccb6eb53d9b1e8a96ac0d633cfd3c53cd9856d96d1741bb8" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.19 (registry+https://github.com/rust-lang/crates.io-index)" = "84321fb9004c3bce5611188a644d6171f895fa2889d155927d528782edb21c5d" -"checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" +"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" +"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18a130a727008cfcd1068a28439fe939897ccad28664422aeca65b384d6de6d0" -"checksum parity-multihash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e8eab0287ccde7821e337a124dc5a4f1d6e4c25d10cc91e3f9361615dd95076" +"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" +"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" @@ -3664,18 +3676,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f50392d1265092fbee9273414cc40eb6d47d307bd66222c477bb8450c8504f9d" -"checksum paste-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3cd512fe3a55e8933b2dcad913e365639db86d512e4004c3084b86864d9467a" +"checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" +"checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" -"checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" +"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" -"checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" +"checksum proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1dd4172a1e1f96f709341418f49b11ea6c2d95d53dca08c0f74cbd332d9cf3" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -"checksum protobuf 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24d5d73d2b88fddb8b8141f2730d950d88772c940ac4f8f3e93230b9a99d92df" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a151c11a92df0059d6ab446fafa3b21a1210aad4bc2293e1c946e8132b10db01" "checksum pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "efb0dcbddbb600f47a7098d33762a00552c671992171637f5bb310b37fe1f0e4" "checksum quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb6ccf8db7bbcb9c2eae558db5ab4f3da1c2a87e4e597ed394726bc8ea6ca1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -3689,37 +3701,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" +"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" -"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" +"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" +"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rw-stream-sink 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d548a40fe17c3a77d54b82457b79fcc9b8a288d509ca20fbf5aa1dac386d22d6" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" +"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" -"checksum schnorrkel 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a700659388785588c75b197cecda0f23c7112a9281ef703e8ffc651061ce014c" +"checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" -"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" +"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -"checksum sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34a5e54083ce2b934bf059fdf38e7330a154177e029ab6c4e18638f2f624053a" +"checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" @@ -3735,44 +3747,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" -"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" +"checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" -"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tiny-bip39 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5388a470627f97a01a6e13389ced797a42b1611f9de7e0f6ca705675ac55297" +"checksum tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" -"checksum tokio 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fcaabb3cec70485d0df6e9454fe514393ad1c4070dee8915f11041e95630b230" +"checksum tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "94a1f9396aec29d31bb16c24d155cfa144d1af91c40740125db3131bdaf76da8" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" -"checksum tokio-current-thread 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c756b04680eea21902a46fca4e9f410a2332c04995af590e07ff262e2193a9a3" +"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" -"checksum tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30c6dbf2d1ad1de300b393910e8a3aa272b724a400b6531da03eed99e329fbf0" +"checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" -"checksum tokio-sync 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1bf2b9dac2a0509b5cfd1df5aa25eafacb616a42a491a13604d6bbeab4486363" +"checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "742e511f6ce2298aeb86fc9ea0d8df81c2388c6ebae3dc8a7316e8c9df0df801" -"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" +"checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" +"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +"checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +"checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba73747fd3a64ab531274c04cb588dfa9d30d972d62990831e63fbce2cfec59" "checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twox-hash 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09871da9f15424236082e0b220fd404a4eb6bebc7205c67653701229234ac64c" +"checksum twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7bcecad121018bdcd6b709fa2325b004878fcb3d3067934ce90749f0faff9a" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum uint 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2143cded94692b156c356508d92888acc824db5bffc0b4089732264c6fcf86d4" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" @@ -3781,20 +3794,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4" -"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1" -"checksum wasm-bindgen-futures 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad171fc1f6e43f97d155d27f4ee5657bd8aa5cce7c497ef3a0a0c5b44618b2d" -"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71" -"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" -"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" -"checksum wasm-bindgen-webidl 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "613dbf4d7d3bf10aeb212b35de14a8ef07222c26526d4f931061a83fc9e2a851" +"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" +"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" +"checksum wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fa1af11c73eca3dc8c51c76ea475a4416e912da6402064a49fc6c0214701866d" +"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047" +"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6" +"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6" +"checksum wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1f42ff7adb8102bf5ad8adbc45b1635c520c8175f9fdf6eb2c54479d485d435a" "checksum wasm-timer 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9ac33c834103916e373d648adf65f58c83fb3d8a0f3e6b9a64bca7253a4dca" -"checksum wasmi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef487a11df1ed468cf613c78798c26282da5c30e9d49f824872d4c77b47d1d" +"checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" -"checksum web-sys 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "24129e4be2281109b3e15a328d3d7f233ee232a5405f75ba1e9bb59a25ebc4d4" -"checksum weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26a4c67f132386d965390b8a734d5d10adbcd30eb5cc74bd9229af8b83f10044" +"checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" @@ -3802,6 +3815,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -"checksum x25519-dalek 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4aca1ba6bec2719576bd20dfe5b24d9359552e616d10bff257e50cd85f745d17" -"checksum yamux 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9073f5dbc901abb0b2ec4f866e726fed2f54953bdf81f8a5fde7762b7cc3b3" +"checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" +"checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" -- GitLab From a3026f7ee5d6bdd729abe5986f2a6f2a0aeb6205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 30 May 2019 13:50:23 +0200 Subject: [PATCH 060/113] Add RPC to remove and ban transactions from the pool. (#2732) --- core/rpc/src/author/hash.rs | 30 +++++++++++++++++++ core/rpc/src/author/mod.rs | 40 ++++++++++++++++++++----- core/rpc/src/author/tests.rs | 28 +++++++++++++++++ core/transaction-pool/graph/src/pool.rs | 3 +- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 core/rpc/src/author/hash.rs diff --git a/core/rpc/src/author/hash.rs b/core/rpc/src/author/hash.rs new file mode 100644 index 0000000000..052c479834 --- /dev/null +++ b/core/rpc/src/author/hash.rs @@ -0,0 +1,30 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +use primitives::Bytes; +use serde::Deserialize; + +/// RPC Extrinsic or hash +/// +/// Allows to refer to extrinsics either by their raw representation or by it's hash. +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum ExtrinsicOrHash { + /// The hash of the extrinsic. + Hash(Hash), + /// Raw extrinsic bytes. + Extrinsic(Bytes), +} diff --git a/core/rpc/src/author/mod.rs b/core/rpc/src/author/mod.rs index ae160f1d1a..59641e8466 100644 --- a/core/rpc/src/author/mod.rs +++ b/core/rpc/src/author/mod.rs @@ -18,9 +18,15 @@ use std::sync::Arc; -use log::warn; use client::{self, Client}; +use crate::rpc::futures::{Sink, Stream, Future}; +use crate::subscriptions::Subscriptions; +use jsonrpc_derive::rpc; +use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; +use log::warn; use parity_codec::{Encode, Decode}; +use primitives::{Bytes, Blake2Hasher, H256}; +use runtime_primitives::{generic, traits}; use transaction_pool::{ txpool::{ ChainApi as PoolChainApi, @@ -31,14 +37,9 @@ use transaction_pool::{ watcher::Status, }, }; -use jsonrpc_derive::rpc; -use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use primitives::{Bytes, Blake2Hasher, H256}; -use crate::rpc::futures::{Sink, Stream, Future}; -use runtime_primitives::{generic, traits}; -use crate::subscriptions::Subscriptions; pub mod error; +mod hash; #[cfg(test)] mod tests; @@ -59,6 +60,10 @@ pub trait AuthorApi { #[rpc(name = "author_pendingExtrinsics")] fn pending_extrinsics(&self) -> Result>; + /// Remove given extrinsic from the pool and temporarily ban it to prevent reimporting. + #[rpc(name = "author_removeExtrinsic")] + fn remove_extrinsic(&self, bytes_or_hash: Vec>) -> Result>; + /// Submit an extrinsic to watch. #[pubsub(subscription = "author_extrinsicUpdate", subscribe, name = "author_submitAndWatchExtrinsic")] fn watch_extrinsic(&self, metadata: Self::Metadata, subscriber: Subscriber>, bytes: Bytes); @@ -72,7 +77,7 @@ pub trait AuthorApi { pub struct Author where P: PoolChainApi + Sync + Send + 'static { /// Substrate client client: Arc::Block, RA>>, - /// Extrinsic pool + /// Transactions pool pool: Arc>, /// Subscriptions manager subscriptions: Subscriptions, @@ -118,6 +123,25 @@ impl AuthorApi, BlockHash

> for Author whe Ok(self.pool.ready().map(|tx| tx.data.encode().into()).collect()) } + fn remove_extrinsic(&self, bytes_or_hash: Vec>>) -> Result>> { + let hashes = bytes_or_hash.into_iter() + .map(|x| match x { + hash::ExtrinsicOrHash::Hash(h) => Ok(h), + hash::ExtrinsicOrHash::Extrinsic(bytes) => { + let xt = Decode::decode(&mut &bytes[..]).ok_or(error::Error::BadFormat)?; + Ok(self.pool.hash_of(&xt)) + }, + }) + .collect::>>()?; + + Ok( + self.pool.remove_invalid(&hashes) + .into_iter() + .map(|tx| tx.hash.clone()) + .collect() + ) + } + fn watch_extrinsic(&self, _metadata: Self::Metadata, subscriber: Subscriber, BlockHash

>>, xt: Bytes) { let submit = || -> Result<_> { let best_block_hash = self.client.info()?.chain.best_hash; diff --git a/core/rpc/src/author/tests.rs b/core/rpc/src/author/tests.rs index 4d0277f7d6..4c6a724acd 100644 --- a/core/rpc/src/author/tests.rs +++ b/core/rpc/src/author/tests.rs @@ -137,3 +137,31 @@ fn should_return_pending_extrinsics() { Ok(ref expected) if *expected == vec![Bytes(ex.encode())] ); } + +#[test] +fn should_remove_extrinsics() { + let runtime = runtime::Runtime::new().unwrap(); + let client = Arc::new(test_client::new()); + let pool = Arc::new(Pool::new(Default::default(), ChainApi::new(client.clone()))); + let p = Author { + client, + pool: pool.clone(), + subscriptions: Subscriptions::new(runtime.executor()), + }; + let ex1 = uxt(AccountKeyring::Alice, 0); + p.submit_extrinsic(ex1.encode().into()).unwrap(); + let ex2 = uxt(AccountKeyring::Alice, 1); + p.submit_extrinsic(ex2.encode().into()).unwrap(); + let ex3 = uxt(AccountKeyring::Bob, 0); + let hash3 = p.submit_extrinsic(ex3.encode().into()).unwrap(); + assert_eq!(pool.status().ready, 3); + + // now remove all 3 + let removed = p.remove_extrinsic(vec![ + hash::ExtrinsicOrHash::Hash(hash3), + // Removing this one will also remove ex2 + hash::ExtrinsicOrHash::Extrinsic(ex1.encode().into()), + ]).unwrap(); + + assert_eq!(removed.len(), 3); +} diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 61e234f156..4498598aee 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -417,8 +417,7 @@ impl Pool { } /// Returns transaction hash - #[cfg(test)] - fn hash_of(&self, xt: &ExtrinsicFor) -> ExHash { + pub fn hash_of(&self, xt: &ExtrinsicFor) -> ExHash { self.api.hash_and_length(xt).0 } } -- GitLab From 2227c4fb6f5f11036b2ae36f67b52e4e33517866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 30 May 2019 17:30:21 +0200 Subject: [PATCH 061/113] Bump structopt and fix compilation. (#2736) --- Cargo.lock | 14 +++++++------- core/cli/src/lib.rs | 8 ++++---- core/cli/src/params.rs | 27 ++++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abd2e63f1b..f7a69e401e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2036,7 +2036,7 @@ dependencies = [ "srml-finality-tracker 2.0.0", "srml-indices 2.0.0", "srml-timestamp 2.0.0", - "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-basic-authorship 2.0.0", "substrate-cli 2.0.0", "substrate-client 2.0.0", @@ -3730,16 +3730,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3841,7 +3841,7 @@ dependencies = [ "rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", - "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-client 2.0.0", "substrate-keyring 2.0.0", "substrate-network 2.0.0", @@ -5822,8 +5822,8 @@ dependencies = [ "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" -"checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" +"checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" +"checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" "checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 101151ea0d..3619e6491a 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -50,7 +50,7 @@ pub use structopt::clap::App; use params::{ RunCmd, PurgeChainCmd, RevertCmd, ImportBlocksCmd, ExportBlocksCmd, BuildSpecCmd, NetworkConfigurationParams, MergeParameters, TransactionPoolParams, - NodeKeyParams, NodeKeyType + NodeKeyParams, NodeKeyType, Cors, }; pub use params::{NoCustom, CoreParams, SharedParams}; pub use traits::{GetLogFilter, AugmentClap}; @@ -485,9 +485,9 @@ where config.rpc_ws_max_connections = cli.ws_max_connections; config.rpc_cors = cli.rpc_cors.unwrap_or_else(|| if is_dev { log::warn!("Running in --dev mode, RPC CORS has been disabled."); - None + Cors::All } else { - Some(vec![ + Cors::List(vec![ "http://localhost:*".into(), "http://127.0.0.1:*".into(), "https://localhost:*".into(), @@ -495,7 +495,7 @@ where "https://polkadot.js.org".into(), "https://substrate-ui.parity.io".into(), ]) - }); + }).into(); // Override telemetry if cli.no_telemetry { diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index e7d466a863..7439cc02c0 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -343,7 +343,7 @@ pub struct RunCmd { /// Default is to allow localhost, https://polkadot.js.org and https://substrate-ui.parity.io origins. /// When running in --dev mode the default is to allow all origins. #[structopt(long = "rpc-cors", value_name = "ORIGINS", parse(try_from_str = "parse_cors"))] - pub rpc_cors: Option>>, + pub rpc_cors: Option, /// Specify the pruning mode, a number of blocks to keep or 'archive'. Default is 256. #[structopt(long = "pruning", value_name = "PRUNING_MODE")] @@ -490,8 +490,29 @@ fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box>` +/// handling of `structopt`. +#[derive(Clone, Debug)] +pub enum Cors { + /// All hosts allowed + All, + /// Only hosts on the list are allowed. + List(Vec), +} + +impl From for Option> { + fn from(cors: Cors) -> Self { + match cors { + Cors::All => None, + Cors::List(list) => Some(list), + } + } +} + /// Parse cors origins -fn parse_cors(s: &str) -> Result>, Box> { +fn parse_cors(s: &str) -> Result> { let mut is_all = false; let mut origins = Vec::new(); for part in s.split(',') { @@ -504,7 +525,7 @@ fn parse_cors(s: &str) -> Result>, Box> { } } - Ok(if is_all { None } else { Some(origins) }) + Ok(if is_all { Cors::All } else { Cors::List(origins) }) } impl_augment_clap!(RunCmd); -- GitLab From e6f75db5fbbb9d933aaf1e0c1719fed0326a199e Mon Sep 17 00:00:00 2001 From: Denis Andrejew Date: Thu, 30 May 2019 23:04:05 +0200 Subject: [PATCH 062/113] fix some typos in node-template/runtime/src/lib.rs (#2737) --- node-template/runtime/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 875b537a9f..b09fe7d787 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -155,7 +155,7 @@ impl indices::Trait for Runtime { type ResolveHint = indices::SimpleResolveHint; /// Determine whether an account is dead. type IsDeadAccount = Balances; - /// The uniquitous event type. + /// The ubiquitous event type. type Event = Event; } @@ -172,7 +172,7 @@ impl balances::Trait for Runtime { type OnFreeBalanceZero = (); /// What to do if a new account is created. type OnNewAccount = Indices; - /// The uniquitous event type. + /// The ubiquitous event type. type Event = Event; type TransactionPayment = (); @@ -181,7 +181,7 @@ impl balances::Trait for Runtime { } impl sudo::Trait for Runtime { - /// The uniquitous event type. + /// The ubiquitous event type. type Event = Event; type Proposal = Call; } -- GitLab From 910747afa6d78fc6ed1294e7a507ee35acd6e6a9 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Fri, 31 May 2019 10:28:09 +0300 Subject: [PATCH 063/113] Import headers from BlockAnnounce message on light nodes (#2731) * import headers from announce message on light * lines width * added comments --- core/network/src/protocol.rs | 50 ++++++- core/network/src/sync.rs | 271 ++++++++++++++++++++++------------ core/network/src/test/mod.rs | 4 +- core/network/src/test/sync.rs | 33 +++++ 4 files changed, 262 insertions(+), 96 deletions(-) diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 2d7799b5bb..baca6f3bf6 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -521,8 +521,9 @@ impl, H: ExHashT> Protocol { } }, GenericMessage::BlockAnnounce(announce) => { - self.on_block_announce(network_out, who.clone(), announce); + let outcome = self.on_block_announce(network_out, who.clone(), announce); self.update_peer_info(&who); + return outcome; }, GenericMessage::Transactions(m) => self.on_extrinsics(network_out, transaction_pool, who, m), @@ -1019,7 +1020,7 @@ impl, H: ExHashT> Protocol { mut network_out: &mut dyn NetworkOut, who: PeerId, announce: message::BlockAnnounce - ) { + ) -> CustomMessageOutcome { let header = announce.header; let hash = header.hash(); { @@ -1028,12 +1029,55 @@ impl, H: ExHashT> Protocol { } } self.on_demand_core.on_block_announce(&mut network_out, who.clone(), *header.number()); - self.sync.on_block_announce( + let try_import = self.sync.on_block_announce( &mut ProtocolContext::new(&mut self.context_data, network_out), who.clone(), hash, &header, ); + + // try_import is only true when we have all data required to import block + // in the BlockAnnounce message. This is only when: + // 1) we're on light client; + // AND + // - EITHER 2.1) announced block is stale; + // - OR 2.2) announced block is NEW and we normally only want to download this single block (i.e. + // there are no ascendants of this block scheduled for retrieval) + if !try_import { + return CustomMessageOutcome::None; + } + + // to import header from announced block let's construct response to request that normally would have + // been sent over network (but it is not in our case) + let blocks_to_import = self.sync.on_block_data( + &mut ProtocolContext::new(&mut self.context_data, network_out), + who.clone(), + message::generic::BlockRequest { + id: 0, + fields: BlockAttributes::HEADER, + from: message::FromBlock::Hash(hash), + to: None, + direction: message::Direction::Ascending, + max: Some(1), + }, + message::generic::BlockResponse { + id: 0, + blocks: vec![ + message::generic::BlockData { + hash: hash, + header: Some(header), + body: None, + receipt: None, + message_queue: None, + justification: None, + }, + ], + }, + ); + match blocks_to_import { + Some((origin, blocks)) => CustomMessageOutcome::BlockImport(origin, blocks), + None => CustomMessageOutcome::None, + } } /// Call this when a block has been imported in the import queue and we should announce it on diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index fdd36a024d..e451372847 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -31,6 +31,7 @@ //! use std::cmp::max; +use std::ops::Range; use std::collections::{HashMap, VecDeque}; use log::{debug, trace, warn, info}; use crate::protocol::PeerInfo as ProtocolPeerInfo; @@ -135,6 +136,7 @@ pub struct ChainSync { blocks: BlockCollection, best_queued_number: NumberFor, best_queued_hash: B::Hash, + role: Roles, required_block_attributes: message::BlockAttributes, extra_requests: ExtraRequestsAggregator, queue_blocks: HashSet, @@ -195,6 +197,7 @@ impl ChainSync { best_queued_hash: info.best_queued_hash.unwrap_or(info.chain.best_hash), best_queued_number: info.best_queued_number.unwrap_or(info.chain.best_number), extra_requests: ExtraRequestsAggregator::new(), + role, required_block_attributes, queue_blocks: Default::default(), best_importing_number: Zero::zero(), @@ -665,12 +668,21 @@ impl ChainSync { // Abort search. peer.state = PeerSyncState::Available; } - trace!(target: "sync", "Updating peer {} info, ours={}, common={}, their best={}", n, number, peer.common_number, peer.best_number); - if peer.best_number >= number { - peer.common_number = number; + let new_common_number = if peer.best_number >= number { + number } else { - peer.common_number = peer.best_number; - } + peer.best_number + }; + trace!( + target: "sync", + "Updating peer {} info, ours={}, common={}->{}, their best={}", + n, + number, + peer.common_number, + new_common_number, + peer.best_number, + ); + peer.common_number = new_common_number; } } @@ -681,12 +693,22 @@ impl ChainSync { } /// Call when a node announces a new block. - pub(crate) fn on_block_announce(&mut self, protocol: &mut Context, who: PeerId, hash: B::Hash, header: &B::Header) { + /// + /// If true is returned, then the caller MUST try to import passed header (call `on_block_data). + /// The network request isn't sent in this case. + #[must_use] + pub(crate) fn on_block_announce( + &mut self, + protocol: &mut Context, + who: PeerId, + hash: B::Hash, + header: &B::Header, + ) -> bool { let number = *header.number(); debug!(target: "sync", "Received block announcement with number {:?}", number); if number.is_zero() { warn!(target: "sync", "Ignored invalid block announcement from {}: {}", who, hash); - return; + return false; } let parent_status = block_status(&*protocol.client(), &self.queue_blocks, header.parent_hash().clone()).ok() .unwrap_or(BlockStatus::Unknown); @@ -705,7 +727,7 @@ impl ChainSync { peer.best_hash = hash; } if let PeerSyncState::AncestorSearch(_, _) = peer.state { - return; + return false; } if header.parent_hash() == &self.best_queued_hash || known_parent { peer.common_number = number - One::one(); @@ -713,39 +735,77 @@ impl ChainSync { peer.common_number = number } } else { - return; + return false; } - if !(known || self.is_already_downloading(&hash)) { - let stale = number <= self.best_queued_number; - if stale { - if !(known_parent || self.is_already_downloading(header.parent_hash())) { - if protocol.client().block_status(&BlockId::Number(*header.number())) - .unwrap_or(BlockStatus::Unknown) == BlockStatus::InChainPruned - { - trace!(target: "sync", "Ignored unknown ancient block announced from {}: {} {:?}", who, hash, header); - } else { - trace!(target: "sync", "Considering new unknown stale block announced from {}: {} {:?}", who, hash, header); - self.download_unknown_stale(protocol, who, &hash); - } - } else { - if ancient_parent { - trace!(target: "sync", "Ignored ancient stale block announced from {}: {} {:?}", who, hash, header); + // known block case + if known || self.is_already_downloading(&hash) { + trace!(target: "sync", "Known block announce from {}: {}", who, hash); + return false; + } + + // stale block case + let requires_additional_data = !self.role.is_light(); + let stale = number <= self.best_queued_number; + if stale { + if !(known_parent || self.is_already_downloading(header.parent_hash())) { + if protocol.client().block_status(&BlockId::Number(*header.number())) + .unwrap_or(BlockStatus::Unknown) == BlockStatus::InChainPruned + { + trace!(target: "sync", "Ignored unknown ancient block announced from {}: {} {:?}", who, hash, header); + return false; + } + + trace!(target: "sync", "Considering new unknown stale block announced from {}: {} {:?}", who, hash, header); + let request = self.download_unknown_stale(&who, &hash); + match request { + Some(request) => if requires_additional_data { + protocol.send_block_request(who, request); + return false; } else { - self.download_stale(protocol, who, &hash); - } + return true; + }, + None => return false, } } else { if ancient_parent { - trace!(target: "sync", "Ignored ancient block announced from {}: {} {:?}", who, hash, header); - } else { - trace!(target: "sync", "Considering new block announced from {}: {} {:?}", who, hash, header); - self.download_new(protocol, who); + trace!(target: "sync", "Ignored ancient stale block announced from {}: {} {:?}", who, hash, header); + return false; + } + + let request = self.download_stale(&who, &hash); + match request { + Some(request) => if requires_additional_data { + protocol.send_block_request(who, request); + return false; + } else { + return true; + }, + None => return false, } } - } else { - trace!(target: "sync", "Known block announce from {}: {}", who, hash); } + + if ancient_parent { + trace!(target: "sync", "Ignored ancient block announced from {}: {} {:?}", who, hash, header); + return false; + } + + trace!(target: "sync", "Considering new block announced from {}: {} {:?}", who, hash, header); + let (range, request) = match self.select_new_blocks(who.clone()) { + Some((range, request)) => (range, request), + None => return false, + }; + let is_required_data_available = + !requires_additional_data && + range.end - range.start == One::one() && + range.start == *header.number(); + if !is_required_data_available { + protocol.send_block_request(who, request); + return false; + } + + true } fn is_already_downloading(&self, hash: &B::Hash) -> bool { @@ -788,76 +848,105 @@ impl ChainSync { } // Download old block with known parent. - fn download_stale(&mut self, protocol: &mut Context, who: PeerId, hash: &B::Hash) { - if let Some(ref mut peer) = self.peers.get_mut(&who) { - match peer.state { - PeerSyncState::Available => { - let request = message::generic::BlockRequest { - id: 0, - fields: self.required_block_attributes.clone(), - from: message::FromBlock::Hash(*hash), - to: None, - direction: message::Direction::Ascending, - max: Some(1), - }; - peer.state = PeerSyncState::DownloadingStale(*hash); - protocol.send_block_request(who, request); - }, - _ => (), - } + fn download_stale( + &mut self, + who: &PeerId, + hash: &B::Hash, + ) -> Option> { + let peer = self.peers.get_mut(who)?; + match peer.state { + PeerSyncState::Available => { + peer.state = PeerSyncState::DownloadingStale(*hash); + Some(message::generic::BlockRequest { + id: 0, + fields: self.required_block_attributes.clone(), + from: message::FromBlock::Hash(*hash), + to: None, + direction: message::Direction::Ascending, + max: Some(1), + }) + }, + _ => None, } } // Download old block with unknown parent. - fn download_unknown_stale(&mut self, protocol: &mut Context, who: PeerId, hash: &B::Hash) { - if let Some(ref mut peer) = self.peers.get_mut(&who) { - match peer.state { - PeerSyncState::Available => { - let request = message::generic::BlockRequest { - id: 0, - fields: self.required_block_attributes.clone(), - from: message::FromBlock::Hash(*hash), - to: None, - direction: message::Direction::Descending, - max: Some(MAX_UNKNOWN_FORK_DOWNLOAD_LEN), - }; - peer.state = PeerSyncState::DownloadingStale(*hash); - protocol.send_block_request(who, request); - }, - _ => (), - } + fn download_unknown_stale( + &mut self, + who: &PeerId, + hash: &B::Hash, + ) -> Option> { + let peer = self.peers.get_mut(who)?; + match peer.state { + PeerSyncState::Available => { + peer.state = PeerSyncState::DownloadingStale(*hash); + Some(message::generic::BlockRequest { + id: 0, + fields: self.required_block_attributes.clone(), + from: message::FromBlock::Hash(*hash), + to: None, + direction: message::Direction::Descending, + max: Some(MAX_UNKNOWN_FORK_DOWNLOAD_LEN), + }) + }, + _ => None, } } - // Issue a request for a peer to download new blocks, if any are available + // Issue a request for a peer to download new blocks, if any are available. fn download_new(&mut self, protocol: &mut Context, who: PeerId) { - if let Some(ref mut peer) = self.peers.get_mut(&who) { - // when there are too many blocks in the queue => do not try to download new blocks - if self.queue_blocks.len() > MAX_IMPORTING_BLOCKS { - trace!(target: "sync", "Too many blocks in the queue."); - return; - } - match peer.state { - PeerSyncState::Available => { - trace!(target: "sync", "Considering new block download from {}, common block is {}, best is {:?}", who, peer.common_number, peer.best_number); - if let Some(range) = self.blocks.needed_blocks(who.clone(), MAX_BLOCKS_TO_REQUEST, peer.best_number, peer.common_number) { + if let Some((_, request)) = self.select_new_blocks(who.clone()) { + protocol.send_block_request(who, request); + } + } + + // Select a range of NEW blocks to download from peer. + fn select_new_blocks(&mut self, who: PeerId) -> Option<(Range>, message::BlockRequest)> { + // when there are too many blocks in the queue => do not try to download new blocks + if self.queue_blocks.len() > MAX_IMPORTING_BLOCKS { + trace!(target: "sync", "Too many blocks in the queue."); + return None; + } + + let peer = self.peers.get_mut(&who)?; + match peer.state { + PeerSyncState::Available => { + trace!( + target: "sync", + "Considering new block download from {}, common block is {}, best is {:?}", + who, + peer.common_number, + peer.best_number, + ); + let range = self.blocks.needed_blocks(who.clone(), MAX_BLOCKS_TO_REQUEST, peer.best_number, peer.common_number); + match range { + Some(range) => { trace!(target: "sync", "Requesting blocks from {}, ({} to {})", who, range.start, range.end); - let request = message::generic::BlockRequest { - id: 0, - fields: self.required_block_attributes.clone(), - from: message::FromBlock::Number(range.start), - to: None, - direction: message::Direction::Ascending, - max: Some((range.end - range.start).saturated_into::()), - }; + let from = message::FromBlock::Number(range.start); + let max = Some((range.end - range.start).saturated_into::()); peer.state = PeerSyncState::DownloadingNew(range.start); - protocol.send_block_request(who, request); - } else { + Some(( + range, + message::generic::BlockRequest { + id: 0, + fields: self.required_block_attributes.clone(), + from, + to: None, + direction: message::Direction::Ascending, + max, + }, + )) + }, + None => { trace!(target: "sync", "Nothing to request"); - } - }, - _ => trace!(target: "sync", "Peer {} is busy", who), - } + None + }, + } + }, + _ => { + trace!(target: "sync", "Peer {} is busy", who); + None + }, } } diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index f31a93cf28..6a7a9ccddd 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -521,7 +521,7 @@ impl> Peer { /// Synchronize with import queue. #[cfg(any(test, feature = "test-helpers"))] - fn import_queue_sync(&self) { + pub fn import_queue_sync(&self) { self.import_queue.synchronize(); let _ = self.net_proto_channel.wait_sync(); } @@ -675,7 +675,7 @@ impl> Peer { /// Push blocks to the peer (simplified: with or without a TX) starting from /// given hash. - fn push_blocks_at(&self, at: BlockId, count: usize, with_tx: bool) -> H256 { + pub fn push_blocks_at(&self, at: BlockId, count: usize, with_tx: bool) -> H256 { let mut nonce = 0; if with_tx { self.generate_blocks_at(at, count, BlockOrigin::File, |mut builder| { diff --git a/core/network/src/test/sync.rs b/core/network/src/test/sync.rs index 8462304e42..50b00ac62a 100644 --- a/core/network/src/test/sync.rs +++ b/core/network/src/test/sync.rs @@ -452,3 +452,36 @@ fn can_not_sync_from_light_peer() { // check that light #1 has disconnected from #2 assert_eq!(net.peer(1).protocol_status().num_peers, 1); } + +#[test] +fn light_peer_imports_header_from_announce() { + let _ = ::env_logger::try_init(); + + fn import_with_announce(net: &mut TestNet, hash: H256) { + let header = net.peer(0).client().header(&BlockId::Hash(hash)).unwrap().unwrap(); + net.peer(1).receive_message( + &net.peer(0).peer_id, + message::generic::Message::BlockAnnounce(message::generic::BlockAnnounce { + header, + }), + ); + + net.peer(1).import_queue_sync(); + assert!(net.peer(1).client().header(&BlockId::Hash(hash)).unwrap().is_some()); + } + + // given the network with 1 full nodes (#0) and 1 light node (#1) + let mut net = TestNet::new(1); + net.add_light_peer(&Default::default()); + + // let them connect to each other + net.sync(); + + // check that NEW block is imported from announce message + let new_hash = net.peer(0).push_blocks(1, false); + import_with_announce(&mut net, new_hash); + + // check that KNOWN STALE block is imported from announce message + let known_stale_hash = net.peer(0).push_blocks_at(BlockId::Number(0), 1, true); + import_with_announce(&mut net, known_stale_hash); +} -- GitLab From 9605d8540d786c1edfd2f02357e49ccf6166af5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 31 May 2019 09:28:31 +0200 Subject: [PATCH 064/113] Remove `StorageList` (#2725) * Remove `StorageList` `StorageList` is not used anymore by `decl_storage!` and thus, it can be removed. * Fixes tests --- srml/support/src/lib.rs | 2 +- srml/support/src/storage/hashed/generator.rs | 30 ----- srml/support/src/storage/mod.rs | 68 ------------ srml/support/src/storage/storage_items.rs | 111 ------------------- 4 files changed, 1 insertion(+), 210 deletions(-) diff --git a/srml/support/src/lib.rs b/srml/support/src/lib.rs index 0931e4c5a3..140b905e78 100644 --- a/srml/support/src/lib.rs +++ b/srml/support/src/lib.rs @@ -58,7 +58,7 @@ mod double_map; pub mod traits; pub use self::storage::{ - StorageList, StorageValue, StorageMap, EnumerableStorageMap, StorageDoubleMap, AppendableStorageMap + StorageValue, StorageMap, EnumerableStorageMap, StorageDoubleMap, AppendableStorageMap }; pub use self::hashable::Hashable; pub use self::dispatch::{Parameter, Dispatchable, Callable, IsSubType}; diff --git a/srml/support/src/storage/hashed/generator.rs b/srml/support/src/storage/hashed/generator.rs index 1cc62c69f7..5a8b2f9d8f 100644 --- a/srml/support/src/storage/hashed/generator.rs +++ b/srml/support/src/storage/hashed/generator.rs @@ -207,36 +207,6 @@ pub trait StorageValue { } } -/// A strongly-typed list in storage. -pub trait StorageList { - /// Get the prefix key in storage. - fn prefix() -> &'static [u8]; - - /// Get the key used to put the length field. - fn len_key() -> Vec; - - /// Get the storage key used to fetch a value at a given index. - fn key_for(index: u32) -> Vec; - - /// Read out all the items. - fn items>(storage: &S) -> Vec; - - /// Set the current set of items. - fn set_items>(items: &[T], storage: &mut S); - - /// Set the item at the given index. - fn set_item>(index: u32, item: &T, storage: &mut S); - - /// Load the value at given index. Returns `None` if the index is out-of-bounds. - fn get>(index: u32, storage: &S) -> Option; - - /// Load the length of the list - fn len>(storage: &S) -> u32; - - /// Clear the list. - fn clear>(storage: &mut S); -} - /// A strongly-typed map in storage. pub trait StorageMap { /// The type that get/take returns. diff --git a/srml/support/src/storage/mod.rs b/srml/support/src/storage/mod.rs index 41ea4cfdbc..a1891dade3 100644 --- a/srml/support/src/storage/mod.rs +++ b/srml/support/src/storage/mod.rs @@ -196,74 +196,6 @@ impl StorageValue for U where U: hashed::generator::StorageValue } } -/// A strongly-typed list in storage. -pub trait StorageList { - /// Get the prefix key in storage. - fn prefix() -> &'static [u8]; - - /// Get the key used to store the length field. - fn len_key() -> Vec; - - /// Get the storage key used to fetch a value at a given index. - fn key_for(index: u32) -> Vec; - - /// Read out all the items. - fn items() -> Vec; - - /// Set the current set of items. - fn set_items(items: &[T]); - - /// Set the item at the given index. - fn set_item>(index: u32, val: Arg); - - /// Load the value at given index. Returns `None` if the index is out-of-bounds. - fn get(index: u32) -> Option; - - /// Load the length of the list - fn len() -> u32; - - /// Clear the list. - fn clear(); -} - -impl StorageList for U where U: hashed::generator::StorageList { - fn prefix() -> &'static [u8] { - >::prefix() - } - - fn len_key() -> Vec { - >::len_key() - } - - fn key_for(index: u32) -> Vec { - >::key_for(index) - } - - fn items() -> Vec { - U::items(&RuntimeStorage) - } - - fn set_items(items: &[T]) { - U::set_items(items, &mut RuntimeStorage) - } - - fn set_item>(index: u32, val: Arg) { - U::set_item(index, val.borrow(), &mut RuntimeStorage) - } - - fn get(index: u32) -> Option { - U::get(index, &RuntimeStorage) - } - - fn len() -> u32 { - U::len(&RuntimeStorage) - } - - fn clear() { - U::clear(&mut RuntimeStorage) - } -} - /// A strongly-typed map in storage. pub trait StorageMap { /// The type that get/take return. diff --git a/srml/support/src/storage/storage_items.rs b/srml/support/src/storage/storage_items.rs index 2e7a8d4bb4..9d89b81e0d 100644 --- a/srml/support/src/storage/storage_items.rs +++ b/srml/support/src/storage/storage_items.rs @@ -22,7 +22,6 @@ //! Three kinds of data types are currently supported: //! - values //! - maps -//! - lists //! //! # Examples: //! @@ -39,8 +38,6 @@ //! pub Value: b"putd_key" => SessionKey; //! // private map. //! Balances: b"private_map:" => map [AuthorityId => Balance]; -//! // private list. -//! Authorities: b"auth:" => list [AuthorityId]; //! } //! //!# fn main() { } @@ -159,16 +156,6 @@ macro_rules! storage_items { storage_items!($($t)*); }; - - // lists - ($name:ident : $prefix:expr => list [$ty:ty]; $($t:tt)*) => { - $crate::__storage_items_internal!(() $name: $prefix => list [$ty]); - storage_items!($($t)*); - }; - (pub $name:ident : $prefix:expr => list [$ty:ty]; $($t:tt)*) => { - $crate::__storage_items_internal!((pub) $name: $prefix => list [$ty]); - storage_items!($($t)*); - }; () => () } @@ -282,84 +269,6 @@ macro_rules! __storage_items_internal { } } }; - // generator for lists. - (($($vis:tt)*) $name:ident : $prefix:expr => list [$ty:ty]) => { - $($vis)* struct $name; - - impl $name { - fn clear_item>(index: u32, storage: &mut S) { - if index < <$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage) { - storage.kill(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::key_for(index)); - } - } - - fn set_len>(count: u32, storage: &mut S) { - (count..<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage)).for_each(|i| $name::clear_item(i, storage)); - storage.put(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len_key(), &count); - } - } - - impl $crate::storage::hashed::generator::StorageList<$ty> for $name { - /// Get the prefix key in storage. - fn prefix() -> &'static [u8] { - $prefix - } - - /// Get the key used to put the length field. - fn len_key() -> $crate::rstd::vec::Vec { - let mut key = $prefix.to_vec(); - key.extend(b"len"); - key - } - - /// Get the storage key used to fetch a value at a given index. - fn key_for(index: u32) -> $crate::rstd::vec::Vec { - let mut key = $prefix.to_vec(); - $crate::codec::Encode::encode_to(&index, &mut key); - key - } - - /// Read out all the items. - fn items>(storage: &S) -> $crate::rstd::vec::Vec<$ty> { - (0..<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage)) - .map(|i| <$name as $crate::storage::hashed::generator::StorageList<$ty>>::get(i, storage).expect("all items within length are set; qed")) - .collect() - } - - /// Set the current set of items. - fn set_items>(items: &[$ty], storage: &mut S) { - $name::set_len(items.len() as u32, storage); - items.iter() - .enumerate() - .for_each(|(i, item)| <$name as $crate::storage::hashed::generator::StorageList<$ty>>::set_item(i as u32, item, storage)); - } - - fn set_item>(index: u32, item: &$ty, storage: &mut S) { - if index < <$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage) { - storage.put(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::key_for(index)[..], item); - } - } - - /// Load the value at given index. Returns `None` if the index is out-of-bounds. - fn get>(index: u32, storage: &S) -> Option<$ty> { - storage.get(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::key_for(index)[..]) - } - - /// Load the length of the list. - fn len>(storage: &S) -> u32 { - storage.get(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len_key()).unwrap_or_default() - } - - /// Clear the list. - fn clear>(storage: &mut S) { - for i in 0..<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len(storage) { - $name::clear_item(i, storage); - } - - storage.kill(&<$name as $crate::storage::hashed::generator::StorageList<$ty>>::len_key()[..]) - } - } - }; } #[macro_export] @@ -391,7 +300,6 @@ mod tests { storage_items! { Value: b"a" => u32; - List: b"b:" => list [u64]; Map: b"c:" => map [u32 => [u8; 32]]; } @@ -405,25 +313,6 @@ mod tests { assert!(Value::get(&storage).is_none()); } - #[test] - fn list() { - let mut storage = HashMap::new(); - assert_eq!(List::len(&storage), 0); - assert!(List::items(&storage).is_empty()); - - List::set_items(&[0, 2, 4, 6, 8], &mut storage); - assert_eq!(List::items(&storage), &[0, 2, 4, 6, 8]); - assert_eq!(List::len(&storage), 5); - - List::set_item(2, &10, &mut storage); - assert_eq!(List::items(&storage), &[0, 2, 10, 6, 8]); - assert_eq!(List::len(&storage), 5); - - List::clear(&mut storage); - assert_eq!(List::len(&storage), 0); - assert!(List::items(&storage).is_empty()); - } - #[test] fn map() { let mut storage = HashMap::new(); -- GitLab From c93ca93e8da8e70ce7188ce369b91d3441123de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 31 May 2019 09:33:44 +0200 Subject: [PATCH 065/113] Offchain-worker APIs stubs (#2615) * WiP: HTTP Apis. * Working on the API. * Add docs, clean up the API. * Expose ext_ stuff as well. * Implement HTTP helpers for offchain sr-io. * Remove HTTP stuff. * Revert "Remove HTTP stuff." This reverts commit 7cca029d6ae93c5849b50edfcc6d2c313ba3e5bf. * HTTP apis. * Additional offchain methods. * Make it compile. * Implement wasm-ext boundary of offchain methods. * Add stubs for offchain stuff to prevent panics. * Fix tests. * Addres some more issues. * Introduce typedef, use unsafe from_utf8 * Bump runtime version. * Introduce error to distinguish deadline and io errors. * Add local_storage_cas * Some tests for offchain stuff. * Address more grumbles. * Fix tests compilation. * Fix borked merge. * Improve docs for expected return values from ext functions. * Adding new sign/enrypt/decrypt APIs. --- Cargo.lock | 2 + core/client/src/call_executor.rs | 16 +- core/client/src/light/call_executor.rs | 14 +- core/client/src/runtime_api.rs | 2 +- core/executor/src/wasm_executor.rs | 363 +++++++++++++++- core/offchain/Cargo.toml | 1 + core/offchain/src/api.rs | 125 +++++- core/offchain/src/lib.rs | 2 + core/offchain/src/testing.rs | 244 +++++++++++ core/primitives/src/lib.rs | 17 +- core/primitives/src/offchain.rs | 410 ++++++++++++++++++ core/sr-io/Cargo.toml | 3 + core/sr-io/src/lib.rs | 141 +++++- core/sr-io/src/offchain/http.rs | 571 +++++++++++++++++++++++++ core/sr-io/src/offchain/mod.rs | 19 + core/sr-io/with_std.rs | 142 +++++- core/sr-io/without_std.rs | 495 +++++++++++++++++++-- core/sr-primitives/src/generic/era.rs | 3 + core/sr-std/with_std.rs | 7 +- core/sr-std/without_std.rs | 8 +- core/state-machine/src/basic.rs | 7 +- core/state-machine/src/ext.rs | 20 +- core/state-machine/src/lib.rs | 130 +++++- core/state-machine/src/testing.rs | 14 +- core/test-runtime/src/lib.rs | 4 +- node/runtime/src/lib.rs | 4 +- 26 files changed, 2646 insertions(+), 118 deletions(-) create mode 100644 core/offchain/src/testing.rs create mode 100644 core/primitives/src/offchain.rs create mode 100644 core/sr-io/src/offchain/http.rs create mode 100644 core/sr-io/src/offchain/mod.rs diff --git a/Cargo.lock b/Cargo.lock index f7a69e401e..7f8f7bd555 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3195,6 +3195,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", + "substrate-offchain 2.0.0", "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", @@ -4235,6 +4236,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", diff --git a/core/client/src/call_executor.rs b/core/client/src/call_executor.rs index 9a47d1ac21..13ee96400f 100644 --- a/core/client/src/call_executor.rs +++ b/core/client/src/call_executor.rs @@ -26,9 +26,7 @@ use state_machine::{ use executor::{RuntimeVersion, RuntimeInfo, NativeVersion}; use hash_db::Hasher; use trie::MemoryDB; -use primitives::{ - H256, Blake2Hasher, NativeOrEncoded, NeverNativeValue, OffchainExt -}; +use primitives::{offchain, H256, Blake2Hasher, NativeOrEncoded, NeverNativeValue}; use crate::runtime_api::{ProofRecorder, InitializeBlock}; use crate::backend; @@ -48,7 +46,7 @@ where /// /// No changes are made. fn call< - O: OffchainExt, + O: offchain::Externalities, >( &self, id: &BlockId, @@ -65,7 +63,7 @@ where /// of the execution context. fn contextual_call< 'a, - O: OffchainExt, + O: offchain::Externalities, IB: Fn() -> error::Result<()>, EM: Fn( Result, Self::Error>, @@ -96,7 +94,7 @@ where /// /// No changes are made. fn call_at_state< - O: OffchainExt, + O: offchain::Externalities, S: state_machine::Backend, F: FnOnce( Result, Self::Error>, @@ -181,7 +179,7 @@ where { type Error = E::Error; - fn call( + fn call( &self, id: &BlockId, method: &str, @@ -211,7 +209,7 @@ where fn contextual_call< 'a, - O: OffchainExt, + O: offchain::Externalities, IB: Fn() -> error::Result<()>, EM: Fn( Result, Self::Error>, @@ -300,7 +298,7 @@ where } fn call_at_state< - O: OffchainExt, + O: offchain::Externalities, S: state_machine::Backend, F: FnOnce( Result, Self::Error>, diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index 9959d29a1b..5fb7e7308a 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -24,7 +24,7 @@ use std::{ use futures::{IntoFuture, Future}; use parity_codec::{Encode, Decode}; -use primitives::{H256, Blake2Hasher, convert_hash, NativeOrEncoded, OffchainExt}; +use primitives::{offchain, H256, Blake2Hasher, convert_hash, NativeOrEncoded}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{One, Block as BlockT, Header as HeaderT}; use state_machine::{ @@ -87,7 +87,7 @@ where type Error = ClientError; fn call< - O: OffchainExt, + O: offchain::Externalities, >( &self, id: &BlockId, @@ -111,7 +111,7 @@ where fn contextual_call< 'a, - O: OffchainExt, + O: offchain::Externalities, IB: Fn() -> ClientResult<()>, EM: Fn( Result, Self::Error>, @@ -154,7 +154,7 @@ where } fn call_at_state< - O: OffchainExt, + O: offchain::Externalities, S: StateBackend, FF: FnOnce( Result, Self::Error>, @@ -230,7 +230,7 @@ impl CallExecutor for type Error = ClientError; fn call< - O: OffchainExt, + O: offchain::Externalities, >( &self, id: &BlockId, @@ -247,7 +247,7 @@ impl CallExecutor for fn contextual_call< 'a, - O: OffchainExt, + O: offchain::Externalities, IB: Fn() -> ClientResult<()>, EM: Fn( Result, Self::Error>, @@ -327,7 +327,7 @@ impl CallExecutor for } fn call_at_state< - O: OffchainExt, + O: offchain::Externalities, S: StateBackend, FF: FnOnce( Result, Self::Error>, diff --git a/core/client/src/runtime_api.rs b/core/client/src/runtime_api.rs index f5c8a59a90..987138e69a 100644 --- a/core/client/src/runtime_api.rs +++ b/core/client/src/runtime_api.rs @@ -31,7 +31,7 @@ pub use runtime_primitives::{ generic::BlockId, transaction_validity::TransactionValidity, }; #[doc(hidden)] -pub use primitives::{ExecutionContext, OffchainExt}; +pub use primitives::{offchain, ExecutionContext}; #[doc(hidden)] pub use runtime_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec}; #[doc(hidden)] diff --git a/core/executor/src/wasm_executor.rs b/core/executor/src/wasm_executor.rs index 464531a5a1..6a3c92b755 100644 --- a/core/executor/src/wasm_executor.rs +++ b/core/executor/src/wasm_executor.rs @@ -17,6 +17,8 @@ //! Rust implementation of Substrate contracts. use std::collections::HashMap; +use std::convert::TryFrom; +use std::str; use tiny_keccak; use secp256k1; @@ -29,6 +31,7 @@ use state_machine::{Externalities, ChildStorageKey}; use crate::error::{Error, Result}; use crate::wasm_utils::UserError; use primitives::{blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Pair}; +use primitives::offchain; use primitives::hexdisplay::HexDisplay; use primitives::sandbox as sandbox_primitives; use primitives::{H256, Blake2Hasher}; @@ -113,6 +116,24 @@ impl ReadPrimitive for MemoryInstance { } } +fn deadline_to_timestamp(deadline: u64) -> Option { + if deadline == 0 { + None + } else { + Some(offchain::Timestamp::from_unix_millis(deadline)) + } +} + +fn u32_to_key(key: u32) -> std::result::Result, ()> { + if key > u16::max_value() as u32 { + Err(()) + } else if key == 0 { + Ok(None) + } else { + Ok(Some(offchain::CryptoKeyId(key as u16))) + } +} + impl_function_executor!(this: FunctionExecutor<'e, E>, ext_print_utf8(utf8_data: *const u8, utf8_len: u32) => { if let Ok(utf8) = this.memory.get(utf8_data, utf8_len as usize) { @@ -459,7 +480,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, let key = this.memory.get(data, len as usize).map_err(|_| UserError("Invalid attempt to get key in ext_twox_64"))?; let hashed_key = twox_64(&key); debug_trace!(target: "xxhash", "XXhash: {} -> {}", - if let Ok(_skey) = ::std::str::from_utf8(&key) { + if let Ok(_skey) = str::from_utf8(&key) { _skey } else { &format!("{}", HexDisplay::from(&key)) @@ -483,7 +504,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, let key = this.memory.get(data, len as usize).map_err(|_| UserError("Invalid attempt to get key in ext_twox_128"))?; let hashed_key = twox_128(&key); debug_trace!(target: "xxhash", "XXhash: {} -> {}", - &if let Ok(_skey) = ::std::str::from_utf8(&key) { + &if let Ok(_skey) = str::from_utf8(&key) { *_skey } else { format!("{}", HexDisplay::from(&key)) @@ -590,15 +611,345 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, Ok(0) }, - ext_submit_extrinsic(msg_data: *const u8, len: u32) => { + ext_submit_transaction(msg_data: *const u8, len: u32) -> u32 => { let extrinsic = this.memory.get(msg_data, len as usize) - .map_err(|_| UserError("OOB while ext_submit_extrinsic: wasm"))?; + .map_err(|_| UserError("OOB while ext_submit_transaction: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.submit_transaction(extrinsic)) + .ok_or_else(|| UserError("Calling unavailable API ext_submit_transaction: wasm"))?; - this.ext.submit_extrinsic(extrinsic) - .map_err(|_| UserError("Calling unavailable API ext_submit_extrinsic: wasm"))?; + Ok(if res.is_ok() { 0 } else { 1 }) + }, + ext_new_crypto_key(crypto: u32) -> u32 => { + let kind = offchain::CryptoKind::try_from(crypto) + .map_err(|_| UserError("crypto kind OOB while ext_new_crypto_key: wasm"))?; + let res = this.ext.offchain() + .map(|api| api.new_crypto_key(kind)) + .ok_or_else(|| UserError("Calling unavailable API ext_new_crypto_key: wasm"))?; + + match res { + Ok(key_id) => Ok(key_id.0 as u32), + Err(()) => Ok(u32::max_value()), + } + }, + ext_encrypt(key: u32, data: *const u8, data_len: u32, msg_len: *mut u32) -> *mut u8 => { + let key = u32_to_key(key) + .map_err(|_| UserError("key OOB while ext_encrypt: wasm"))?; + let message = this.memory.get(data, data_len as usize) + .map_err(|_| UserError("OOB while ext_encrypt: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.encrypt(key, &*message)) + .ok_or_else(|| UserError("Calling unavailable API ext_encrypt: wasm"))?; + + let (offset,len) = match res { + Ok(encrypted) => { + let len = encrypted.len() as u32; + let offset = this.heap.allocate(len)? as u32; + this.memory.set(offset, &encrypted) + .map_err(|_| UserError("Invalid attempt to set memory in ext_encrypt"))?; + (offset, len) + }, + Err(()) => (0, u32::max_value()), + }; + + this.memory.write_primitive(msg_len, len) + .map_err(|_| UserError("Invalid attempt to write msg_len in ext_encrypt"))?; + + Ok(offset) + }, + ext_decrypt(key: u32, data: *const u8, data_len: u32, msg_len: *mut u32) -> *mut u8 => { + let key = u32_to_key(key) + .map_err(|_| UserError("key OOB while ext_decrypt: wasm"))?; + let message = this.memory.get(data, data_len as usize) + .map_err(|_| UserError("OOB while ext_decrypt: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.decrypt(key, &*message)) + .ok_or_else(|| UserError("Calling unavailable API ext_decrypt: wasm"))?; + + let (offset,len) = match res { + Ok(decrypted) => { + let len = decrypted.len() as u32; + let offset = this.heap.allocate(len)? as u32; + this.memory.set(offset, &decrypted) + .map_err(|_| UserError("Invalid attempt to set memory in ext_decrypt"))?; + (offset, len) + }, + Err(()) => (0, u32::max_value()), + }; + + this.memory.write_primitive(msg_len, len) + .map_err(|_| UserError("Invalid attempt to write msg_len in ext_decrypt"))?; + + Ok(offset) + }, + ext_sign(key: u32, data: *const u8, data_len: u32, sig_data_len: *mut u32) -> *mut u8 => { + let key = u32_to_key(key) + .map_err(|_| UserError("key OOB while ext_sign: wasm"))?; + let message = this.memory.get(data, data_len as usize) + .map_err(|_| UserError("OOB while ext_sign: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.sign(key, &*message)) + .ok_or_else(|| UserError("Calling unavailable API ext_sign: wasm"))?; + + let (offset,len) = match res { + Ok(signature) => { + let len = signature.len() as u32; + let offset = this.heap.allocate(len)? as u32; + this.memory.set(offset, &signature) + .map_err(|_| UserError("Invalid attempt to set memory in ext_sign"))?; + (offset, len) + }, + Err(()) => (0, u32::max_value()), + }; + + this.memory.write_primitive(sig_data_len, len) + .map_err(|_| UserError("Invalid attempt to write sig_data_len in ext_sign"))?; + + Ok(offset) + }, + ext_verify( + key: u32, + msg: *const u8, + msg_len: u32, + signature: *const u8, + signature_len: u32 + ) -> u32 => { + let key = u32_to_key(key) + .map_err(|_| UserError("key OOB while ext_verify: wasm"))?; + let message = this.memory.get(msg, msg_len as usize) + .map_err(|_| UserError("OOB while ext_verify: wasm"))?; + let signature = this.memory.get(signature, signature_len as usize) + .map_err(|_| UserError("OOB while ext_verify: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.verify(key, &*message, &*signature)) + .ok_or_else(|| UserError("Calling unavailable API ext_verify: wasm"))?; + + match res { + Ok(true) => Ok(0), + Ok(false) => Ok(1), + Err(()) => Ok(u32::max_value()), + } + }, + ext_timestamp() -> u64 => { + let timestamp = this.ext.offchain() + .map(|api| api.timestamp()) + .ok_or_else(|| UserError("Calling unavailable API ext_timestamp: wasm"))?; + Ok(timestamp.unix_millis()) + }, + ext_sleep_until(deadline: u64) => { + this.ext.offchain() + .map(|api| api.sleep_until(offchain::Timestamp::from_unix_millis(deadline))) + .ok_or_else(|| UserError("Calling unavailable API ext_sleep_until: wasm"))?; Ok(()) }, + ext_random_seed(seed_data: *mut u8) => { + // NOTE the runtime as assumptions about seed size. + let seed: [u8; 32] = this.ext.offchain() + .map(|api| api.random_seed()) + .ok_or_else(|| UserError("Calling unavailable API ext_random_seed: wasm"))?; + + this.memory.set(seed_data, &seed) + .map_err(|_| UserError("Invalid attempt to set value in ext_random_seed"))?; + Ok(()) + }, + ext_local_storage_set(key: *const u8, key_len: u32, value: *const u8, value_len: u32) => { + let key = this.memory.get(key, key_len as usize) + .map_err(|_| UserError("OOB while ext_local_storage_set: wasm"))?; + let value = this.memory.get(value, value_len as usize) + .map_err(|_| UserError("OOB while ext_local_storage_set: wasm"))?; + + this.ext.offchain() + .map(|api| api.local_storage_set(&key, &value)) + .ok_or_else(|| UserError("Calling unavailable API ext_local_storage_set: wasm"))?; + + Ok(()) + }, + ext_local_storage_get(key: *const u8, key_len: u32, value_len: *mut u32) -> *mut u8 => { + let key = this.memory.get(key, key_len as usize) + .map_err(|_| UserError("OOB while ext_local_storage_get: wasm"))?; + + let maybe_value = this.ext.offchain() + .map(|api| api.local_storage_get(&key)) + .ok_or_else(|| UserError("Calling unavailable API ext_local_storage_get: wasm"))?; + + let (offset, len) = if let Some(value) = maybe_value { + let offset = this.heap.allocate(value.len() as u32)? as u32; + this.memory.set(offset, &value) + .map_err(|_| UserError("Invalid attempt to set memory in ext_local_storage_get"))?; + (offset, value.len() as u32) + } else { + (0, u32::max_value()) + }; + + this.memory.write_primitive(value_len, len) + .map_err(|_| UserError("Invalid attempt to write value_len in ext_local_storage_get"))?; + + Ok(offset) + }, + ext_http_request_start( + method: *const u8, + method_len: u32, + url: *const u8, + url_len: u32, + meta: *const u8, + meta_len: u32 + ) -> u32 => { + let method = this.memory.get(method, method_len as usize) + .map_err(|_| UserError("OOB while ext_http_request_start: wasm"))?; + let url = this.memory.get(url, url_len as usize) + .map_err(|_| UserError("OOB while ext_http_request_start: wasm"))?; + let meta = this.memory.get(meta, meta_len as usize) + .map_err(|_| UserError("OOB while ext_http_request_start: wasm"))?; + + let method_str = str::from_utf8(&method) + .map_err(|_| UserError("invalid str while ext_http_request_start: wasm"))?; + let url_str = str::from_utf8(&url) + .map_err(|_| UserError("invalid str while ext_http_request_start: wasm"))?; + + let id = this.ext.offchain() + .map(|api| api.http_request_start(method_str, url_str, &*meta)) + .ok_or_else(|| UserError("Calling unavailable API ext_http_request_start: wasm"))?; + + if let Ok(id) = id { + Ok(id.0 as u32) + } else { + Ok(u32::max_value()) + } + }, + ext_http_request_add_header( + request_id: u32, + name: *const u8, + name_len: u32, + value: *const u8, + value_len: u32 + ) -> u32 => { + let name = this.memory.get(name, name_len as usize) + .map_err(|_| UserError("OOB while ext_http_request_add_header: wasm"))?; + let value = this.memory.get(value, value_len as usize) + .map_err(|_| UserError("OOB while ext_http_request_add_header: wasm"))?; + + let name_str = str::from_utf8(&name) + .map_err(|_| UserError("invalid str while ext_http_request_add_header: wasm"))?; + let value_str = str::from_utf8(&value) + .map_err(|_| UserError("invalid str while ext_http_request_add_header: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.http_request_add_header( + offchain::HttpRequestId(request_id as u16), + &name_str, + &value_str, + )) + .ok_or_else(|| UserError("Calling unavailable API ext_http_request_add_header: wasm"))?; + + Ok(if res.is_ok() { 0 } else { 1 }) + }, + ext_http_request_write_body( + request_id: u32, + chunk: *const u8, + chunk_len: u32, + deadline: u64 + ) -> u32 => { + let chunk = this.memory.get(chunk, chunk_len as usize) + .map_err(|_| UserError("OOB while ext_http_request_write_body: wasm"))?; + + let res = this.ext.offchain() + .map(|api| api.http_request_write_body( + offchain::HttpRequestId(request_id as u16), + &chunk, + deadline_to_timestamp(deadline) + )) + .ok_or_else(|| UserError("Calling unavailable API ext_http_request_write_body: wasm"))?; + + Ok(match res { + Ok(()) => 0, + Err(e) => e as u8 as u32, + }) + }, + ext_http_response_wait( + ids: *const u32, + ids_len: u32, + statuses: *mut u32, + deadline: u64 + ) => { + let ids = (0..ids_len) + .map(|i| + this.memory.read_primitive(ids + i * 4) + .map(|id: u32| offchain::HttpRequestId(id as u16)) + .map_err(|_| UserError("OOB while ext_http_response_wait: wasm")) + ) + .collect::<::std::result::Result, _>>()?; + + let res = this.ext.offchain() + .map(|api| api.http_response_wait(&ids, deadline_to_timestamp(deadline))) + .ok_or_else(|| UserError("Calling unavailable API ext_http_response_wait: wasm"))? + .into_iter() + .map(|status| status.into()) + .enumerate() + // make sure to take up to `ids_len` to avoid exceeding the mem. + .take(ids_len as usize); + + for (i, status) in res { + this.memory.write_primitive(statuses + i as u32 * 4, status) + .map_err(|_| UserError("Invalid attempt to set memory in ext_http_response_wait"))?; + } + + Ok(()) + }, + ext_http_response_headers( + request_id: u32, + written_out: *mut u32 + ) -> *mut u8 => { + use parity_codec::Encode; + + let headers = this.ext.offchain() + .map(|api| api.http_response_headers(offchain::HttpRequestId(request_id as u16))) + .ok_or_else(|| UserError("Calling unavailable API ext_http_response_headers: wasm"))?; + + let encoded = headers.encode(); + let len = encoded.len() as u32; + let offset = this.heap.allocate(len)? as u32; + this.memory.set(offset, &encoded) + .map_err(|_| UserError("Invalid attempt to set memory in ext_http_response_headers"))?; + this.memory.write_primitive(written_out, len) + .map_err(|_| UserError("Invalid attempt to write written_out in ext_http_response_headers"))?; + + Ok(offset) + }, + ext_http_response_read_body( + request_id: u32, + buffer: *mut u8, + buffer_len: u32, + deadline: u64 + ) -> u32 => { + let mut internal_buffer = Vec::with_capacity(buffer_len as usize); + internal_buffer.resize(buffer_len as usize, 0); + + let res = this.ext.offchain() + .map(|api| api.http_response_read_body( + offchain::HttpRequestId(request_id as u16), + &mut internal_buffer, + deadline_to_timestamp(deadline), + )) + .ok_or_else(|| UserError("Calling unavailable API ext_http_response_read_body: wasm"))?; + + Ok(match res { + Ok(read) => { + this.memory.set(buffer, &internal_buffer[..read]) + .map_err(|_| UserError("Invalid attempt to set memory in ext_http_response_read_body"))?; + + read as u32 + }, + Err(err) => { + u32::max_value() - err as u8 as u32 + 1 + } + }) + }, ext_sandbox_instantiate( dispatch_thunk_idx: usize, wasm_ptr: *const u8, diff --git a/core/offchain/Cargo.toml b/core/offchain/Cargo.toml index 14341e2458..da2aeb4334 100644 --- a/core/offchain/Cargo.toml +++ b/core/offchain/Cargo.toml @@ -13,6 +13,7 @@ futures = "0.1.25" log = "0.4" offchain-primitives = { package = "substrate-offchain-primitives", path = "./primitives" } parity-codec = { version = "3.3", features = ["derive"] } +parking_lot = "0.7.1" primitives = { package = "substrate-primitives", path = "../../core/primitives" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } tokio = "0.1.7" diff --git a/core/offchain/src/api.rs b/core/offchain/src/api.rs index 25a8a2ebaa..d2c7630c24 100644 --- a/core/offchain/src/api.rs +++ b/core/offchain/src/api.rs @@ -16,9 +16,13 @@ use std::sync::Arc; use futures::{Stream, Future, sync::mpsc}; -use log::{info, debug, warn}; +use log::{info, debug, warn, error}; use parity_codec::Decode; -use primitives::OffchainExt; +use primitives::offchain::{ + Timestamp, HttpRequestId, HttpRequestStatus, HttpError, + Externalities as OffchainExt, + CryptoKind, CryptoKeyId, +}; use runtime_primitives::{ generic::BlockId, traits::{self, Extrinsic}, @@ -35,9 +39,122 @@ enum ExtMessage { /// NOTE this is done to prevent recursive calls into the runtime (which are not supported currently). pub(crate) struct AsyncApi(mpsc::UnboundedSender); +fn unavailable_yet(name: &str) -> R { + error!("This {:?} API is not available for offchain workers yet. Follow + https://github.com/paritytech/substrate/issues/1458 for details", name); + Default::default() +} + impl OffchainExt for AsyncApi { - fn submit_extrinsic(&mut self, ext: Vec) { - let _ = self.0.unbounded_send(ExtMessage::SubmitExtrinsic(ext)); + fn submit_transaction(&mut self, ext: Vec) -> Result<(), ()> { + self.0.unbounded_send(ExtMessage::SubmitExtrinsic(ext)) + .map(|_| ()) + .map_err(|_| ()) + } + + fn new_crypto_key(&mut self, _crypto: CryptoKind) -> Result { + unavailable_yet::<()>("new_crypto_key"); + Err(()) + } + + fn encrypt(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unavailable_yet::<()>("encrypt"); + Err(()) + } + + fn decrypt(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unavailable_yet::<()>("decrypt"); + Err(()) + } + + fn sign(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unavailable_yet::<()>("sign"); + Err(()) + } + + fn verify(&mut self, _key: Option, _msg: &[u8], _signature: &[u8]) -> Result { + unavailable_yet::<()>("verify"); + Err(()) + } + + fn timestamp(&mut self) -> Timestamp { + unavailable_yet("timestamp") + } + + fn sleep_until(&mut self, _deadline: Timestamp) { + unavailable_yet::<()>("sleep_until") + } + + fn random_seed(&mut self) -> [u8; 32] { + unavailable_yet("random_seed") + } + + fn local_storage_set(&mut self, _key: &[u8], _value: &[u8]) { + unavailable_yet("local_storage_set") + } + + fn local_storage_compare_and_set(&mut self, _key: &[u8], _old_value: &[u8], _new_value: &[u8]) { + unavailable_yet("local_storage_compare_and_set") + } + + fn local_storage_get(&mut self, _key: &[u8]) -> Option> { + unavailable_yet("local_storage_get") + } + + fn http_request_start( + &mut self, + _method: &str, + _uri: &str, + _meta: &[u8] + ) -> Result { + unavailable_yet::<()>("http_request_start"); + Err(()) + } + + fn http_request_add_header( + &mut self, + _request_id: HttpRequestId, + _name: &str, + _value: &str + ) -> Result<(), ()> { + unavailable_yet::<()>("http_request_add_header"); + Err(()) + } + + fn http_request_write_body( + &mut self, + _request_id: HttpRequestId, + _chunk: &[u8], + _deadline: Option + ) -> Result<(), HttpError> { + unavailable_yet::<()>("http_request_write_body"); + Err(HttpError::IoError) + } + + fn http_response_wait( + &mut self, + ids: &[HttpRequestId], + _deadline: Option + ) -> Vec { + unavailable_yet::<()>("http_response_wait"); + ids.iter().map(|_| HttpRequestStatus::Unknown).collect() + } + + fn http_response_headers( + &mut self, + _request_id: HttpRequestId + ) -> Vec<(Vec, Vec)> { + unavailable_yet("http_response_headers") + } + + fn http_response_read_body( + &mut self, + _request_id: HttpRequestId, + _buffer: &mut [u8], + _deadline: Option + ) -> Result { + unavailable_yet::<()>("http_response_read_body"); + Err(HttpError::IoError) } } diff --git a/core/offchain/src/lib.rs b/core/offchain/src/lib.rs index f176fadd0d..376f41b445 100644 --- a/core/offchain/src/lib.rs +++ b/core/offchain/src/lib.rs @@ -50,6 +50,8 @@ use transaction_pool::txpool::{Pool, ChainApi}; mod api; +pub mod testing; + pub use offchain_primitives::OffchainWorkerApi; /// An offchain workers manager. diff --git a/core/offchain/src/testing.rs b/core/offchain/src/testing.rs new file mode 100644 index 0000000000..3419665d0a --- /dev/null +++ b/core/offchain/src/testing.rs @@ -0,0 +1,244 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Offchain Externalities implementation for tests. + +use std::{ + collections::BTreeMap, + sync::Arc, +}; +use parking_lot::RwLock; +use primitives::offchain::{ + self, + HttpError, + HttpRequestId as RequestId, + HttpRequestStatus as RequestStatus, + Timestamp, + CryptoKind, + CryptoKeyId, +}; + +/// Pending request. +#[derive(Debug, Default, PartialEq, Eq)] +pub struct PendingRequest { + /// HTTP method + pub method: String, + /// URI + pub uri: String, + /// Encoded Metadata + pub meta: Vec, + /// Request headers + pub headers: Vec<(String, String)>, + /// Request body + pub body: Vec, + /// Has the request been sent already. + pub sent: bool, + /// Response body + pub response: Vec, + /// Number of bytes already read from the response body. + pub read: usize, + /// Response headers + pub response_headers: Vec<(String, String)>, +} + +/// Internal state of the externalities. +/// +/// This can be used in tests to respond or assert stuff about interactions. +#[derive(Debug, Default)] +pub struct State { + /// A list of pending requests. + pub requests: BTreeMap, +} + +impl State { + /// Asserts that pending request has been submitted and fills it's response. + pub fn fulfill_pending_request( + &mut self, + id: u16, + expected: PendingRequest, + response: impl Into>, + response_headers: impl IntoIterator, + ) { + match self.requests.get_mut(&RequestId(id)) { + None => { + panic!("Missing expected request: {:?}.\n\nAll: {:?}", id, self.requests); + } + Some(req) => { + assert_eq!( + *req, + expected, + ); + req.response = response.into(); + req.response_headers = response_headers.into_iter().collect(); + } + } + } +} + +/// Implementation of offchain externalities used for tests. +#[derive(Clone, Default, Debug)] +pub struct TestOffchainExt(pub Arc>); + +impl offchain::Externalities for TestOffchainExt { + fn submit_transaction(&mut self, _ex: Vec) -> Result<(), ()> { + unimplemented!("not needed in tests so far") + } + + fn new_crypto_key(&mut self, _crypto: CryptoKind) -> Result { + unimplemented!("not needed in tests so far") + } + + fn encrypt(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unimplemented!("not needed in tests so far") + } + + fn decrypt(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unimplemented!("not needed in tests so far") + } + + fn sign(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unimplemented!("not needed in tests so far") + } + + fn verify(&mut self, _key: Option, _msg: &[u8], _signature: &[u8]) -> Result { + unimplemented!("not needed in tests so far") + } + + fn timestamp(&mut self) -> Timestamp { + unimplemented!("not needed in tests so far") + } + + fn sleep_until(&mut self, _deadline: Timestamp) { + unimplemented!("not needed in tests so far") + } + + fn random_seed(&mut self) -> [u8; 32] { + unimplemented!("not needed in tests so far") + } + + fn local_storage_set(&mut self, _key: &[u8], _value: &[u8]) { + unimplemented!("not needed in tests so far") + } + + fn local_storage_compare_and_set( + &mut self, + _key: &[u8], + _old_value: &[u8], + _new_value: &[u8] + ) { + unimplemented!("not needed in tests so far") + } + + fn local_storage_get(&mut self, _key: &[u8]) -> Option> { + unimplemented!("not needed in tests so far") + } + + fn http_request_start(&mut self, method: &str, uri: &str, meta: &[u8]) -> Result { + let mut state = self.0.write(); + let id = RequestId(state.requests.len() as u16); + state.requests.insert(id.clone(), PendingRequest { + method: method.into(), + uri: uri.into(), + meta: meta.into(), + ..Default::default() + }); + Ok(id) + } + + fn http_request_add_header( + &mut self, + request_id: RequestId, + name: &str, + value: &str, + ) -> Result<(), ()> { + let mut state = self.0.write(); + if let Some(req) = state.requests.get_mut(&request_id) { + req.headers.push((name.into(), value.into())); + Ok(()) + } else { + Err(()) + } + } + + fn http_request_write_body( + &mut self, + request_id: RequestId, + chunk: &[u8], + _deadline: Option + ) -> Result<(), HttpError> { + let mut state = self.0.write(); + if let Some(req) = state.requests.get_mut(&request_id) { + if chunk.is_empty() { + req.sent = true; + } + req.body.extend(chunk); + Ok(()) + } else { + Err(HttpError::IoError) + } + } + + fn http_response_wait( + &mut self, + ids: &[RequestId], + _deadline: Option, + ) -> Vec { + let state = self.0.read(); + + ids.iter().map(|id| match state.requests.get(id) { + Some(req) if req.response.is_empty() => RequestStatus::DeadlineReached, + None => RequestStatus::Unknown, + _ => RequestStatus::Finished(200), + }).collect() + } + + fn http_response_headers(&mut self, request_id: RequestId) -> Vec<(Vec, Vec)> { + let state = self.0.read(); + if let Some(req) = state.requests.get(&request_id) { + req.response_headers + .clone() + .into_iter() + .map(|(k, v)| (k.into_bytes(), v.into_bytes())) + .collect() + } else { + Default::default() + } + } + + fn http_response_read_body( + &mut self, + request_id: RequestId, + buffer: &mut [u8], + _deadline: Option + ) -> Result { + let mut state = self.0.write(); + if let Some(req) = state.requests.get_mut(&request_id) { + if req.read >= req.response.len() { + // Remove the pending request as per spec. + state.requests.remove(&request_id); + Ok(0) + } else { + let read = std::cmp::min(buffer.len(), req.response[req.read..].len()); + buffer[0..read].copy_from_slice(&req.response[req.read..read]); + req.read += read; + Ok(read) + } + } else { + Err(HttpError::IoError) + } + } +} + diff --git a/core/primitives/src/lib.rs b/core/primitives/src/lib.rs index c9008171df..69b9f1a960 100644 --- a/core/primitives/src/lib.rs +++ b/core/primitives/src/lib.rs @@ -56,6 +56,7 @@ pub mod ed25519; pub mod sr25519; pub mod hash; mod hasher; +pub mod offchain; pub mod sandbox; pub mod storage; pub mod uint; @@ -85,25 +86,11 @@ pub enum ExecutionContext { /// Context used for block construction. BlockConstruction, /// Offchain worker context. - OffchainWorker(Box), + OffchainWorker(Box), /// Context used for other calls. Other, } -/// An extended externalities for offchain workers. -pub trait OffchainExt { - /// Submits an extrinsics. - /// - /// The extrinsic will either go to the pool (signed) - /// or to the next produced block (inherent). - fn submit_extrinsic(&mut self, extrinsic: Vec); -} -impl OffchainExt for Box { - fn submit_extrinsic(&mut self, ex: Vec) { - (&mut **self).submit_extrinsic(ex) - } -} - /// Hex-serialized shim for `Vec`. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug, Hash, PartialOrd, Ord))] diff --git a/core/primitives/src/offchain.rs b/core/primitives/src/offchain.rs new file mode 100644 index 0000000000..764837d7b4 --- /dev/null +++ b/core/primitives/src/offchain.rs @@ -0,0 +1,410 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Offchain workers types + +use rstd::prelude::{Vec, Box}; +use rstd::convert::TryFrom; + +/// A type of supported crypto. +#[derive(Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +#[repr(C)] +pub enum CryptoKind { + /// SR25519 crypto (Schnorrkel) + Sr25519 = 1, + /// ED25519 crypto (Edwards) + Ed25519 = 2, +} + +impl TryFrom for CryptoKind { + type Error = (); + + fn try_from(kind: u32) -> Result { + match kind { + e if e == CryptoKind::Sr25519 as u8 as u32 => Ok(CryptoKind::Sr25519), + e if e == CryptoKind::Ed25519 as u8 as u32 => Ok(CryptoKind::Ed25519), + _ => Err(()) + } + } +} + +/// Opaque type for created crypto keys. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct CryptoKeyId(pub u16); + +/// Opaque type for offchain http requests. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct HttpRequestId(pub u16); + +/// An error enum returned by some http methods. +#[derive(Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +#[repr(C)] +pub enum HttpError { + /// The requested action couldn't been completed within a deadline. + DeadlineReached = 1, + /// There was an IO Error while processing the request. + IoError = 2, +} + +impl TryFrom for HttpError { + type Error = (); + + fn try_from(error: u32) -> Result { + match error { + e if e == HttpError::DeadlineReached as u8 as u32 => Ok(HttpError::DeadlineReached), + e if e == HttpError::IoError as u8 as u32 => Ok(HttpError::IoError), + _ => Err(()) + } + } +} + +/// Status of the HTTP request +#[derive(Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub enum HttpRequestStatus { + /// Deadline was reached while we waited for this request to finish. + /// + /// Note the deadline is controlled by the calling part, it not necessarily means + /// that the request has timed out. + DeadlineReached, + /// Request timed out. + /// + /// This means that the request couldn't be completed by the host environment + /// within a reasonable time (according to the host), has now been terminated + /// and is considered finished. + /// To retry the request you need to construct it again. + Timeout, + /// Request status of this ID is not known. + Unknown, + /// The request has finished with given status code. + Finished(u16), +} + +impl From for u32 { + fn from(status: HttpRequestStatus) -> Self { + match status { + HttpRequestStatus::Unknown => 0, + HttpRequestStatus::DeadlineReached => 10, + HttpRequestStatus::Timeout => 20, + HttpRequestStatus::Finished(code) => code as u32, + } + } +} + +impl TryFrom for HttpRequestStatus { + type Error = (); + + fn try_from(status: u32) -> Result { + match status { + 0 => Ok(HttpRequestStatus::Unknown), + 10 => Ok(HttpRequestStatus::DeadlineReached), + 20 => Ok(HttpRequestStatus::Timeout), + 100...999 => Ok(HttpRequestStatus::Finished(status as u16)), + _ => Err(()), + } + } +} + +/// Opaque timestamp type +#[derive(Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Default)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct Timestamp(u64); + +/// Duration type +#[derive(Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Default)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct Duration(u64); + +impl Duration { + /// Create new duration representing given number of milliseconds. + pub fn from_millis(millis: u64) -> Self { + Duration(millis) + } + + /// Returns number of milliseconds this Duration represents. + pub fn millis(&self) -> u64 { + self.0 + } +} + +impl Timestamp { + /// Creates new `Timestamp` given unix timestamp in miliseconds. + pub fn from_unix_millis(millis: u64) -> Self { + Timestamp(millis) + } + + /// Increase the timestamp by given `Duration`. + pub fn add(&self, duration: Duration) -> Timestamp { + Timestamp(self.0.saturating_add(duration.0)) + } + + /// Decrease the timestamp by given `Duration` + pub fn sub(&self, duration: Duration) -> Timestamp { + Timestamp(self.0.saturating_sub(duration.0)) + } + + /// Returns a saturated difference (Duration) between two Timestamps. + pub fn diff(&self, other: &Self) -> Duration { + Duration(self.0.saturating_sub(other.0)) + } + + /// Return number of milliseconds since UNIX epoch. + pub fn unix_millis(&self) -> u64 { + self.0 + } +} + +/// An extended externalities for offchain workers. +pub trait Externalities { + /// Submit transaction. + /// + /// The transaction will end up in the pool and be propagated to others. + fn submit_transaction(&mut self, extrinsic: Vec) -> Result<(), ()>; + + /// Create new key(pair) for signing/encryption/decryption. + /// + /// Returns an error if given crypto kind is not supported. + fn new_crypto_key(&mut self, crypto: CryptoKind) -> Result; + + /// Encrypt a piece of data using given crypto key. + /// + /// If `key` is `None`, it will attempt to use current authority key. + /// + /// Returns an error if `key` is not available or does not exist. + fn encrypt(&mut self, key: Option, data: &[u8]) -> Result, ()>; + + /// Decrypt a piece of data using given crypto key. + /// + /// If `key` is `None`, it will attempt to use current authority key. + /// + /// Returns an error if data cannot be decrypted or the `key` is not available or does not exist. + fn decrypt(&mut self, key: Option, data: &[u8]) -> Result, ()>; + + /// Sign a piece of data using given crypto key. + /// + /// If `key` is `None`, it will attempt to use current authority key. + /// + /// Returns an error if `key` is not available or does not exist. + fn sign(&mut self, key: Option, data: &[u8]) -> Result, ()>; + + /// Verifies that `signature` for `msg` matches given `key`. + /// + /// Returns an `Ok` with `true` in case it does, `false` in case it doesn't. + /// Returns an error in case the key is not available or does not exist or the parameters + /// lengths are incorrect. + fn verify(&mut self, key: Option, msg: &[u8], signature: &[u8]) -> Result; + + /// Returns current UNIX timestamp (in millis) + fn timestamp(&mut self) -> Timestamp; + + /// Pause the execution until `deadline` is reached. + fn sleep_until(&mut self, deadline: Timestamp); + + /// Returns a random seed. + /// + /// This is a trully random non deterministic seed generated by host environment. + /// Obviously fine in the off-chain worker context. + fn random_seed(&mut self) -> [u8; 32]; + + /// Sets a value in the local storage. + /// + /// Note this storage is not part of the consensus, it's only accessible by + /// offchain worker tasks running on the same machine. It IS persisted between runs. + fn local_storage_set(&mut self, key: &[u8], value: &[u8]); + + /// Sets a value in the local storage if it matches current value. + /// + /// Since multiple offchain workers may be running concurrently, to prevent + /// data races use CAS to coordinate between them. + /// + /// Note this storage is not part of the consensus, it's only accessible by + /// offchain worker tasks running on the same machine. It IS persisted between runs. + fn local_storage_compare_and_set(&mut self, key: &[u8], old_value: &[u8], new_value: &[u8]); + + /// Gets a value from the local storage. + /// + /// If the value does not exist in the storage `None` will be returned. + /// Note this storage is not part of the consensus, it's only accessible by + /// offchain worker tasks running on the same machine. It IS persisted between runs. + fn local_storage_get(&mut self, key: &[u8]) -> Option>; + + /// Initiaties a http request given HTTP verb and the URL. + /// + /// Meta is a future-reserved field containing additional, parity-codec encoded parameters. + /// Returns the id of newly started request. + fn http_request_start( + &mut self, + method: &str, + uri: &str, + meta: &[u8] + ) -> Result; + + /// Append header to the request. + fn http_request_add_header( + &mut self, + request_id: HttpRequestId, + name: &str, + value: &str + ) -> Result<(), ()>; + + /// Write a chunk of request body. + /// + /// Writing an empty chunks finalises the request. + /// Passing `None` as deadline blocks forever. + /// + /// Returns an error in case deadline is reached or the chunk couldn't be written. + fn http_request_write_body( + &mut self, + request_id: HttpRequestId, + chunk: &[u8], + deadline: Option + ) -> Result<(), HttpError>; + + /// Block and wait for the responses for given requests. + /// + /// Returns a vector of request statuses (the len is the same as ids). + /// Note that if deadline is not provided the method will block indefinitely, + /// otherwise unready responses will produce `DeadlineReached` status. + /// + /// Passing `None` as deadline blocks forever. + fn http_response_wait( + &mut self, + ids: &[HttpRequestId], + deadline: Option + ) -> Vec; + + /// Read all response headers. + /// + /// Returns a vector of pairs `(HeaderKey, HeaderValue)`. + fn http_response_headers( + &mut self, + request_id: HttpRequestId + ) -> Vec<(Vec, Vec)>; + + /// Read a chunk of body response to given buffer. + /// + /// Returns the number of bytes written or an error in case a deadline + /// is reached or server closed the connection. + /// Passing `None` as a deadline blocks forever. + fn http_response_read_body( + &mut self, + request_id: HttpRequestId, + buffer: &mut [u8], + deadline: Option + ) -> Result; + +} +impl Externalities for Box { + fn submit_transaction(&mut self, ex: Vec) -> Result<(), ()> { + (&mut **self).submit_transaction(ex) + } + + fn new_crypto_key(&mut self, crypto: CryptoKind) -> Result { + (&mut **self).new_crypto_key(crypto) + } + + fn encrypt(&mut self, key: Option, data: &[u8]) -> Result, ()> { + (&mut **self).encrypt(key, data) + } + + fn decrypt(&mut self, key: Option, data: &[u8]) -> Result, ()> { + (&mut **self).decrypt(key, data) + } + + fn sign(&mut self, key: Option, data: &[u8]) -> Result, ()> { + (&mut **self).sign(key, data) + } + + fn verify(&mut self, key: Option, msg: &[u8], signature: &[u8]) -> Result { + (&mut **self).verify(key, msg, signature) + } + + fn timestamp(&mut self) -> Timestamp { + (&mut **self).timestamp() + } + + fn sleep_until(&mut self, deadline: Timestamp) { + (&mut **self).sleep_until(deadline) + } + + fn random_seed(&mut self) -> [u8; 32] { + (&mut **self).random_seed() + } + + fn local_storage_set(&mut self, key: &[u8], value: &[u8]) { + (&mut **self).local_storage_set(key, value) + } + + fn local_storage_compare_and_set(&mut self, key: &[u8], old_value: &[u8], new_value: &[u8]) { + (&mut **self).local_storage_compare_and_set(key, old_value, new_value) + } + + fn local_storage_get(&mut self, key: &[u8]) -> Option> { + (&mut **self).local_storage_get(key) + } + + fn http_request_start(&mut self, method: &str, uri: &str, meta: &[u8]) -> Result { + (&mut **self).http_request_start(method, uri, meta) + } + + fn http_request_add_header(&mut self, request_id: HttpRequestId, name: &str, value: &str) -> Result<(), ()> { + (&mut **self).http_request_add_header(request_id, name, value) + } + + fn http_request_write_body( + &mut self, + request_id: HttpRequestId, + chunk: &[u8], + deadline: Option + ) -> Result<(), HttpError> { + (&mut **self).http_request_write_body(request_id, chunk, deadline) + } + + fn http_response_wait(&mut self, ids: &[HttpRequestId], deadline: Option) -> Vec { + (&mut **self).http_response_wait(ids, deadline) + } + + fn http_response_headers(&mut self, request_id: HttpRequestId) -> Vec<(Vec, Vec)> { + (&mut **self).http_response_headers(request_id) + } + + fn http_response_read_body( + &mut self, + request_id: HttpRequestId, + buffer: &mut [u8], + deadline: Option + ) -> Result { + (&mut **self).http_response_read_body(request_id, buffer, deadline) + } +} + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn timestamp_ops() { + let t = Timestamp(5); + assert_eq!(t.add(Duration::from_millis(10)), Timestamp(15)); + assert_eq!(t.sub(Duration::from_millis(10)), Timestamp(0)); + assert_eq!(t.diff(&Timestamp(3)), Duration(2)); + } +} diff --git a/core/sr-io/Cargo.toml b/core/sr-io/Cargo.toml index dbe699b4b5..0c97ba8050 100644 --- a/core/sr-io/Cargo.toml +++ b/core/sr-io/Cargo.toml @@ -19,6 +19,9 @@ environmental = { version = "1.0.1", optional = true } substrate-state-machine = { path = "../state-machine", optional = true } trie = { package = "substrate-trie", path = "../trie", optional = true } +[dev-dependencies] +substrate-offchain = { path = "../offchain" } + [features] default = ["std"] std = [ diff --git a/core/sr-io/src/lib.rs b/core/sr-io/src/lib.rs index 314aa3b61e..cd9b43798b 100644 --- a/core/sr-io/src/lib.rs +++ b/core/sr-io/src/lib.rs @@ -33,6 +33,7 @@ use rstd::vec::Vec; pub use codec; pub use primitives::Blake2Hasher; +use primitives::offchain::{Timestamp, HttpRequestId, HttpRequestStatus, HttpError, CryptoKind, CryptoKeyId}; /// Error verifying ECDSA signature pub enum EcdsaVerifyError { @@ -44,6 +45,8 @@ pub enum EcdsaVerifyError { BadSignature, } +pub mod offchain; + /// Trait for things which can be printed. pub trait Printable { /// Print the object. @@ -226,12 +229,140 @@ export_api! { export_api! { pub(crate) trait OffchainApi { - /// Submit extrinsic from the runtime. + /// Submit transaction to the pool. + /// + /// The transaction will end up in the pool. + fn submit_transaction(data: &T) -> Result<(), ()>; + + /// Create new key(pair) for signing/encryption/decryption. + /// + /// Returns an error if given crypto kind is not supported. + fn new_crypto_key(crypto: CryptoKind) -> Result; + + /// Encrypt a piece of data using given crypto key. + /// + /// If `key` is `None`, it will attempt to use current authority key. + /// + /// Returns an error if `key` is not available or does not exist. + fn encrypt(key: Option, data: &[u8]) -> Result, ()>; + + /// Decrypt a piece of data using given crypto key. + /// + /// If `key` is `None`, it will attempt to use current authority key. + /// + /// Returns an error if data cannot be decrypted or the `key` is not available or does not exist. + fn decrypt(key: Option, data: &[u8]) -> Result, ()>; + + /// Sign a piece of data using given crypto key. + /// + /// If `key` is `None`, it will attempt to use current authority key. + /// + /// Returns an error if `key` is not available or does not exist. + fn sign(key: Option, data: &[u8]) -> Result, ()>; + + /// Verifies that `signature` for `msg` matches given `key`. + /// + /// Returns an `Ok` with `true` in case it does, `false` in case it doesn't. + /// Returns an error in case the key is not available or does not exist or the parameters + /// lengths are incorrect. + fn verify(key: Option, msg: &[u8], signature: &[u8]) -> Result; + + /// Returns current UNIX timestamp (in millis) + fn timestamp() -> Timestamp; + + /// Pause the execution until `deadline` is reached. + fn sleep_until(deadline: Timestamp); + + /// Returns a random seed. + /// + /// This is a trully random non deterministic seed generated by host environment. + /// Obviously fine in the off-chain worker context. + fn random_seed() -> [u8; 32]; + + /// Sets a value in the local storage. + /// + /// Note this storage is not part of the consensus, it's only accessible by + /// offchain worker tasks running on the same machine. It IS persisted between runs. + fn local_storage_set(key: &[u8], value: &[u8]); + + /// Sets a value in the local storage if it matches current value. + /// + /// Since multiple offchain workers may be running concurrently, to prevent + /// data races use CAS to coordinate between them. + /// + /// Note this storage is not part of the consensus, it's only accessible by + /// offchain worker tasks running on the same machine. It IS persisted between runs. + fn local_storage_compare_and_set(key: &[u8], old_value: &[u8], new_value: &[u8]); + + /// Gets a value from the local storage. + /// + /// If the value does not exist in the storage `None` will be returned. + /// Note this storage is not part of the consensus, it's only accessible by + /// offchain worker tasks running on the same machine. It IS persisted between runs. + fn local_storage_get(key: &[u8]) -> Option>; + + /// Initiaties a http request given HTTP verb and the URL. + /// + /// Meta is a future-reserved field containing additional, parity-codec encoded parameters. + /// Returns the id of newly started request. + fn http_request_start( + method: &str, + uri: &str, + meta: &[u8] + ) -> Result; + + /// Append header to the request. + fn http_request_add_header( + request_id: HttpRequestId, + name: &str, + value: &str + ) -> Result<(), ()>; + + /// Write a chunk of request body. + /// + /// Writing an empty chunks finalises the request. + /// Passing `None` as deadline blocks forever. + /// + /// Returns an error in case deadline is reached or the chunk couldn't be written. + fn http_request_write_body( + request_id: HttpRequestId, + chunk: &[u8], + deadline: Option + ) -> Result<(), HttpError>; + + /// Block and wait for the responses for given requests. + /// + /// Returns a vector of request statuses (the len is the same as ids). + /// Note that if deadline is not provided the method will block indefinitely, + /// otherwise unready responses will produce `DeadlineReached` status. + /// + /// Passing `None` as deadline blocks forever. + fn http_response_wait( + ids: &[HttpRequestId], + deadline: Option + ) -> Vec; + + /// Read all response headers. + /// + /// Returns a vector of pairs `(HeaderKey, HeaderValue)`. + /// NOTE response headers have to be read before response body. + fn http_response_headers( + request_id: HttpRequestId + ) -> Vec<(Vec, Vec)>; + + /// Read a chunk of body response to given buffer. /// - /// Depending on the kind of extrinsic it will either be: - /// 1. scheduled to be included in the next produced block (inherent) - /// 2. added to the pool and propagated (transaction) - fn submit_extrinsic(data: &T); + /// Returns the number of bytes written or an error in case a deadline + /// is reached or server closed the connection. + /// If `0` is returned it means that the response has been fully consumed + /// and the `request_id` is now invalid. + /// NOTE this implies that response headers must be read before draining the body. + /// Passing `None` as a deadline blocks forever. + fn http_response_read_body( + request_id: HttpRequestId, + buffer: &mut [u8], + deadline: Option + ) -> Result; } } diff --git a/core/sr-io/src/offchain/http.rs b/core/sr-io/src/offchain/http.rs new file mode 100644 index 0000000000..0708f83717 --- /dev/null +++ b/core/sr-io/src/offchain/http.rs @@ -0,0 +1,571 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! A non-std set of HTTP types. + +use rstd::str; +use rstd::prelude::Vec; +#[cfg(not(feature = "std"))] +use rstd::prelude::vec; +use primitives::offchain::{ + Timestamp, + HttpRequestId as RequestId, + HttpRequestStatus as RequestStatus, + HttpError, +}; + +/// Request method (HTTP verb) +#[derive(Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub enum Method { + /// GET request + Get, + /// POST request + Post, + /// PUT request + Put, + /// PATCH request + Patch, + /// DELETE request + Delete, + /// Custom verb + Other(&'static str), +} + +impl AsRef for Method { + fn as_ref(&self) -> &str { + match *self { + Method::Get => "GET", + Method::Post => "POST", + Method::Put => "PUT", + Method::Patch => "PATCH", + Method::Delete => "DELETE", + Method::Other(m) => m, + } + } +} + +mod header { + use super::*; + + /// A header type. + #[derive(Clone, PartialEq, Eq)] + #[cfg_attr(feature = "std", derive(Debug))] + pub struct Header { + name: Vec, + value: Vec, + } + + impl Header { + /// Creates new header given it's name and value. + pub fn new(name: &str, value: &str) -> Self { + Header { + name: name.as_bytes().to_vec(), + value: value.as_bytes().to_vec(), + } + } + + /// Returns the name of this header. + pub fn name(&self) -> &str { + // Header keys are always produced from `&str` so this is safe. + // we don't store them as `Strings` to avoid bringing `alloc::String` to rstd + // or here. + unsafe { str::from_utf8_unchecked(&self.name) } + } + + /// Returns the value of this header. + pub fn value(&self) -> &str { + // Header values are always produced from `&str` so this is safe. + // we don't store them as `Strings` to avoid bringing `alloc::String` to rstd + // or here. + unsafe { str::from_utf8_unchecked(&self.value) } + } + } +} + +/// An HTTP request builder. +#[derive(Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct Request<'a, T = Vec<&'static [u8]>> { + /// Request method + pub method: Method, + /// Request URL + pub url: &'a str, + /// Body of the request + pub body: T, + /// Deadline to finish sending the request + pub deadline: Option, + /// Request list of headers. + headers: Vec, +} + +impl Default for Request<'static, T> { + fn default() -> Self { + Request { + method: Method::Get, + url: "http://localhost", + headers: Vec::new(), + body: Default::default(), + deadline: None, + } + } +} + +impl<'a> Request<'a> { + /// Start a simple GET request + pub fn get(url: &'a str) -> Self { + Self::new(url) + } +} + +impl<'a, T> Request<'a, T> { + /// Create new POST request with given body. + pub fn post(url: &'a str, body: T) -> Self { + let req: Request = Request::default(); + + Request { + url, + body, + method: Method::Post, + headers: req.headers, + deadline: req.deadline, + } + } +} + +impl<'a, T: Default> Request<'a, T> { + /// Create new Request builder with given URL and body. + pub fn new(url: &'a str) -> Self { + Request::default().url(url) + } + + /// Change the method of the request + pub fn method(mut self, method: Method) -> Self { + self.method = method; + self + } + + /// Change the URL of the request. + pub fn url(mut self, url: &'a str) -> Self { + self.url = url; + self + } + + /// Set the body of the request. + pub fn body(mut self, body: T) -> Self { + self.body = body; + self + } + + /// Add a header. + pub fn add_header(mut self, name: &str, value: &str) -> Self { + self.headers.push(header::Header::new(name, value)); + self + } + + /// Set the deadline of the request. + pub fn deadline(mut self, deadline: Timestamp) -> Self { + self.deadline = Some(deadline); + self + } +} + +impl<'a, I: AsRef<[u8]>, T: IntoIterator> Request<'a, T> { + /// Send the request and return a handle. + /// + /// Err is returned in case the deadline is reached + /// or the request timeouts. + pub fn send(self) -> Result { + let meta = &[]; + + // start an http request. + let id = crate::http_request_start(self.method.as_ref(), self.url, meta).map_err(|_| HttpError::IoError)?; + + // add custom headers + for header in &self.headers { + crate::http_request_add_header( + id, + header.name(), + header.value(), + ).map_err(|_| HttpError::IoError)? + } + + // write body + for chunk in self.body { + crate::http_request_write_body(id, chunk.as_ref(), self.deadline)?; + } + + // finalise the request + crate::http_request_write_body(id, &[], self.deadline)?; + + Ok(PendingRequest { + id, + }) + } +} + +/// A request error +#[derive(Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub enum Error { + /// Deadline has been reached. + DeadlineReached, + /// Request had timed out. + Timeout, + /// Unknown error has been ecountered. + Unknown, +} + +/// A struct representing an uncompleted http request. +#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct PendingRequest { + /// Request ID + pub id: RequestId, +} + +/// A result of waiting for a pending request. +pub type HttpResult = Result; + +impl PendingRequest { + /// Wait for the request to complete. + /// + /// NOTE this waits for the request indefinitely. + pub fn wait(self) -> HttpResult { + match self.try_wait(None) { + Ok(res) => res, + Err(_) => panic!("Since `None` is passed we will never get a deadline error; qed"), + } + } + + /// Attempts to wait for the request to finish, + /// but will return `Err` in case the deadline is reached. + pub fn try_wait(self, deadline: impl Into>) -> Result { + Self::try_wait_all(vec![self], deadline).pop().expect("One request passed, one status received; qed") + } + + /// Wait for all provided requests. + pub fn wait_all(requests: Vec) -> Vec { + Self::try_wait_all(requests, None) + .into_iter() + .map(|r| match r { + Ok(r) => r, + Err(_) => panic!("Since `None` is passed we will never get a deadline error; qed"), + }) + .collect() + } + + /// Attempt to wait for all provided requests, but up to given deadline. + /// + /// Requests that are complete will resolve to an `Ok` others will return a `DeadlineReached` error. + pub fn try_wait_all( + requests: Vec, + deadline: impl Into> + ) -> Vec> { + let ids = requests.iter().map(|r| r.id).collect::>(); + let statuses = crate::http_response_wait(&ids, deadline.into()); + + statuses + .into_iter() + .zip(requests.into_iter()) + .map(|(status, req)| match status { + RequestStatus::DeadlineReached => Err(req), + RequestStatus::Timeout => Ok(Err(Error::Timeout)), + RequestStatus::Unknown => Ok(Err(Error::Unknown)), + RequestStatus::Finished(code) => Ok(Ok(Response::new(req.id, code))), + }) + .collect() + } +} + +/// A HTTP response. +#[cfg_attr(feature = "std", derive(Debug))] +pub struct Response { + /// Request id + pub id: RequestId, + /// Response status code + pub code: u16, + /// A collection of headers. + headers: Option, +} + +impl Response { + fn new(id: RequestId, code: u16) -> Self { + Self { + id, + code, + headers: None, + } + } + + /// Retrieve the headers for this response. + pub fn headers(&mut self) -> &Headers { + if self.headers.is_none() { + self.headers = Some(Headers { raw: crate::http_response_headers(self.id) }); + } + self.headers.as_ref().expect("Headers were just set; qed") + } + + /// Retrieve the body of this response. + pub fn body(&self) -> ResponseBody { + ResponseBody::new(self.id) + } +} + +/// A buffered byte iterator over response body. +/// +/// Note that reading the body may return `None` in following cases: +/// 1. Either the deadline you've set is reached (check via `#error`; +/// In such case you can resume the reader by setting a new deadline) +/// 2. Or because of IOError. In such case the reader is not resumable and will keep +/// returning `None`. +/// 3. The body has been returned. The reader will keep returning `None`. +#[derive(Clone)] +pub struct ResponseBody { + id: RequestId, + error: Option, + buffer: [u8; 4096], + filled_up_to: Option, + position: usize, + deadline: Option, +} + +#[cfg(feature = "std")] +impl std::fmt::Debug for ResponseBody { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + fmt.debug_struct("ResponseBody") + .field("id", &self.id) + .field("error", &self.error) + .field("buffer", &self.buffer.len()) + .field("filled_up_to", &self.filled_up_to) + .field("position", &self.position) + .field("deadline", &self.deadline) + .finish() + } +} + +impl ResponseBody { + fn new(id: RequestId) -> Self { + ResponseBody { + id, + error: None, + buffer: [0_u8; 4096], + filled_up_to: None, + position: 0, + deadline: None, + } + } + + /// Set the deadline for reading the body. + pub fn deadline(&mut self, deadline: impl Into>) { + self.deadline = deadline.into(); + self.error = None; + } + + /// Return an error that caused the iterator to return `None`. + /// + /// If the error is `DeadlineReached` you can resume the iterator by setting + /// a new deadline. + pub fn error(&self) -> &Option { + &self.error + } +} + +impl Iterator for ResponseBody { + type Item = u8; + + fn next(&mut self) -> Option { + if self.error.is_some() { + return None; + } + + if self.filled_up_to.is_none() { + let result = crate::http_response_read_body(self.id, &mut self.buffer, self.deadline); + match result { + Err(e) => { + self.error = Some(e); + return None; + } + Ok(0) => { + return None; + } + Ok(size) => { + self.position = 0; + self.filled_up_to = Some(size); + } + } + } + + if Some(self.position) == self.filled_up_to { + self.filled_up_to = None; + return self.next(); + } + + let result = self.buffer[self.position]; + self.position += 1; + Some(result) + } +} + +/// A collection of Headers in the response. +#[derive(Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct Headers { + /// Raw headers + pub raw: Vec<(Vec, Vec)>, +} + +impl Headers { + /// Retrieve a single header from the list of headers. + /// + /// Note this method is linearly looking from all the headers + /// comparing them with the needle byte-by-byte. + /// If you want to consume multiple headers it's better to iterate + /// and collect them on your own. + pub fn find(&self, name: &str) -> Option<&str> { + let raw = name.as_bytes(); + for &(ref key, ref val) in &self.raw { + if &**key == raw { + return str::from_utf8(&val).ok() + } + } + None + } + + /// Convert this headers into an iterator. + pub fn into_iter(&self) -> HeadersIterator { + HeadersIterator { collection: &self.raw, index: None } + } +} + +/// A custom iterator traversing all the headers. +#[derive(Clone)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct HeadersIterator<'a> { + collection: &'a [(Vec, Vec)], + index: Option, +} + +impl<'a> HeadersIterator<'a> { + /// Move the iterator to the next position. + /// + /// Returns `true` is `current` has been set by this call. + pub fn next(&mut self) -> bool { + let index = self.index.map(|x| x + 1).unwrap_or(0); + self.index = Some(index); + index < self.collection.len() + } + + /// Returns current element (if any). + /// + /// Note that you have to call `next` prior to calling this + pub fn current(&self) -> Option<(&str, &str)> { + self.collection.get(self.index?) + .map(|val| (str::from_utf8(&val.0).unwrap_or(""), str::from_utf8(&val.1).unwrap_or(""))) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{TestExternalities, with_externalities}; + use substrate_offchain::testing; + + #[test] + fn should_send_a_basic_request_and_get_response() { + let offchain = testing::TestOffchainExt::default(); + let mut t = TestExternalities::default(); + let state = offchain.0.clone(); + t.set_offchain_externalities(offchain); + + with_externalities(&mut t, || { + let request: Request = Request::get("http://localhost:1234"); + let pending = request + .add_header("X-Auth", "hunter2") + .send() + .unwrap(); + // make sure it's sent correctly + state.write().fulfill_pending_request( + 0, + testing::PendingRequest { + method: "GET".into(), + uri: "http://localhost:1234".into(), + headers: vec![("X-Auth".into(), "hunter2".into())], + sent: true, + ..Default::default() + }, + b"1234".to_vec(), + None, + ); + + // wait + let mut response = pending.wait().unwrap(); + + // then check the response + let mut headers = response.headers().into_iter(); + assert_eq!(headers.current(), None); + assert_eq!(headers.next(), false); + assert_eq!(headers.current(), None); + + let body = response.body(); + assert_eq!(body.clone().collect::>(), b"1234".to_vec()); + assert_eq!(body.error(), &None); + }) + } + + #[test] + fn should_send_a_post_request() { + let offchain = testing::TestOffchainExt::default(); + let mut t = TestExternalities::default(); + let state = offchain.0.clone(); + t.set_offchain_externalities(offchain); + + with_externalities(&mut t, || { + let pending = Request::default() + .method(Method::Post) + .url("http://localhost:1234") + .body(vec![b"1234"]) + .send() + .unwrap(); + // make sure it's sent correctly + state.write().fulfill_pending_request( + 0, + testing::PendingRequest { + method: "POST".into(), + uri: "http://localhost:1234".into(), + body: b"1234".to_vec(), + sent: true, + ..Default::default() + }, + b"1234".to_vec(), + Some(("Test".to_owned(), "Header".to_owned())), + ); + + // wait + let mut response = pending.wait().unwrap(); + + // then check the response + let mut headers = response.headers().into_iter(); + assert_eq!(headers.current(), None); + assert_eq!(headers.next(), true); + assert_eq!(headers.current(), Some(("Test", "Header"))); + + let body = response.body(); + assert_eq!(body.clone().collect::>(), b"1234".to_vec()); + assert_eq!(body.error(), &None); + }) + } +} diff --git a/core/sr-io/src/offchain/mod.rs b/core/sr-io/src/offchain/mod.rs new file mode 100644 index 0000000000..6b82f77111 --- /dev/null +++ b/core/sr-io/src/offchain/mod.rs @@ -0,0 +1,19 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! A collection of higher lever helpers for offchain workers. + +pub mod http; diff --git a/core/sr-io/with_std.rs b/core/sr-io/with_std.rs index 1bc0141c1d..01e7614de6 100644 --- a/core/sr-io/with_std.rs +++ b/core/sr-io/with_std.rs @@ -28,7 +28,7 @@ pub use substrate_state_machine::{ }; use environmental::environmental; -use primitives::{hexdisplay::HexDisplay, H256}; +use primitives::{offchain, hexdisplay::HexDisplay, H256}; #[cfg(feature = "std")] use std::collections::HashMap; @@ -251,12 +251,142 @@ impl HashingApi for () { } } +fn with_offchain(f: impl FnOnce(&mut offchain::Externalities) -> R, msg: &'static str) -> R { + ext::with(|ext| ext + .offchain() + .map(|ext| f(ext)) + .expect(msg) + ).expect("offchain-worker functions cannot be called outside of an Externalities-provided environment.") +} + impl OffchainApi for () { - fn submit_extrinsic(data: &T) { - ext::with(|ext| ext - .submit_extrinsic(codec::Encode::encode(data)) - .expect("submit_extrinsic can be called only in offchain worker context") - ).expect("submit_extrinsic cannot be called outside of an Externalities-provided environment.") + fn submit_transaction(data: &T) -> Result<(), ()> { + with_offchain(|ext| { + ext.submit_transaction(codec::Encode::encode(data)) + }, "submit_transaction can be called only in the offchain worker context") + } + + fn new_crypto_key(crypto: offchain::CryptoKind) -> Result { + with_offchain(|ext| { + ext.new_crypto_key(crypto) + }, "new_crypto_key can be called only in the offchain worker context") + } + + fn encrypt(key: Option, data: &[u8]) -> Result, ()> { + with_offchain(|ext| { + ext.encrypt(key, data) + }, "encrypt can be called only in the offchain worker context") + } + + fn decrypt(key: Option, data: &[u8]) -> Result, ()> { + with_offchain(|ext| { + ext.decrypt(key, data) + }, "decrypt can be called only in the offchain worker context") + } + + fn sign(key: Option, data: &[u8]) -> Result, ()> { + with_offchain(|ext| { + ext.sign(key, data) + }, "sign can be called only in the offchain worker context") + } + + fn verify(key: Option, msg: &[u8], signature: &[u8]) -> Result { + with_offchain(|ext| { + ext.verify(key, msg, signature) + }, "verify can be called only in the offchain worker context") + } + + fn timestamp() -> offchain::Timestamp { + with_offchain(|ext| { + ext.timestamp() + }, "timestamp can be called only in the offchain worker context") + } + + fn sleep_until(deadline: Timestamp) { + with_offchain(|ext| { + ext.sleep_until(deadline) + }, "sleep_until can be called only in the offchain worker context") + } + + fn random_seed() -> [u8; 32] { + with_offchain(|ext| { + ext.random_seed() + }, "random_seed can be called only in the offchain worker context") + } + + fn local_storage_set(key: &[u8], value: &[u8]) { + with_offchain(|ext| { + ext.local_storage_set(key, value) + }, "local_storage_set can be called only in the offchain worker context") + } + + fn local_storage_compare_and_set(key: &[u8], old_value: &[u8], new_value: &[u8]) { + with_offchain(|ext| { + ext.local_storage_compare_and_set(key, old_value, new_value) + }, "local_storage_compare_and_set can be called only in the offchain worker context") + } + + fn local_storage_get(key: &[u8]) -> Option> { + with_offchain(|ext| { + ext.local_storage_get(key) + }, "local_storage_get can be called only in the offchain worker context") + } + + fn http_request_start( + method: &str, + uri: &str, + meta: &[u8] + ) -> Result { + with_offchain(|ext| { + ext.http_request_start(method, uri, meta) + }, "http_request_start can be called only in the offchain worker context") + } + + fn http_request_add_header( + request_id: offchain::HttpRequestId, + name: &str, + value: &str + ) -> Result<(), ()> { + with_offchain(|ext| { + ext.http_request_add_header(request_id, name, value) + }, "http_request_add_header can be called only in the offchain worker context") + } + + fn http_request_write_body( + request_id: offchain::HttpRequestId, + chunk: &[u8], + deadline: Option + ) -> Result<(), offchain::HttpError> { + with_offchain(|ext| { + ext.http_request_write_body(request_id, chunk, deadline) + }, "http_request_write_body can be called only in the offchain worker context") + } + + fn http_response_wait( + ids: &[offchain::HttpRequestId], + deadline: Option + ) -> Vec { + with_offchain(|ext| { + ext.http_response_wait(ids, deadline) + }, "http_response_wait can be called only in the offchain worker context") + } + + fn http_response_headers( + request_id: offchain::HttpRequestId + ) -> Vec<(Vec, Vec)> { + with_offchain(|ext| { + ext.http_response_headers(request_id) + }, "http_response_headers can be called only in the offchain worker context") + } + + fn http_response_read_body( + request_id: offchain::HttpRequestId, + buffer: &mut [u8], + deadline: Option + ) -> Result { + with_offchain(|ext| { + ext.http_response_read_body(request_id, buffer, deadline) + }, "http_response_read_body can be called only in the offchain worker context") } } diff --git a/core/sr-io/without_std.rs b/core/sr-io/without_std.rs index de87aeddbd..84e717ffae 100644 --- a/core/sr-io/without_std.rs +++ b/core/sr-io/without_std.rs @@ -19,8 +19,8 @@ pub use rstd; pub use rstd::{mem, slice}; use core::{intrinsics, panic::PanicInfo}; -use rstd::{vec::Vec, cell::Cell}; -use primitives::Blake2Hasher; +use rstd::{vec::Vec, cell::Cell, convert::TryInto}; +use primitives::{offchain, Blake2Hasher}; #[cfg(not(feature = "no_panic_handler"))] #[panic_handler] @@ -219,7 +219,6 @@ pub mod ext { /// # Returns /// /// - `0` if no value exists to the given key. `written_out` is set to `u32::max_value()`. - /// /// - Otherwise, pointer to the value in memory. `written_out` contains the length of the value. fn ext_get_allocated_storage(key_data: *const u8, key_len: u32, written_out: *mut u32) -> *mut u8; /// Gets the value of the given key from storage. @@ -331,8 +330,206 @@ pub mod ext { // Offchain-worker Context //================================ - /// Submit extrinsic. - fn ext_submit_extrinsic(data: *const u8, len: u32); + /// Submit transaction. + /// + /// # Returns + /// + /// - 0 if it was successfuly added to the pool + /// - nonzero otherwise. + fn ext_submit_transaction(data: *const u8, len: u32) -> u32; + + /// Create new key(pair) for signing/encryption/decryption. + /// + /// # Returns + /// + /// - A crypto key id (if the value is less than u16::max_value) + /// - `u32::max_value` in case the crypto is not supported + fn ext_new_crypto_key(crypto: u32) -> u32; + + /// Encrypt a piece of data using given crypto key. + /// + /// If `key` is `0`, it will attempt to use current authority key. + /// + /// # Returns + /// + /// - `0` in case the key is invalid, `msg_len` is set to `u32::max_value` + /// - Otherwise, pointer to the encrypted message in memory, + /// `msg_len` contains the length of the message. + fn ext_encrypt(key: u32, data: *const u8, data_len: u32, msg_len: *mut u32) -> *mut u8; + + /// Decrypt a piece of data using given crypto key. + /// + /// If `key `is `0`, it will attempt to use current authority key. + /// + /// # Returns + /// + /// - `0` in case the key is invalid or data couldn't be decrypted, + /// `msg_len` is set to `u32::max_value` + /// - Otherwise, pointer to the decrypted message in memory, + /// `msg_len` contains the length of the message. + fn ext_decrypt(key: u32, data: *const u8, data_len: u32, msg_len: *mut u32) -> *mut u8; + + /// Sign a piece of data using given crypto key. + /// + /// If `key` is `0`, it will attempt to use current authority key. + /// + /// # Returns + /// + /// - `0` in case the key is invalid, + /// `sig_data_len` is set to `u32::max_value` + /// - Otherwise, pointer to the signature in memory, + /// `sig_data_len` contains the length of the signature. + fn ext_sign(key: u32, data: *const u8, data_len: u32, sig_data_len: *mut u32) -> *mut u8; + + /// Verifies that `signature` for `msg` matches given `key`. + /// + /// If `key` is `0`, it will attempt to use current authority key. + /// + /// # Returns + /// - `0` in case the signature is correct + /// - `1` in case it doesn't match the key + /// - `u32::max_value` if the key is invalid. + fn ext_verify( + key: u32, + msg: *const u8, + msg_len: u32, + signature: *const u8, + signature_len: u32 + ) -> u32; + + /// Returns current UNIX timestamp (milliseconds) + fn ext_timestamp() -> u64; + + /// Pause execution until given timestamp (milliseconds; `deadline`) is reached. + /// + /// The deadline is obtained by querying the current timestamp via `ext_timestamp` + /// and then adding some time to it. + fn ext_sleep_until(deadline: u64); + + /// Generate a random seed + /// + /// `data` has to be a pointer to a slice of 32 bytes. + fn ext_random_seed(data: *mut u8); + + /// Write a value to local storage. + fn ext_local_storage_set(key: *const u8, key_len: u32, value: *const u8, value_len: u32); + + /// Write a value to local storage in atomic fashion. + fn ext_local_storage_compare_and_set( + key: *const u8, + key_len: u32, + old_value: *const u8, + old_value_len: u32, + new_value: *const u8, + new_value_len: u32 + ); + + /// Read a value from local storage. + /// + /// + /// # Returns + /// + /// - 0 if the value has not been found, the `value_len` is set to `u32::max_value`. + /// - Otherwise, pointer to the value in memory. `value_len` contains the length of the value. + fn ext_local_storage_get(key: *const u8, key_len: u32, value_len: *mut u32) -> *mut u8; + + /// Initiaties a http request. + /// + /// `meta` is parity-codec encoded additional parameters to the request (like redirection policy, + /// timeouts, certificates policy, etc). The format is not yet specified and the field is currently + /// only reserved for future use. + /// + /// # Returns + /// + /// `RequestId(u16)` of initiated request, any value beyond `u16::max_value` + /// signifies an error. + fn ext_http_request_start( + method: *const u8, + method_len: u32, + url: *const u8, + url_len: u32, + meta: *const u8, + meta_len: u32 + ) -> u32; + + /// Add a header to the request. + /// + /// # Returns + /// + /// - `0` if successful (and the request id exists) + /// - nonzero otherwise + fn ext_http_request_add_header( + request_id: u32, + name: *const u8, + name_len: u32, + value: *const u8, + value_len: u32 + ) -> u32; + + /// Write a chunk of request body. + /// + /// Writing an empty chunks finalises the request. + /// Passing `0` as deadline blocks forever. + /// + /// # Returns + /// + /// - `0` if successful, + /// - nonzero otherwise (see HttpError for the codes) + fn ext_http_request_write_body( + request_id: u32, + chunk: *const u8, + chunk_len: u32, + deadline: u64 + ) -> u32; + + /// Block and wait for the responses for given requests. + /// + /// Note that if deadline is 0 the method will block indefinitely, + /// otherwise unready responses will produce `DeadlineReached` status. + /// (see #primitives::offchain::HttpRequestStatus) + /// + /// Make sure that `statuses` have the same length as ids. + fn ext_http_response_wait( + ids: *const u32, + ids_len: u32, + statuses: *mut u32, + deadline: u64 + ); + + /// Read all response headers. + /// + /// Note the headers are only available before response body is fully consumed. + /// + /// # Returns + /// + /// - A pointer to parity-codec encoded vector of pairs `(HeaderKey, HeaderValue)`. + /// - In case invalid `id` is passed it returns a pointer to parity-encoded empty vector. + fn ext_http_response_headers( + id: u32, + written_out: *mut u32 + ) -> *mut u8; + + /// Read a chunk of body response to given buffer. + /// + /// Passing `0` as deadline blocks forever. + /// + /// # Returns + /// + /// The number of bytes written if successful, + /// - if it's `0` it means response has been fully consumed, + /// - if it's greater than `u32::max_value() - 255` it means reading body failed. + /// + /// In case of failure, the error code should be mapped to `HttpError` + /// in a following manner: + /// - `u32::max_value()` HttpError code 1 (DeadlineReached) + /// - `u32::max_value() - 1` HttpError code 2 (IoError) + /// The rest is reserved for potential future errors. + fn ext_http_response_read_body( + id: u32, + buffer: *mut u8, + buffer_len: u32, + deadline: u64 + ) -> u32; } } @@ -343,14 +540,7 @@ impl StorageApi for () { let mut length: u32 = 0; unsafe { let ptr = ext_get_allocated_storage.get()(key.as_ptr(), key.len() as u32, &mut length); - if length == u32::max_value() { - None - } else { - // Invariants required by Vec::from_raw_parts are not formally fulfilled. - // We don't allocate via String/Vec, but use a custom allocator instead. - // See #300 for more details. - Some(>::from_raw_parts(ptr, length as usize, length as usize)) - } + from_raw_parts(ptr, length) } } @@ -364,14 +554,7 @@ impl StorageApi for () { key.len() as u32, &mut length ); - if length == u32::max_value() { - None - } else { - // Invariants required by Vec::from_raw_parts are not formally fulfilled. - // We don't allocate via String/Vec, but use a custom allocator instead. - // See #300 for more details. - Some(>::from_raw_parts(ptr, length as usize, length as usize)) - } + from_raw_parts(ptr, length) } } @@ -491,10 +674,7 @@ impl StorageApi for () { storage_key.len() as u32, &mut length ); - // Invariants required by Vec::from_raw_parts are not formally fulfilled. - // We don't allocate via String/Vec, but use a custom allocator instead. - // See #300 for more details. - >::from_raw_parts(ptr, length as usize, length as usize) + from_raw_parts(ptr, length).expect("ext_child_storage_root never returns u32::max_value; qed") } } @@ -624,12 +804,273 @@ impl CryptoApi for () { } impl OffchainApi for () { - fn submit_extrinsic(data: &T) { + fn submit_transaction(data: &T) -> Result<(), ()> { let encoded_data = codec::Encode::encode(data); + let ret = unsafe { + ext_submit_transaction.get()(encoded_data.as_ptr(), encoded_data.len() as u32) + }; + + if ret == 0 { + Ok(()) + } else { + Err(()) + } + } + + fn new_crypto_key(crypto: offchain::CryptoKind) -> Result { + let crypto = crypto as u8 as u32; + let ret = unsafe { + ext_new_crypto_key.get()(crypto) + }; + + if ret > u16::max_value() as u32 { + Err(()) + } else { + Ok(offchain::CryptoKeyId(ret as u16)) + } + } + + fn encrypt(key: Option, data: &[u8]) -> Result, ()> { + let key = key.map(|x| x.0 as u32).unwrap_or(0); + let mut len = 0_u32; + unsafe { + let ptr = ext_encrypt.get()(key, data.as_ptr(), data.len() as u32, &mut len); + + from_raw_parts(ptr, len).ok_or(()) + } + } + + fn decrypt(key: Option, data: &[u8]) -> Result, ()> { + let key = key.map(|x| x.0 as u32).unwrap_or(0); + let mut len = 0_u32; + unsafe { + let ptr = ext_decrypt.get()(key, data.as_ptr(), data.len() as u32, &mut len); + + from_raw_parts(ptr, len).ok_or(()) + } + } + + fn sign(key: Option, data: &[u8]) -> Result, ()> { + let key = key.map(|x| x.0 as u32).unwrap_or(0); + let mut len = 0_u32; + unsafe { + let ptr = ext_sign.get()(key, data.as_ptr(), data.len() as u32, &mut len); + + from_raw_parts(ptr, len).ok_or(()) + } + } + + fn verify(key: Option, msg: &[u8], signature: &[u8]) -> Result { + let key = key.map(|x| x.0 as u32).unwrap_or(0); + let val = unsafe { + ext_verify.get()( + key, + msg.as_ptr(), + msg.len() as u32, + signature.as_ptr(), + signature.len() as u32, + ) + }; + + match val { + 0 => Ok(true), + 1 => Ok(false), + _ => Err(()), + } + } + + fn timestamp() -> offchain::Timestamp { + offchain::Timestamp::from_unix_millis(unsafe { + ext_timestamp.get()() + }) + } + + fn sleep_until(deadline: Timestamp) { + unsafe { + ext_sleep_until.get()(deadline.unix_millis()) + } + } + + fn random_seed() -> [u8; 32] { + let mut result = [0_u8; 32]; + unsafe { + ext_random_seed.get()(result.as_mut_ptr()) + } + result + } + + fn local_storage_set(key: &[u8], value: &[u8]) { + unsafe { + ext_local_storage_set.get()( + key.as_ptr(), + key.len() as u32, + value.as_ptr(), + value.len() as u32, + ) + } + } + + fn local_storage_compare_and_set(key: &[u8], old_value: &[u8], new_value: &[u8]) { unsafe { - ext_submit_extrinsic.get()(encoded_data.as_ptr(), encoded_data.len() as u32) + ext_local_storage_compare_and_set.get()( + key.as_ptr(), + key.len() as u32, + old_value.as_ptr(), + old_value.len() as u32, + new_value.as_ptr(), + new_value.len() as u32, + ) } } + + fn local_storage_get(key: &[u8]) -> Option> { + let mut len = 0u32; + unsafe { + let ptr = ext_local_storage_get.get()( + key.as_ptr(), + key.len() as u32, + &mut len, + ); + + from_raw_parts(ptr, len) + } + } + + fn http_request_start(method: &str, url: &str, meta: &[u8]) -> Result { + let method = method.as_bytes(); + let url = url.as_bytes(); + + let result = unsafe { + ext_http_request_start.get()( + method.as_ptr(), + method.len() as u32, + url.as_ptr(), + url.len() as u32, + meta.as_ptr(), + meta.len() as u32, + ) + }; + + if result > u16::max_value() as u32 { + Err(()) + } else { + Ok(offchain::HttpRequestId(result as u16)) + } + } + + fn http_request_add_header(request_id: offchain::HttpRequestId, name: &str, value: &str) -> Result<(), ()> { + let name = name.as_bytes(); + let value = value.as_bytes(); + + let result = unsafe { + ext_http_request_add_header.get()( + request_id.0 as u32, + name.as_ptr(), + name.len() as u32, + value.as_ptr(), + value.len() as u32, + ) + }; + + if result == 0 { + Ok(()) + } else { + Err(()) + } + } + + fn http_request_write_body( + request_id: offchain::HttpRequestId, + chunk: &[u8], + deadline: Option + ) -> Result<(), offchain::HttpError> { + let res = unsafe { + ext_http_request_write_body.get()( + request_id.0 as u32, + chunk.as_ptr(), + chunk.len() as u32, + deadline.map_or(0, |x| x.unix_millis()), + ) + }; + + if res == 0 { + Ok(()) + } else { + Err(res.try_into().unwrap_or(offchain::HttpError::IoError)) + } + } + + fn http_response_wait( + ids: &[offchain::HttpRequestId], + deadline: Option + ) -> Vec { + let ids = ids.iter().map(|x| x.0 as u32).collect::>(); + let mut statuses = Vec::new(); + statuses.resize(ids.len(), 0u32); + + unsafe { + ext_http_response_wait.get()( + ids.as_ptr(), + ids.len() as u32, + statuses.as_mut_ptr(), + deadline.map_or(0, |x| x.unix_millis()), + ) + } + + statuses + .into_iter() + .map(|status| status.try_into().unwrap_or(offchain::HttpRequestStatus::Unknown)) + .collect() + } + + fn http_response_headers( + request_id: offchain::HttpRequestId, + ) -> Vec<(Vec, Vec)> { + let mut len = 0u32; + let raw_result = unsafe { + let ptr = ext_http_response_headers.get()( + request_id.0 as u32, + &mut len, + ); + + from_raw_parts(ptr, len).expect("ext_http_response_headers never return u32::max_value; qed") + }; + + codec::Decode::decode(&mut &*raw_result).unwrap_or_default() + } + + fn http_response_read_body( + request_id: offchain::HttpRequestId, + buffer: &mut [u8], + deadline: Option, + ) -> Result { + let res = unsafe { + ext_http_response_read_body.get()( + request_id.0 as u32, + buffer.as_mut_ptr(), + buffer.len() as u32, + deadline.map_or(0, |x| x.unix_millis()), + ) + }; + + if res >= u32::max_value() - 255 { + let code = (u32::max_value() - res) + 1; + code.try_into().map_err(|_| offchain::HttpError::IoError) + } else { + Ok(res as usize) + } + } +} + +unsafe fn from_raw_parts(ptr: *mut u8, len: u32) -> Option> { + if len == u32::max_value() { + None + } else { + // Invariants required by Vec::from_raw_parts are not formally fulfilled. + // We don't allocate via String/Vec, but use a custom allocator instead. + // See #300 for more details. + Some(>::from_raw_parts(ptr, len as usize, len as usize)) + } } impl Api for () {} diff --git a/core/sr-primitives/src/generic/era.rs b/core/sr-primitives/src/generic/era.rs index 22f47b6769..c41d3eedfc 100644 --- a/core/sr-primitives/src/generic/era.rs +++ b/core/sr-primitives/src/generic/era.rs @@ -21,7 +21,10 @@ use serde::{Serialize, Deserialize}; use crate::codec::{Decode, Encode, Input, Output}; +/// Era period pub type Period = u64; + +/// Era phase pub type Phase = u64; /// An era to describe the longevity of a transaction. diff --git a/core/sr-std/with_std.rs b/core/sr-std/with_std.rs index d71b9dcb69..5824e26241 100644 --- a/core/sr-std/with_std.rs +++ b/core/sr-std/with_std.rs @@ -19,6 +19,8 @@ pub use std::boxed; pub use std::cell; pub use std::clone; pub use std::cmp; +pub use std::convert; +pub use std::default; pub use std::fmt; pub use std::hash; pub use std::iter; @@ -28,11 +30,10 @@ pub use std::num; pub use std::ops; pub use std::ptr; pub use std::rc; +pub use std::result; pub use std::slice; +pub use std::str; pub use std::vec; -pub use std::default; -pub use std::result; -pub use std::convert; pub mod collections { pub use std::collections::btree_map; diff --git a/core/sr-std/without_std.rs b/core/sr-std/without_std.rs index 9214a0ed2f..db81372c2f 100755 --- a/core/sr-std/without_std.rs +++ b/core/sr-std/without_std.rs @@ -53,6 +53,8 @@ pub use core::borrow; pub use core::cell; pub use core::clone; pub use core::cmp; +pub use core::convert; +pub use core::default; pub use core::hash; pub use core::intrinsics; pub use core::iter; @@ -61,10 +63,10 @@ pub use core::mem; pub use core::num; pub use core::ops; pub use core::ptr; -pub use core::slice; -pub use core::default; pub use core::result; -pub use core::convert; +pub use core::slice; +// Allow intepreting vectors of bytes as strings, but not constructing them. +pub use core::str; // We are trying to avoid certain things here, such as `core::string` // (if you need `String` you most probably doing something wrong, since // runtime doesn't require anything human readable). diff --git a/core/state-machine/src/basic.rs b/core/state-machine/src/basic.rs index 6cb3efd267..0eb0b84b27 100644 --- a/core/state-machine/src/basic.rs +++ b/core/state-machine/src/basic.rs @@ -20,6 +20,7 @@ use std::collections::HashMap; use std::iter::FromIterator; use hash_db::Hasher; use trie::trie_root; +use primitives::offchain; use primitives::storage::well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES}; use parity_codec::Encode; use super::{ChildStorageKey, Externalities, OverlayedChanges}; @@ -155,9 +156,9 @@ impl Externalities for BasicExternalities where H::Out: Ord { Ok(None) } - fn submit_extrinsic(&mut self, _extrinsic: Vec) -> Result<(), ()> { - warn!("Call to submit_extrinsic without offchain externalities set."); - Err(()) + fn offchain(&mut self) -> Option<&mut offchain::Externalities> { + warn!("Call to non-existent out offchain externalities set."); + None } } diff --git a/core/state-machine/src/ext.rs b/core/state-machine/src/ext.rs index f0638edf65..6ec1ce77e6 100644 --- a/core/state-machine/src/ext.rs +++ b/core/state-machine/src/ext.rs @@ -20,8 +20,9 @@ use std::{error, fmt, cmp::Ord}; use log::warn; use crate::backend::Backend; use crate::changes_trie::{Storage as ChangesTrieStorage, compute_changes_trie_root}; -use crate::{Externalities, OverlayedChanges, OffchainExt, ChildStorageKey}; +use crate::{Externalities, OverlayedChanges, ChildStorageKey}; use hash_db::Hasher; +use primitives::offchain; use primitives::storage::well_known_keys::is_child_storage_key; use trie::{MemoryDB, TrieDBMut, TrieMut, default_child_trie_root}; @@ -91,7 +92,7 @@ where H: Hasher, B: 'a + Backend, T: 'a + ChangesTrieStorage, - O: 'a + OffchainExt, + O: 'a + offchain::Externalities, H::Out: Ord + 'static, N: crate::changes_trie::BlockNumber, { @@ -145,7 +146,7 @@ where H: Hasher, B: 'a + Backend, T: 'a + ChangesTrieStorage, - O: 'a + OffchainExt, + O: 'a + offchain::Externalities, N: crate::changes_trie::BlockNumber, { pub fn storage_pairs(&self) -> Vec<(Vec, Vec)> { @@ -167,7 +168,7 @@ where H: Hasher, B: 'a + Backend, T: 'a + ChangesTrieStorage, - O: 'a + OffchainExt, + O: 'a + offchain::Externalities, H::Out: Ord + 'static, N: crate::changes_trie::BlockNumber, { @@ -342,15 +343,8 @@ where Ok(root) } - fn submit_extrinsic(&mut self, extrinsic: Vec) -> Result<(), ()> { - let _guard = panic_handler::AbortGuard::new(true); - if let Some(ext) = self.offchain_externalities.as_mut() { - ext.submit_extrinsic(extrinsic); - Ok(()) - } else { - warn!("Call to submit_extrinsic without offchain externalities set."); - Err(()) - } + fn offchain(&mut self) -> Option<&mut offchain::Externalities> { + self.offchain_externalities.as_mut().map(|x| &mut **x as _) } } diff --git a/core/state-machine/src/lib.rs b/core/state-machine/src/lib.rs index 4f51677fff..f16c3db14e 100644 --- a/core/state-machine/src/lib.rs +++ b/core/state-machine/src/lib.rs @@ -24,7 +24,7 @@ use log::warn; use hash_db::Hasher; use parity_codec::{Decode, Encode}; use primitives::{ - storage::well_known_keys, NativeOrEncoded, NeverNativeValue, OffchainExt + storage::well_known_keys, NativeOrEncoded, NeverNativeValue, offchain }; pub mod backend; @@ -221,10 +221,8 @@ pub trait Externalities { /// Get the change trie root of the current storage overlay at a block with given parent. fn storage_changes_root(&mut self, parent: H::Out) -> Result, ()> where H::Out: Ord; - /// Submit extrinsic. - /// - /// Returns an error in case the API is not available. - fn submit_extrinsic(&mut self, extrinsic: Vec) -> Result<(), ()>; + /// Returns offchain externalities extension if present. + fn offchain(&mut self) -> Option<&mut offchain::Externalities>; } /// An implementation of offchain extensions that should never be triggered. @@ -237,8 +235,121 @@ impl NeverOffchainExt { } } -impl OffchainExt for NeverOffchainExt { - fn submit_extrinsic(&mut self, _extrinsic: Vec) { unreachable!() } +impl offchain::Externalities for NeverOffchainExt { + fn submit_transaction(&mut self, _extrinsic: Vec) -> Result<(), ()> { + unreachable!() + } + + fn new_crypto_key( + &mut self, + _crypto: offchain::CryptoKind, + ) -> Result { + unreachable!() + } + + fn encrypt( + &mut self, + _key: Option, + _data: &[u8], + ) -> Result, ()> { + unreachable!() + } + + fn decrypt( + &mut self, + _key: Option, + _data: &[u8], + ) -> Result, ()> { + unreachable!() + } + + fn sign(&mut self, _key: Option, _data: &[u8]) -> Result, ()> { + unreachable!() + } + + fn verify( + &mut self, + _key: Option, + _msg: &[u8], + _signature: &[u8], + ) -> Result { + unreachable!() + } + + fn timestamp(&mut self) -> offchain::Timestamp { + unreachable!() + } + + fn sleep_until(&mut self, _deadline: offchain::Timestamp) { + unreachable!() + } + + fn random_seed(&mut self) -> [u8; 32] { + unreachable!() + } + + fn local_storage_set(&mut self, _key: &[u8], _value: &[u8]) { + unreachable!() + } + + fn local_storage_compare_and_set(&mut self, _key: &[u8], _old_value: &[u8], _new_value: &[u8]) { + unreachable!() + } + + fn local_storage_get(&mut self, _key: &[u8]) -> Option> { + unreachable!() + } + + fn http_request_start( + &mut self, + _method: &str, + _uri: &str, + _meta: &[u8] + ) -> Result { + unreachable!() + } + + fn http_request_add_header( + &mut self, + _request_id: offchain::HttpRequestId, + _name: &str, + _value: &str + ) -> Result<(), ()> { + unreachable!() + } + + fn http_request_write_body( + &mut self, + _request_id: offchain::HttpRequestId, + _chunk: &[u8], + _deadline: Option + ) -> Result<(), offchain::HttpError> { + unreachable!() + } + + fn http_response_wait( + &mut self, + _ids: &[offchain::HttpRequestId], + _deadline: Option + ) -> Vec { + unreachable!() + } + + fn http_response_headers( + &mut self, + _request_id: offchain::HttpRequestId + ) -> Vec<(Vec, Vec)> { + unreachable!() + } + + fn http_response_read_body( + &mut self, + _request_id: offchain::HttpRequestId, + _buffer: &mut [u8], + _deadline: Option + ) -> Result { + unreachable!() + } } /// Code execution engine. @@ -376,7 +487,7 @@ impl<'a, H, N, B, T, O, Exec> StateMachine<'a, H, N, B, T, O, Exec> where Exec: CodeExecutor, B: Backend, T: ChangesTrieStorage, - O: OffchainExt, + O: offchain::Externalities, H::Out: Ord + 'static, N: crate::changes_trie::BlockNumber, { @@ -415,12 +526,11 @@ impl<'a, H, N, B, T, O, Exec> StateMachine<'a, H, N, B, T, O, Exec> where R: Decode + Encode + PartialEq, NC: FnOnce() -> result::Result + UnwindSafe, { - let offchain = self.offchain_ext.as_mut(); let mut externalities = ext::Ext::new( self.overlay, self.backend, self.changes_trie_storage, - offchain.map(|x| &mut **x), + self.offchain_ext.as_mut().map(|x| &mut **x), ); let (result, was_native) = self.exec.call( &mut externalities, diff --git a/core/state-machine/src/testing.rs b/core/state-machine/src/testing.rs index 52d208142d..3934e726af 100644 --- a/core/state-machine/src/testing.rs +++ b/core/state-machine/src/testing.rs @@ -25,6 +25,7 @@ use crate::changes_trie::{ compute_changes_trie_root, InMemoryStorage as ChangesTrieInMemoryStorage, BlockNumber as ChangesTrieBlockNumber, }; +use primitives::offchain; use primitives::storage::well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES}; use parity_codec::Encode; use super::{ChildStorageKey, Externalities, OverlayedChanges}; @@ -36,6 +37,7 @@ pub struct TestExternalities { overlay: OverlayedChanges, backend: InMemory, changes_trie_storage: ChangesTrieInMemoryStorage, + offchain: Option>, } impl TestExternalities { @@ -61,6 +63,7 @@ impl TestExternalities { overlay, changes_trie_storage: ChangesTrieInMemoryStorage::new(), backend: inner.into(), + offchain: None, } } @@ -80,6 +83,11 @@ impl TestExternalities { .filter_map(|(k, maybe_val)| maybe_val.map(|val| (k, val))) } + /// Set offchain externaltiies. + pub fn set_offchain_externalities(&mut self, offchain: impl offchain::Externalities + 'static) { + self.offchain = Some(Box::new(offchain)); + } + /// Get mutable reference to changes trie storage. pub fn changes_trie_storage(&mut self) -> &mut ChangesTrieInMemoryStorage { &mut self.changes_trie_storage @@ -226,8 +234,10 @@ impl Externalities for TestExternalities )?.map(|(root, _)| root.clone())) } - fn submit_extrinsic(&mut self, _extrinsic: Vec) -> Result<(), ()> { - unimplemented!() + fn offchain(&mut self) -> Option<&mut offchain::Externalities> { + self.offchain + .as_mut() + .map(|x| &mut **x as _) } } diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index 980ce810e4..e582fd4dc7 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -476,7 +476,7 @@ cfg_if! { impl offchain_primitives::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); - runtime_io::submit_extrinsic(&ex) + runtime_io::submit_transaction(&ex).unwrap(); } } @@ -628,7 +628,7 @@ cfg_if! { impl offchain_primitives::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); - runtime_io::submit_extrinsic(&ex) + runtime_io::submit_transaction(&ex).unwrap() } } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 86c73307b8..d243357fc2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 88, - impl_version: 90, + spec_version: 89, + impl_version: 89, apis: RUNTIME_API_VERSIONS, }; -- GitLab From 4a143611c3abd3ee546410e8e0010b495b5c7a1b Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Fri, 31 May 2019 10:40:27 +0200 Subject: [PATCH 066/113] Remove unneeded derive (#2743) --- srml/staking/src/phragmen.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/srml/staking/src/phragmen.rs b/srml/staking/src/phragmen.rs index 56f6419c06..888e38a7ec 100644 --- a/srml/staking/src/phragmen.rs +++ b/srml/staking/src/phragmen.rs @@ -19,7 +19,6 @@ use rstd::{prelude::*, collections::btree_map::BTreeMap}; use primitives::{PerU128}; use primitives::traits::{Zero, Convert, Saturating}; -use parity_codec::{Encode, Decode}; use crate::{BalanceOf, Assignment, RawAssignment, ExpoMap, Trait, ValidatorPrefs}; type Fraction = PerU128; @@ -35,7 +34,7 @@ const SCALE_FACTOR: ExtendedBalance = u32::max_value() as ExtendedBalance + 1; pub const ACCURACY: ExtendedBalance = u32::max_value() as ExtendedBalance + 1; /// Wrapper around validation candidates some metadata. -#[derive(Clone, Encode, Decode, Default)] +#[derive(Clone, Default)] #[cfg_attr(feature = "std", derive(Debug))] pub struct Candidate { /// The validator's account @@ -49,7 +48,7 @@ pub struct Candidate { } /// Wrapper around the nomination info of a single nominator for a group of validators. -#[derive(Clone, Encode, Decode, Default)] +#[derive(Clone, Default)] #[cfg_attr(feature = "std", derive(Debug))] pub struct Nominator { /// The nominator's account. @@ -63,7 +62,7 @@ pub struct Nominator { } /// Wrapper around a nominator vote and the load of that vote. -#[derive(Clone, Encode, Decode, Default)] +#[derive(Clone, Default)] #[cfg_attr(feature = "std", derive(Debug))] pub struct Edge { /// Account being voted for -- GitLab From 4c9a2d75680930761de799c60a927c02d2ba2cec Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Sat, 1 Jun 2019 00:50:05 -0400 Subject: [PATCH 067/113] Typo fix Substate -> Substrate (#2754) --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index f1ffc20d91..2a76525914 100644 --- a/README.adoc +++ b/README.adoc @@ -307,7 +307,7 @@ cargo run --release \-- \ --telemetry-url ws://telemetry.polkadot.io:1024 \ --validator -Additional Substate CLI usage options are available and may be shown by running `cargo run \-- --help`. +Additional Substrate CLI usage options are available and may be shown by running `cargo run \-- --help`. [[flaming-fir]] === Joining the Flaming Fir Testnet -- GitLab From a9469eeee848d616bc11231517af499ed8baf8e4 Mon Sep 17 00:00:00 2001 From: kaichao Date: Mon, 3 Jun 2019 17:55:16 +0800 Subject: [PATCH 068/113] Fix typo (#2762) --- core/rpc/src/author/hash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rpc/src/author/hash.rs b/core/rpc/src/author/hash.rs index 052c479834..96addf8ebc 100644 --- a/core/rpc/src/author/hash.rs +++ b/core/rpc/src/author/hash.rs @@ -19,7 +19,7 @@ use serde::Deserialize; /// RPC Extrinsic or hash /// -/// Allows to refer to extrinsics either by their raw representation or by it's hash. +/// Allows to refer to extrinsic either by its raw representation or its hash. #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub enum ExtrinsicOrHash { -- GitLab From e45524e52925557d182bb8bbe9d8fa4a2182beb5 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 3 Jun 2019 14:48:46 +0200 Subject: [PATCH 069/113] Add warning about secp256k1 network keys (#2764) --- core/network-libp2p/src/service_task.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/network-libp2p/src/service_task.rs b/core/network-libp2p/src/service_task.rs index a58b24cbfe..e74757e0b1 100644 --- a/core/network-libp2p/src/service_task.rs +++ b/core/network-libp2p/src/service_task.rs @@ -16,6 +16,7 @@ use crate::{ behaviour::Behaviour, + config::NodeKeyConfig, transport, NetworkState, NetworkStatePeer, NetworkStateNotConnectedPeer }; use crate::custom_proto::{CustomProto, CustomProtoOut, CustomMessage, RegisteredProtocol}; @@ -79,6 +80,9 @@ where TMessage: CustomMessage + Send + 'static { }); // Private and public keys configuration. + if let NodeKeyConfig::Secp256k1(_) = config.node_key { + warn!(target: "sub-libp2p", "Secp256k1 keys are deprecated in favour of ed25519"); + } let local_identity = config.node_key.clone().into_keypair()?; let local_public = local_identity.public(); let local_peer_id = local_public.clone().into_peer_id(); -- GitLab From 7efd7e77bff06330bf3ecec13752236a786c8b17 Mon Sep 17 00:00:00 2001 From: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> Date: Mon, 3 Jun 2019 10:34:38 -0400 Subject: [PATCH 070/113] Remove spurious `#[derive(Encode, Decode)]` (#2759) They did not compile, since `Encode` and `Decode` are deliberately not implemented for `usize`. --- node/runtime/src/lib.rs | 2 +- srml/aura/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index d243357fc2..1e31e5400e 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 89, - impl_version: 89, + impl_version: 90, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index 646ad972d0..3b557e2944 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -57,7 +57,6 @@ use primitives::traits::{SaturatedConversion, Saturating, Zero, One}; use timestamp::OnTimestampSet; #[cfg(feature = "std")] use timestamp::TimestampInherentData; -use parity_codec::{Encode, Decode}; use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; @@ -133,6 +132,7 @@ impl ProvideInherentData for InherentDataProvider { } fn error_to_string(&self, error: &[u8]) -> Option { + use parity_codec::Decode; RuntimeString::decode(&mut &error[..]).map(Into::into) } } @@ -163,7 +163,7 @@ decl_module! { } /// A report of skipped authorities in Aura. -#[derive(Clone, Encode, Decode, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] pub struct AuraReport { // The first skipped slot. -- GitLab From b30bff5bce27979c78e655c492dbca09c5fe0079 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Mon, 3 Jun 2019 16:45:12 +0200 Subject: [PATCH 071/113] Peer prioritization (#2717) * Added priority groups * Added a test * Whitespace * Added add/remove single peer API * Added a warning * Fixed removing reserved peer * Fixed build * Made some methods private and made get_priority_group return an Option --- core/peerset/src/lib.rs | 94 ++++-- core/peerset/src/peersstate.rs | 505 +++++++++++++++++---------------- 2 files changed, 330 insertions(+), 269 deletions(-) diff --git a/core/peerset/src/lib.rs b/core/peerset/src/lib.rs index 6956cd16e1..aa3ce02076 100644 --- a/core/peerset/src/lib.rs +++ b/core/peerset/src/lib.rs @@ -19,7 +19,7 @@ mod peersstate; -use std::{collections::HashMap, collections::VecDeque, time::Instant}; +use std::{collections::{HashSet, HashMap}, collections::VecDeque, time::Instant}; use futures::{prelude::*, sync::mpsc, try_ready}; use libp2p::PeerId; use log::{debug, error, trace}; @@ -29,6 +29,8 @@ use serde_json::json; const BANNED_THRESHOLD: i32 = 82 * (i32::min_value() / 100); /// Reputation change for a node when we get disconnected from it. const DISCONNECT_REPUTATION_CHANGE: i32 = -10; +/// Reserved peers group ID +const RESERVED_NODES: &'static str = "reserved"; #[derive(Debug)] enum Action { @@ -36,6 +38,9 @@ enum Action { RemoveReservedPeer(PeerId), SetReservedOnly(bool), ReportPeer(PeerId, i32), + SetPriorityGroup(String, HashSet), + AddToPriorityGroup(String, PeerId), + RemoveFromPriorityGroup(String, PeerId), } /// Shared handle to the peer set manager (PSM). Distributed around the code. @@ -72,6 +77,21 @@ impl PeersetHandle { pub fn report_peer(&self, peer_id: PeerId, score_diff: i32) { let _ = self.tx.unbounded_send(Action::ReportPeer(peer_id, score_diff)); } + + /// Modify a priority group. + pub fn set_priority_group(&self, group_id: String, peers: HashSet) { + let _ = self.tx.unbounded_send(Action::SetPriorityGroup(group_id, peers)); + } + + /// Add a peer to a priority group. + pub fn add_to_priority_group(&self, group_id: String, peer_id: PeerId) { + let _ = self.tx.unbounded_send(Action::AddToPriorityGroup(group_id, peer_id)); + } + + /// Remove a peer from a priority group. + pub fn remove_from_priority_group(&self, group_id: String, peer_id: PeerId) { + let _ = self.tx.unbounded_send(Action::RemoveFromPriorityGroup(group_id, peer_id)); + } } /// Message that can be sent by the peer set manager (PSM). @@ -161,14 +181,7 @@ impl Peerset { latest_time_update: Instant::now(), }; - for peer_id in config.reserved_nodes { - if let peersstate::Peer::Unknown(entry) = peerset.data.peer(&peer_id) { - entry.discover().set_reserved(true); - } else { - debug!(target: "peerset", "Duplicate reserved node in config: {:?}", peer_id); - } - } - + peerset.data.set_priority_group(RESERVED_NODES, config.reserved_nodes.into_iter().collect()); for peer_id in config.bootnodes { if let peersstate::Peer::Unknown(entry) = peerset.data.peer(&peer_id) { entry.discover(); @@ -182,32 +195,25 @@ impl Peerset { } fn on_add_reserved_peer(&mut self, peer_id: PeerId) { - let mut entry = match self.data.peer(&peer_id) { - peersstate::Peer::Connected(mut connected) => { - connected.set_reserved(true); - return - } - peersstate::Peer::NotConnected(entry) => entry, - peersstate::Peer::Unknown(entry) => entry.discover(), - }; - - // We reach this point if and only if we were not connected to the node. - entry.set_reserved(true); - entry.force_outgoing(); - self.message_queue.push_back(Message::Connect(peer_id)); + let mut reserved = self.data.get_priority_group(RESERVED_NODES).unwrap_or_default(); + reserved.insert(peer_id); + self.data.set_priority_group(RESERVED_NODES, reserved); + self.alloc_slots(); } fn on_remove_reserved_peer(&mut self, peer_id: PeerId) { + let mut reserved = self.data.get_priority_group(RESERVED_NODES).unwrap_or_default(); + reserved.remove(&peer_id); + self.data.set_priority_group(RESERVED_NODES, reserved); match self.data.peer(&peer_id) { - peersstate::Peer::Connected(mut peer) => { - peer.set_reserved(false); + peersstate::Peer::Connected(peer) => { if self.reserved_only { peer.disconnect(); self.message_queue.push_back(Message::Drop(peer_id)); } } - peersstate::Peer::NotConnected(mut peer) => peer.set_reserved(false), - peersstate::Peer::Unknown(_) => {} + peersstate::Peer::NotConnected(_) => {}, + peersstate::Peer::Unknown(_) => {}, } } @@ -215,20 +221,35 @@ impl Peerset { // Disconnect non-reserved nodes. self.reserved_only = reserved_only; if self.reserved_only { + let reserved = self.data.get_priority_group(RESERVED_NODES).unwrap_or_default(); for peer_id in self.data.connected_peers().cloned().collect::>().into_iter() { let peer = self.data.peer(&peer_id).into_connected() .expect("We are enumerating connected peers, therefore the peer is connected; qed"); - if !peer.is_reserved() { + if !reserved.contains(&peer_id) { peer.disconnect(); self.message_queue.push_back(Message::Drop(peer_id)); } } - } else { self.alloc_slots(); } } + fn on_set_priority_group(&mut self, group_id: &str, peers: HashSet) { + self.data.set_priority_group(group_id, peers); + self.alloc_slots(); + } + + fn on_add_to_priority_group(&mut self, group_id: &str, peer_id: PeerId) { + self.data.add_to_priority_group(group_id, peer_id); + self.alloc_slots(); + } + + fn on_remove_from_priority_group(&mut self, group_id: &str, peer_id: PeerId) { + self.data.remove_from_priority_group(group_id, &peer_id); + self.alloc_slots(); + } + fn on_report_peer(&mut self, peer_id: PeerId, score_diff: i32) { // We want reputations to be up-to-date before adjusting them. self.update_time(); @@ -292,7 +313,13 @@ impl Peerset { self.update_time(); // Try to grab the next node to attempt to connect to. - while let Some(next) = self.data.reserved_not_connected_peer() { + while let Some(next) = { + if self.reserved_only { + self.data.priority_not_connected_peer_from_group(RESERVED_NODES) + } else { + self.data.priority_not_connected_peer() + } + } { match next.try_outgoing() { Ok(conn) => self.message_queue.push_back(Message::Connect(conn.into_peer_id())), Err(_) => break, // No more slots available. @@ -421,6 +448,11 @@ impl Peerset { "message_queue": self.message_queue.len(), }) } + + /// Returns priority group by id. + pub fn get_priority_group(&self, group_id: &str) -> Option> { + self.data.get_priority_group(group_id) + } } impl Stream for Peerset { @@ -439,6 +471,9 @@ impl Stream for Peerset { Action::RemoveReservedPeer(peer_id) => self.on_remove_reserved_peer(peer_id), Action::SetReservedOnly(reserved) => self.on_set_reserved_only(reserved), Action::ReportPeer(peer_id, score_diff) => self.on_report_peer(peer_id, score_diff), + Action::SetPriorityGroup(group_id, peers) => self.on_set_priority_group(&group_id, peers), + Action::AddToPriorityGroup(group_id, peer_id) => self.on_add_to_priority_group(&group_id, peer_id), + Action::RemoveFromPriorityGroup(group_id, peer_id) => self.on_remove_from_priority_group(&group_id, peer_id), } } } @@ -590,3 +625,4 @@ mod tests { tokio::runtime::current_thread::Runtime::new().unwrap().block_on(fut).unwrap(); } } + diff --git a/core/peerset/src/peersstate.rs b/core/peerset/src/peersstate.rs index a6a375b369..e02d630404 100644 --- a/core/peerset/src/peersstate.rs +++ b/core/peerset/src/peersstate.rs @@ -17,7 +17,8 @@ //! Contains the state storage behind the peerset. use libp2p::PeerId; -use std::{borrow::Cow, collections::HashMap}; +use std::{borrow::Cow, collections::{HashSet, HashMap}}; +use log::warn; /// State storage behind the peerset. /// @@ -35,17 +36,20 @@ pub struct PeersState { /// sort, to make the logic easier. nodes: HashMap, - /// Number of non-reserved nodes for which the `ConnectionState` is `In`. + /// Number of non-priority nodes for which the `ConnectionState` is `In`. num_in: u32, - /// Number of non-reserved nodes for which the `ConnectionState` is `In`. + /// Number of non-priority nodes for which the `ConnectionState` is `In`. num_out: u32, - /// Maximum allowed number of non-reserved nodes for which the `ConnectionState` is `In`. + /// Maximum allowed number of non-priority nodes for which the `ConnectionState` is `In`. max_in: u32, - /// Maximum allowed number of non-reserved nodes for which the `ConnectionState` is `Out`. + /// Maximum allowed number of non-priority nodes for which the `ConnectionState` is `Out`. max_out: u32, + + /// Priority groups. Each group is identified by a string ID and contains a set of peer IDs. + priority_nodes: HashMap>, } /// State of a single node that we know about. @@ -54,14 +58,20 @@ struct Node { /// Whether we are connected to this node. connection_state: ConnectionState, - /// If true, this node is reserved and should always be connected to. - reserved: bool, - /// Reputation value of the node, between `i32::min_value` (we hate that node) and /// `i32::max_value` (we love that node). reputation: i32, } +impl Default for Node { + fn default() -> Node { + Node { + connection_state: ConnectionState::NotConnected, + reputation: 0, + } + } +} + /// Whether we are connected to a node. #[derive(Debug, Copy, Clone, PartialEq, Eq)] enum ConnectionState { @@ -93,42 +103,30 @@ impl PeersState { num_out: 0, max_in: in_peers, max_out: out_peers, + priority_nodes: HashMap::new(), } } /// Returns an object that grants access to the state of a peer. pub fn peer<'a>(&'a mut self, peer_id: &'a PeerId) -> Peer<'a> { - // Note: the Rust borrow checker still has some issues. In particular, we can't put this - // block as an `else` below (as the obvious solution would be here), or it will complain - // that we borrow `self` while it is already borrowed. - if !self.nodes.contains_key(peer_id) { - return Peer::Unknown(UnknownPeer { + match self.nodes.get_mut(peer_id) { + None => return Peer::Unknown(UnknownPeer { parent: self, peer_id: Cow::Borrowed(peer_id), - }); - } - - let state = self.nodes.get_mut(peer_id) - .expect("We check that the value is present right above; QED"); - - if state.connection_state.is_connected() { - Peer::Connected(ConnectedPeer { - state, - peer_id: Cow::Borrowed(peer_id), - num_in: &mut self.num_in, - num_out: &mut self.num_out, - max_in: self.max_in, - max_out: self.max_out, - }) - } else { - Peer::NotConnected(NotConnectedPeer { - state, - peer_id: Cow::Borrowed(peer_id), - num_in: &mut self.num_in, - num_out: &mut self.num_out, - max_in: self.max_in, - max_out: self.max_out, - }) + }), + Some(peer) => { + if peer.connection_state.is_connected() { + Peer::Connected(ConnectedPeer { + state: self, + peer_id: Cow::Borrowed(peer_id), + }) + } else { + Peer::NotConnected(NotConnectedPeer { + state: self, + peer_id: Cow::Borrowed(peer_id), + }) + } + } } } @@ -148,28 +146,32 @@ impl PeersState { .map(|(p, _)| p) } - /// Returns the first reserved peer that we are not connected to. + /// Returns the first priority peer that we are not connected to. /// - /// If multiple nodes are reserved, which one is returned is unspecified. - pub fn reserved_not_connected_peer(&mut self) -> Option { - let outcome = self.nodes.iter_mut() - .find(|(_, &mut Node { connection_state, reserved, .. })| { - reserved && !connection_state.is_connected() - }) - .map(|(peer_id, node)| (peer_id.clone(), node)); - - if let Some((peer_id, state)) = outcome { - Some(NotConnectedPeer { - state, - peer_id: Cow::Owned(peer_id), - num_in: &mut self.num_in, - num_out: &mut self.num_out, - max_in: self.max_in, - max_out: self.max_out, - }) - } else { - None - } + /// If multiple nodes are prioritized, which one is returned is unspecified. + pub fn priority_not_connected_peer(&mut self) -> Option { + let id = self.priority_nodes.values() + .flatten() + .find(|id| self.nodes.get(id).map_or(false, |node| !node.connection_state.is_connected())) + .cloned(); + id.map(move |id| NotConnectedPeer { + state: self, + peer_id: Cow::Owned(id), + }) + } + + /// Returns the first priority peer that we are not connected to. + /// + /// If multiple nodes are prioritized, which one is returned is unspecified. + pub fn priority_not_connected_peer_from_group(&mut self, group_id: &str) -> Option { + let id = self.priority_nodes.get(group_id) + .and_then(|group| group.iter() + .find(|id| self.nodes.get(id).map_or(false, |node| !node.connection_state.is_connected())) + .cloned()); + id.map(move |id| NotConnectedPeer { + state: self, + peer_id: Cow::Owned(id), + }) } /// Returns the peer with the highest reputation and that we are not connected to. @@ -187,21 +189,160 @@ impl PeersState { } Some(to_try) }) - .map(|(peer_id, state)| (peer_id.clone(), state)); + .map(|(peer_id, _)| peer_id.clone()); - if let Some((peer_id, state)) = outcome { + if let Some(peer_id) = outcome { Some(NotConnectedPeer { - state, + state: self, peer_id: Cow::Owned(peer_id), - num_in: &mut self.num_in, - num_out: &mut self.num_out, - max_in: self.max_in, - max_out: self.max_out, }) } else { None } } + + fn disconnect(&mut self, peer_id: &PeerId) { + let is_priority = self.is_priority(peer_id); + if let Some(mut node) = self.nodes.get_mut(peer_id) { + if !is_priority { + match node.connection_state { + ConnectionState::In => self.num_in -= 1, + ConnectionState::Out => self.num_out -= 1, + ConnectionState::NotConnected => + debug_assert!(false, "State inconsistency: disconnecting a disconnected node") + } + } + node.connection_state = ConnectionState::NotConnected; + } else { + warn!(target: "peerset", "Attempting to disconnect unknown peer {}", peer_id); + } + } + + /// Sets the peer as connected with an outgoing connection. + fn try_outgoing(&mut self, peer_id: &PeerId) -> bool { + // Note that it is possible for num_out to be strictly superior to the max, in case we were + // connected to reserved node then marked them as not reserved. + let is_priority = self.is_priority(peer_id); + if self.num_out >= self.max_out && !is_priority { + return false; + } + + if let Some(mut peer) = self.nodes.get_mut(peer_id) { + peer.connection_state = ConnectionState::Out; + if !is_priority { + self.num_out += 1; + } + return true; + } + false + } + + /// Tries to accept the peer as an incoming connection. + /// + /// If there are enough slots available, switches the node to "connected" and returns `Ok`. If + /// the slots are full, the node stays "not connected" and we return `Err`. + /// + /// Note that reserved nodes don't count towards the number of slots. + fn try_accept_incoming(&mut self, peer_id: &PeerId) -> bool { + let is_priority = self.is_priority(peer_id); + // Note that it is possible for num_in to be strictly superior to the max, in case we were + // connected to reserved node then marked them as not reserved. + if self.num_in >= self.max_in && !is_priority { + return false; + } + if let Some(mut peer) = self.nodes.get_mut(peer_id) { + peer.connection_state = ConnectionState::In; + if !is_priority { + self.num_in += 1; + } + return true; + } + false + } + + /// Sets priority group + pub fn set_priority_group(&mut self, group_id: &str, peers: HashSet) { + // update slot counters + let all_other_groups: HashSet<_> = self.priority_nodes + .iter() + .filter(|(g, _)| *g != group_id) + .flat_map(|(_, id)| id.clone()) + .collect(); + let existing_group = self.priority_nodes.remove(group_id).unwrap_or_default(); + for id in existing_group { + // update slots for nodes that are no longer priority + if !all_other_groups.contains(&id) { + if let Some(peer) = self.nodes.get_mut(&id) { + match peer.connection_state { + ConnectionState::In => self.num_in += 1, + ConnectionState::Out => self.num_out += 1, + ConnectionState::NotConnected => {}, + } + } + } + } + + for id in &peers { + // update slots for nodes that become priority + if !all_other_groups.contains(&id) { + let peer = self.nodes.entry(id.clone()).or_default(); + match peer.connection_state { + ConnectionState::In => self.num_in -= 1, + ConnectionState::Out => self.num_out -= 1, + ConnectionState::NotConnected => {}, + } + } + } + self.priority_nodes.insert(group_id.into(), peers); + } + + /// Add a peer to a priority group. + pub fn add_to_priority_group(&mut self, group_id: &str, peer_id: PeerId) { + let mut peers = self.priority_nodes.get(group_id).cloned().unwrap_or_default(); + peers.insert(peer_id); + self.set_priority_group(group_id, peers); + } + + /// Remove a peer from a priority group. + pub fn remove_from_priority_group(&mut self, group_id: &str, peer_id: &PeerId) { + let mut peers = self.priority_nodes.get(group_id).cloned().unwrap_or_default(); + peers.remove(&peer_id); + self.set_priority_group(group_id, peers); + } + + /// Get priority group content. + pub fn get_priority_group(&self, group_id: &str) -> Option> { + self.priority_nodes.get(group_id).cloned() + } + + /// Check that node is any priority group. + fn is_priority(&self, peer_id: &PeerId) -> bool { + self.priority_nodes.iter().any(|(_, group)| group.contains(peer_id)) + } + + /// Returns the reputation value of the node. + fn reputation(&self, peer_id: &PeerId) -> i32 { + self.nodes.get(peer_id).map_or(0, |p| p.reputation) + } + + /// Sets the reputation of the peer. + fn set_reputation(&mut self, peer_id: &PeerId, value: i32) { + let node = self.nodes + .entry(peer_id.clone()) + .or_default(); + node.reputation = value; + } + + /// Performs an arithmetic addition on the reputation score of that peer. + /// + /// In case of overflow, the value will be capped. + /// If the peer is unknown to us, we insert it and consider that it has a reputation of 0. + fn add_reputation(&mut self, peer_id: &PeerId, modifier: i32) { + let node = self.nodes + .entry(peer_id.clone()) + .or_default(); + node.reputation = node.reputation.saturating_add(modifier); + } } /// Grants access to the state of a peer in the `PeersState`. @@ -250,12 +391,8 @@ impl<'a> Peer<'a> { /// A peer that is connected to us. pub struct ConnectedPeer<'a> { - state: &'a mut Node, + state: &'a mut PeersState, peer_id: Cow<'a, PeerId>, - num_in: &'a mut u32, - num_out: &'a mut u32, - max_in: u32, - max_out: u32, } impl<'a> ConnectedPeer<'a> { @@ -266,87 +403,36 @@ impl<'a> ConnectedPeer<'a> { /// Switches the peer to "not connected". pub fn disconnect(self) -> NotConnectedPeer<'a> { - let connec_state = &mut self.state.connection_state; - - if !self.state.reserved { - match *connec_state { - ConnectionState::In => *self.num_in -= 1, - ConnectionState::Out => *self.num_out -= 1, - ConnectionState::NotConnected => - debug_assert!(false, "State inconsistency: disconnecting a disconnected node") - } - } - - *connec_state = ConnectionState::NotConnected; - + self.state.disconnect(&self.peer_id); NotConnectedPeer { state: self.state, peer_id: self.peer_id, - num_in: self.num_in, - num_out: self.num_out, - max_in: self.max_in, - max_out: self.max_out, - } - } - - /// Sets whether or not the node is reserved. - pub fn set_reserved(&mut self, reserved: bool) { - if reserved == self.state.reserved { - return; } - - if reserved { - self.state.reserved = true; - match self.state.connection_state { - ConnectionState::In => *self.num_in -= 1, - ConnectionState::Out => *self.num_out -= 1, - ConnectionState::NotConnected => debug_assert!(false, "State inconsistency: \ - connected node is in fact not connected"), - } - - } else { - self.state.reserved = false; - match self.state.connection_state { - ConnectionState::In => *self.num_in += 1, - ConnectionState::Out => *self.num_out += 1, - ConnectionState::NotConnected => debug_assert!(false, "State inconsistency: \ - connected node is in fact not connected"), - } - } - } - - /// Returns whether or not the node is reserved. - pub fn is_reserved(&self) -> bool { - self.state.reserved } /// Returns the reputation value of the node. pub fn reputation(&self) -> i32 { - self.state.reputation + self.state.reputation(&self.peer_id) } /// Sets the reputation of the peer. pub fn set_reputation(&mut self, value: i32) { - self.state.reputation = value; + self.state.set_reputation(&self.peer_id, value) } /// Performs an arithmetic addition on the reputation score of that peer. /// /// In case of overflow, the value will be capped. pub fn add_reputation(&mut self, modifier: i32) { - let reputation = &mut self.state.reputation; - *reputation = reputation.saturating_add(modifier); + self.state.add_reputation(&self.peer_id, modifier) } } /// A peer that is not connected to us. +#[derive(Debug)] pub struct NotConnectedPeer<'a> { - state: &'a mut Node, + state: &'a mut PeersState, peer_id: Cow<'a, PeerId>, - num_in: &'a mut u32, - num_out: &'a mut u32, - max_in: u32, - max_out: u32, } impl<'a> NotConnectedPeer<'a> { @@ -360,41 +446,16 @@ impl<'a> NotConnectedPeer<'a> { /// /// If there are enough slots available, switches the node to "connected" and returns `Ok`. If /// the slots are full, the node stays "not connected" and we return `Err`. - /// If the node is reserved, this method always succeeds. /// - /// Note that reserved nodes don't count towards the number of slots. + /// Note that priority nodes don't count towards the number of slots. pub fn try_outgoing(self) -> Result, NotConnectedPeer<'a>> { - if self.is_reserved() { - return Ok(self.force_outgoing()) - } - - // Note that it is possible for num_out to be strictly superior to the max, in case we were - // connected to reserved node then marked them as not reserved, or if the user used - // `force_outgoing`. - if *self.num_out >= self.max_out { - return Err(self); - } - - Ok(self.force_outgoing()) - } - - /// Sets the peer as connected as an outgoing connection. - pub fn force_outgoing(self) -> ConnectedPeer<'a> { - let connec_state = &mut self.state.connection_state; - debug_assert!(!connec_state.is_connected()); - *connec_state = ConnectionState::Out; - - if !self.state.reserved { - *self.num_out += 1; - } - - ConnectedPeer { - state: self.state, - peer_id: self.peer_id, - num_in: self.num_in, - num_out: self.num_out, - max_in: self.max_in, - max_out: self.max_out, + if self.state.try_outgoing(&self.peer_id) { + Ok(ConnectedPeer { + state: self.state, + peer_id: self.peer_id, + }) + } else { + Err(self) } } @@ -403,59 +464,26 @@ impl<'a> NotConnectedPeer<'a> { /// If there are enough slots available, switches the node to "connected" and returns `Ok`. If /// the slots are full, the node stays "not connected" and we return `Err`. /// - /// Note that reserved nodes don't count towards the number of slots. + /// Note that priority nodes don't count towards the number of slots. pub fn try_accept_incoming(self) -> Result, NotConnectedPeer<'a>> { - if self.is_reserved() { - return Ok(self.force_ingoing()) - } - - // Note that it is possible for num_in to be strictly superior to the max, in case we were - // connected to reserved node then marked them as not reserved. - if *self.num_in >= self.max_in { - return Err(self); - } - - Ok(self.force_ingoing()) - } - - /// Sets the peer as connected as an ingoing connection. - pub fn force_ingoing(self) -> ConnectedPeer<'a> { - let connec_state = &mut self.state.connection_state; - debug_assert!(!connec_state.is_connected()); - *connec_state = ConnectionState::In; - - if !self.state.reserved { - *self.num_in += 1; - } - - ConnectedPeer { - state: self.state, - peer_id: self.peer_id, - num_in: self.num_in, - num_out: self.num_out, - max_in: self.max_in, - max_out: self.max_out, + if self.state.try_accept_incoming(&self.peer_id) { + Ok(ConnectedPeer { + state: self.state, + peer_id: self.peer_id, + }) + } else { + Err(self) } } - /// Sets whether or not the node is reserved. - pub fn set_reserved(&mut self, reserved: bool) { - self.state.reserved = reserved; - } - - /// Returns true if the the node is reserved. - pub fn is_reserved(&self) -> bool { - self.state.reserved - } - /// Returns the reputation value of the node. pub fn reputation(&self) -> i32 { - self.state.reputation + self.state.reputation(&self.peer_id) } /// Sets the reputation of the peer. pub fn set_reputation(&mut self, value: i32) { - self.state.reputation = value; + self.state.set_reputation(&self.peer_id, value) } /// Performs an arithmetic addition on the reputation score of that peer. @@ -463,8 +491,7 @@ impl<'a> NotConnectedPeer<'a> { /// In case of overflow, the value will be capped. /// If the peer is unknown to us, we insert it and consider that it has a reputation of 0. pub fn add_reputation(&mut self, modifier: i32) { - let reputation = &mut self.state.reputation; - *reputation = reputation.saturating_add(modifier); + self.state.add_reputation(&self.peer_id, modifier) } } @@ -477,25 +504,18 @@ pub struct UnknownPeer<'a> { impl<'a> UnknownPeer<'a> { /// Inserts the peer identity in our list. /// - /// The node is not reserved and starts with a reputation of 0. You can adjust these default + /// The node starts with a reputation of 0. You can adjust these default /// values using the `NotConnectedPeer` that this method returns. pub fn discover(self) -> NotConnectedPeer<'a> { self.parent.nodes.insert(self.peer_id.clone().into_owned(), Node { connection_state: ConnectionState::NotConnected, reputation: 0, - reserved: false, }); - let state = self.parent.nodes.get_mut(&self.peer_id) - .expect("We insert that key into the HashMap right above; QED"); - + let state = self.parent; NotConnectedPeer { state, peer_id: self.peer_id, - num_in: &mut self.parent.num_in, - num_out: &mut self.parent.num_out, - max_in: self.parent.max_in, - max_out: self.parent.max_out, } } } @@ -521,14 +541,13 @@ mod tests { } #[test] - fn reserved_node_doesnt_use_slot() { + fn priority_node_doesnt_use_slot() { let mut peers_state = PeersState::new(1, 1); let id1 = PeerId::random(); let id2 = PeerId::random(); - if let Peer::Unknown(e) = peers_state.peer(&id1) { - let mut p = e.discover(); - p.set_reserved(true); + peers_state.set_priority_group("test", vec![id1.clone()].into_iter().collect()); + if let Peer::NotConnected(p) = peers_state.peer(&id1) { assert!(p.try_accept_incoming().is_ok()); } else { panic!() } @@ -550,23 +569,22 @@ mod tests { } #[test] - fn reserved_not_connected_peer() { + fn priority_not_connected_peer() { let mut peers_state = PeersState::new(25, 25); let id1 = PeerId::random(); let id2 = PeerId::random(); - assert!(peers_state.reserved_not_connected_peer().is_none()); + assert!(peers_state.priority_not_connected_peer().is_none()); peers_state.peer(&id1).into_unknown().unwrap().discover(); peers_state.peer(&id2).into_unknown().unwrap().discover(); - assert!(peers_state.reserved_not_connected_peer().is_none()); - peers_state.peer(&id1).into_not_connected().unwrap().set_reserved(true); - assert!(peers_state.reserved_not_connected_peer().is_some()); - peers_state.peer(&id2).into_not_connected().unwrap().set_reserved(true); - peers_state.peer(&id1).into_not_connected().unwrap().set_reserved(false); - assert!(peers_state.reserved_not_connected_peer().is_some()); - peers_state.peer(&id2).into_not_connected().unwrap().set_reserved(false); - assert!(peers_state.reserved_not_connected_peer().is_none()); + assert!(peers_state.priority_not_connected_peer().is_none()); + peers_state.set_priority_group("test", vec![id1.clone()].into_iter().collect()); + assert!(peers_state.priority_not_connected_peer().is_some()); + peers_state.set_priority_group("test", vec![id2.clone(), id2.clone()].into_iter().collect()); + assert!(peers_state.priority_not_connected_peer().is_some()); + peers_state.set_priority_group("test", vec![].into_iter().collect()); + assert!(peers_state.priority_not_connected_peer().is_none()); } #[test] @@ -581,7 +599,7 @@ mod tests { assert_eq!(peers_state.highest_not_connected_peer().map(|p| p.into_peer_id()), Some(id1.clone())); peers_state.peer(&id2).into_not_connected().unwrap().set_reputation(75); assert_eq!(peers_state.highest_not_connected_peer().map(|p| p.into_peer_id()), Some(id2.clone())); - peers_state.peer(&id2).into_not_connected().unwrap().force_ingoing(); + peers_state.peer(&id2).into_not_connected().unwrap().try_accept_incoming().unwrap(); assert_eq!(peers_state.highest_not_connected_peer().map(|p| p.into_peer_id()), Some(id1.clone())); peers_state.peer(&id1).into_not_connected().unwrap().set_reputation(100); peers_state.peer(&id2).into_connected().unwrap().disconnect(); @@ -591,24 +609,31 @@ mod tests { } #[test] - fn disconnect_reserved_doesnt_panic() { + fn disconnect_priority_doesnt_panic() { let mut peers_state = PeersState::new(1, 1); let id = PeerId::random(); - let mut peer = peers_state.peer(&id).into_unknown().unwrap().discover() - .force_outgoing(); - peer.set_reserved(true); + peers_state.set_priority_group("test", vec![id.clone()].into_iter().collect()); + let peer = peers_state.peer(&id).into_not_connected().unwrap().try_outgoing().unwrap(); peer.disconnect(); } #[test] - fn multiple_set_reserved_calls_doesnt_panic() { + fn multiple_priority_groups_slot_count() { let mut peers_state = PeersState::new(1, 1); let id = PeerId::random(); - let mut peer = peers_state.peer(&id) - .into_unknown().unwrap().discover() - .force_outgoing(); - peer.set_reserved(true); - peer.set_reserved(true); - peer.disconnect(); + + if let Peer::Unknown(p) = peers_state.peer(&id) { + assert!(p.discover().try_accept_incoming().is_ok()); + } else { panic!() } + + assert_eq!(peers_state.num_in, 1); + peers_state.set_priority_group("test1", vec![id.clone()].into_iter().collect()); + assert_eq!(peers_state.num_in, 0); + peers_state.set_priority_group("test2", vec![id.clone()].into_iter().collect()); + assert_eq!(peers_state.num_in, 0); + peers_state.set_priority_group("test1", vec![].into_iter().collect()); + assert_eq!(peers_state.num_in, 0); + peers_state.set_priority_group("test2", vec![].into_iter().collect()); + assert_eq!(peers_state.num_in, 1); } } -- GitLab From 029a778243e79de872e85e01823f6806876febe0 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 3 Jun 2019 16:47:48 +0200 Subject: [PATCH 072/113] Nonlinear locking and cleanups (#2733) * Nonlinear locking and cleanups * Bump runtime version * Minor cleanup * Fix tests * Fix council tests * Fix flaw in turnout counting * fix: lock_voting_should_work_with_delegation test * chore: fix comment refering to unexisting function --- node/cli/src/chain_spec.rs | 16 +- node/executor/src/lib.rs | 4 +- node/runtime/src/lib.rs | 19 +- srml/council/src/lib.rs | 22 +- srml/democracy/src/lib.rs | 964 ++++++++++++++++++++++++------------- srml/support/src/lib.rs | 33 ++ srml/support/src/traits.rs | 37 +- 7 files changed, 688 insertions(+), 407 deletions(-) diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 336636fef8..18238eaa12 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -119,13 +119,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig { stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(), invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(), }), - democracy: Some(DemocracyConfig { - launch_period: 10 * MINUTES, // 1 day per public referendum - voting_period: 10 * MINUTES, // 3 days to discuss & vote on an active referendum - minimum_deposit: 50 * DOLLARS, // 12000 as the minimum deposit for a referendum - public_delay: 10 * MINUTES, - max_lock_periods: 6, - }), + democracy: Some(DemocracyConfig::default()), council_seats: Some(CouncilSeatsConfig { active_council: vec![], candidacy_bond: 10 * DOLLARS, @@ -303,13 +297,7 @@ pub fn testnet_genesis( stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(), invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(), }), - democracy: Some(DemocracyConfig { - launch_period: 9, - voting_period: 18, - minimum_deposit: 10, - public_delay: 0, - max_lock_periods: 6, - }), + democracy: Some(DemocracyConfig::default()), council_seats: Some(CouncilSeatsConfig { active_council: endowed_accounts.iter() .filter(|&endowed| initial_authorities.iter().find(|&(_, controller, _)| controller == endowed).is_none()) diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index 6c4b93b2ad..8813850bbd 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -38,13 +38,13 @@ mod tests { NativeOrEncoded}; use node_primitives::{Hash, BlockNumber, AccountId}; use runtime_primitives::traits::{Header as HeaderT, Hash as HashT, Digest, DigestItem}; - use runtime_primitives::{generic::{self, Era}, ApplyOutcome, ApplyError, ApplyResult, Perbill}; + use runtime_primitives::{generic::Era, ApplyOutcome, ApplyError, ApplyResult, Perbill}; use {balances, indices, session, system, staking, consensus, timestamp, treasury, contract}; use contract::ContractAddressFor; use system::{EventRecord, Phase}; use node_runtime::{Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances, BuildStorage, GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, System, - SystemConfig, GrandpaConfig, IndicesConfig, Event, Log}; + SystemConfig, GrandpaConfig, IndicesConfig, Event}; use wabt; use primitives::map; diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 1e31e5400e..34a8a30524 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -21,7 +21,7 @@ #![recursion_limit="256"] use rstd::prelude::*; -use support::construct_runtime; +use support::{construct_runtime, parameter_types}; use substrate_primitives::u32_trait::{_2, _4}; use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, AuthorityId, Signature, AuthoritySignature @@ -58,7 +58,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 89, + spec_version: 90, impl_version: 90, apis: RUNTIME_API_VERSIONS, }; @@ -150,10 +150,23 @@ impl staking::Trait for Runtime { type Reward = (); } +const MINUTES: BlockNumber = 6; +const BUCKS: Balance = 1_000_000_000_000; + +parameter_types! { + pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const MinimumDeposit: Balance = 100 * BUCKS; + pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES; +} impl democracy::Trait for Runtime { - type Currency = Balances; type Proposal = Call; type Event = Event; + type Currency = Balances; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; } impl council::Trait for Runtime { diff --git a/srml/council/src/lib.rs b/srml/council/src/lib.rs index a13eb7e280..ac5396e4da 100644 --- a/srml/council/src/lib.rs +++ b/srml/council/src/lib.rs @@ -29,7 +29,7 @@ mod tests { // These re-exports are here for a reason, edit with care pub use super::*; pub use runtime_io::with_externalities; - use srml_support::{impl_outer_origin, impl_outer_event, impl_outer_dispatch}; + use srml_support::{impl_outer_origin, impl_outer_event, impl_outer_dispatch, parameter_types}; pub use substrate_primitives::H256; pub use primitives::BuildStorage; pub use primitives::traits::{BlakeTwo256, IdentityLookup}; @@ -81,10 +81,20 @@ mod tests { type TransferPayment = (); type DustRemoval = (); } + parameter_types! { + pub const LaunchPeriod: u64 = 1; + pub const VotingPeriod: u64 = 3; + pub const MinimumDeposit: u64 = 1; + pub const EnactmentPeriod: u64 = 0; + } impl democracy::Trait for Test { - type Currency = balances::Module; type Proposal = Call; type Event = Event; + type Currency = balances::Module; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; } impl seats::Trait for Test { type Event = Event; @@ -111,13 +121,7 @@ mod tests { creation_fee: 0, vesting: vec![], }.build_storage().unwrap().0); - t.extend(democracy::GenesisConfig::{ - launch_period: 1, - voting_period: 3, - minimum_deposit: 1, - public_delay: 0, - max_lock_periods: 6, - }.build_storage().unwrap().0); + t.extend(democracy::GenesisConfig::::default().build_storage().unwrap().0); t.extend(seats::GenesisConfig:: { candidacy_bond: 9, voter_bond: 3, diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index c2a9b849f6..1846f3462d 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -19,13 +19,17 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::prelude::*; -use rstd::result; -use primitives::traits::{Zero, Bounded}; -use parity_codec::{Encode, Decode}; -use srml_support::{StorageValue, StorageMap, Parameter, Dispatchable, IsSubType, EnumerableStorageMap}; -use srml_support::{decl_module, decl_storage, decl_event, ensure}; -use srml_support::traits::{Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, - OnFreeBalanceZero}; +use rstd::{result, convert::TryFrom}; +use primitives::traits::{Zero, Bounded, CheckedMul, CheckedDiv}; +use parity_codec::{Encode, Decode, Input, Output}; +use srml_support::{ + decl_module, decl_storage, decl_event, ensure, + StorageValue, StorageMap, Parameter, Dispatchable, IsSubType, EnumerableStorageMap, + traits::{ + Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, + OnFreeBalanceZero, Get + } +}; use srml_support::dispatch::Result; use system::ensure_signed; @@ -36,50 +40,235 @@ const DEMOCRACY_ID: LockIdentifier = *b"democrac"; /// A proposal index. pub type PropIndex = u32; + /// A referendum index. pub type ReferendumIndex = u32; -/// A number of lock periods. -pub type LockPeriods = i8; -const MAX_RECURSION_LIMIT: u32 = 16; - -/// A number of lock periods, plus a vote, one way or the other. -#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Default)] +/// A value denoting the strength of conviction of a vote. +#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "std", derive(Debug))] -pub struct Vote(i8); +pub enum Conviction { + /// 0.1x votes, unlocked. + None, + /// 1x votes, locked for an enactment period following a successful vote. + Locked1x, + /// 2x votes, locked for 2x enactment periods following a successful vote. + Locked2x, + /// 3x votes, locked for 4x... + Locked3x, + /// 4x votes, locked for 8x... + Locked4x, + /// 5x votes, locked for 16x... + Locked5x, +} -impl Vote { - /// Create a new instance. - pub fn new(aye: bool, multiplier: LockPeriods) -> Self { - let m = multiplier.max(1) - 1; - Vote(if aye { - -1 - m - } else { - m +impl Default for Conviction { + fn default() -> Self { + Conviction::None + } +} + +impl From for u8 { + fn from(c: Conviction) -> u8 { + match c { + Conviction::None => 0, + Conviction::Locked1x => 1, + Conviction::Locked2x => 2, + Conviction::Locked3x => 3, + Conviction::Locked4x => 4, + Conviction::Locked5x => 5, + } + } +} + +impl TryFrom for Conviction { + type Error = (); + fn try_from(i: u8) -> result::Result { + Ok(match i { + 0 => Conviction::None, + 1 => Conviction::Locked1x, + 2 => Conviction::Locked2x, + 3 => Conviction::Locked3x, + 4 => Conviction::Locked4x, + 5 => Conviction::Locked5x, + _ => return Err(()), }) } +} - /// Is this an aye vote? - pub fn is_aye(self) -> bool { - self.0 < 0 +impl Conviction { + /// The amount of time (in number of periods) that our conviction implies a successful voter's + /// balance should be locked for. + fn lock_periods(self) -> u32 { + match self { + Conviction::None => 0, + Conviction::Locked1x => 1, + Conviction::Locked2x => 2, + Conviction::Locked3x => 4, + Conviction::Locked4x => 8, + Conviction::Locked5x => 16, + } } - /// The strength (measured in lock periods). - pub fn multiplier(self) -> LockPeriods { - 1 + if self.0 < 0 { -(self.0 + 1) } else { self.0 } + /// The votes of a voter of the given `balance` with our conviction. + fn votes< + B: From + Zero + Copy + CheckedMul + CheckedDiv + Bounded + >(self, balance: B) -> (B, B) { + match self { + Conviction::None => { + let r = balance.checked_div(&10u8.into()).unwrap_or_else(Zero::zero); + (r, r) + } + x => ( + balance.checked_mul(&u8::from(x).into()).unwrap_or_else(B::max_value), + balance, + ) + } + } +} + +impl Bounded for Conviction { + fn min_value() -> Self { + Conviction::None + } + + fn max_value() -> Self { + Conviction::Locked5x + } +} + +const MAX_RECURSION_LIMIT: u32 = 16; + +/// A number of lock periods, plus a vote, one way or the other. +#[derive(Copy, Clone, Eq, PartialEq, Default)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct Vote { + pub aye: bool, + pub conviction: Conviction, +} + +impl Encode for Vote { + fn encode_to(&self, output: &mut T) { + output.push_byte(u8::from(self.conviction) | if self.aye { 0b1000_0000 } else { 0 }); + } +} + +impl Decode for Vote { + fn decode(input: &mut I) -> Option { + let b = input.read_byte()?; + Some(Vote { + aye: (b & 0b1000_0000) == 0b1000_0000, + conviction: Conviction::try_from(b & 0b0111_1111).ok()?, + }) } } type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; pub trait Trait: system::Trait + Sized { - type Currency: ReservableCurrency + LockableCurrency; - type Proposal: Parameter + Dispatchable + IsSubType>; - type Event: From> + Into<::Event>; + + /// Currency type for this module. + type Currency: ReservableCurrency + + LockableCurrency; + + /// The minimum period of locking and the period between a proposal being approved and enacted. + /// + /// It should generally be a little more than the unstake period to ensure that + /// voting stakers have an opportunity to remove themselves from the system in the case where + /// they are on the losing side of a vote. + type EnactmentPeriod: Get; + + /// How often (in blocks) new public referenda are launched. + type LaunchPeriod: Get; + + /// How often (in blocks) to check for new votes. + type VotingPeriod: Get; + + /// The minimum amount to be used as a deposit for a public referendum proposal. + type MinimumDeposit: Get>; +} + +/// Info regarding an ongoing referendum. +#[derive(Encode, Decode, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct ReferendumInfo { + /// When voting on this referendum will end. + end: BlockNumber, + /// The proposal being voted on. + proposal: Proposal, + /// The thresholding mechanism to determine whether it passed. + threshold: VoteThreshold, + /// The delay (in blocks) to wait after a successful referendum before deploying. + delay: BlockNumber, +} + +impl ReferendumInfo { + /// Create a new instance. + pub fn new( + end: BlockNumber, + proposal: Proposal, + threshold: VoteThreshold, + delay: BlockNumber + ) -> Self { + ReferendumInfo { end, proposal, threshold, delay } + } +} + +decl_storage! { + trait Store for Module as Democracy { + + /// The number of (public) proposals that have been made so far. + pub PublicPropCount get(public_prop_count) build(|_| 0 as PropIndex) : PropIndex; + /// The public proposals. Unsorted. + pub PublicProps get(public_props): Vec<(PropIndex, T::Proposal, T::AccountId)>; + /// Those who have locked a deposit. + pub DepositOf get(deposit_of): map PropIndex => Option<(BalanceOf, Vec)>; + + /// The next free referendum index, aka the number of referenda started so far. + pub ReferendumCount get(referendum_count) build(|_| 0 as ReferendumIndex): ReferendumIndex; + /// The next referendum index that should be tallied. + pub NextTally get(next_tally) build(|_| 0 as ReferendumIndex): ReferendumIndex; + /// Information concerning any given referendum. + pub ReferendumInfoOf get(referendum_info): + map ReferendumIndex => Option<(ReferendumInfo)>; + /// Queue of successful referenda to be dispatched. + pub DispatchQueue get(dispatch_queue): + map T::BlockNumber => Vec>; + + /// Get the voters for the current proposal. + pub VotersFor get(voters_for): map ReferendumIndex => Vec; + + /// Get the vote in a given referendum of a particular voter. The result is meaningful only + /// if `voters_for` includes the voter when called with the referendum (you'll get the + /// default `Vote` value otherwise). If you don't want to check `voters_for`, then you can + /// also check for simple existence with `VoteOf::exists` first. + pub VoteOf get(vote_of): map (ReferendumIndex, T::AccountId) => Vote; + + /// Who is able to vote for whom. Value is the fund-holding account, key is the + /// vote-transaction-sending account. + pub Proxy get(proxy): map T::AccountId => Option; + + /// Get the account (and lock periods) to which another account is delegating vote. + pub Delegations get(delegations): linked_map T::AccountId => (T::AccountId, Conviction); + } } +decl_event!( + pub enum Event where Balance = BalanceOf, ::AccountId { + Proposed(PropIndex, Balance), + Tabled(PropIndex, Balance, Vec), + Started(ReferendumIndex, VoteThreshold), + Passed(ReferendumIndex), + NotPassed(ReferendumIndex), + Cancelled(ReferendumIndex), + Executed(ReferendumIndex, bool), + Delegated(AccountId, AccountId), + Undelegated(AccountId), + } +); + decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; @@ -92,7 +281,7 @@ decl_module! { ) { let who = ensure_signed(origin)?; - ensure!(value >= Self::minimum_deposit(), "value too low"); + ensure!(value >= T::MinimumDeposit::get(), "value too low"); T::Currency::reserve(&who, value) .map_err(|_| "proposer's balance too low")?; @@ -118,24 +307,34 @@ decl_module! { >::insert(proposal, deposit); } - /// Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; + /// Vote in a referendum. If vote is aye, the vote is to enact the proposal; /// otherwise it is a vote to keep the status quo. - fn vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote) -> Result { + fn vote(origin, + #[compact] ref_index: ReferendumIndex, + vote: Vote + ) -> Result { let who = ensure_signed(origin)?; Self::do_vote(who, ref_index, vote) } - /// Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; - /// otherwise it is a vote to keep the status quo. - fn proxy_vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote) -> Result { + /// Vote in a referendum on behalf of a stash. If vote is aye, the vote is to enact + /// the proposal; otherwise it is a vote to keep the status quo. + fn proxy_vote(origin, + #[compact] ref_index: ReferendumIndex, + vote: Vote + ) -> Result { let who = Self::proxy(ensure_signed(origin)?).ok_or("not a proxy")?; Self::do_vote(who, ref_index, vote) } /// Start a referendum. - fn start_referendum(proposal: Box, threshold: VoteThreshold, delay: T::BlockNumber) -> Result { + fn start_referendum( + proposal: Box, + threshold: VoteThreshold, + delay: T::BlockNumber + ) -> Result { Self::inject_referendum( - >::block_number() + Self::voting_period(), + >::block_number() + T::VotingPeriod::get(), *proposal, threshold, delay, @@ -150,7 +349,10 @@ decl_module! { /// Cancel a proposal queued for enactment. pub fn cancel_queued(#[compact] when: T::BlockNumber, #[compact] which: u32) { let which = which as usize; - >::mutate(when, |items| if items.len() > which { items[which] = None }); + >::mutate( + when, + |items| if items.len() > which { items[which] = None } + ); } fn on_finalize(n: T::BlockNumber) { @@ -180,11 +382,17 @@ decl_module! { } /// Delegate vote. - pub fn delegate(origin, to: T::AccountId, lock_periods: LockPeriods) { + pub fn delegate(origin, to: T::AccountId, conviction: Conviction) { let who = ensure_signed(origin)?; - >::insert(who.clone(), (to.clone(), lock_periods.clone())); + >::insert(who.clone(), (to.clone(), conviction)); // Currency is locked indefinitely as long as it's delegated. - T::Currency::extend_lock(DEMOCRACY_ID, &who, Bounded::max_value(), T::BlockNumber::max_value(), WithdrawReason::Transfer.into()); + T::Currency::extend_lock( + DEMOCRACY_ID, + &who, + Bounded::max_value(), + T::BlockNumber::max_value(), + WithdrawReason::Transfer.into() + ); Self::deposit_event(RawEvent::Delegated(who, to)); } @@ -192,98 +400,22 @@ decl_module! { fn undelegate(origin) { let who = ensure_signed(origin)?; ensure!(>::exists(&who), "not delegated"); - let d = >::take(&who); + let (_, conviction) = >::take(&who); // Indefinite lock is reduced to the maximum voting lock that could be possible. - let lock_period = Self::public_delay(); let now = >::block_number(); - let locked_until = now + lock_period * (d.1 as u32).into(); - T::Currency::set_lock(DEMOCRACY_ID, &who, Bounded::max_value(), locked_until, WithdrawReason::Transfer.into()); + let locked_until = now + T::EnactmentPeriod::get() * conviction.lock_periods().into(); + T::Currency::set_lock( + DEMOCRACY_ID, + &who, + Bounded::max_value(), + locked_until, + WithdrawReason::Transfer.into() + ); Self::deposit_event(RawEvent::Undelegated(who)); } } } -/// Info regarding an ongoing referendum. -#[derive(Encode, Decode, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(Debug))] -pub struct ReferendumInfo { - /// When voting on this referendum will end. - end: BlockNumber, - /// The proposal being voted on. - proposal: Proposal, - /// The thresholding mechanism to determine whether it passed. - threshold: VoteThreshold, - /// The delay (in blocks) to wait after a successful referendum before deploying. - delay: BlockNumber, -} - -impl ReferendumInfo { - /// Create a new instance. - pub fn new(end: BlockNumber, proposal: Proposal, threshold: VoteThreshold, delay: BlockNumber) -> Self { - ReferendumInfo { end, proposal, threshold, delay } - } -} - -decl_storage! { - trait Store for Module as Democracy { - - /// The number of (public) proposals that have been made so far. - pub PublicPropCount get(public_prop_count) build(|_| 0 as PropIndex) : PropIndex; - /// The public proposals. Unsorted. - pub PublicProps get(public_props): Vec<(PropIndex, T::Proposal, T::AccountId)>; - /// Those who have locked a deposit. - pub DepositOf get(deposit_of): map PropIndex => Option<(BalanceOf, Vec)>; - /// How often (in blocks) new public referenda are launched. - pub LaunchPeriod get(launch_period) config(): T::BlockNumber = 1000.into(); - /// The minimum amount to be used as a deposit for a public referendum proposal. - pub MinimumDeposit get(minimum_deposit) config(): BalanceOf; - /// The delay before enactment for all public referenda. - pub PublicDelay get(public_delay) config(): T::BlockNumber; - /// The maximum number of additional lock periods a voter may offer to strengthen their vote. Multiples of `PublicDelay`. - pub MaxLockPeriods get(max_lock_periods) config(): LockPeriods; - - /// How often (in blocks) to check for new votes. - pub VotingPeriod get(voting_period) config(): T::BlockNumber = 1000.into(); - - /// The next free referendum index, aka the number of referenda started so far. - pub ReferendumCount get(referendum_count) build(|_| 0 as ReferendumIndex): ReferendumIndex; - /// The next referendum index that should be tallied. - pub NextTally get(next_tally) build(|_| 0 as ReferendumIndex): ReferendumIndex; - /// Information concerning any given referendum. - pub ReferendumInfoOf get(referendum_info): map ReferendumIndex => Option<(ReferendumInfo)>; - /// Queue of successful referenda to be dispatched. - pub DispatchQueue get(dispatch_queue): map T::BlockNumber => Vec>; - - /// Get the voters for the current proposal. - pub VotersFor get(voters_for): map ReferendumIndex => Vec; - - /// Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the - /// voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check - /// `voters_for`, then you can also check for simple existence with `VoteOf::exists` first. - pub VoteOf get(vote_of): map (ReferendumIndex, T::AccountId) => Vote; - - /// Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account. - pub Proxy get(proxy): map T::AccountId => Option; - - /// Get the account (and lock periods) to which another account is delegating vote. - pub Delegations get(delegations): linked_map T::AccountId => (T::AccountId, LockPeriods); - } -} - -decl_event!( - pub enum Event where Balance = BalanceOf, ::AccountId { - Proposed(PropIndex, Balance), - Tabled(PropIndex, Balance, Vec), - Started(ReferendumIndex, VoteThreshold), - Passed(ReferendumIndex), - NotPassed(ReferendumIndex), - Cancelled(ReferendumIndex), - Executed(ReferendumIndex, bool), - Delegated(AccountId, AccountId), - Undelegated(AccountId), - } -); - impl Module { // exposed immutables. @@ -299,7 +431,9 @@ impl Module { } /// Get all referenda currently active. - pub fn active_referenda() -> Vec<(ReferendumIndex, ReferendumInfo)> { + pub fn active_referenda() + -> Vec<(ReferendumIndex, ReferendumInfo)> + { let next = Self::next_tally(); let last = Self::referendum_count(); (next..last).into_iter() @@ -308,7 +442,9 @@ impl Module { } /// Get all referenda ready for tally at block `n`. - pub fn maturing_referenda_at(n: T::BlockNumber) -> Vec<(ReferendumIndex, ReferendumInfo)> { + pub fn maturing_referenda_at( + n: T::BlockNumber + ) -> Vec<(ReferendumIndex, ReferendumInfo)> { let next = Self::next_tally(); let last = Self::referendum_count(); (next..last).into_iter() @@ -319,52 +455,75 @@ impl Module { /// Get the voters for the current proposal. pub fn tally(ref_index: ReferendumIndex) -> (BalanceOf, BalanceOf, BalanceOf) { - let (approve, against, capital): (BalanceOf, BalanceOf, BalanceOf) = Self::voters_for(ref_index).iter() - .map(|voter| ( - T::Currency::total_balance(voter), Self::vote_of((ref_index, voter.clone())) - )) - .map(|(bal, vote)| - if vote.is_aye() { - (bal * (vote.multiplier() as u32).into(), Zero::zero(), bal) - } else { - (Zero::zero(), bal * (vote.multiplier() as u32).into(), bal) - } - ).fold((Zero::zero(), Zero::zero(), Zero::zero()), |(a, b, c), (d, e, f)| (a + d, b + e, c + f)); + let (approve, against, capital): + (BalanceOf, BalanceOf, BalanceOf) = Self::voters_for(ref_index) + .iter() + .map(|voter| ( + T::Currency::total_balance(voter), Self::vote_of((ref_index, voter.clone())) + )) + .map(|(balance, Vote { aye, conviction })| { + let (votes, turnout) = conviction.votes(balance); + if aye { + (votes, Zero::zero(), turnout) + } else { + (Zero::zero(), votes, turnout) + } + }).fold( + (Zero::zero(), Zero::zero(), Zero::zero()), + |(a, b, c), (d, e, f)| (a + d, b + e, c + f) + ); let (del_approve, del_against, del_capital) = Self::tally_delegation(ref_index); (approve + del_approve, against + del_against, capital + del_capital) } /// Get the delegated voters for the current proposal. - /// I think this goes into a worker once https://github.com/paritytech/substrate/issues/1458 is done. + /// I think this goes into a worker once https://github.com/paritytech/substrate/issues/1458 is + /// done. fn tally_delegation(ref_index: ReferendumIndex) -> (BalanceOf, BalanceOf, BalanceOf) { - Self::voters_for(ref_index).iter() - .fold((Zero::zero(), Zero::zero(), Zero::zero()), |(approve_acc, against_acc, capital_acc), voter| { - let vote = Self::vote_of((ref_index, voter.clone())); - let (votes, balance) = Self::delegated_votes(ref_index, voter.clone(), vote.multiplier(), MAX_RECURSION_LIMIT); - if vote.is_aye() { - (approve_acc + votes, against_acc, capital_acc + balance) + Self::voters_for(ref_index).iter().fold( + (Zero::zero(), Zero::zero(), Zero::zero()), + |(approve_acc, against_acc, turnout_acc), voter| { + let Vote { aye, conviction } = Self::vote_of((ref_index, voter.clone())); + let (votes, turnout) = Self::delegated_votes( + ref_index, + voter.clone(), + conviction, + MAX_RECURSION_LIMIT + ); + if aye { + (approve_acc + votes, against_acc, turnout_acc + turnout) } else { - (approve_acc, against_acc + votes, capital_acc + balance) + (approve_acc, against_acc + votes, turnout_acc + turnout) } - }) + } + ) } fn delegated_votes( ref_index: ReferendumIndex, to: T::AccountId, - min_lock_periods: LockPeriods, + parent_conviction: Conviction, recursion_limit: u32, ) -> (BalanceOf, BalanceOf) { if recursion_limit == 0 { return (Zero::zero(), Zero::zero()); } >::enumerate() - .filter(|(delegator, (delegate, _))| *delegate == to && !>::exists(&(ref_index, delegator.clone()))) - .fold((Zero::zero(), Zero::zero()), |(votes_acc, balance_acc), (delegator, (_delegate, periods))| { - let lock_periods = if min_lock_periods <= periods { min_lock_periods } else { periods }; - let balance = T::Currency::total_balance(&delegator); - let votes = T::Currency::total_balance(&delegator) * (lock_periods as u32).into(); - let (del_votes, del_balance) = Self::delegated_votes(ref_index, delegator, lock_periods, recursion_limit - 1); - (votes_acc + votes + del_votes, balance_acc + balance + del_balance) - }) + .filter(|(delegator, (delegate, _))| + *delegate == to && !>::exists(&(ref_index, delegator.clone())) + ).fold( + (Zero::zero(), Zero::zero()), + |(votes_acc, turnout_acc), (delegator, (_delegate, max_conviction))| { + let conviction = Conviction::min(parent_conviction, max_conviction); + let balance = T::Currency::total_balance(&delegator); + let (votes, turnout) = conviction.votes(balance); + let (del_votes, del_turnout) = Self::delegated_votes( + ref_index, + delegator, + conviction, + recursion_limit - 1 + ); + (votes_acc + votes + del_votes, turnout_acc + turnout + del_turnout) + } + ) } // Exposed mutables. @@ -375,8 +534,17 @@ impl Module { } /// Start a referendum. Can be called directly by the council. - pub fn internal_start_referendum(proposal: T::Proposal, threshold: VoteThreshold, delay: T::BlockNumber) -> result::Result { - >::inject_referendum(>::block_number() + >::voting_period(), proposal, threshold, delay) + pub fn internal_start_referendum( + proposal: T::Proposal, + threshold: VoteThreshold, + delay: T::BlockNumber + ) -> result::Result { + >::inject_referendum( + >::block_number() + T::VotingPeriod::get(), + proposal, + threshold, + delay + ) } /// Remove a referendum. Can be called directly by the council. @@ -389,7 +557,6 @@ impl Module { /// Actually enact a vote, if legit. fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> Result { - ensure!(vote.multiplier() <= Self::max_lock_periods(), "vote has too great a strength"); ensure!(Self::is_active_referendum(ref_index), "vote given for invalid referendum."); if !>::exists(&(ref_index, who.clone())) { >::mutate(ref_index, |voters| voters.push(who.clone())); @@ -406,12 +573,17 @@ impl Module { delay: T::BlockNumber, ) -> result::Result { let ref_index = Self::referendum_count(); - if ref_index > 0 && Self::referendum_info(ref_index - 1).map(|i| i.end > end).unwrap_or(false) { + if ref_index.checked_sub(1) + .and_then(Self::referendum_info) + .map(|i| i.end > end) + .unwrap_or(false) + { Err("Cannot inject a referendum that ends earlier than preceeding referendum")? } >::put(ref_index + 1); - >::insert(ref_index, ReferendumInfo { end, proposal, threshold, delay }); + let item = ReferendumInfo { end, proposal, threshold, delay }; + >::insert(ref_index, item); Self::deposit_event(RawEvent::Started(ref_index, threshold)); Ok(ref_index) } @@ -435,43 +607,59 @@ impl Module { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter() .enumerate() - .max_by_key(|x| Self::locked_for((x.1).0).unwrap_or_else(Zero::zero)/*defensive only: All current public proposals have an amount locked*/) + .max_by_key(|x| Self::locked_for((x.1).0).unwrap_or_else(Zero::zero) + /* ^^ defensive only: All current public proposals have an amount locked*/) { let (prop_index, proposal, _) = public_props.swap_remove(winner_index); >::put(public_props); - if let Some((deposit, depositors)) = >::take(prop_index) {//: (BalanceOf, Vec) = + if let Some((deposit, depositors)) = >::take(prop_index) { // refund depositors for d in &depositors { T::Currency::unreserve(d, deposit); } Self::deposit_event(RawEvent::Tabled(prop_index, deposit, depositors)); - Self::inject_referendum(now + Self::voting_period(), proposal, VoteThreshold::SuperMajorityApprove, Self::public_delay())?; + Self::inject_referendum( + now + T::VotingPeriod::get(), + proposal, + VoteThreshold::SuperMajorityApprove, + T::EnactmentPeriod::get(), + )?; } } Ok(()) } - fn bake_referendum(now: T::BlockNumber, index: ReferendumIndex, info: ReferendumInfo) -> Result { + fn bake_referendum( + now: T::BlockNumber, + index: ReferendumIndex, + info: ReferendumInfo + ) -> Result { let (approve, against, capital) = Self::tally(index); let total_issuance = T::Currency::total_issuance(); let approved = info.threshold.approved(approve, against, capital, total_issuance); - let lock_period = Self::public_delay(); // Logic defined in https://www.slideshare.net/gavofyork/governance-in-polkadot-poc3 // Essentially, we extend the lock-period of the coins behind the winning votes to be the // vote strength times the public delay period from now. - for (a, vote) in Self::voters_for(index).into_iter() + for (a, Vote { conviction, .. }) in Self::voters_for(index).into_iter() .map(|a| (a.clone(), Self::vote_of((index, a)))) - // ^^^ defensive only: all items come from `voters`; for an item to be in `voters` there must be a vote registered; qed - .filter(|&(_, vote)| vote.is_aye() == approved) // Just the winning coins + // ^^^ defensive only: all items come from `voters`; for an item to be in `voters` + // there must be a vote registered; qed + .filter(|&(_, vote)| vote.aye == approved) // Just the winning coins { - // now plus: the base lock period multiplied by the number of periods this voter offered to - // lock should they win... - let locked_until = now + lock_period * (vote.multiplier() as u32).into(); + // now plus: the base lock period multiplied by the number of periods this voter + // offered to lock should they win... + let locked_until = now + T::EnactmentPeriod::get() * conviction.lock_periods().into(); // ...extend their bondage until at least then. - T::Currency::extend_lock(DEMOCRACY_ID, &a, Bounded::max_value(), locked_until, WithdrawReason::Transfer.into()); + T::Currency::extend_lock( + DEMOCRACY_ID, + &a, + Bounded::max_value(), + locked_until, + WithdrawReason::Transfer.into() + ); } Self::clear_referendum(index); @@ -480,7 +668,10 @@ impl Module { if info.delay.is_zero() { Self::enact_proposal(info.proposal, index); } else { - >::mutate(now + info.delay, |q| q.push(Some((info.proposal, index)))); + >::mutate( + now + info.delay, + |q| q.push(Some((info.proposal, index))) + ); } } else { Self::deposit_event(RawEvent::NotPassed(index)); @@ -491,9 +682,10 @@ impl Module { } /// Current era is ending; we should finish up any proposals. + // TODO: move to `initialize_block fn end_block(now: T::BlockNumber) -> Result { // pick out another public referendum if it's time. - if (now % Self::launch_period()).is_zero() { + if (now % T::LaunchPeriod::get()).is_zero() { Self::launch_next(now.clone())?; } @@ -519,15 +711,19 @@ impl OnFreeBalanceZero for Module { mod tests { use super::*; use runtime_io::with_externalities; - use srml_support::{impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok}; + use srml_support::{ + impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types + }; use substrate_primitives::{H256, Blake2Hasher}; use primitives::BuildStorage; - use primitives::traits::{BlakeTwo256, IdentityLookup}; + use primitives::traits::{BlakeTwo256, IdentityLookup, Bounded}; use primitives::testing::{Digest, DigestItem, Header}; use balances::BalanceLock; - const AYE: Vote = Vote(-1); - const NAY: Vote = Vote(0); + const AYE: Vote = Vote{ aye: true, conviction: Conviction::None }; + const NAY: Vote = Vote{ aye: false, conviction: Conviction::None }; + const BIG_AYE: Vote = Vote{ aye: true, conviction: Conviction::Locked1x }; + const BIG_NAY: Vote = Vote{ aye: false, conviction: Conviction::Locked1x }; impl_outer_origin! { pub enum Origin for Test {} @@ -565,17 +761,23 @@ mod tests { type TransferPayment = (); type DustRemoval = (); } + parameter_types! { + pub const LaunchPeriod: u64 = 1; + pub const VotingPeriod: u64 = 1; + pub const MinimumDeposit: u64 = 1; + pub const EnactmentPeriod: u64 = 1; + } impl Trait for Test { - type Currency = balances::Module; type Proposal = Call; type Event = (); + type Currency = balances::Module; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; } fn new_test_ext() -> runtime_io::TestExternalities { - new_test_ext_with_public_delay(0) - } - - fn new_test_ext_with_public_delay(public_delay: u64) -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap().0; t.extend(balances::GenesisConfig::{ transaction_base_fee: 0, @@ -586,13 +788,7 @@ mod tests { creation_fee: 0, vesting: vec![], }.build_storage().unwrap().0); - t.extend(GenesisConfig::{ - launch_period: 1, - voting_period: 1, - minimum_deposit: 1, - public_delay, - max_lock_periods: 6, - }.build_storage().unwrap().0); + t.extend(GenesisConfig::::default().build_storage().unwrap().0); runtime_io::TestExternalities::new(t) } @@ -603,40 +799,9 @@ mod tests { #[test] fn params_should_work() { with_externalities(&mut new_test_ext(), || { - assert_eq!(Democracy::launch_period(), 1); - assert_eq!(Democracy::voting_period(), 1); - assert_eq!(Democracy::minimum_deposit(), 1); assert_eq!(Democracy::referendum_count(), 0); assert_eq!(Balances::free_balance(&42), 0); assert_eq!(Balances::total_issuance(), 210); - assert_eq!(Democracy::public_delay(), 0); - assert_eq!(Democracy::max_lock_periods(), 6); - }); - } - - #[test] - fn vote_should_work() { - assert_eq!(Vote::new(true, 0).multiplier(), 1); - assert_eq!(Vote::new(true, 1).multiplier(), 1); - assert_eq!(Vote::new(true, 2).multiplier(), 2); - assert_eq!(Vote::new(true, 0).is_aye(), true); - assert_eq!(Vote::new(true, 1).is_aye(), true); - assert_eq!(Vote::new(true, 2).is_aye(), true); - assert_eq!(Vote::new(false, 0).multiplier(), 1); - assert_eq!(Vote::new(false, 1).multiplier(), 1); - assert_eq!(Vote::new(false, 2).multiplier(), 2); - assert_eq!(Vote::new(false, 0).is_aye(), false); - assert_eq!(Vote::new(false, 1).is_aye(), false); - assert_eq!(Vote::new(false, 2).is_aye(), false); - } - - #[test] - fn invalid_vote_strength_should_not_work() { - with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); - assert_noop!(Democracy::vote(Origin::signed(1), r, Vote::new(true, 7)), "vote has too great a strength"); - assert_noop!(Democracy::vote(Origin::signed(1), r, Vote::new(false, 7)), "vote has too great a strength"); }); } @@ -645,7 +810,15 @@ mod tests { } fn propose_set_balance(who: u64, value: u64, locked: u64) -> super::Result { - Democracy::propose(Origin::signed(who), Box::new(set_balance_proposal(value)), locked.into()) + Democracy::propose( + Origin::signed(who), + Box::new(set_balance_proposal(value)), locked.into() + ) + } + + fn next_block() { + assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + System::set_block_number(System::block_number() + 1); } #[test] @@ -675,9 +848,10 @@ mod tests { assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); - assert_eq!(Democracy::tally(r), (10, 0, 10)); + assert_eq!(Democracy::tally(r), (1, 0, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); } @@ -727,9 +901,10 @@ mod tests { assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); - assert_eq!(Democracy::tally(r), (10, 0, 10)); + assert_eq!(Democracy::tally(r), (1, 0, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); } @@ -741,12 +916,11 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - System::set_block_number(2); + next_block(); let r = 0; // Delegate vote. - assert_ok!(Democracy::delegate(Origin::signed(2), 1, 100)); + assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -755,9 +929,10 @@ mod tests { assert_eq!(Democracy::vote_of((r, 1)), AYE); // Delegated vote is counted. - assert_eq!(Democracy::tally(r), (30, 0, 30)); + assert_eq!(Democracy::tally(r), (3, 0, 3)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -770,14 +945,13 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - System::set_block_number(2); + next_block(); let r = 0; // Check behavior with cycle. - assert_ok!(Democracy::delegate(Origin::signed(2), 1, 100)); - assert_ok!(Democracy::delegate(Origin::signed(3), 2, 100)); - assert_ok!(Democracy::delegate(Origin::signed(1), 3, 100)); + assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); + assert_ok!(Democracy::delegate(Origin::signed(3), 2, Conviction::max_value())); + assert_ok!(Democracy::delegate(Origin::signed(1), 3, Conviction::max_value())); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -785,8 +959,9 @@ mod tests { assert_eq!(Democracy::voters_for(r), vec![1]); // Delegated vote is counted. - assert_eq!(Democracy::tally(r), (60, 0, 60)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + assert_eq!(Democracy::tally(r), (6, 0, 6)); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -800,8 +975,7 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - System::set_block_number(2); + next_block(); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -810,16 +984,17 @@ mod tests { assert_ok!(Democracy::vote(Origin::signed(2), r, AYE)); // Delegate vote. - assert_ok!(Democracy::delegate(Origin::signed(2), 1, 100)); + assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1, 2]); assert_eq!(Democracy::vote_of((r, 1)), AYE); // Delegated vote is not counted. - assert_eq!(Democracy::tally(r), (30, 0, 30)); + assert_eq!(Democracy::tally(r), (3, 0, 3)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -833,11 +1008,10 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 1)); // Delegate and undelegate vote. - assert_ok!(Democracy::delegate(Origin::signed(2), 1, 100)); + assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); assert_ok!(Democracy::undelegate(Origin::signed(2))); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - System::set_block_number(2); + next_block(); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -846,9 +1020,10 @@ mod tests { assert_eq!(Democracy::vote_of((r, 1)), AYE); // Delegated vote is not counted. - assert_eq!(Democracy::tally(r), (10, 0, 10)); + assert_eq!(Democracy::tally(r), (1, 0, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -862,14 +1037,13 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - System::set_block_number(2); + next_block(); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); // Delegate vote. - assert_ok!(Democracy::delegate(Origin::signed(2), 1, 100)); + assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); // Vote. assert_ok!(Democracy::vote(Origin::signed(2), r, AYE)); @@ -879,9 +1053,10 @@ mod tests { assert_eq!(Democracy::vote_of((r, 1)), AYE); // Delegated vote is not counted. - assert_eq!(Democracy::tally(r), (30, 0, 30)); + assert_eq!(Democracy::tally(r), (3, 0, 3)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -950,21 +1125,12 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 2)); assert_ok!(propose_set_balance(1, 4, 4)); assert_ok!(propose_set_balance(1, 3, 3)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - - System::set_block_number(1); + next_block(); assert_ok!(Democracy::vote(Origin::signed(1), 0, AYE)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - assert_eq!(Balances::free_balance(&42), 4); - - System::set_block_number(2); + next_block(); assert_ok!(Democracy::vote(Origin::signed(1), 1, AYE)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - assert_eq!(Balances::free_balance(&42), 3); - - System::set_block_number(3); + next_block(); assert_ok!(Democracy::vote(Origin::signed(1), 2, AYE)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); }); } @@ -972,14 +1138,20 @@ mod tests { fn simple_passing_should_work() { with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); - assert_eq!(Democracy::tally(r), (10, 0, 10)); + assert_eq!(Democracy::tally(r), (1, 0, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -989,11 +1161,17 @@ mod tests { fn cancel_referendum_should_work() { with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_ok!(Democracy::cancel_referendum(r.into())); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 0); }); @@ -1003,14 +1181,20 @@ mod tests { fn simple_failing_should_work() { with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); assert_ok!(Democracy::vote(Origin::signed(1), r, NAY)); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), NAY); - assert_eq!(Democracy::tally(r), (0, 10, 10)); + assert_eq!(Democracy::tally(r), (0, 1, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 0); }); @@ -1020,17 +1204,23 @@ mod tests { fn controversial_voting_should_work() { with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); - assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); - assert_ok!(Democracy::vote(Origin::signed(2), r, NAY)); - assert_ok!(Democracy::vote(Origin::signed(3), r, NAY)); - assert_ok!(Democracy::vote(Origin::signed(4), r, AYE)); - assert_ok!(Democracy::vote(Origin::signed(5), r, NAY)); - assert_ok!(Democracy::vote(Origin::signed(6), r, AYE)); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, BIG_AYE)); + assert_ok!(Democracy::vote(Origin::signed(2), r, BIG_NAY)); + assert_ok!(Democracy::vote(Origin::signed(3), r, BIG_NAY)); + assert_ok!(Democracy::vote(Origin::signed(4), r, BIG_AYE)); + assert_ok!(Democracy::vote(Origin::signed(5), r, BIG_NAY)); + assert_ok!(Democracy::vote(Origin::signed(6), r, BIG_AYE)); assert_eq!(Democracy::tally(r), (110, 100, 210)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1040,7 +1230,12 @@ mod tests { fn delayed_enactment_should_work() { with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 1).unwrap(); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 1 + ).unwrap(); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_ok!(Democracy::vote(Origin::signed(2), r, AYE)); assert_ok!(Democracy::vote(Origin::signed(3), r, AYE)); @@ -1048,102 +1243,181 @@ mod tests { assert_ok!(Democracy::vote(Origin::signed(5), r, AYE)); assert_ok!(Democracy::vote(Origin::signed(6), r, AYE)); - assert_eq!(Democracy::tally(r), (210, 0, 210)); + assert_eq!(Democracy::tally(r), (21, 0, 21)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); assert_eq!(Balances::free_balance(&42), 0); - System::set_block_number(2); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); } #[test] - fn lock_voting_should_work() { - with_externalities(&mut new_test_ext_with_public_delay(1), || { + fn controversial_low_turnout_voting_should_work() { + with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); - assert_ok!(Democracy::vote(Origin::signed(1), r, Vote::new(false, 6))); - assert_ok!(Democracy::vote(Origin::signed(2), r, Vote::new(true, 5))); - assert_ok!(Democracy::vote(Origin::signed(3), r, Vote::new(true, 4))); - assert_ok!(Democracy::vote(Origin::signed(4), r, Vote::new(true, 3))); - assert_ok!(Democracy::vote(Origin::signed(5), r, Vote::new(true, 2))); - assert_ok!(Democracy::vote(Origin::signed(6), r, Vote::new(false, 1))); - - assert_eq!(Democracy::tally(r), (440, 120, 210)); - - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(5), r, BIG_NAY)); + assert_ok!(Democracy::vote(Origin::signed(6), r, BIG_AYE)); - assert_eq!(Balances::locks(1), vec![]); - assert_eq!(Balances::locks(2), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), until: 6, reasons: WithdrawReason::Transfer.into() }]); - assert_eq!(Balances::locks(3), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), until: 5, reasons: WithdrawReason::Transfer.into() }]); - assert_eq!(Balances::locks(4), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), until: 4, reasons: WithdrawReason::Transfer.into() }]); - assert_eq!(Balances::locks(5), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), until: 3, reasons: WithdrawReason::Transfer.into() }]); - assert_eq!(Balances::locks(6), vec![]); + assert_eq!(Democracy::tally(r), (60, 50, 110)); - System::set_block_number(2); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); - assert_eq!(Balances::free_balance(&42), 2); + assert_eq!(Balances::free_balance(&42), 0); }); } #[test] - fn lock_voting_should_work_with_delegation() { - with_externalities(&mut new_test_ext_with_public_delay(1), || { - System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); - assert_ok!(Democracy::vote(Origin::signed(1), r, Vote::new(false, 6))); - assert_ok!(Democracy::vote(Origin::signed(2), r, Vote::new(true, 5))); - assert_ok!(Democracy::vote(Origin::signed(3), r, Vote::new(true, 4))); - assert_ok!(Democracy::vote(Origin::signed(4), r, Vote::new(true, 3))); - assert_ok!(Democracy::delegate(Origin::signed(5), 2, 2)); - assert_ok!(Democracy::vote(Origin::signed(6), r, Vote::new(false, 1))); + fn passing_low_turnout_voting_should_work() { + with_externalities(&mut new_test_ext(), || { + assert_eq!(Balances::free_balance(&42), 0); + assert_eq!(Balances::total_issuance(), 210); - assert_eq!(Democracy::tally(r), (440, 120, 210)); + System::set_block_number(1); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(4), r, BIG_AYE)); + assert_ok!(Democracy::vote(Origin::signed(5), r, BIG_NAY)); + assert_ok!(Democracy::vote(Origin::signed(6), r, BIG_AYE)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + assert_eq!(Democracy::tally(r), (100, 50, 150)); - System::set_block_number(2); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + next_block(); + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); } #[test] - fn controversial_low_turnout_voting_should_work() { + fn lock_voting_should_work() { with_externalities(&mut new_test_ext(), || { System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); - assert_ok!(Democracy::vote(Origin::signed(5), r, NAY)); - assert_ok!(Democracy::vote(Origin::signed(6), r, AYE)); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, Vote { + aye: false, + conviction: Conviction::Locked5x + })); + assert_ok!(Democracy::vote(Origin::signed(2), r, Vote { + aye: true, + conviction: Conviction::Locked4x + })); + assert_ok!(Democracy::vote(Origin::signed(3), r, Vote { + aye: true, + conviction: Conviction::Locked3x + })); + assert_ok!(Democracy::vote(Origin::signed(4), r, Vote { + aye: true, + conviction: Conviction::Locked2x + })); + assert_ok!(Democracy::vote(Origin::signed(5), r, Vote { + aye: false, + conviction: Conviction::Locked1x + })); + + assert_eq!(Democracy::tally(r), (250, 100, 150)); + + next_block(); - assert_eq!(Democracy::tally(r), (60, 50, 110)); - - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + assert_eq!(Balances::locks(1), vec![]); + assert_eq!(Balances::locks(2), vec![BalanceLock { + id: DEMOCRACY_ID, + amount: u64::max_value(), + until: 9, + reasons: WithdrawReason::Transfer.into() + }]); + assert_eq!(Balances::locks(3), vec![BalanceLock { + id: DEMOCRACY_ID, + amount: u64::max_value(), + until: 5, + reasons: WithdrawReason::Transfer.into() + }]); + assert_eq!(Balances::locks(4), vec![BalanceLock { + id: DEMOCRACY_ID, + amount: u64::max_value(), + until: 3, + reasons: WithdrawReason::Transfer.into() + }]); + assert_eq!(Balances::locks(5), vec![]); + + next_block(); - assert_eq!(Balances::free_balance(&42), 0); + assert_eq!(Balances::free_balance(&42), 2); }); } #[test] - fn passing_low_turnout_voting_should_work() { + fn lock_voting_should_work_with_delegation() { with_externalities(&mut new_test_ext(), || { - assert_eq!(Balances::free_balance(&42), 0); - assert_eq!(Balances::total_issuance(), 210); - System::set_block_number(1); - let r = Democracy::inject_referendum(1, set_balance_proposal(2), VoteThreshold::SuperMajorityApprove, 0).unwrap(); - assert_ok!(Democracy::vote(Origin::signed(4), r, AYE)); - assert_ok!(Democracy::vote(Origin::signed(5), r, NAY)); - assert_ok!(Democracy::vote(Origin::signed(6), r, AYE)); + let r = Democracy::inject_referendum( + 1, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, Vote { + aye: false, + conviction: Conviction::Locked5x + })); + assert_ok!(Democracy::vote(Origin::signed(2), r, Vote { + aye: true, + conviction: Conviction::Locked4x + })); + assert_ok!(Democracy::vote(Origin::signed(3), r, Vote { + aye: true, + conviction: Conviction::Locked3x + })); + assert_ok!(Democracy::delegate(Origin::signed(4), 2, Conviction::Locked2x)); + assert_ok!(Democracy::vote(Origin::signed(5), r, Vote { + aye: false, + conviction: Conviction::Locked1x + })); + + assert_eq!(Democracy::tally(r), (250, 100, 150)); + + next_block(); - assert_eq!(Democracy::tally(r), (100, 50, 150)); - - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + assert_eq!(Balances::locks(1), vec![]); + assert_eq!(Balances::locks(2), vec![BalanceLock { + id: DEMOCRACY_ID, + amount: u64::max_value(), + until: 9, + reasons: WithdrawReason::Transfer.into() + }]); + assert_eq!(Balances::locks(3), vec![BalanceLock { + id: DEMOCRACY_ID, + amount: u64::max_value(), + until: 5, + reasons: WithdrawReason::Transfer.into() + }]); + assert_eq!(Balances::locks(4), vec![BalanceLock { + id: DEMOCRACY_ID, + amount: u64::max_value(), + until: u64::max_value(), + reasons: WithdrawReason::Transfer.into() + }]); + assert_eq!(Balances::locks(5), vec![]); + + next_block(); assert_eq!(Balances::free_balance(&42), 2); }); diff --git a/srml/support/src/lib.rs b/srml/support/src/lib.rs index 140b905e78..64256d876d 100644 --- a/srml/support/src/lib.rs +++ b/srml/support/src/lib.rs @@ -65,6 +65,39 @@ pub use self::dispatch::{Parameter, Dispatchable, Callable, IsSubType}; pub use self::double_map::StorageDoubleMapWithHasher; pub use runtime_io::{print, storage_root}; +/// Macro for easily creating a new implementation of the `Get` trait. Use similarly to +/// how you would declare a `const`: +/// +/// ```no_compile +/// parameter_types! { +/// pub const Argument: u64 = 42; +/// } +/// trait Config { +/// type Parameter: Get; +/// } +/// struct Runtime; +/// impl Config for Runtime { +/// type Parameter = Argument; +/// } +/// ``` +#[macro_export] +macro_rules! parameter_types { + (pub const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => ( + pub struct $name; + $crate::parameter_types!{IMPL $name , $type , $value} + $crate::parameter_types!{ $( $rest )* } + ); + (const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => ( + struct $name; + $crate::parameter_types!{IMPL $name , $type , $value} + $crate::parameter_types!{ $( $rest )* } + ); + () => (); + (IMPL $name:ident , $type:ty , $value:expr) => { + impl $crate::traits::Get<$type> for $name { fn get() -> $type { $value } } + } +} + #[doc(inline)] pub use srml_support_procedural::decl_storage; diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index dd4398844c..a83af94836 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -14,7 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Traits for SRML +//! Traits for SRML. +//! +//! NOTE: If you're looking for `parameter_types`, it has moved in to the top-level module. use crate::rstd::result; use crate::codec::{Codec, Encode, Decode}; @@ -28,39 +30,6 @@ pub trait Get { fn get() -> T; } -/// Macro for easily creating a new implementation of the `Get` trait. Use similarly to -/// how you would declare a `const`: -/// -/// ```no_compile -/// parameter_types! { -/// pub const Argument: u64 = 42; -/// } -/// trait Config { -/// type Parameter: Get; -/// } -/// struct Runtime; -/// impl Config for Runtime { -/// type Parameter = Argument; -/// } -/// ``` -#[macro_export] -macro_rules! parameter_types { - (pub const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => ( - pub struct $name; - $crate::parameter_types!{IMPL $name , $type , $value} - $crate::parameter_types!{ $( $rest )* } - ); - (const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => ( - struct $name; - $crate::parameter_types!{IMPL $name , $type , $value} - $crate::parameter_types!{ $( $rest )* } - ); - () => (); - (IMPL $name:ident , $type:ty , $value:expr) => { - impl $crate::traits::Get<$type> for $name { fn get() -> $type { $value } } - } -} - /// The account with the given id was killed. pub trait OnFreeBalanceZero { /// The account was the given id was killed. -- GitLab From 51ee761152c8bcaab3798772c40b3ea98b4a5e79 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 3 Jun 2019 20:26:17 +0200 Subject: [PATCH 073/113] Split specialization context from network context (#2745) * Split specialization context from network context * Line width --- core/network/src/lib.rs | 3 ++- core/network/src/protocol.rs | 15 +++++++++++---- core/network/src/specialization.rs | 25 +++++++++++++++++++++++-- core/network/src/test/mod.rs | 13 +++++++++---- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/core/network/src/lib.rs b/core/network/src/lib.rs index e2def15425..5b438135ed 100644 --- a/core/network/src/lib.rs +++ b/core/network/src/lib.rs @@ -46,7 +46,8 @@ pub use service::{ NetworkService, NetworkWorker, FetchFuture, TransactionPool, ManageNetwork, NetworkMsg, SyncProvider, ExHashT, ReportHandle, }; -pub use protocol::{ProtocolStatus, PeerInfo, Context}; +pub use protocol::{ProtocolStatus, PeerInfo}; +pub use specialization::Context; pub use sync::{Status as SyncStatus, SyncState}; pub use network_libp2p::{ identity, multiaddr, diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index baca6f3bf6..e1fa38576a 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -32,7 +32,7 @@ use crate::message::{BlockAttributes, Direction, FromBlock, RequestId}; use crate::message::generic::{Message as GenericMessage, ConsensusMessage}; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; -use crate::specialization::NetworkSpecialization; +use crate::specialization::{NetworkSpecialization, Context as SpecializationContext}; use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; use crate::service::{TransactionPool, ExHashT}; use crate::config::Roles; @@ -281,9 +281,6 @@ pub trait Context { /// Send a consensus message to a peer. fn send_consensus(&mut self, who: PeerId, consensus: ConsensusMessage); - - /// Send a chain-specific message to a peer. - fn send_chain_specific(&mut self, who: PeerId, message: Vec); } /// Protocol context. @@ -315,6 +312,16 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, GenericMessage::Consensus(consensus) ) } +} + +impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SpecializationContext for ProtocolContext<'a, B, H> { + fn report_peer(&mut self, who: PeerId, reputation: i32) { + self.network_out.report_peer(who, reputation) + } + + fn disconnect_peer(&mut self, who: PeerId) { + self.network_out.disconnect_peer(who) + } fn send_chain_specific(&mut self, who: PeerId, message: Vec) { send_message( diff --git a/core/network/src/specialization.rs b/core/network/src/specialization.rs index 41d6c2edc8..2778146b52 100644 --- a/core/network/src/specialization.rs +++ b/core/network/src/specialization.rs @@ -18,7 +18,6 @@ use crate::PeerId; use runtime_primitives::traits::Block as BlockT; -use crate::protocol::Context; /// A specialization of the substrate network protocol. Handles events and sends messages. pub trait NetworkSpecialization: Send + Sync + 'static { @@ -32,7 +31,12 @@ pub trait NetworkSpecialization: Send + Sync + 'static { fn on_disconnect(&mut self, ctx: &mut Context, who: PeerId); /// Called when a network-specific message arrives. - fn on_message(&mut self, ctx: &mut Context, who: PeerId, message: &mut Option>); + fn on_message( + &mut self, + ctx: &mut Context, + who: PeerId, + message: &mut Option> + ); /// Called on abort. #[deprecated(note = "This method is never called; aborting corresponds to dropping the object")] @@ -46,6 +50,23 @@ pub trait NetworkSpecialization: Send + Sync + 'static { fn on_block_imported(&mut self, _ctx: &mut Context, _hash: B::Hash, _header: &B::Header) { } } +/// Context for a network-specific handler. +pub trait Context { + /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or + /// irresponsible or appeared lazy. + fn report_peer(&mut self, who: PeerId, reputation: i32); + + /// Force disconnecting from a peer. Use this when a peer misbehaved. + fn disconnect_peer(&mut self, who: PeerId); + + /// Send a consensus message to a peer. + #[deprecated(note = "This method shouldn't have been part of the specialization API")] + fn send_consensus(&mut self, _who: PeerId, _consensus: crate::message::generic::ConsensusMessage) {} + + /// Send a chain-specific message to a peer. + fn send_chain_specific(&mut self, who: PeerId, message: Vec); +} + /// Construct a simple protocol that is composed of several sub protocols. /// Each "sub protocol" needs to implement `Specialization` and needs to provide a `new()` function. /// For more fine grained implementations, this macro is not usable. diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 6a7a9ccddd..6103a6ecd9 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -50,7 +50,7 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{AuthorityIdFor, Block as BlockT, Digest, DigestItem, Header, NumberFor}; use runtime_primitives::{Justification, ConsensusEngineId}; use crate::service::{NetworkLink, NetworkMsg, ProtocolMsg, TransactionPool}; -use crate::specialization::NetworkSpecialization; +use crate::specialization::{NetworkSpecialization, Context as SpecializationContext}; use test_client::{self, AccountKeyring}; pub use test_client::runtime::{Block, Extrinsic, Hash, Transfer}; @@ -101,15 +101,20 @@ impl NetworkSpecialization for DummySpecialization { vec![] } - fn on_connect(&mut self, _ctx: &mut Context, _peer_id: PeerId, _status: crate::message::Status) { + fn on_connect( + &mut self, + _ctx: &mut SpecializationContext, + _peer_id: PeerId, + _status: crate::message::Status + ) { } - fn on_disconnect(&mut self, _ctx: &mut Context, _peer_id: PeerId) { + fn on_disconnect(&mut self, _ctx: &mut SpecializationContext, _peer_id: PeerId) { } fn on_message( &mut self, - _ctx: &mut Context, + _ctx: &mut SpecializationContext, _peer_id: PeerId, _message: &mut Option>, ) { -- GitLab From 2a2a6806e339a05c28f177009a66481cca7aea7a Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 4 Jun 2019 08:48:22 +0200 Subject: [PATCH 074/113] Add support for tuples in `OnNewAccount` hook (#2765) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add support for tuples in `OnNewAccount` hook * Bump impl version * Use `for_each_tuple` with `OnNewAccount` hook * Update `OnFreeBalanceZero` to also use `for_each_tuple` * Fix spelling/typo * Bump spec again * Update srml/support/src/traits.rs Co-Authored-By: Bastian Köcher * Update srml/system/src/lib.rs Co-Authored-By: Bastian Köcher --- node/runtime/src/lib.rs | 2 +- srml/support/src/traits.rs | 28 +++++++++++++++++----------- srml/system/src/lib.rs | 20 +++++++++++++++++--- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 34a8a30524..e892ceda81 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 90, - impl_version: 90, + impl_version: 91, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index a83af94836..599de27c2e 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -24,6 +24,8 @@ use crate::runtime_primitives::traits::{ MaybeSerializeDebug, SimpleArithmetic }; +use super::for_each_tuple; + /// New trait for querying a single fixed value from a type. pub trait Get { /// Return a constant value. @@ -36,20 +38,24 @@ pub trait OnFreeBalanceZero { fn on_free_balance_zero(who: &AccountId); } -impl OnFreeBalanceZero for () { - fn on_free_balance_zero(_who: &AccountId) {} -} -impl< - AccountId, - X: OnFreeBalanceZero, - Y: OnFreeBalanceZero, -> OnFreeBalanceZero for (X, Y) { - fn on_free_balance_zero(who: &AccountId) { - X::on_free_balance_zero(who); - Y::on_free_balance_zero(who); +macro_rules! impl_on_free_balance_zero { + () => ( + impl OnFreeBalanceZero for () { + fn on_free_balance_zero(_: &AccountId) {} + } + ); + + ( $($t:ident)* ) => { + impl),*> OnFreeBalanceZero for ($($t,)*) { + fn on_free_balance_zero(who: &AccountId) { + $($t::on_free_balance_zero(who);)* + } + } } } +for_each_tuple!(impl_on_free_balance_zero); + /// Trait for a hook to get called when some balance has been minted, causing dilution. pub trait OnDilution { /// Some `portion` of the total balance just "grew" by `minted`. `portion` is the pre-growth diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index 7c4a95a30f..5a3094d821 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -85,7 +85,7 @@ use primitives::traits::Zero; use substrate_primitives::storage::well_known_keys; use srml_support::{ storage, decl_module, decl_event, decl_storage, StorageDoubleMap, StorageValue, - StorageMap, Parameter, + StorageMap, Parameter, for_each_tuple, }; use safe_mix::TripletMix; use parity_codec::{Encode, Decode}; @@ -102,10 +102,24 @@ pub trait OnNewAccount { fn on_new_account(who: &AccountId); } -impl OnNewAccount for () { - fn on_new_account(_who: &AccountId) {} +macro_rules! impl_on_new_account { + () => ( + impl OnNewAccount for () { + fn on_new_account(_: &AccountId) {} + } + ); + + ( $($t:ident)* ) => { + impl),*> OnNewAccount for ($($t,)*) { + fn on_new_account(who: &AccountId) { + $($t::on_new_account(who);)* + } + } + } } +for_each_tuple!(impl_on_new_account); + /// Determiner to say whether a given account is unused. pub trait IsDeadAccount { /// Is the given account dead? -- GitLab From d314fa6856d296fbe896ed9809b3adebf31076a7 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 4 Jun 2019 10:01:12 +0200 Subject: [PATCH 075/113] Pin states in memory so that they are not pruned away while still referenced (#2761) * State pinning in client * Canonicalization queue * Fixed prioritization queue * possible fix of "hash mismatch" * Check for pinned discarded states * Release state before finalization * Style * Style --- core/client/db/src/lib.rs | 117 +++++++++++++-- core/client/db/src/storage_cache.rs | 164 ++++++++++++---------- core/client/src/call_executor.rs | 12 +- core/client/src/cht.rs | 8 +- core/client/src/client.rs | 2 +- core/client/src/light/backend.rs | 18 +-- core/client/src/light/call_executor.rs | 6 +- core/state-db/src/lib.rs | 72 +++++++--- core/state-db/src/noncanonical.rs | 106 ++++++++++---- core/state-machine/src/backend.rs | 35 ++--- core/state-machine/src/lib.rs | 28 ++-- core/state-machine/src/proving_backend.rs | 16 +-- core/state-machine/src/trie_backend.rs | 2 +- 13 files changed, 392 insertions(+), 194 deletions(-) diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 82d570567b..dd38f10bcd 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -72,6 +72,97 @@ const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768; /// DB-backed patricia trie state, transaction type is an overlay of changes to commit. pub type DbState = state_machine::TrieBackend>, Blake2Hasher>; +pub struct RefTrackingState { + state: DbState, + storage: Arc>, + parent_hash: Option, +} + +impl RefTrackingState { + fn new(state: DbState, storage: Arc>, parent_hash: Option) -> RefTrackingState { + if let Some(hash) = &parent_hash { + storage.state_db.pin(hash); + } + RefTrackingState { + state, + parent_hash, + storage, + } + } +} + +impl Drop for RefTrackingState { + fn drop(&mut self) { + if let Some(hash) = &self.parent_hash { + self.storage.state_db.unpin(hash); + } + } +} + +impl StateBackend for RefTrackingState { + type Error = >::Error; + type Transaction = >::Transaction; + type TrieBackendStorage = >::TrieBackendStorage; + + fn storage(&self, key: &[u8]) -> Result>, Self::Error> { + self.state.storage(key) + } + + fn storage_hash(&self, key: &[u8]) -> Result, Self::Error> { + self.state.storage_hash(key) + } + + fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + self.state.child_storage(storage_key, key) + } + + fn exists_storage(&self, key: &[u8]) -> Result { + self.state.exists_storage(key) + } + + fn exists_child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result { + self.state.exists_child_storage(storage_key, key) + } + + fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { + self.state.for_keys_with_prefix(prefix, f) + } + + fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { + self.state.for_keys_in_child_storage(storage_key, f) + } + + fn storage_root(&self, delta: I) -> (H256, Self::Transaction) + where + I: IntoIterator, Option>)> + { + self.state.storage_root(delta) + } + + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + where + I: IntoIterator, Option>)>, + { + self.state.child_storage_root(storage_key, delta) + } + + fn pairs(&self) -> Vec<(Vec, Vec)> { + self.state.pairs() + } + + fn keys(&self, prefix: &[u8]) -> Vec> { + self.state.keys(prefix) + } + + fn child_keys(&self, child_key: &[u8], prefix: &[u8]) -> Vec> { + self.state.child_keys(child_key, prefix) + } + + fn as_trie_backend(&mut self) -> Option<&state_machine::TrieBackend> { + self.state.as_trie_backend() + } +} + /// Database settings. pub struct DatabaseSettings { /// Cache size in bytes. If `None` default is used. @@ -270,7 +361,7 @@ impl client::blockchain::ProvideCache for BlockchainDb { - old_state: CachingState, + old_state: CachingState, Block>, db_updates: PrefixedMemoryDB, storage_updates: Vec<(Vec, Option>)>, changes_trie_updates: MemoryDB, @@ -295,7 +386,7 @@ impl client::backend::BlockImportOperation for BlockImportOperation where Block: BlockT, { - type State = CachingState; + type State = CachingState, Block>; fn state(&self) -> Result, client::error::Error> { Ok(Some(&self.old_state)) @@ -922,6 +1013,8 @@ impl> Backend { let changes_trie_updates = operation.changes_trie_updates; self.changes_tries_storage.commit(&mut transaction, changes_trie_updates); + let cache = operation.old_state.release(); // release state reference so that it can be finalized + if finalized { // TODO: ensure best chain contains this block. @@ -953,7 +1046,7 @@ impl> Backend { meta_updates.push((hash, number, pending_block.leaf_state.is_best(), finalized)); - Some((number, hash, enacted, retracted, displaced_leaf, is_best)) + Some((number, hash, enacted, retracted, displaced_leaf, is_best, cache)) } else { None }; @@ -975,7 +1068,7 @@ impl> Backend { let write_result = self.storage.db.write(transaction).map_err(db_err); - if let Some((number, hash, enacted, retracted, displaced_leaf, is_best)) = imported { + if let Some((number, hash, enacted, retracted, displaced_leaf, is_best, mut cache)) = imported { if let Err(e) = write_result { let mut leaves = self.blockchain.leaves.write(); let mut undo = leaves.undo(); @@ -990,7 +1083,7 @@ impl> Backend { return Err(e) } - operation.old_state.sync_cache( + cache.sync_cache( &enacted, &retracted, operation.storage_updates, @@ -1090,7 +1183,7 @@ impl client::backend::AuxStore for Backend where Block: BlockT client::backend::Backend for Backend where Block: BlockT { type BlockImportOperation = BlockImportOperation; type Blockchain = BlockchainDb; - type State = CachingState; + type State = CachingState, Block>; type ChangesTrieStorage = DbChangesTrieStorage; fn begin_operation(&self) -> Result { @@ -1217,7 +1310,8 @@ impl client::backend::Backend for Backend whe BlockId::Hash(h) if h == Default::default() => { let genesis_storage = DbGenesisStorage::new(); let root = genesis_storage.0.clone(); - let state = DbState::new(Arc::new(genesis_storage), root); + let db_state = DbState::new(Arc::new(genesis_storage), root); + let state = RefTrackingState::new(db_state, self.storage.clone(), None); return Ok(CachingState::new(state, self.shared_cache.clone(), None)); }, _ => {} @@ -1228,7 +1322,8 @@ impl client::backend::Backend for Backend whe let hash = hdr.hash(); if !self.storage.state_db.is_pruned(&hash, (*hdr.number()).saturated_into::()) { let root = H256::from_slice(hdr.state_root().as_ref()); - let state = DbState::new(self.storage.clone(), root); + let db_state = DbState::new(self.storage.clone(), root); + let state = RefTrackingState::new(db_state, self.storage.clone(), Some(hash.clone())); Ok(CachingState::new(state, self.shared_cache.clone(), Some(hash))) } else { Err(client::error::Error::UnknownBlock(format!("State already discarded for {:?}", block))) @@ -1243,10 +1338,10 @@ impl client::backend::Backend for Backend whe !self.storage.state_db.is_pruned(hash, number.saturated_into::()) } - fn destroy_state(&self, mut state: Self::State) -> Result<(), client::error::Error> { - if let Some(hash) = state.parent_hash.clone() { + fn destroy_state(&self, state: Self::State) -> Result<(), client::error::Error> { + if let Some(hash) = state.cache.parent_hash.clone() { let is_best = || self.blockchain.meta.read().best_hash == hash; - state.sync_cache(&[], &[], vec![], None, None, is_best); + state.release().sync_cache(&[], &[], vec![], None, None, is_best); } Ok(()) } diff --git a/core/client/db/src/storage_cache.rs b/core/client/db/src/storage_cache.rs index bc0a179cf8..cc4670866c 100644 --- a/core/client/db/src/storage_cache.rs +++ b/core/client/db/src/storage_cache.rs @@ -99,6 +99,17 @@ struct LocalCache { hashes: HashMap>, } +/// Cache changes. +pub struct CacheChanges { + /// Shared canonical state cache. + shared_cache: SharedCache, + /// Local cache of values for this state. + local_cache: RwLock>, + /// Hash of the block on top of which this instance was created or + /// `None` if cache is disabled + pub parent_hash: Option, +} + /// State abstraction. /// Manages shared global state cache which reflects the canonical /// state as it is on the disk. @@ -109,56 +120,11 @@ struct LocalCache { pub struct CachingState, B: Block> { /// Backing state. state: S, - /// Shared canonical state cache. - shared_cache: SharedCache, - /// Local cache of values for this state. - local_cache: RwLock>, - /// Hash of the block on top of which this instance was created or - /// `None` if cache is disabled - pub parent_hash: Option, + /// Cache data. + pub cache: CacheChanges } -impl, B: Block> CachingState { - /// Create a new instance wrapping generic State and shared cache. - pub fn new(state: S, shared_cache: SharedCache, parent_hash: Option) -> CachingState { - CachingState { - state, - shared_cache, - local_cache: RwLock::new(LocalCache { - storage: Default::default(), - hashes: Default::default(), - }), - parent_hash: parent_hash, - } - } - - fn storage_insert(cache: &mut Cache, k: StorageValue, v: Option) { - if let Some(v_) = &v { - while cache.storage_used_size + v_.len() > cache.shared_cache_size { - // pop until space constraint satisfied - match cache.storage.remove_lru() { - Some((_, Some(popped_v))) => - cache.storage_used_size = cache.storage_used_size - popped_v.len(), - Some((_, None)) => continue, - None => break, - }; - } - cache.storage_used_size = cache.storage_used_size + v_.len(); - } - cache.storage.insert(k, v); - } - - fn storage_remove( - storage: &mut LruCache>, - k: &StorageKey, - storage_used_size: &mut usize, - ) { - let v = storage.remove(k); - if let Some(Some(v_)) = v { - *storage_used_size = *storage_used_size - v_.len(); - } - } - +impl CacheChanges { /// Propagate local cache into the shared cache and synchronize /// the shared cache with the best block state. /// This function updates the shared cache by removing entries @@ -189,7 +155,7 @@ impl, B: Block> CachingState { m.is_canon = true; for a in &m.storage { trace!("Reverting enacted key {:?}", a); - CachingState::::storage_remove(&mut cache.storage, a, &mut cache.storage_used_size); + CacheChanges::::storage_remove(&mut cache.storage, a, &mut cache.storage_used_size); } false } else { @@ -205,7 +171,7 @@ impl, B: Block> CachingState { m.is_canon = false; for a in &m.storage { trace!("Retracted key {:?}", a); - CachingState::::storage_remove(&mut cache.storage, a, &mut cache.storage_used_size); + CacheChanges::::storage_remove(&mut cache.storage, a, &mut cache.storage_used_size); } false } else { @@ -228,7 +194,7 @@ impl, B: Block> CachingState { if is_best { trace!("Committing {} local, {} hashes, {} modified entries", local_cache.storage.len(), local_cache.hashes.len(), changes.len()); for (k, v) in local_cache.storage.drain() { - CachingState::::storage_insert(cache, k, v); + CacheChanges::::storage_insert(cache, k, v); } for (k, v) in local_cache.hashes.drain() { cache.hashes.insert(k, v); @@ -248,7 +214,7 @@ impl, B: Block> CachingState { modifications.insert(k.clone()); if is_best { cache.hashes.remove(&k); - CachingState::::storage_insert(cache, k, v); + CacheChanges::::storage_insert(cache, k, v); } } // Save modified storage. These are ordered by the block number. @@ -272,6 +238,50 @@ impl, B: Block> CachingState { } } + fn storage_insert(cache: &mut Cache, k: StorageValue, v: Option) { + if let Some(v_) = &v { + while cache.storage_used_size + v_.len() > cache.shared_cache_size { + // pop until space constraint satisfied + match cache.storage.remove_lru() { + Some((_, Some(popped_v))) => + cache.storage_used_size = cache.storage_used_size - popped_v.len(), + Some((_, None)) => continue, + None => break, + }; + } + cache.storage_used_size = cache.storage_used_size + v_.len(); + } + cache.storage.insert(k, v); + } + + fn storage_remove( + storage: &mut LruCache>, + k: &StorageKey, + storage_used_size: &mut usize, + ) { + let v = storage.remove(k); + if let Some(Some(v_)) = v { + *storage_used_size = *storage_used_size - v_.len(); + } + } +} + +impl, B: Block> CachingState { + /// Create a new instance wrapping generic State and shared cache. + pub fn new(state: S, shared_cache: SharedCache, parent_hash: Option) -> CachingState { + CachingState { + state, + cache: CacheChanges { + shared_cache, + local_cache: RwLock::new(LocalCache { + storage: Default::default(), + hashes: Default::default(), + }), + parent_hash: parent_hash, + }, + } + } + /// Check if the key can be returned from cache by matching current block parent hash against canonical /// state and filtering out entries modified in later blocks. fn is_allowed( @@ -312,6 +322,11 @@ impl, B: Block> CachingState { trace!("Cache lookup skipped for {:?}: parent hash is unknown", key); false } + + /// Dispose state and return cache data. + pub fn release(self) -> CacheChanges { + self.cache + } } impl, B:Block> StateBackend for CachingState { @@ -320,13 +335,13 @@ impl, B:Block> StateBackend for CachingState Result>, Self::Error> { - let local_cache = self.local_cache.upgradable_read(); + let local_cache = self.cache.local_cache.upgradable_read(); if let Some(entry) = local_cache.storage.get(key).cloned() { trace!("Found in local cache: {:?}", key); return Ok(entry) } - let mut cache = self.shared_cache.lock(); - if Self::is_allowed(key, &self.parent_hash, &cache.modifications) { + let mut cache = self.cache.shared_cache.lock(); + if Self::is_allowed(key, &self.cache.parent_hash, &cache.modifications) { if let Some(entry) = cache.storage.get_mut(key).map(|a| a.clone()) { trace!("Found in shared cache: {:?}", key); return Ok(entry) @@ -339,13 +354,13 @@ impl, B:Block> StateBackend for CachingState Result, Self::Error> { - let local_cache = self.local_cache.upgradable_read(); + let local_cache = self.cache.local_cache.upgradable_read(); if let Some(entry) = local_cache.hashes.get(key).cloned() { trace!("Found hash in local cache: {:?}", key); return Ok(entry) } - let mut cache = self.shared_cache.lock(); - if Self::is_allowed(key, &self.parent_hash, &cache.modifications) { + let mut cache = self.cache.shared_cache.lock(); + if Self::is_allowed(key, &self.cache.parent_hash, &cache.modifications) { if let Some(entry) = cache.hashes.get_mut(key).map(|a| a.clone()) { trace!("Found hash in shared cache: {:?}", key); return Ok(entry) @@ -405,8 +420,8 @@ impl, B:Block> StateBackend for CachingState Option> { - self.state.try_into_trie_backend() + fn as_trie_backend(&mut self) -> Option<&TrieBackend> { + self.state.as_trie_backend() } } @@ -436,22 +451,22 @@ mod tests { // blocks [ 3a(c) 2a(c) 2b 1b 1a(c) 0 ] // state [ 5 5 4 3 2 2 ] let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent.clone())); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], Some(h0.clone()), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], Some(h0.clone()), Some(0), || true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h0.clone())); - s.sync_cache(&[], &[], vec![], Some(h1a.clone()), Some(1), || true); + s.cache.sync_cache(&[], &[], vec![], Some(h1a.clone()), Some(1), || true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h0.clone())); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], Some(h1b.clone()), Some(1), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], Some(h1b.clone()), Some(1), || false); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1b.clone())); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![4]))], Some(h2b.clone()), Some(2), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![4]))], Some(h2b.clone()), Some(2), || false); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1a.clone())); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![5]))], Some(h2a.clone()), Some(2), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![5]))], Some(h2a.clone()), Some(2), || true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2a.clone())); - s.sync_cache(&[], &[], vec![], Some(h3a.clone()), Some(3), || true); + s.cache.sync_cache(&[], &[], vec![], Some(h3a.clone()), Some(3), || true); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h3a.clone())); assert_eq!(s.storage(&key).unwrap().unwrap(), vec![5]); @@ -468,7 +483,14 @@ mod tests { // reorg to 3b // blocks [ 3b(c) 3a 2a 2b(c) 1b 1a 0 ] let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2b.clone())); - s.sync_cache(&[h1b.clone(), h2b.clone(), h3b.clone()], &[h1a.clone(), h2a.clone(), h3a.clone()], vec![], Some(h3b.clone()), Some(3), || true); + s.cache.sync_cache( + &[h1b.clone(), h2b.clone(), h3b.clone()], + &[h1a.clone(), h2a.clone(), h3a.clone()], + vec![], + Some(h3b.clone()), + Some(3), + || true + ); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h3a.clone())); assert!(s.storage(&key).unwrap().is_none()); } @@ -482,11 +504,11 @@ mod tests { let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent.clone())); let key = H256::random()[..].to_vec(); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2, 3]))], Some(h0.clone()), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2, 3]))], Some(h0.clone()), Some(0), || true); assert_eq!(shared.lock().used_storage_cache_size(), 3 /* bytes */); let key = H256::random()[..].to_vec(); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2]))], Some(h0.clone()), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2]))], Some(h0.clone()), Some(0), || true); assert_eq!(shared.lock().used_storage_cache_size(), 5 /* bytes */); } @@ -499,11 +521,11 @@ mod tests { let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent.clone())); let key = H256::random()[..].to_vec(); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2, 3, 4]))], Some(h0.clone()), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2, 3, 4]))], Some(h0.clone()), Some(0), || true); assert_eq!(shared.lock().used_storage_cache_size(), 4 /* bytes */); let key = H256::random()[..].to_vec(); - s.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2]))], Some(h0.clone()), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![1, 2]))], Some(h0.clone()), Some(0), || true); assert_eq!(shared.lock().used_storage_cache_size(), 2 /* bytes */); } } diff --git a/core/client/src/call_executor.rs b/core/client/src/call_executor.rs index 13ee96400f..bb59be44c3 100644 --- a/core/client/src/call_executor.rs +++ b/core/client/src/call_executor.rs @@ -117,17 +117,17 @@ where /// No changes are made. fn prove_at_state>( &self, - state: S, + mut state: S, overlay: &mut OverlayedChanges, method: &str, call_data: &[u8] ) -> Result<(Vec, Vec>), error::Error> { - let trie_state = state.try_into_trie_backend() + let trie_state = state.as_trie_backend() .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box )?; - self.prove_at_trie_state(&trie_state, overlay, method, call_data) + self.prove_at_trie_state(trie_state, overlay, method, call_data) } /// Execute a call to a contract on top of given trie state, gathering execution proof. @@ -239,18 +239,18 @@ where _ => {}, } - let state = self.backend.state_at(*at)?; + let mut state = self.backend.state_at(*at)?; match recorder { Some(recorder) => { - let trie_state = state.try_into_trie_backend() + let trie_state = state.as_trie_backend() .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box )?; let backend = state_machine::ProvingBackend::new_with_recorder( - &trie_state, + trie_state, recorder.clone() ); diff --git a/core/client/src/cht.rs b/core/client/src/cht.rs index 996a6b37f1..fc8920327e 100644 --- a/core/client/src/cht.rs +++ b/core/client/src/cht.rs @@ -101,14 +101,14 @@ pub fn build_proof( .into_iter() .map(|(k, v)| (None, k, Some(v))) .collect::>(); - let storage = InMemoryState::::default().update(transaction); - let trie_storage = storage.try_into_trie_backend() - .expect("InMemoryState::try_into_trie_backend always returns Some; qed"); + let mut storage = InMemoryState::::default().update(transaction); + let trie_storage = storage.as_trie_backend() + .expect("InMemoryState::as_trie_backend always returns Some; qed"); let mut total_proof = HashSet::new(); for block in blocks.into_iter() { debug_assert_eq!(block_to_cht_number(cht_size, block), Some(cht_num)); - let (value, proof) = prove_read_on_trie_backend(&trie_storage, &encode_cht_key(block))?; + let (value, proof) = prove_read_on_trie_backend(trie_storage, &encode_cht_key(block))?; assert!(value.is_some(), "we have just built trie that includes the value for block"); total_proof.extend(proof); } diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 874cf7636b..1f19b96d3c 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -1277,7 +1277,7 @@ impl Client where /// Prepare in-memory header that is used in execution environment. fn prepare_environment_block(&self, parent: &BlockId) -> error::Result { - let parent_header = self.backend().blockchain().expect_header(*parent)?; + let parent_header = self.backend.blockchain().expect_header(*parent)?; Ok(<::Header as HeaderT>::new( self.backend.blockchain().expect_block_number_from_id(parent)? + One::one(), Default::default(), diff --git a/core/client/src/light/backend.rs b/core/client/src/light/backend.rs index bf5eb11f26..0c2279bf3d 100644 --- a/core/client/src/light/backend.rs +++ b/core/client/src/light/backend.rs @@ -38,13 +38,13 @@ use consensus::well_known_cache_keys; const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type and always suceeds; qed"; /// Light client backend. -pub struct Backend { +pub struct Backend { blockchain: Arc>, genesis_state: RwLock>>, } /// Light block (header and justification) import operation. -pub struct ImportOperation { +pub struct ImportOperation { header: Option, cache: HashMap>, leaf_state: NewBlockState, @@ -64,14 +64,14 @@ pub struct OnDemandState { } /// On-demand or in-memory genesis state. -pub enum OnDemandOrGenesisState { +pub enum OnDemandOrGenesisState { /// On-demand state - storage values are fetched from remote nodes. OnDemand(OnDemandState), /// Genesis state - storage values are stored in-memory. Genesis(InMemoryState), } -impl Backend { +impl Backend { /// Create new light backend. pub fn new(blockchain: Arc>) -> Self { Self { @@ -86,7 +86,7 @@ impl Backend { } } -impl AuxStore for Backend { +impl AuxStore for Backend { fn insert_aux< 'a, 'b: 'a, @@ -387,7 +387,7 @@ where Vec::new() } - fn try_into_trie_backend(self) -> Option> { + fn as_trie_backend(&mut self) -> Option<&TrieBackend> { None } } @@ -482,10 +482,10 @@ where } } - fn try_into_trie_backend(self) -> Option> { + fn as_trie_backend(&mut self) -> Option<&TrieBackend> { match self { - OnDemandOrGenesisState::OnDemand(state) => state.try_into_trie_backend(), - OnDemandOrGenesisState::Genesis(state) => state.try_into_trie_backend(), + OnDemandOrGenesisState::OnDemand(ref mut state) => state.as_trie_backend(), + OnDemandOrGenesisState::Genesis(ref mut state) => state.as_trie_backend(), } } } diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index 5fb7e7308a..5b6d1b3a29 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -388,7 +388,7 @@ impl CallExecutor for /// Method is executed using passed header as environment' current block. /// Proof includes both environment preparation proof and method execution proof. pub fn prove_execution( - state: S, + mut state: S, header: Block::Header, executor: &E, method: &str, @@ -399,13 +399,13 @@ pub fn prove_execution( S: StateBackend, E: CallExecutor, { - let trie_state = state.try_into_trie_backend() + let trie_state = state.as_trie_backend() .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box)?; // prepare execution environment + record preparation proof let mut changes = Default::default(); let (_, init_proof) = executor.prove_at_trie_state( - &trie_state, + trie_state, &mut changes, "Core_initialize_block", &header.encode(), diff --git a/core/state-db/src/lib.rs b/core/state-db/src/lib.rs index 8d9cf9c965..8986dda32d 100644 --- a/core/state-db/src/lib.rs +++ b/core/state-db/src/lib.rs @@ -37,7 +37,7 @@ use std::fmt; use parking_lot::RwLock; use parity_codec as codec; use codec::Codec; -use std::collections::HashSet; +use std::collections::{VecDeque, HashMap, hash_map::Entry}; use noncanonical::NonCanonicalOverlay; use pruning::RefWindow; use log::trace; @@ -78,6 +78,8 @@ pub enum Error { InvalidBlockNumber, /// Trying to insert block with unknown parent. InvalidParent, + /// Canonicalization would discard pinned state. + DiscardingPinned, } impl fmt::Debug for Error { @@ -88,6 +90,7 @@ impl fmt::Debug for Error { Error::InvalidBlock => write!(f, "Trying to canonicalize invalid block"), Error::InvalidBlockNumber => write!(f, "Trying to insert block with invalid number"), Error::InvalidParent => write!(f, "Trying to insert block with unknown parent"), + Error::DiscardingPinned => write!(f, "Trying to discard pinned state"), } } } @@ -112,7 +115,7 @@ pub struct CommitSet { } /// Pruning constraints. If none are specified pruning is -#[derive(Default, Debug, Clone)] +#[derive(Default, Debug, Clone, Eq, PartialEq)] pub struct Constraints { /// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical states. pub max_blocks: Option, @@ -121,7 +124,7 @@ pub struct Constraints { } /// Pruning mode. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Eq, PartialEq)] pub enum PruningMode { /// Maintain a pruning window. Constrained(Constraints), @@ -165,13 +168,14 @@ fn to_meta_key(suffix: &[u8], data: &S) -> Vec { struct StateDbSync { mode: PruningMode, non_canonical: NonCanonicalOverlay, + canonicalization_queue: VecDeque, pruning: Option>, - pinned: HashSet, + pinned: HashMap, } impl StateDbSync { pub fn new(mode: PruningMode, db: &D) -> Result, Error> { - trace!("StateDb settings: {:?}", mode); + trace!(target: "state-db", "StateDb settings: {:?}", mode); let non_canonical: NonCanonicalOverlay = NonCanonicalOverlay::new(db)?; let pruning: Option> = match mode { PruningMode::Constrained(Constraints { @@ -186,6 +190,7 @@ impl StateDbSync { non_canonical, pruning, pinned: Default::default(), + canonicalization_queue: Default::default(), }) } @@ -206,21 +211,30 @@ impl StateDbSync { } pub fn canonicalize_block(&mut self, hash: &BlockHash) -> Result, Error> { - let mut commit = match self.mode { - PruningMode::ArchiveAll => { - CommitSet::default() - }, - PruningMode::ArchiveCanonical => { - let mut commit = self.non_canonical.canonicalize(hash)?; - commit.data.deleted.clear(); - commit - }, - PruningMode::Constrained(_) => { - self.non_canonical.canonicalize(hash)? - }, - }; - if let Some(ref mut pruning) = self.pruning { - pruning.note_canonical(hash, &mut commit); + let mut commit = CommitSet::default(); + if self.mode == PruningMode::ArchiveAll { + return Ok(commit) + } + self.canonicalization_queue.push_back(hash.clone()); + while let Some(hash) = self.canonicalization_queue.front().cloned() { + if self.pinned.contains_key(&hash) { + break; + } + match self.non_canonical.canonicalize(&hash, &self.pinned, &mut commit) { + Ok(()) => { + self.canonicalization_queue.pop_front(); + if self.mode == PruningMode::ArchiveCanonical { + commit.data.deleted.clear(); + } + } + Err(Error::DiscardingPinned) => { + break; + } + Err(e) => return Err(e), + }; + if let Some(ref mut pruning) = self.pruning { + pruning.note_canonical(&hash, &mut commit); + } } self.prune(&mut commit); Ok(commit) @@ -255,7 +269,7 @@ impl StateDbSync { } let pinned = &self.pinned; - if pruning.next_hash().map_or(false, |h| pinned.contains(&h)) { + if pruning.next_hash().map_or(false, |h| pinned.contains_key(&h)) { break; } pruning.prune_one(commit); @@ -278,11 +292,23 @@ impl StateDbSync { } pub fn pin(&mut self, hash: &BlockHash) { - self.pinned.insert(hash.clone()); + trace!(target: "state-db", "Pinned block: {:?}", hash); + *self.pinned.entry(hash.clone()).or_default() += 1; } pub fn unpin(&mut self, hash: &BlockHash) { - self.pinned.remove(hash); + match self.pinned.entry(hash.clone()) { + Entry::Occupied(mut entry) => { + *entry.get_mut() -= 1; + if *entry.get() == 0 { + trace!(target: "state-db", "Unpinned block: {:?}", hash); + entry.remove(); + } else { + trace!(target: "state-db", "Releasing reference for {:?}", hash); + } + }, + Entry::Vacant(_) => {}, + } } pub fn get(&self, key: &Key, db: &D) -> Result, Error> diff --git a/core/state-db/src/noncanonical.rs b/core/state-db/src/noncanonical.rs index da957335ba..0d43389a0b 100644 --- a/core/state-db/src/noncanonical.rs +++ b/core/state-db/src/noncanonical.rs @@ -230,13 +230,20 @@ impl NonCanonicalOverlay { Ok(commit) } - fn discard_journals(&self, level_index: usize, discarded_journals: &mut Vec>, hash: &BlockHash) { + fn discard_journals( + &self, + level_index: usize, + discarded_journals: &mut Vec>, + discarded_blocks: &mut Vec, + hash: &BlockHash + ) { if let Some(level) = self.levels.get(level_index) { level.iter().for_each(|overlay| { let parent = self.parents.get(&overlay.hash).expect("there is a parent entry for each entry in levels; qed").clone(); if parent == *hash { discarded_journals.push(overlay.journal_key.clone()); - self.discard_journals(level_index + 1, discarded_journals, &overlay.hash); + discarded_blocks.push(overlay.hash.clone()); + self.discard_journals(level_index + 1, discarded_journals, discarded_blocks, &overlay.hash); } }); } @@ -268,7 +275,12 @@ impl NonCanonicalOverlay { /// Select a top-level root and canonicalized it. Discards all sibling subtrees and the root. /// Returns a set of changes that need to be added to the DB. - pub fn canonicalize(&mut self, hash: &BlockHash) -> Result, Error> { + pub fn canonicalize( + &mut self, + hash: &BlockHash, + pinned: &HashMap, + commit: &mut CommitSet, + ) -> Result<(), Error> { trace!(target: "state-db", "Canonicalizing {:?}", hash); let level = self.levels.get(self.pending_canonicalizations.len()).ok_or_else(|| Error::InvalidBlock)?; let index = level @@ -276,26 +288,40 @@ impl NonCanonicalOverlay { .position(|overlay| overlay.hash == *hash) .ok_or_else(|| Error::InvalidBlock)?; - let mut commit = CommitSet::default(); let mut discarded_journals = Vec::new(); - for (i, overlay) in level.into_iter().enumerate() { - if i == index { - // that's the one we need to canonicalize - commit.data.inserted = overlay.inserted.iter() - .map(|k| (k.clone(), self.values.get(k).expect("For each key in verlays there's a value in values").1.clone())) - .collect(); - commit.data.deleted = overlay.deleted.clone(); - } else { - self.discard_journals(self.pending_canonicalizations.len() + 1, &mut discarded_journals, &overlay.hash); + let mut discarded_blocks = Vec::new(); + for (i, overlay) in level.iter().enumerate() { + if i != index { + self.discard_journals( + self.pending_canonicalizations.len() + 1, + &mut discarded_journals, + &mut discarded_blocks, + &overlay.hash + ); } discarded_journals.push(overlay.journal_key.clone()); + discarded_blocks.push(overlay.hash.clone()); } + + for hash in discarded_blocks.into_iter() { + if pinned.contains_key(&hash) { + trace!(target: "state-db", "Refusing to discard pinned state {:?}", hash); + return Err(Error::DiscardingPinned) + } + } + + // get the one we need to canonicalize + let overlay = &level[index]; + commit.data.inserted.extend(overlay.inserted.iter() + .map(|k| (k.clone(), self.values.get(k).expect("For each key in overlays there's a value in values").1.clone()))); + commit.data.deleted.extend(overlay.deleted.clone()); + commit.meta.deleted.append(&mut discarded_journals); let canonicalized = (hash.clone(), self.front_block_number() + self.pending_canonicalizations.len() as u64); commit.meta.inserted.push((to_meta_key(LAST_CANONICAL, &()), canonicalized.encode())); trace!(target: "state-db", "Discarding {} records", commit.meta.deleted.len()); self.pending_canonicalizations.push(hash.clone()); - Ok(commit) + Ok(()) } fn apply_canonicalizations(&mut self) { @@ -385,10 +411,10 @@ impl NonCanonicalOverlay { #[cfg(test)] mod tests { - use std::io; + use std::{collections::HashMap, io}; use primitives::H256; use super::{NonCanonicalOverlay, to_journal_key}; - use crate::ChangeSet; + use crate::{ChangeSet, CommitSet}; use crate::test::{make_db, make_changeset}; fn contains(overlay: &NonCanonicalOverlay, key: u64) -> bool { @@ -409,7 +435,8 @@ mod tests { fn canonicalize_empty_panics() { let db = make_db(&[]); let mut overlay = NonCanonicalOverlay::::new(&db).unwrap(); - overlay.canonicalize::(&H256::default()).unwrap(); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&H256::default(), &HashMap::default(), &mut commit).unwrap(); } #[test] @@ -453,7 +480,8 @@ mod tests { let db = make_db(&[]); let mut overlay = NonCanonicalOverlay::::new(&db).unwrap(); overlay.insert::(&h1, 1, &H256::default(), ChangeSet::default()).unwrap(); - overlay.canonicalize::(&h2).unwrap(); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h2, &HashMap::default(), &mut commit).unwrap(); } #[test] @@ -468,7 +496,8 @@ mod tests { assert_eq!(insertion.meta.inserted.len(), 2); assert_eq!(insertion.meta.deleted.len(), 0); db.commit(&insertion); - let finalization = overlay.canonicalize::(&h1).unwrap(); + let mut finalization = CommitSet::default(); + overlay.canonicalize::(&h1, &HashMap::default(), &mut finalization).unwrap(); assert_eq!(finalization.data.inserted.len(), changeset.inserted.len()); assert_eq!(finalization.data.deleted.len(), changeset.deleted.len()); assert_eq!(finalization.meta.inserted.len(), 1); @@ -501,7 +530,9 @@ mod tests { let mut overlay = NonCanonicalOverlay::::new(&db).unwrap(); db.commit(&overlay.insert::(&h1, 10, &H256::default(), make_changeset(&[3, 4], &[2])).unwrap()); db.commit(&overlay.insert::(&h2, 11, &h1, make_changeset(&[5], &[3])).unwrap()); - db.commit(&overlay.canonicalize::(&h1).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h1, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); overlay.apply_pending(); assert_eq!(overlay.levels.len(), 1); @@ -526,7 +557,9 @@ mod tests { assert!(contains(&overlay, 5)); assert_eq!(overlay.levels.len(), 2); assert_eq!(overlay.parents.len(), 2); - db.commit(&overlay.canonicalize::(&h1).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h1, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); assert!(contains(&overlay, 5)); assert_eq!(overlay.levels.len(), 2); assert_eq!(overlay.parents.len(), 2); @@ -535,7 +568,9 @@ mod tests { assert_eq!(overlay.parents.len(), 1); assert!(!contains(&overlay, 5)); assert!(contains(&overlay, 7)); - db.commit(&overlay.canonicalize::(&h2).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h2, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); overlay.apply_pending(); assert_eq!(overlay.levels.len(), 0); assert_eq!(overlay.parents.len(), 0); @@ -552,7 +587,9 @@ mod tests { db.commit(&overlay.insert::(&h_1, 1, &H256::default(), c_1).unwrap()); db.commit(&overlay.insert::(&h_2, 1, &H256::default(), c_2).unwrap()); assert!(contains(&overlay, 1)); - db.commit(&overlay.canonicalize::(&h_1).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h_1, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); assert!(contains(&overlay, 1)); overlay.apply_pending(); assert!(!contains(&overlay, 1)); @@ -569,8 +606,10 @@ mod tests { db.commit(&overlay.insert::(&h1, 1, &H256::default(), changeset.clone()).unwrap()); db.commit(&overlay.insert::(&h2, 2, &h1, changeset.clone()).unwrap()); overlay.apply_pending(); - db.commit(&overlay.canonicalize::(&h1).unwrap()); - db.commit(&overlay.canonicalize::(&h2).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h1, &HashMap::default(), &mut commit).unwrap(); + overlay.canonicalize::(&h2, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); db.commit(&overlay.insert::(&h3, 3, &h2, changeset.clone()).unwrap()); overlay.apply_pending(); assert_eq!(overlay.levels.len(), 1); @@ -639,7 +678,9 @@ mod tests { assert_eq!(overlay.last_canonicalized, overlay2.last_canonicalized); // canonicalize 1. 2 and all its children should be discarded - db.commit(&overlay.canonicalize::(&h_1).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h_1, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); overlay.apply_pending(); assert_eq!(overlay.levels.len(), 2); assert_eq!(overlay.parents.len(), 6); @@ -657,8 +698,15 @@ mod tests { assert!(db.get_meta(&to_journal_key(2, 2)).unwrap().is_none()); assert!(db.get_meta(&to_journal_key(2, 3)).unwrap().is_none()); + // check that discarding pinned state produces an error. + let mut commit = CommitSet::default(); + let pinned = vec![(h_1_1_1, 1)].into_iter().collect(); + assert!(overlay.canonicalize::(&h_1_2, &pinned, &mut commit).is_err()); + // canonicalize 1_2. 1_1 and all its children should be discarded - db.commit(&overlay.canonicalize::(&h_1_2).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h_1_2, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); overlay.apply_pending(); assert_eq!(overlay.levels.len(), 1); assert_eq!(overlay.parents.len(), 3); @@ -673,7 +721,9 @@ mod tests { assert!(!overlay.have_block(&h_1_1_1)); // canonicalize 1_2_2 - db.commit(&overlay.canonicalize::(&h_1_2_2).unwrap()); + let mut commit = CommitSet::default(); + overlay.canonicalize::(&h_1_2_2, &HashMap::default(), &mut commit).unwrap(); + db.commit(&commit); overlay.apply_pending(); assert_eq!(overlay.levels.len(), 0); assert_eq!(overlay.parents.len(), 0); diff --git a/core/state-machine/src/backend.rs b/core/state-machine/src/backend.rs index fd143a553e..81529c6da3 100644 --- a/core/state-machine/src/backend.rs +++ b/core/state-machine/src/backend.rs @@ -106,7 +106,7 @@ pub trait Backend { } /// Try convert into trie backend. - fn try_into_trie_backend(self) -> Option>; + fn as_trie_backend(&mut self) -> Option<&TrieBackend>; /// Calculate the storage root, with given delta over what is already stored /// in the backend, and produce a "transaction" that can be used to commit. @@ -185,31 +185,33 @@ impl error::Error for Void { /// In-memory backend. Fully recomputes tries on each commit but useful for /// tests. -#[derive(Eq)] -pub struct InMemory { +pub struct InMemory { inner: HashMap>, HashMap, Vec>>, + trie: Option, H>>, _hasher: PhantomData, } -impl Default for InMemory { +impl Default for InMemory { fn default() -> Self { InMemory { inner: Default::default(), + trie: None, _hasher: PhantomData, } } } -impl Clone for InMemory { +impl Clone for InMemory { fn clone(&self) -> Self { InMemory { inner: self.inner.clone(), + trie: None, _hasher: PhantomData, } } } -impl PartialEq for InMemory { +impl PartialEq for InMemory { fn eq(&self, other: &Self) -> bool { self.inner.eq(&other.inner) } @@ -230,27 +232,29 @@ impl InMemory { } } -impl From>, HashMap, Vec>>> for InMemory { +impl From>, HashMap, Vec>>> for InMemory { fn from(inner: HashMap>, HashMap, Vec>>) -> Self { InMemory { inner: inner, + trie: None, _hasher: PhantomData, } } } -impl From, Vec>> for InMemory { +impl From, Vec>> for InMemory { fn from(inner: HashMap, Vec>) -> Self { let mut expanded = HashMap::new(); expanded.insert(None, inner); InMemory { inner: expanded, + trie: None, _hasher: PhantomData, } } } -impl From>, Vec, Option>)>> for InMemory { +impl From>, Vec, Option>)>> for InMemory { fn from(inner: Vec<(Option>, Vec, Option>)>) -> Self { let mut expanded: HashMap>, HashMap, Vec>> = HashMap::new(); for (child_key, key, value) in inner { @@ -365,16 +369,14 @@ impl Backend for InMemory { .collect() } - fn try_into_trie_backend( - self - )-> Option> { + fn as_trie_backend(&mut self)-> Option<&TrieBackend> { let mut mdb = MemoryDB::default(); let mut root = None; let mut new_child_roots = Vec::new(); let mut root_map = None; - for (storage_key, map) in self.inner { + for (storage_key, map) in &self.inner { if let Some(storage_key) = storage_key.as_ref() { - let ch = insert_into_memory_db::(&mut mdb, map.into_iter())?; + let ch = insert_into_memory_db::(&mut mdb, map.clone().into_iter())?; new_child_roots.push((storage_key.clone(), ch.as_ref().into())); } else { root_map = Some(map); @@ -384,14 +386,15 @@ impl Backend for InMemory { if let Some(map) = root_map.take() { root = Some(insert_into_memory_db::( &mut mdb, - map.into_iter().chain(new_child_roots.into_iter()) + map.clone().into_iter().chain(new_child_roots.into_iter()) )?); } let root = match root { Some(root) => root, None => insert_into_memory_db::(&mut mdb, ::std::iter::empty())?, }; - Some(TrieBackend::new(mdb, root)) + self.trie = Some(TrieBackend::new(mdb, root)); + self.trie.as_ref() } } diff --git a/core/state-machine/src/lib.rs b/core/state-machine/src/lib.rs index f16c3db14e..9f0e20ce01 100644 --- a/core/state-machine/src/lib.rs +++ b/core/state-machine/src/lib.rs @@ -669,7 +669,7 @@ impl<'a, H, N, B, T, O, Exec> StateMachine<'a, H, N, B, T, O, Exec> where /// Prove execution using the given state backend, overlayed changes, and call executor. pub fn prove_execution( - backend: B, + mut backend: B, overlay: &mut OverlayedChanges, exec: &Exec, method: &str, @@ -681,9 +681,9 @@ where Exec: CodeExecutor, H::Out: Ord + 'static, { - let trie_backend = backend.try_into_trie_backend() + let trie_backend = backend.as_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; - prove_execution_on_trie_backend(&trie_backend, overlay, exec, method, call_data) + prove_execution_on_trie_backend(trie_backend, overlay, exec, method, call_data) } /// Prove execution using the given trie backend, overlayed changes, and call executor. @@ -778,7 +778,7 @@ where /// Generate storage read proof. pub fn prove_read( - backend: B, + mut backend: B, key: &[u8] ) -> Result<(Option>, Vec>), Box> where @@ -786,16 +786,16 @@ where H: Hasher, H::Out: Ord { - let trie_backend = backend.try_into_trie_backend() + let trie_backend = backend.as_trie_backend() .ok_or_else( ||Box::new(ExecutionError::UnableToGenerateProof) as Box )?; - prove_read_on_trie_backend(&trie_backend, key) + prove_read_on_trie_backend(trie_backend, key) } /// Generate child storage read proof. pub fn prove_child_read( - backend: B, + mut backend: B, storage_key: &[u8], key: &[u8], ) -> Result<(Option>, Vec>), Box> @@ -804,9 +804,9 @@ where H: Hasher, H::Out: Ord { - let trie_backend = backend.try_into_trie_backend() + let trie_backend = backend.as_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; - prove_child_read_on_trie_backend(&trie_backend, storage_key, key) + prove_child_read_on_trie_backend(trie_backend, storage_key, key) } @@ -1100,7 +1100,8 @@ mod tests { b"abc".to_vec() => b"2".to_vec(), b"bbb".to_vec() => b"3".to_vec() ]; - let backend = InMemory::::from(initial).try_into_trie_backend().unwrap(); + let mut state = InMemory::::from(initial); + let backend = state.as_trie_backend().unwrap(); let mut overlay = OverlayedChanges { committed: map![ b"aba".to_vec() => OverlayedValue::from(Some(b"1312".to_vec())), @@ -1115,7 +1116,7 @@ mod tests { { let changes_trie_storage = InMemoryChangesTrieStorage::::new(); - let mut ext = Ext::new(&mut overlay, &backend, Some(&changes_trie_storage), NeverOffchainExt::new()); + let mut ext = Ext::new(&mut overlay, backend, Some(&changes_trie_storage), NeverOffchainExt::new()); ext.clear_prefix(b"ab"); } overlay.commit_prospective(); @@ -1136,12 +1137,13 @@ mod tests { #[test] fn set_child_storage_works() { - let backend = InMemory::::default().try_into_trie_backend().unwrap(); + let mut state = InMemory::::default(); + let backend = state.as_trie_backend().unwrap(); let changes_trie_storage = InMemoryChangesTrieStorage::::new(); let mut overlay = OverlayedChanges::default(); let mut ext = Ext::new( &mut overlay, - &backend, + backend, Some(&changes_trie_storage), NeverOffchainExt::new() ); diff --git a/core/state-machine/src/proving_backend.rs b/core/state-machine/src/proving_backend.rs index c23838bc21..f9472ed747 100644 --- a/core/state-machine/src/proving_backend.rs +++ b/core/state-machine/src/proving_backend.rs @@ -184,7 +184,7 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.backend.child_storage_root(storage_key, delta) } - fn try_into_trie_backend(self) -> Option> { + fn as_trie_backend(&mut self) -> Option<&TrieBackend> { None } } @@ -269,16 +269,16 @@ mod tests { fn proof_recorded_and_checked() { let contents = (0..64).map(|i| (None, vec![i], Some(vec![i]))).collect::>(); let in_memory = InMemory::::default(); - let in_memory = in_memory.update(contents); + let mut in_memory = in_memory.update(contents); let in_memory_root = in_memory.storage_root(::std::iter::empty()).0; (0..64).for_each(|i| assert_eq!(in_memory.storage(&[i]).unwrap().unwrap(), vec![i])); - let trie = in_memory.try_into_trie_backend().unwrap(); + let trie = in_memory.as_trie_backend().unwrap(); let trie_root = trie.storage_root(::std::iter::empty()).0; assert_eq!(in_memory_root, trie_root); (0..64).for_each(|i| assert_eq!(trie.storage(&[i]).unwrap().unwrap(), vec![i])); - let proving = ProvingBackend::new(&trie); + let proving = ProvingBackend::new(trie); assert_eq!(proving.storage(&[42]).unwrap().unwrap(), vec![42]); let proof = proving.extract_proof(); @@ -302,7 +302,7 @@ mod tests { .chain((10..15).map(|i| (Some(own2.clone()), vec![i], Some(vec![i])))) .collect::>(); let in_memory = InMemory::::default(); - let in_memory = in_memory.update(contents); + let mut in_memory = in_memory.update(contents); let in_memory_root = in_memory.full_storage_root::<_, Vec<_>, _>( ::std::iter::empty(), in_memory.child_storage_keys().map(|k|(k.to_vec(), Vec::new())) @@ -320,7 +320,7 @@ mod tests { vec![i] )); - let trie = in_memory.try_into_trie_backend().unwrap(); + let trie = in_memory.as_trie_backend().unwrap(); let trie_root = trie.storage_root(::std::iter::empty()).0; assert_eq!(in_memory_root, trie_root); (0..64).for_each(|i| assert_eq!( @@ -328,7 +328,7 @@ mod tests { vec![i] )); - let proving = ProvingBackend::new(&trie); + let proving = ProvingBackend::new(trie); assert_eq!(proving.storage(&[42]).unwrap().unwrap(), vec![42]); let proof = proving.extract_proof(); @@ -343,7 +343,7 @@ mod tests { assert_eq!(proof_check.storage(&[41]).unwrap().unwrap(), vec![41]); assert_eq!(proof_check.storage(&[64]).unwrap(), None); - let proving = ProvingBackend::new(&trie); + let proving = ProvingBackend::new(trie); assert_eq!(proving.child_storage(&own1[..], &[64]), Ok(Some(vec![64]))); let proof = proving.extract_proof(); diff --git a/core/state-machine/src/trie_backend.rs b/core/state-machine/src/trie_backend.rs index 00c0aca006..0c57cf3682 100644 --- a/core/state-machine/src/trie_backend.rs +++ b/core/state-machine/src/trie_backend.rs @@ -179,7 +179,7 @@ impl, H: Hasher> Backend for TrieBackend where (root, is_default, write_overlay) } - fn try_into_trie_backend(self) -> Option> { + fn as_trie_backend(&mut self) -> Option<&TrieBackend> { Some(self) } } -- GitLab From 6ea53d8614e7dd46f21d912bbcb2b8b1555df636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 4 Jun 2019 10:14:46 +0200 Subject: [PATCH 076/113] Generate docs for all workspace crates (#2773) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55c83328d4..f29e1b0dc8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -178,7 +178,7 @@ build-rust-doc-release: script: - ./scripts/build.sh - rm -f ./crate-docs/index.html # use it as an indicator if the job succeeds - - time cargo +nightly doc --release --verbose + - time cargo +nightly doc --release --all --verbose - cp -R ./target/doc ./crate-docs - echo "" > ./crate-docs/index.html - sccache -s -- GitLab From 46121f7c073f1b6ee34718bcaacf09e0f8fb395a Mon Sep 17 00:00:00 2001 From: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> Date: Tue, 4 Jun 2019 09:59:47 -0400 Subject: [PATCH 077/113] Add runtime support for `PreRuntime` and `Consensus` digests (#2757) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Try to fix runtime panic Does not work * Fix trivial typo * Add runtime support for `PreRuntime` and `Consensus` digests Fixes 6e253c899e67ce4e29b70e5eca3a3763fa42233f * Fix silly compile error. * Fix overly-long lines Also remove some in-progress code that would not wind up being useful anyway. * Respond to review comments * delete `unset RUSTC_WRAPPER` from scripts/common.sh * delete unnecessary `use aura::AURA_ENGINE_ID` from `node/runtime/src/lib.rs` * add comments explaining why `PreRuntime` and `Consensus` must be special-cased in `core/sr-primitives/lib.rs` * switch to using `$crate::rstd::marker::PhantomData` in `impl_outer_log!` * improve documentation of `DigestItem::Seal` * Fix compilation and add proof that we do not panic Also fix some warnings. * Apply suggestions from code review Mostly for readability Co-Authored-By: Sergei Pepyakin * Apply suggestions from code review Co-Authored-By: Bastian Köcher * $crate::rstd::marker::PhantomData → Default::default() The import is still needed, as `Default::default()` can’t be used in patterns. * Bump `spec_version` Also do some reformatting. --- core/sr-primitives/src/generic/digest.rs | 8 +- core/sr-primitives/src/lib.rs | 114 +++++++++++++++++++---- core/sr-sandbox/without_std.rs | 2 +- node-template/runtime/src/lib.rs | 2 +- node/runtime/src/lib.rs | 6 +- srml/aura/src/lib.rs | 18 ++++ srml/babe/src/lib.rs | 22 ++++- srml/consensus/src/lib.rs | 1 + srml/contract/src/account_db.rs | 4 +- 9 files changed, 144 insertions(+), 33 deletions(-) diff --git a/core/sr-primitives/src/generic/digest.rs b/core/sr-primitives/src/generic/digest.rs index 8f7055b843..79a2991e5f 100644 --- a/core/sr-primitives/src/generic/digest.rs +++ b/core/sr-primitives/src/generic/digest.rs @@ -74,13 +74,14 @@ pub enum DigestItem { /// be generated by the native code of any consensus engine, but this is not /// checked (yet). Consensus(ConsensusEngineId, Vec), - /// Put a Seal on it. + /// Put a Seal on it. This is only used by native code, and is never seen + /// by runtimes. Seal(ConsensusEngineId, SealSignature), /// A pre-runtime digest. /// /// These are messages from the consensus engine to the runtime, although /// the consensus engine can (and should) read them itself to avoid - /// code and state duplication. It is erroneous for a runtime to produce + /// code and state duplication. It is erroneous for a runtime to produce /// these, but this is not (yet) checked. PreRuntime(ConsensusEngineId, Vec), /// Any 'non-system' digest item, opaque to the native code. @@ -110,7 +111,8 @@ pub enum DigestItemRef<'a, Hash: 'a, AuthorityId: 'a, SealSignature: 'a> { /// be generated by the native code of any consensus engine, but this is not /// checked (yet). Consensus(&'a ConsensusEngineId, &'a Vec), - /// Put a Seal on it. + /// Put a Seal on it. This is only used by native code, and is never seen + /// by runtimes. Seal(&'a ConsensusEngineId, &'a SealSignature), /// A pre-runtime digest. /// diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index e6cf9142ad..55e03e47f3 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -25,6 +25,8 @@ pub use parity_codec as codec; #[cfg(feature = "std")] #[doc(hidden)] pub use serde; +#[doc(hidden)] +pub use rstd; #[cfg(feature = "std")] pub use runtime_io::{StorageOverlay, ChildrenStorageOverlay}; @@ -341,8 +343,8 @@ impl ::rstd::ops::Deref for PerU128 { type Target = u128; fn deref(&self) -> &u128 { - &self.0 - } + &self.0 + } } impl codec::CompactAs for PerU128 { @@ -611,6 +613,69 @@ macro_rules! impl_outer_config { } } +// NOTE [`PreRuntime` and `Consensus` are special] +// +// We MUST treat `PreRuntime` and `Consensus` variants specially, as they: +// +// * have more parameters (both in `generic::DigestItem` and in runtimes) +// * have a `PhantomData` parameter in the runtime, but not in `generic::DigestItem` + +#[macro_export] +#[doc(hidden)] +macro_rules! __parse_pattern_2 { + (PreRuntime $module:ident $internal:ident $v1:ident $v2:ident) => { + $internal::$module($module::RawLog::PreRuntime(ref $v1, ref $v2, $crate::rstd::marker::PhantomData)) + }; + (Consensus $module:ident $internal:ident $v1:ident $v2:ident) => { + $internal::$module($module::RawLog::Consensus(ref $v1, ref $v2, $crate::rstd::marker::PhantomData)) + }; + ($name:ident $module:ident $internal:ident $v1:ident $v2:ident) => { + $internal::$module($module::RawLog::$name(ref $v1)) + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! __parse_pattern { + (PreRuntime $engine_id:pat, $binder:pat) => { + $crate::generic::DigestItem::PreRuntime($engine_id, $binder) + }; + (Consensus $engine_id:pat, $binder:pat) => { + $crate::generic::DigestItem::Consensus($engine_id, $binder) + }; + ($name:ident $engine_id:pat, $binder:pat) => { + $crate::generic::DigestItem::$name($binder) + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! __parse_expr { + (PreRuntime $engine_id:expr, $module:ident $internal:ident $binder:expr) => { + $internal::$module($module::RawLog::PreRuntime($engine_id, $binder, Default::default())) + }; + (Consensus $engine_id:expr, $module:ident $internal:ident $binder:expr) => { + $internal::$module($module::RawLog::Consensus($engine_id, $binder, Default::default())) + }; + ($name:ident $engine_id:expr, $module:ident $internal:ident $binder:expr) => { + $internal::$module($module::RawLog::$name($binder)) + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! __parse_expr_2 { + (PreRuntime $module:ident $internal:ident $v1:ident $v2:ident) => { + $crate::generic::DigestItemRef::PreRuntime($v1, $v2) + }; + (Consensus $module:ident $internal:ident $v1:ident $v2:ident) => { + $crate::generic::DigestItemRef::Consensus($v1, $v2) + }; + ($name:ident $module:ident $internal:ident $v1:ident $v2:ident) => { + $crate::generic::DigestItemRef::$name($v1) + }; +} + /// Generates enum that contains all possible log entries for the runtime. /// Every individual module of the runtime that is mentioned, must /// expose a `Log` and `RawLog` enums. @@ -631,7 +696,7 @@ macro_rules! impl_outer_log { ( $(#[$attr:meta])* pub enum $name:ident ($internal:ident: DigestItem<$( $genarg:ty ),*>) for $trait:ident { - $( $module:ident $(<$instance:path>)? ( $( $sitem:ident ),* ) ),* + $( $module:ident $(<$instance:path>)? ( $( $sitem:tt ),* ) ),* } ) => { /// Wrapper for all possible log entries for the `$trait` runtime. Provides binary-compatible @@ -650,7 +715,7 @@ macro_rules! impl_outer_log { #[allow(non_camel_case_types)] pub enum InternalLog { $( - $module($module::Log<$trait $(, $instance)? >), + $module($module::Log <$trait $(, $instance)?>), )* } @@ -662,8 +727,8 @@ macro_rules! impl_outer_log { fn dref<'a>(&'a self) -> Option<$crate::generic::DigestItemRef<'a, $($genarg),*>> { match self.0 { $($( - $internal::$module($module::RawLog::$sitem(ref v)) => - Some($crate::generic::DigestItemRef::$sitem(v)), + $crate::__parse_pattern_2!($sitem $module $internal a b) => + Some($crate::__parse_expr_2!($sitem $module $internal a b)), )*)* _ => None, } @@ -688,22 +753,31 @@ macro_rules! impl_outer_log { } impl From<$crate::generic::DigestItem<$($genarg),*>> for $name { - /// Converts `generic::DigestItem` into `$name`. If `generic::DigestItem` represents - /// a system item which is supported by the runtime, it is returned. - /// Otherwise we expect a `Other` log item. Trying to convert from anything other - /// will lead to panic in runtime, since the runtime does not supports this 'system' - /// log item. + /// Converts `generic::DigestItem` into `$name`. If + /// `generic::DigestItem` represents a system item which is + /// supported by the runtime, it is returned. Otherwise we expect a + /// `Other`, `PreDigest`, or `Consensus` log item. Trying to convert + /// from anything else will lead to panic at runtime, since the + /// runtime does not supports this 'system' log item. #[allow(unreachable_patterns)] fn from(gen: $crate::generic::DigestItem<$($genarg),*>) -> Self { match gen { $($( - $crate::generic::DigestItem::$sitem(value) => - $name($internal::$module($module::RawLog::$sitem(value))), + $crate::__parse_pattern!($sitem b, a) => + $name($crate::__parse_expr!($sitem b, $module $internal a)), )*)* - _ => gen.as_other() - .and_then(|value| $crate::codec::Decode::decode(&mut &value[..])) - .map($name) - .expect("not allowed to fail in runtime"), + _ => { + if let Some(s) = gen.as_other() + .and_then(|value| $crate::codec::Decode::decode(&mut &value[..])) + .map($name) + { + s + } else { + panic!("we only reach here if the runtime did not handle a digest; \ + runtimes are required to handle all digests they receive; qed" + ) + } + } } } } @@ -732,16 +806,16 @@ macro_rules! impl_outer_log { } $( - impl From<$module::Log<$trait $(, $instance)? >> for $name { + impl From<$module::Log<$trait $(, $instance)?>> for $name { /// Converts single module log item into `$name`. fn from(x: $module::Log<$trait $(, $instance)? >) -> Self { $name(x.into()) } } - impl From<$module::Log<$trait $(, $instance)? >> for InternalLog { + impl From<$module::Log<$trait $(, $instance)?>> for InternalLog { /// Converts single module log item into `$internal`. - fn from(x: $module::Log<$trait $(, $instance)? >) -> Self { + fn from(x: $module::Log<$trait $(, $instance)?>) -> Self { InternalLog::$module(x) } } diff --git a/core/sr-sandbox/without_std.rs b/core/sr-sandbox/without_std.rs index 070ca1ddf1..894ba43eb0 100755 --- a/core/sr-sandbox/without_std.rs +++ b/core/sr-sandbox/without_std.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use rstd::prelude::*; -use rstd::{slice, marker, mem}; +use rstd::{slice, marker, mem, vec}; use rstd::rc::Rc; use codec::{Decode, Encode}; use primitives::sandbox as sandbox_primitives; diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index b09fe7d787..19f5f36862 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -200,7 +200,7 @@ construct_runtime!( System: system::{default, Log(ChangesTrieRoot)}, Timestamp: timestamp::{Module, Call, Storage, Config, Inherent}, Consensus: consensus::{Module, Call, Storage, Config, Log(AuthoritiesChange), Inherent}, - Aura: aura::{Module}, + Aura: aura::{Module, Log(PreRuntime)}, Indices: indices, Balances: balances, Sudo: sudo, diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index e892ceda81..c31c6b41cc 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 90, - impl_version: 91, + spec_version: 91, + impl_version: 92, apis: RUNTIME_API_VERSIONS, }; @@ -227,7 +227,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{default, Log(ChangesTrieRoot)}, - Aura: aura::{Module, Inherent(Timestamp)}, + Aura: aura::{Module, Inherent(Timestamp), Log(PreRuntime)}, Timestamp: timestamp::{Module, Call, Storage, Config, Inherent}, Consensus: consensus::{Module, Call, Storage, Config, Log(AuthoritiesChange), Inherent}, Indices: indices, diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index 3b557e2944..bc46e98ec2 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -51,15 +51,19 @@ pub use timestamp; use rstd::{result, prelude::*}; +use parity_codec::{Encode, Decode}; use srml_support::storage::StorageValue; use srml_support::{decl_storage, decl_module}; use primitives::traits::{SaturatedConversion, Saturating, Zero, One}; use timestamp::OnTimestampSet; +use rstd::marker::PhantomData; #[cfg(feature = "std")] use timestamp::TimestampInherentData; use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; +#[cfg(feature = "std")] +use serde::Serialize; mod mock; mod tests; @@ -89,6 +93,20 @@ impl AuraInherentData for InherentData { } } +/// Logs in this module. +pub type Log = RawLog; + +/// Logs in this module. +/// +/// The type parameter distinguishes logs belonging to two different runtimes, +/// which should not be mixed. +#[cfg_attr(feature = "std", derive(Serialize, Debug))] +#[derive(Encode, Decode, PartialEq, Eq, Clone)] +pub enum RawLog { + /// AuRa inherent digests + PreRuntime([u8; 4], Vec, PhantomData), +} + /// Provides the slot duration inherent data for `Aura`. #[cfg(feature = "std")] pub struct InherentDataProvider { diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 3e36481151..e969dee74b 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -17,19 +17,21 @@ //! Consensus extension module for BABE consensus. #![cfg_attr(not(feature = "std"), no_std)] -#![forbid(unsafe_code, warnings)] +#![forbid(unsafe_code)] pub use timestamp; -use rstd::{result, prelude::*}; +use rstd::{result, prelude::*, marker::PhantomData}; use srml_support::{decl_storage, decl_module}; use timestamp::{OnTimestampSet, Trait}; use primitives::traits::{SaturatedConversion, Saturating}; #[cfg(feature = "std")] use timestamp::TimestampInherentData; -use parity_codec::Decode; +use parity_codec::{Encode, Decode}; use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; +#[cfg(feature = "std")] +use serde::Serialize; /// The BABE inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot"; @@ -56,6 +58,20 @@ impl BabeInherentData for InherentData { } } +/// Logs in this module. +pub type Log = RawLog; + +/// Logs in this module. +/// +/// The type parameter distinguishes logs belonging to two different runtimes, +/// which should not be mixed. +#[cfg_attr(feature = "std", derive(Serialize, Debug))] +#[derive(Encode, Decode, PartialEq, Eq, Clone)] +pub enum RawLog { + /// BABE inherent digests + PreRuntime([u8; 4], Vec, PhantomData), +} + /// Provides the slot duration inherent data for BABE. #[cfg(feature = "std")] pub struct InherentDataProvider { diff --git a/srml/consensus/src/lib.rs b/srml/consensus/src/lib.rs index 696b9d75f4..4613981ec5 100644 --- a/srml/consensus/src/lib.rs +++ b/srml/consensus/src/lib.rs @@ -221,6 +221,7 @@ impl>> InherentOfflineReport for InstantFinalityRepo } } +/// Logs in this module. pub type Log = RawLog< ::SessionKey, >; diff --git a/srml/contract/src/account_db.rs b/srml/contract/src/account_db.rs index 5cae9f05dc..2421eab00a 100644 --- a/srml/contract/src/account_db.rs +++ b/srml/contract/src/account_db.rs @@ -177,10 +177,10 @@ impl AccountDb for DirectAccountDb { } pub struct OverlayAccountDb<'a, T: Trait + 'a> { local: RefCell>, - underlying: &'a AccountDb, + underlying: &'a dyn AccountDb, } impl<'a, T: Trait> OverlayAccountDb<'a, T> { - pub fn new(underlying: &'a AccountDb) -> OverlayAccountDb<'a, T> { + pub fn new(underlying: &'a dyn AccountDb) -> OverlayAccountDb<'a, T> { OverlayAccountDb { local: RefCell::new(ChangeSet::new()), underlying, -- GitLab From a7dd2559a7658f11eed101efdcfc26dd8b57a9b5 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 4 Jun 2019 16:09:46 +0200 Subject: [PATCH 078/113] Client::info() no longer returns a Result (#2776) --- core/cli/src/informant.rs | 133 +++++++++--------- core/client/db/src/lib.rs | 14 +- core/client/db/src/light.rs | 14 +- .../client/src/block_builder/block_builder.rs | 4 +- core/client/src/blockchain.rs | 2 +- core/client/src/client.rs | 61 ++++---- core/client/src/in_mem.rs | 6 +- core/client/src/light/blockchain.rs | 6 +- core/client/src/light/fetcher.rs | 8 +- core/consensus/aura/src/lib.rs | 2 +- core/consensus/babe/src/lib.rs | 2 +- core/finality-grandpa/src/environment.rs | 4 +- core/finality-grandpa/src/finality_proof.rs | 2 +- core/finality-grandpa/src/import.rs | 6 +- core/finality-grandpa/src/lib.rs | 27 ++-- core/finality-grandpa/src/light_import.rs | 9 +- core/finality-grandpa/src/observer.rs | 13 +- core/finality-grandpa/src/tests.rs | 26 ++-- core/network/src/chain.rs | 4 +- core/network/src/protocol.rs | 29 ++-- core/network/src/sync.rs | 16 +-- core/network/src/test/mod.rs | 12 +- core/network/src/test/sync.rs | 24 ++-- core/rpc/src/author/mod.rs | 4 +- core/rpc/src/chain/mod.rs | 8 +- core/rpc/src/state/mod.rs | 10 +- core/service/src/chain_ops.rs | 6 +- core/service/src/lib.rs | 9 +- core/service/test/src/lib.rs | 8 +- core/sr-api-macros/benches/bench.rs | 12 +- core/sr-api-macros/tests/runtime_calls.rs | 28 ++-- core/test-client/src/trait_tests.rs | 6 +- node/cli/src/service.rs | 2 +- 33 files changed, 239 insertions(+), 278 deletions(-) diff --git a/core/cli/src/informant.rs b/core/cli/src/informant.rs index 6149d6c95b..607ab9ae85 100644 --- a/core/cli/src/informant.rs +++ b/core/cli/src/informant.rs @@ -53,79 +53,76 @@ where C: Components { let display_notifications = network.status().for_each(move |sync_status| { - if let Ok(info) = client.info() { - let best_number = info.chain.best_number.saturated_into::(); - let best_hash = info.chain.best_hash; - let num_peers = sync_status.num_peers; - let speed = move || speed(best_number, last_number, last_update); - last_update = time::Instant::now(); - let (status, target) = match (sync_status.sync.state, sync_status.sync.best_seen_block) { - (SyncState::Idle, _) => ("Idle".into(), "".into()), - (SyncState::Downloading, None) => (format!("Syncing{}", speed()), "".into()), - (SyncState::Downloading, Some(n)) => (format!("Syncing{}", speed()), format!(", target=#{}", n)), - }; - last_number = Some(best_number); - let txpool_status = txpool.status(); - let finalized_number: u64 = info.chain.finalized_number.saturated_into::(); - let bandwidth_download = network.average_download_per_sec(); - let bandwidth_upload = network.average_upload_per_sec(); - info!( - target: "substrate", - "{}{} ({} peers), best: #{} ({}), finalized #{} ({}), ⬇ {} ⬆ {}", - Colour::White.bold().paint(&status), - target, - Colour::White.bold().paint(format!("{}", sync_status.num_peers)), - Colour::White.paint(format!("{}", best_number)), - best_hash, - Colour::White.paint(format!("{}", finalized_number)), - info.chain.finalized_hash, - TransferRateFormat(bandwidth_download), - TransferRateFormat(bandwidth_upload), - ); - - #[allow(deprecated)] - let backend = (*client).backend(); - let used_state_cache_size = match backend.used_state_cache_size(){ - Some(size) => size, - None => 0, - }; - - // get cpu usage and memory usage of this process - let (cpu_usage, memory) = if sys.refresh_process(self_pid) { - let proc = sys.get_process(self_pid).expect("Above refresh_process succeeds, this should be Some(), qed"); - (proc.cpu_usage(), proc.memory()) - } else { (0.0, 0) }; - - let network_state = network.network_state(); - - telemetry!( - SUBSTRATE_INFO; - "system.interval"; - "network_state" => network_state, - "status" => format!("{}{}", status, target), - "peers" => num_peers, - "height" => best_number, - "best" => ?best_hash, - "txcount" => txpool_status.ready, - "cpu" => cpu_usage, - "memory" => memory, - "finalized_height" => finalized_number, - "finalized_hash" => ?info.chain.finalized_hash, - "bandwidth_download" => bandwidth_download, - "bandwidth_upload" => bandwidth_upload, - "used_state_cache_size" => used_state_cache_size, - ); - } else { - warn!("Error getting best block information"); - } + let info = client.info(); + let best_number = info.chain.best_number.saturated_into::(); + let best_hash = info.chain.best_hash; + let num_peers = sync_status.num_peers; + let speed = move || speed(best_number, last_number, last_update); + last_update = time::Instant::now(); + let (status, target) = match (sync_status.sync.state, sync_status.sync.best_seen_block) { + (SyncState::Idle, _) => ("Idle".into(), "".into()), + (SyncState::Downloading, None) => (format!("Syncing{}", speed()), "".into()), + (SyncState::Downloading, Some(n)) => (format!("Syncing{}", speed()), format!(", target=#{}", n)), + }; + last_number = Some(best_number); + let txpool_status = txpool.status(); + let finalized_number: u64 = info.chain.finalized_number.saturated_into::(); + let bandwidth_download = network.average_download_per_sec(); + let bandwidth_upload = network.average_upload_per_sec(); + info!( + target: "substrate", + "{}{} ({} peers), best: #{} ({}), finalized #{} ({}), ⬇ {} ⬆ {}", + Colour::White.bold().paint(&status), + target, + Colour::White.bold().paint(format!("{}", sync_status.num_peers)), + Colour::White.paint(format!("{}", best_number)), + best_hash, + Colour::White.paint(format!("{}", finalized_number)), + info.chain.finalized_hash, + TransferRateFormat(bandwidth_download), + TransferRateFormat(bandwidth_upload), + ); + + #[allow(deprecated)] + let backend = (*client).backend(); + let used_state_cache_size = match backend.used_state_cache_size(){ + Some(size) => size, + None => 0, + }; + + // get cpu usage and memory usage of this process + let (cpu_usage, memory) = if sys.refresh_process(self_pid) { + let proc = sys.get_process(self_pid).expect("Above refresh_process succeeds, this should be Some(), qed"); + (proc.cpu_usage(), proc.memory()) + } else { (0.0, 0) }; + + let network_state = network.network_state(); + + telemetry!( + SUBSTRATE_INFO; + "system.interval"; + "network_state" => network_state, + "status" => format!("{}{}", status, target), + "peers" => num_peers, + "height" => best_number, + "best" => ?best_hash, + "txcount" => txpool_status.ready, + "cpu" => cpu_usage, + "memory" => memory, + "finalized_height" => finalized_number, + "finalized_hash" => ?info.chain.finalized_hash, + "bandwidth_download" => bandwidth_download, + "bandwidth_upload" => bandwidth_upload, + "used_state_cache_size" => used_state_cache_size, + ); Ok(()) }); let client = service.client(); - let mut last = match client.info() { - Ok(info) => Some((info.chain.best_number, info.chain.best_hash)), - Err(e) => { warn!("Error getting best block information: {:?}", e); None } + let mut last = { + let info = client.info(); + Some((info.chain.best_number, info.chain.best_hash)) }; let display_block_import = client.import_notification_stream().for_each(move |n| { diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index dd38f10bcd..a253cc6783 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -271,15 +271,15 @@ impl client::blockchain::HeaderBackend for BlockchainDb Result, client::error::Error> { + fn info(&self) -> client::blockchain::Info { let meta = self.meta.read(); - Ok(client::blockchain::Info { + client::blockchain::Info { best_hash: meta.best_hash, best_number: meta.best_number, genesis_hash: meta.genesis_hash, finalized_hash: meta.finalized_hash, finalized_number: meta.finalized_number, - }) + } } fn status(&self, id: BlockId) -> Result { @@ -742,7 +742,7 @@ impl> Backend { } // insert all other headers + bodies + justifications - let info = self.blockchain.info().unwrap(); + let info = self.blockchain.info(); for (number, hash, header) in headers { let id = BlockId::Hash(hash); let justification = self.blockchain.justification(id).unwrap(); @@ -1258,8 +1258,8 @@ impl client::backend::Backend for Backend whe } fn revert(&self, n: NumberFor) -> Result, client::error::Error> { - let mut best = self.blockchain.info()?.best_number; - let finalized = self.blockchain.info()?.finalized_number; + let mut best = self.blockchain.info().best_number; + let finalized = self.blockchain.info().finalized_number; let revertible = best - finalized; let n = if revertible < n { revertible } else { n }; @@ -1463,7 +1463,7 @@ mod tests { }; let backend = Backend::::from_kvdb(backing, PruningMode::keep_blocks(1), 0, 16777216).unwrap(); - assert_eq!(backend.blockchain().info().unwrap().best_number, 9); + assert_eq!(backend.blockchain().info().best_number, 9); for i in 0..10 { assert!(backend.blockchain().hash(i).unwrap().is_some()) } diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index 16b0fc616a..e0f2153a13 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -155,15 +155,15 @@ impl BlockchainHeaderBackend for LightStorage utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id) } - fn info(&self) -> ClientResult> { + fn info(&self) -> BlockchainInfo { let meta = self.meta.read(); - Ok(BlockchainInfo { + BlockchainInfo { best_hash: meta.best_hash, best_number: meta.best_number, genesis_hash: meta.genesis_hash, finalized_hash: meta.finalized_hash, finalized_number: meta.finalized_number, - }) + } } fn status(&self, id: BlockId) -> ClientResult { @@ -655,12 +655,12 @@ pub(crate) mod tests { fn returns_info() { let db = LightStorage::new_test(); let genesis_hash = insert_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); - let info = db.info().unwrap(); + let info = db.info(); assert_eq!(info.best_hash, genesis_hash); assert_eq!(info.best_number, 0); assert_eq!(info.genesis_hash, genesis_hash); let best_hash = insert_block(&db, HashMap::new(), || default_header(&genesis_hash, 1)); - let info = db.info().unwrap(); + let info = db.info(); assert_eq!(info.best_hash, best_hash); assert_eq!(info.best_number, 1); assert_eq!(info.genesis_hash, genesis_hash); @@ -1034,12 +1034,12 @@ pub(crate) mod tests { fn database_is_reopened() { let db = LightStorage::new_test(); let hash0 = insert_final_block(&db, HashMap::new(), || default_header(&Default::default(), 0)); - assert_eq!(db.info().unwrap().best_hash, hash0); + assert_eq!(db.info().best_hash, hash0); assert_eq!(db.header(BlockId::Hash(hash0)).unwrap().unwrap().hash(), hash0); let db = db.db; let db = LightStorage::from_kvdb(db).unwrap(); - assert_eq!(db.info().unwrap().best_hash, hash0); + assert_eq!(db.info().best_hash, hash0); assert_eq!(db.header(BlockId::Hash::(hash0)).unwrap().unwrap().hash(), hash0); } diff --git a/core/client/src/block_builder/block_builder.rs b/core/client/src/block_builder/block_builder.rs index eb7d81f978..4564c29aae 100644 --- a/core/client/src/block_builder/block_builder.rs +++ b/core/client/src/block_builder/block_builder.rs @@ -44,9 +44,7 @@ where /// Create a new instance of builder from the given client, building on the /// latest block. pub fn new(api: &'a A, inherent_digests: DigestFor) -> error::Result { - api.info().and_then(|i| - Self::at_block(&BlockId::Hash(i.best_hash), api, false, inherent_digests) - ) + Self::at_block(&BlockId::Hash(api.info().best_hash), api, false, inherent_digests) } /// Create a new instance of builder from the given client using a diff --git a/core/client/src/blockchain.rs b/core/client/src/blockchain.rs index d168ecda19..05210fc9ad 100644 --- a/core/client/src/blockchain.rs +++ b/core/client/src/blockchain.rs @@ -30,7 +30,7 @@ pub trait HeaderBackend: Send + Sync { /// Get block header. Returns `None` if block is not found. fn header(&self, id: BlockId) -> Result>; /// Get blockchain info. - fn info(&self) -> Result>; + fn info(&self) -> Info; /// Get block status. fn status(&self, id: BlockId) -> Result; /// Get block number by hash. Returns `None` if the header is not in the chain. diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 1f19b96d3c..0d8f8aa548 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -497,7 +497,7 @@ impl Client where if first > last_num { return Err(error::Error::ChangesTrieAccessFailed("Invalid changes trie range".into())); } - let finalized_number = self.backend.blockchain().info()?.finalized_number; + let finalized_number = self.backend.blockchain().info().finalized_number; let oldest = storage.oldest_changes_trie_block(&config, finalized_number); let first = ::std::cmp::max(first, oldest); Ok(Some((first, last))) @@ -523,7 +523,7 @@ impl Client where hash: convert_hash(&last_hash), number: last_number, }, - self.backend.blockchain().info()?.best_number, + self.backend.blockchain().info().best_number, &key.0) .and_then(|r| r.map(|r| r.map(|(block, tx)| (block, tx))).collect::>()) .map_err(|err| error::Error::ChangesTrieAccessFailed(err)) @@ -608,7 +608,7 @@ impl Client where }; let max_number = ::std::cmp::min( - self.backend.blockchain().info()?.best_number, + self.backend.blockchain().info().best_number, self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(max))?, ); @@ -879,7 +879,7 @@ impl Client where } let (last_best, last_best_number) = { - let info = self.backend.blockchain().info()?; + let info = self.backend.blockchain().info(); (info.best_hash, info.best_number) }; @@ -1152,7 +1152,7 @@ impl Client where justification: Option, notify: bool, ) -> error::Result<()> { - let last_best = self.backend.blockchain().info()?.best_hash; + let last_best = self.backend.blockchain().info().best_hash; let to_finalize_hash = self.backend.blockchain().expect_block_hash_from_id(&id)?; self.apply_finality_with_block_hash(operation, to_finalize_hash, justification, last_best, notify) } @@ -1165,7 +1165,7 @@ impl Client where /// while performing major synchronization work. pub fn finalize_block(&self, id: BlockId, justification: Option, notify: bool) -> error::Result<()> { self.lock_import_and_run(|operation| { - let last_best = self.backend.blockchain().info()?.best_hash; + let last_best = self.backend.blockchain().info().best_hash; let to_finalize_hash = self.backend.blockchain().expect_block_hash_from_id(&id)?; self.apply_finality_with_block_hash(operation, to_finalize_hash, justification, last_best, notify) }) @@ -1178,13 +1178,13 @@ impl Client where } /// Get blockchain info. - pub fn info(&self) -> error::Result> { - let info = self.backend.blockchain().info().map_err(|e| error::Error::from_blockchain(Box::new(e)))?; - Ok(ClientInfo { + pub fn info(&self) -> ClientInfo { + let info = self.backend.blockchain().info(); + ClientInfo { chain: info, best_queued_hash: None, best_queued_number: None, - }) + } } /// Get block status. @@ -1246,7 +1246,7 @@ impl Client where } }; - let genesis_hash = self.backend.blockchain().info()?.genesis_hash; + let genesis_hash = self.backend.blockchain().info().genesis_hash; if genesis_hash == target_hash { return Ok(Vec::new()); } let mut current_hash = target_hash; @@ -1269,7 +1269,7 @@ impl Client where } fn changes_trie_config(&self) -> Result, Error> { - Ok(self.backend.state_at(BlockId::Number(self.backend.blockchain().info()?.best_number))? + Ok(self.backend.state_at(BlockId::Number(self.backend.blockchain().info().best_number))? .storage(well_known_keys::CHANGES_TRIE_CONFIG) .map_err(|e| error::Error::from_state(Box::new(e)))? .and_then(|c| Decode::decode(&mut &*c))) @@ -1298,7 +1298,7 @@ impl ChainHeaderBackend for Client wher self.backend.blockchain().header(id) } - fn info(&self) -> error::Result> { + fn info(&self) -> blockchain::Info { self.backend.blockchain().info() } @@ -1448,7 +1448,7 @@ impl CurrentHeight for Client where { type BlockNumber = ::Number; fn current_height(&self) -> Self::BlockNumber { - self.backend.blockchain().info().map(|i| i.best_number).unwrap_or_else(|_| Zero::zero()) + self.backend.blockchain().info().best_number } } @@ -1524,10 +1524,7 @@ where } fn best_block_header(&self) -> error::Result<::Header> { - let info : ChainInfo = match self.backend.blockchain().info() { - Ok(i) => i, - Err(e) => return Err(error::Error::from_blockchain(Box::new(e))) - }; + let info : ChainInfo = self.backend.blockchain().info(); Ok(self.backend.blockchain().header(BlockId::Hash(info.best_hash))? .expect("Best block header must always exist")) } @@ -1569,7 +1566,7 @@ where // we depend on the canonical chain staying the same during this code block. let _import_lock = self.import_lock.lock(); - let info = self.backend.blockchain().info()?; + let info = self.backend.blockchain().info(); let canon_hash = self.backend.blockchain().hash(*target_header.number())? .ok_or_else(|| error::Error::from(format!("failed to get hash for block number {}", target_header.number())))?; @@ -1816,14 +1813,14 @@ pub(crate) mod tests { assert_eq!( client.runtime_api().balance_of( - &BlockId::Number(client.info().unwrap().chain.best_number), + &BlockId::Number(client.info().chain.best_number), AccountKeyring::Alice.into() ).unwrap(), 1000 ); assert_eq!( client.runtime_api().balance_of( - &BlockId::Number(client.info().unwrap().chain.best_number), + &BlockId::Number(client.info().chain.best_number), AccountKeyring::Ferdie.into() ).unwrap(), 0 @@ -1838,7 +1835,7 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); - assert_eq!(client.info().unwrap().chain.best_number, 1); + assert_eq!(client.info().chain.best_number, 1); } #[test] @@ -1856,18 +1853,18 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); - assert_eq!(client.info().unwrap().chain.best_number, 1); + assert_eq!(client.info().chain.best_number, 1); assert!(client.state_at(&BlockId::Number(1)).unwrap().pairs() != client.state_at(&BlockId::Number(0)).unwrap().pairs()); assert_eq!( client.runtime_api().balance_of( - &BlockId::Number(client.info().unwrap().chain.best_number), + &BlockId::Number(client.info().chain.best_number), AccountKeyring::Alice.into() ).unwrap(), 958 ); assert_eq!( client.runtime_api().balance_of( - &BlockId::Number(client.info().unwrap().chain.best_number), + &BlockId::Number(client.info().chain.best_number), AccountKeyring::Ferdie.into() ).unwrap(), 42 @@ -1896,7 +1893,7 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); - assert_eq!(client.info().unwrap().chain.best_number, 1); + assert_eq!(client.info().chain.best_number, 1); assert!(client.state_at(&BlockId::Number(1)).unwrap().pairs() != client.state_at(&BlockId::Number(0)).unwrap().pairs()); assert_eq!(client.body(&BlockId::Number(1)).unwrap().unwrap().len(), 1) } @@ -1908,7 +1905,7 @@ pub(crate) mod tests { let client = test_client::new(); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( client.backend().clone(), @@ -2029,7 +2026,7 @@ pub(crate) mod tests { let d2 = builder.bake().unwrap(); client.import(BlockOrigin::Own, d2.clone()).unwrap(); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; let uncles1 = client.uncles(a4.hash(), 10).unwrap(); assert_eq!(vec![b2.hash(), d2.hash()], uncles1); @@ -2065,7 +2062,7 @@ pub(crate) mod tests { let a2 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(client.backend().as_in_memory()), @@ -2152,9 +2149,9 @@ pub(crate) mod tests { let d2 = builder.bake().unwrap(); client.import(BlockOrigin::Own, d2.clone()).unwrap(); - assert_eq!(client.info().unwrap().chain.best_hash, a5.hash()); + assert_eq!(client.info().chain.best_hash, a5.hash()); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(client.backend().as_in_memory()), @@ -2385,7 +2382,7 @@ pub(crate) mod tests { let a2 = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, a2.clone()).unwrap(); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; #[allow(deprecated)] let longest_chain_select = test_client::client::LongestChain::new( Arc::new(client.backend().as_in_memory()), diff --git a/core/client/src/in_mem.rs b/core/client/src/in_mem.rs index 1172939b34..6c11d0ed57 100644 --- a/core/client/src/in_mem.rs +++ b/core/client/src/in_mem.rs @@ -297,15 +297,15 @@ impl HeaderBackend for Blockchain { })) } - fn info(&self) -> error::Result> { + fn info(&self) -> blockchain::Info { let storage = self.storage.read(); - Ok(blockchain::Info { + blockchain::Info { best_hash: storage.best_hash, best_number: storage.best_number, genesis_hash: storage.genesis_hash, finalized_hash: storage.finalized_hash, finalized_number: storage.finalized_number, - }) + } } fn status(&self, id: BlockId) -> error::Result { diff --git a/core/client/src/light/blockchain.rs b/core/client/src/light/blockchain.rs index b231f7e8aa..62c13db5a4 100644 --- a/core/client/src/light/blockchain.rs +++ b/core/client/src/light/blockchain.rs @@ -134,7 +134,7 @@ impl BlockchainHeaderBackend for Blockchain where Bloc } } - fn info(&self) -> ClientResult> { + fn info(&self) -> BlockchainInfo { self.storage.info() } @@ -223,8 +223,8 @@ pub mod tests { Err(ClientError::Backend("Test error".into())) } - fn info(&self) -> ClientResult> { - Err(ClientError::Backend("Test error".into())) + fn info(&self) -> Info { + panic!("Test error") } fn status(&self, _id: BlockId) -> ClientResult { diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index 0a8a05b850..f25a2acd30 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -668,8 +668,8 @@ pub mod tests { test_client::LocalExecutor::new(None) ); let local_checker = &local_checker as &FetchChecker; - let max = remote_client.info().unwrap().chain.best_number; - let max_hash = remote_client.info().unwrap().chain.best_hash; + let max = remote_client.info().chain.best_number; + let max_hash = remote_client.info().chain.best_hash; for (index, (begin, end, key, expected_result)) in test_cases.into_iter().enumerate() { let begin_hash = remote_client.block_hash(begin).unwrap().unwrap(); @@ -764,8 +764,8 @@ pub mod tests { test_client::LocalExecutor::new(None) ); let local_checker = &local_checker as &FetchChecker; - let max = remote_client.info().unwrap().chain.best_number; - let max_hash = remote_client.info().unwrap().chain.best_hash; + let max = remote_client.info().chain.best_number; + let max_hash = remote_client.info().chain.best_hash; let (begin, end, key, _) = test_cases[0].clone(); let begin_hash = remote_client.block_hash(begin).unwrap().unwrap(); diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 36c51c8cff..263381d5f1 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -943,7 +943,7 @@ mod tests { fn authorities_call_works() { let client = test_client::new(); - assert_eq!(client.info().unwrap().chain.best_number, 0); + assert_eq!(client.info().chain.best_number, 0); assert_eq!(authorities(&client, &BlockId::Number(0)).unwrap(), vec![ Keyring::Alice.into(), Keyring::Bob.into(), diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 81b4be4137..969c7b8593 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -1058,7 +1058,7 @@ mod tests { drop(env_logger::try_init()); let client = test_client::new(); - assert_eq!(client.info().unwrap().chain.best_number, 0); + assert_eq!(client.info().chain.best_number, 0); assert_eq!(authorities(&client, &BlockId::Number(0)).unwrap(), vec![ Keyring::Alice.into(), Keyring::Bob.into(), diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index ed50629f47..4aab32be8a 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -662,7 +662,7 @@ where #[allow(deprecated)] let blockchain = self.inner.backend().blockchain(); - let status = blockchain.info()?; + let status = blockchain.info(); if number <= status.finalized_number && blockchain.hash(number)? == Some(hash) { // This can happen after a forced change (triggered by the finality tracker when finality is stalled), since // the voter will be restarted at the median last finalized block, which can be lower than the local best @@ -812,7 +812,7 @@ pub(crate) fn finalize_block, E, RA>( // finalization to remote nodes if !justification_required { if let Some(justification_period) = justification_period { - let last_finalized_number = client.info()?.chain.finalized_number; + let last_finalized_number = client.info().chain.finalized_number; justification_required = (!last_finalized_number.is_zero() || number - last_finalized_number == justification_period) && (last_finalized_number / justification_period != number / justification_period); diff --git a/core/finality-grandpa/src/finality_proof.rs b/core/finality-grandpa/src/finality_proof.rs index 4ad1844358..e8af599279 100644 --- a/core/finality-grandpa/src/finality_proof.rs +++ b/core/finality-grandpa/src/finality_proof.rs @@ -268,7 +268,7 @@ pub(crate) fn prove_finality, B: BlockchainBackend, RA, PRA, SC> JustificationImport type Error = ConsensusError; fn on_start(&self, link: &::consensus_common::import_queue::Link) { - let chain_info = match self.inner.info() { - Ok(info) => info.chain, - _ => return, - }; + let chain_info = self.inner.info().chain; // request justifications for all pending changes for which change blocks have already been imported let authorities = self.authority_set.inner().read(); @@ -320,7 +317,6 @@ where #[allow(deprecated)] let best_finalized_number = self.inner.backend().blockchain().info() - .map_err(|e| ConsensusError::ClientImport(e.to_string()))? .finalized_number; let canon_number = best_finalized_number.min(median_last_finalized_number); diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index aee6c16d13..2a1da15499 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -316,7 +316,7 @@ where { use runtime_primitives::traits::Zero; - let chain_info = client.info()?; + let chain_info = client.info(); let genesis_hash = chain_info.chain.genesis_hash; let persistent_data = aux_schema::load_persistent( @@ -431,15 +431,13 @@ fn register_finality_tracker_inherent_data_provider Err(std::borrow::Cow::Owned(e.to_string())), - Ok(info) => { - telemetry!(CONSENSUS_INFO; "afg.finalized"; - "finalized_number" => ?info.finalized_number, - "finalized_hash" => ?info.finalized_hash, - ); - Ok(info.finalized_number) - }, + { + let info = client.backend().blockchain().info(); + telemetry!(CONSENSUS_INFO; "afg.finalized"; + "finalized_number" => ?info.finalized_number, + "finalized_hash" => ?info.finalized_hash, + ); + Ok(info.finalized_number) } })) .map_err(|err| consensus_common::Error::InherentData(err.into())) @@ -579,10 +577,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( let mut maybe_voter = match &*env.voter_set_state.read() { VoterSetState::Live { completed_rounds, .. } => { - let chain_info = match client.info() { - Ok(i) => i, - Err(e) => return future::Either::B(future::err(Error::Client(e))), - }; + let chain_info = client.info(); let last_finalized = ( chain_info.chain.finalized_hash, @@ -691,7 +686,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( } }; - future::Either::A(poll_voter.select2(voter_commands_rx).then(move |res| match res { + poll_voter.select2(voter_commands_rx).then(move |res| match res { Ok(future::Either::A(((), _))) => { // voters don't conclude naturally; this could reasonably be an error. Ok(FutureLoop::Break(())) @@ -716,7 +711,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( // some command issued internally. handle_voter_command(command, voter_commands_rx) }, - })) + }) }); let voter_work = voter_work diff --git a/core/finality-grandpa/src/light_import.rs b/core/finality-grandpa/src/light_import.rs index 9e257e9ccc..73bc3411fe 100644 --- a/core/finality-grandpa/src/light_import.rs +++ b/core/finality-grandpa/src/light_import.rs @@ -63,7 +63,7 @@ pub fn light_block_import, RA, PRA>( PRA: ProvideRuntimeApi, PRA::Api: GrandpaApi, { - let info = client.info()?; + let info = client.info(); #[allow(deprecated)] let import_data = load_aux_import_data(info.chain.finalized_hash, &**client.backend(), api)?; Ok(GrandpaLightBlockImport { @@ -145,10 +145,7 @@ impl, RA> FinalityProofImport type Error = ConsensusError; fn on_start(&self, link: &::consensus_common::import_queue::Link) { - let chain_info = match self.client.info() { - Ok(info) => info.chain, - _ => return, - }; + let chain_info = self.client.info().chain; let data = self.data.read(); for (pending_number, pending_hash) in data.consensus_changes.pending_changes() { @@ -620,7 +617,7 @@ pub mod tests { origin: BlockOrigin::Own, header: Header { number: 1, - parent_hash: client.info().unwrap().chain.best_hash, + parent_hash: client.info().chain.best_hash, state_root: Default::default(), digest: Default::default(), extrinsics_root: Default::default(), diff --git a/core/finality-grandpa/src/observer.rs b/core/finality-grandpa/src/observer.rs index 3fc9665a8d..f172e58ee9 100644 --- a/core/finality-grandpa/src/observer.rs +++ b/core/finality-grandpa/src/observer.rs @@ -31,7 +31,7 @@ use substrate_primitives::{ed25519::Public as AuthorityId, H256, Blake2Hasher}; use crate::{ AuthoritySignature, global_communication, CommandOrError, Config, environment, - Error, LinkHalf, Network, aux_schema::PersistentData, VoterCommand, VoterSetState, + LinkHalf, Network, aux_schema::PersistentData, VoterCommand, VoterSetState, }; use crate::authorities::SharedAuthoritySet; use crate::communication::NetworkBridge; @@ -191,12 +191,7 @@ pub fn run_grandpa_observer, N, RA, SC>( &network, ); - let chain_info = match client.info() { - Ok(i) => i, - Err(e) => return future::Either::B(future::err(Error::Client(e))), - }; - - let last_finalized_number = chain_info.chain.finalized_number; + let last_finalized_number = client.info().chain.finalized_number; // create observer for the current set let observer = grandpa_observer( @@ -250,7 +245,7 @@ pub fn run_grandpa_observer, N, RA, SC>( }; // run observer and listen to commands (switch authorities or pause) - future::Either::A(observer.select2(voter_commands_rx).then(move |res| match res { + observer.select2(voter_commands_rx).then(move |res| match res { Ok(future::Either::A((_, _))) => { // observer commit stream doesn't conclude naturally; this could reasonably be an error. Ok(FutureLoop::Break(())) @@ -275,7 +270,7 @@ pub fn run_grandpa_observer, N, RA, SC>( // some command issued internally handle_voter_command(command, voter_commands_rx) }, - })) + }) }); let observer_work = observer_work diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 5b4fa9155a..ef04396b5f 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -561,7 +561,7 @@ fn finalize_3_voters_no_observers() { net.sync(); for i in 0..3 { - assert_eq!(net.peer(i).client().info().unwrap().chain.best_number, 20, + assert_eq!(net.peer(i).client().info().chain.best_number, 20, "Peer #{} failed to sync", i); } @@ -673,7 +673,7 @@ fn transition_3_voters_twice_1_full_observer() { for (i, peer) in net.lock().peers().iter().enumerate() { let full_client = peer.client().as_full().expect("only full clients are used in test"); - assert_eq!(full_client.info().unwrap().chain.best_number, 1, + assert_eq!(full_client.info().chain.best_number, 1, "Peer #{} failed to sync", i); let set: AuthoritySet = crate::aux_schema::load_authorities( @@ -895,7 +895,7 @@ fn sync_justifications_on_change_blocks() { net.sync(); for i in 0..4 { - assert_eq!(net.peer(i).client().info().unwrap().chain.best_number, 25, + assert_eq!(net.peer(i).client().info().chain.best_number, 25, "Peer #{} failed to sync", i); } @@ -966,7 +966,7 @@ fn finalizes_multiple_pending_changes_in_order() { // all peers imported both change blocks for i in 0..6 { - assert_eq!(net.peer(i).client().info().unwrap().chain.best_number, 30, + assert_eq!(net.peer(i).client().info().chain.best_number, 30, "Peer #{} failed to sync", i); } @@ -986,7 +986,7 @@ fn doesnt_vote_on_the_tip_of_the_chain() { net.sync(); for i in 0..3 { - assert_eq!(net.peer(i).client().info().unwrap().chain.best_number, 100, + assert_eq!(net.peer(i).client().info().chain.best_number, 100, "Peer #{} failed to sync", i); } @@ -1016,7 +1016,7 @@ fn force_change_to_new_set() { { // add a forced transition at block 12. - let parent_hash = net.lock().peer(0).client().info().unwrap().chain.best_hash; + let parent_hash = net.lock().peer(0).client().info().chain.best_hash; forced_transitions.lock().insert(parent_hash, (0, ScheduledChange { next_authorities: voters.clone(), delay: 10, @@ -1033,7 +1033,7 @@ fn force_change_to_new_set() { net.lock().sync(); for (i, peer) in net.lock().peers().iter().enumerate() { - assert_eq!(peer.client().info().unwrap().chain.best_number, 26, + assert_eq!(peer.client().info().chain.best_number, 26, "Peer #{} failed to sync", i); let full_client = peer.client().as_full().expect("only full clients are used in test"); @@ -1172,7 +1172,7 @@ fn voter_persists_its_votes() { net.peer(0).push_blocks(20, false); net.sync(); - assert_eq!(net.peer(0).client().info().unwrap().chain.best_number, 20, + assert_eq!(net.peer(0).client().info().chain.best_number, 20, "Peer #{} failed to sync", 0); let mut runtime = current_thread::Runtime::new().unwrap(); @@ -1289,7 +1289,7 @@ fn voter_persists_its_votes() { net.lock().peer(0).push_blocks(20, false); net.lock().sync(); - assert_eq!(net.lock().peer(0).client().info().unwrap().chain.best_number, 40, + assert_eq!(net.lock().peer(0).client().info().chain.best_number, 40, "Peer #{} failed to sync", 0); #[allow(deprecated)] @@ -1366,7 +1366,7 @@ fn finalize_3_voters_1_light_observer() { net.sync(); for i in 0..4 { - assert_eq!(net.peer(i).client().info().unwrap().chain.best_number, 20, + assert_eq!(net.peer(i).client().info().chain.best_number, 20, "Peer #{} failed to sync", i); } @@ -1412,7 +1412,7 @@ fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() { net.lock().sync_without_disconnects(); // check that the block#1 is finalized on light client - while net.lock().peer(1).client().info().unwrap().chain.finalized_number != 1 { + while net.lock().peer(1).client().info().chain.finalized_number != 1 { net.lock().tick_peer(1); net.lock().sync_without_disconnects(); } @@ -1455,7 +1455,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ // add a forced transition at block 5. if FORCE_CHANGE { - let parent_hash = net.lock().peer(0).client().info().unwrap().chain.best_hash; + let parent_hash = net.lock().peer(0).client().info().chain.best_hash; forced_transitions.lock().insert(parent_hash, (0, ScheduledChange { next_authorities: voters.clone(), delay: 3, @@ -1482,7 +1482,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ // check block, finalized on light client assert_eq!( - runner_net.lock().peer(3).client().info().unwrap().chain.finalized_number, + runner_net.lock().peer(3).client().info().chain.finalized_number, if FORCE_CHANGE { 0 } else { 10 }, ); } diff --git a/core/network/src/chain.rs b/core/network/src/chain.rs index f7ce4f9d5c..76096a44aa 100644 --- a/core/network/src/chain.rs +++ b/core/network/src/chain.rs @@ -28,7 +28,7 @@ use primitives::{H256, Blake2Hasher, storage::StorageKey}; /// Local client abstraction for the network. pub trait Client: Send + Sync { /// Get blockchain info. - fn info(&self) -> Result, Error>; + fn info(&self) -> ClientInfo; /// Get block status. fn block_status(&self, id: &BlockId) -> Result; @@ -81,7 +81,7 @@ impl Client for SubstrateClient where Block: BlockT, RA: Send + Sync { - fn info(&self) -> Result, Error> { + fn info(&self) -> ClientInfo { (self as &SubstrateClient).info() } diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index e1fa38576a..b660e097a1 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -399,7 +399,7 @@ impl, H: ExHashT> Protocol { checker: Arc>, specialization: S, ) -> error::Result> { - let info = chain.info()?; + let info = chain.info(); let sync = ChainSync::new(config.roles, &info); Ok(Protocol { tick_timeout: tokio_timer::Interval::new_interval(TICK_TIMEOUT), @@ -861,8 +861,7 @@ impl, H: ExHashT> Protocol { .context_data .chain .info() - .ok() - .and_then(|info| info.best_queued_number) + .best_queued_number .unwrap_or_else(|| Zero::zero()); let blocks_difference = self_best_block .checked_sub(&status.best_number) @@ -1008,18 +1007,18 @@ impl, H: ExHashT> Protocol { /// Send Status message fn send_status(&mut self, network_out: &mut dyn NetworkOut, who: PeerId) { - if let Ok(info) = self.context_data.chain.info() { - let status = message::generic::Status { - version: CURRENT_VERSION, - min_supported_version: MIN_VERSION, - genesis_hash: info.chain.genesis_hash, - roles: self.config.roles.into(), - best_number: info.chain.best_number, - best_hash: info.chain.best_hash, - chain_status: self.specialization.status(), - }; - self.send_message(network_out, who, GenericMessage::Status(status)) - } + let info = self.context_data.chain.info(); + let status = message::generic::Status { + version: CURRENT_VERSION, + min_supported_version: MIN_VERSION, + genesis_hash: info.chain.genesis_hash, + roles: self.config.roles.into(), + best_number: info.chain.best_number, + best_hash: info.chain.best_hash, + chain_status: self.specialization.status(), + }; + + self.send_message(network_out, who, GenericMessage::Status(status)) } fn on_block_announce( diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index e451372847..27a412ca0e 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -829,18 +829,10 @@ impl ChainSync { self.queue_blocks.clear(); self.best_importing_number = Zero::zero(); self.blocks.clear(); - match protocol.client().info() { - Ok(info) => { - self.best_queued_hash = info.best_queued_hash.unwrap_or(info.chain.best_hash); - self.best_queued_number = info.best_queued_number.unwrap_or(info.chain.best_number); - debug!(target:"sync", "Restarted with {} ({})", self.best_queued_number, self.best_queued_hash); - }, - Err(e) => { - debug!(target:"sync", "Error reading blockchain: {:?}", e); - self.best_queued_hash = self.genesis_hash; - self.best_queued_number = Zero::zero(); - } - } + let info = protocol.client().info(); + self.best_queued_hash = info.best_queued_hash.unwrap_or(info.chain.best_hash); + self.best_queued_number = info.best_queued_number.unwrap_or(info.chain.best_number); + debug!(target:"sync", "Restarted with {} ({})", self.best_queued_number, self.best_queued_hash); let ids: Vec = self.peers.drain().map(|(id, _)| id).collect(); for id in ids { self.new_peer(protocol, id); diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 6103a6ecd9..b47cef11ac 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -163,7 +163,7 @@ impl PeersClient { } } - pub fn info(&self) -> ClientResult> { + pub fn info(&self) -> ClientInfo { match *self { PeersClient::Full(ref client) => client.info(), PeersClient::Light(ref client) => client.info(), @@ -465,7 +465,7 @@ impl> Peer { /// Called after blockchain has been populated to updated current state. fn start(&self) { // Update the sync state to the latest chain state. - let info = self.client.info().expect("In-mem client does not fail"); + let info = self.client.info(); let header = self .client .header(&BlockId::Hash(info.chain.best_hash)) @@ -538,7 +538,7 @@ impl> Peer { /// Send block import notifications. fn send_import_notifications(&self) { - let info = self.client.info().expect("In-mem client does not fail"); + let info = self.client.info(); let mut best_hash = self.best_hash.lock(); match *best_hash { @@ -554,7 +554,7 @@ impl> Peer { /// Send block finalization notifications. fn send_finality_notifications(&self) { - let info = self.client.info().expect("In-mem client does not fail"); + let info = self.client.info(); let mut finalized_hash = self.finalized_hash.lock(); match *finalized_hash { @@ -625,7 +625,7 @@ impl> Peer { pub fn generate_blocks(&self, count: usize, origin: BlockOrigin, edit_block: F) -> H256 where F: FnMut(BlockBuilder) -> Block { - let best_hash = self.client.info().unwrap().chain.best_hash; + let best_hash = self.client.info().chain.best_hash; self.generate_blocks_at(BlockId::Hash(best_hash), count, origin, edit_block) } @@ -674,7 +674,7 @@ impl> Peer { /// Push blocks to the peer (simplified: with or without a TX) pub fn push_blocks(&self, count: usize, with_tx: bool) -> H256 { - let best_hash = self.client.info().unwrap().chain.best_hash; + let best_hash = self.client.info().chain.best_hash; self.push_blocks_at(BlockId::Hash(best_hash), count, with_tx) } diff --git a/core/network/src/test/sync.rs b/core/network/src/test/sync.rs index 50b00ac62a..1e9e2948f3 100644 --- a/core/network/src/test/sync.rs +++ b/core/network/src/test/sync.rs @@ -320,8 +320,8 @@ fn own_blocks_are_announced() { net.peer(0).on_block_imported(header.hash(), &header); net.sync(); - assert_eq!(net.peer(0).client.as_in_memory_backend().blockchain().info().unwrap().best_number, 1); - assert_eq!(net.peer(1).client.as_in_memory_backend().blockchain().info().unwrap().best_number, 1); + assert_eq!(net.peer(0).client.as_in_memory_backend().blockchain().info().best_number, 1); + assert_eq!(net.peer(1).client.as_in_memory_backend().blockchain().info().best_number, 1); let peer0_chain = net.peer(0).client.as_in_memory_backend().blockchain().clone(); assert!(net.peer(1).client.as_in_memory_backend().blockchain().canon_equals_to(&peer0_chain)); assert!(net.peer(2).client.as_in_memory_backend().blockchain().canon_equals_to(&peer0_chain)); @@ -356,9 +356,9 @@ fn blocks_are_not_announced_by_light_nodes() { // peer 0 has the best chain // peer 1 has the best chain // peer 2 has genesis-chain only - assert_eq!(net.peer(0).client.info().unwrap().chain.best_number, 1); - assert_eq!(net.peer(1).client.info().unwrap().chain.best_number, 1); - assert_eq!(net.peer(2).client.info().unwrap().chain.best_number, 0); + assert_eq!(net.peer(0).client.info().chain.best_number, 1); + assert_eq!(net.peer(1).client.info().chain.best_number, 1); + assert_eq!(net.peer(2).client.info().chain.best_number, 0); } #[test] @@ -371,13 +371,13 @@ fn can_sync_small_non_best_forks() { // small fork + reorg on peer 1. net.peer(0).push_blocks_at(BlockId::Number(30), 2, true); - let small_hash = net.peer(0).client().info().unwrap().chain.best_hash; + let small_hash = net.peer(0).client().info().chain.best_hash; net.peer(0).push_blocks_at(BlockId::Number(30), 10, false); - assert_eq!(net.peer(0).client().info().unwrap().chain.best_number, 40); + assert_eq!(net.peer(0).client().info().chain.best_number, 40); // peer 1 only ever had the long fork. net.peer(1).push_blocks(10, false); - assert_eq!(net.peer(1).client().info().unwrap().chain.best_number, 40); + assert_eq!(net.peer(1).client().info().chain.best_number, 40); assert!(net.peer(0).client().header(&BlockId::Hash(small_hash)).unwrap().is_some()); assert!(net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_none()); @@ -386,7 +386,7 @@ fn can_sync_small_non_best_forks() { // synchronization: 0 synced to longer chain and 1 didn't sync to small chain. - assert_eq!(net.peer(0).client().info().unwrap().chain.best_number, 40); + assert_eq!(net.peer(0).client().info().chain.best_number, 40); assert!(net.peer(0).client().header(&BlockId::Hash(small_hash)).unwrap().is_some()); assert!(!net.peer(1).client().header(&BlockId::Hash(small_hash)).unwrap().is_some()); @@ -416,8 +416,8 @@ fn can_not_sync_from_light_peer() { net.sync(); // ensure #0 && #1 have the same best block - let full0_info = net.peer(0).client.info().unwrap().chain; - let light_info = net.peer(1).client.info().unwrap().chain; + let full0_info = net.peer(0).client.info().chain; + let light_info = net.peer(1).client.info().chain; assert_eq!(full0_info.best_number, 1); assert_eq!(light_info.best_number, 1); assert_eq!(light_info.best_hash, full0_info.best_hash); @@ -430,7 +430,7 @@ fn can_not_sync_from_light_peer() { net.sync_with(true, Some(vec![0].into_iter().collect())); // ensure that the #2 has failed to sync block #1 - assert_eq!(net.peer(2).client.info().unwrap().chain.best_number, 0); + assert_eq!(net.peer(2).client.info().chain.best_number, 0); // and that the #1 is still connected to #2 // (because #2 has not tried to fetch block data from the #1 light node) assert_eq!(net.peer(1).protocol_status().num_peers, 2); diff --git a/core/rpc/src/author/mod.rs b/core/rpc/src/author/mod.rs index 59641e8466..4e3bc96ca9 100644 --- a/core/rpc/src/author/mod.rs +++ b/core/rpc/src/author/mod.rs @@ -110,7 +110,7 @@ impl AuthorApi, BlockHash

> for Author whe fn submit_extrinsic(&self, ext: Bytes) -> Result> { let xt = Decode::decode(&mut &ext[..]).ok_or(error::Error::BadFormat)?; - let best_block_hash = self.client.info()?.chain.best_hash; + let best_block_hash = self.client.info().chain.best_hash; self.pool .submit_one(&generic::BlockId::hash(best_block_hash), xt) .map_err(|e| e.into_pool_error() @@ -144,7 +144,7 @@ impl AuthorApi, BlockHash

> for Author whe fn watch_extrinsic(&self, _metadata: Self::Metadata, subscriber: Subscriber, BlockHash

>>, xt: Bytes) { let submit = || -> Result<_> { - let best_block_hash = self.client.info()?.chain.best_hash; + let best_block_hash = self.client.info().chain.best_hash; let dxt = <

::Block as traits::Block>::Extrinsic::decode(&mut &xt[..]) .ok_or(error::Error::BadFormat)?; self.pool diff --git a/core/rpc/src/chain/mod.rs b/core/rpc/src/chain/mod.rs index 9dd7ad84b8..90c833e3fd 100644 --- a/core/rpc/src/chain/mod.rs +++ b/core/rpc/src/chain/mod.rs @@ -124,7 +124,7 @@ impl Chain where { fn unwrap_or_best(&self, hash: Option) -> Result { Ok(match hash.into() { - None => self.client.info()?.chain.best_hash, + None => self.client.info().chain.best_hash, Some(hash) => hash, }) } @@ -188,13 +188,13 @@ impl ChainApi, Block::Hash, Block::Header, Sig fn block_hash(&self, number: Option>>) -> Result> { Ok(match number { - None => Some(self.client.info()?.chain.best_hash), + None => Some(self.client.info().chain.best_hash), Some(num_or_hex) => self.client.header(&BlockId::number(num_or_hex.to_number()?))?.map(|h| h.hash()), }) } fn finalized_head(&self) -> Result { - Ok(self.client.info()?.chain.finalized_hash) + Ok(self.client.info().chain.finalized_hash) } fn subscribe_new_head(&self, _metadata: Self::Metadata, subscriber: Subscriber) { @@ -214,7 +214,7 @@ impl ChainApi, Block::Hash, Block::Header, Sig fn subscribe_finalized_heads(&self, _meta: Self::Metadata, subscriber: Subscriber) { self.subscribe_headers( subscriber, - || Ok(Some(self.client.info()?.chain.finalized_hash)), + || Ok(Some(self.client.info().chain.finalized_hash)), || self.client.finality_notification_stream() .map(|notification| notification.header), ) diff --git a/core/rpc/src/state/mod.rs b/core/rpc/src/state/mod.rs index 98d62d678d..ebb45d6b5f 100644 --- a/core/rpc/src/state/mod.rs +++ b/core/rpc/src/state/mod.rs @@ -322,7 +322,7 @@ impl State where E: CallExecutor, { fn unwrap_or_best(&self, hash: Option) -> Result { - crate::helpers::unwrap_or_else(|| Ok(self.client.info()?.chain.best_hash), hash) + crate::helpers::unwrap_or_else(|| Ok(self.client.info().chain.best_hash), hash) } } @@ -449,7 +449,7 @@ impl StateApi for State where // initial values let initial = stream::iter_result(keys .map(|keys| { - let block = self.client.info().map(|info| info.chain.best_hash).unwrap_or_default(); + let block = self.client.info().chain.best_hash; let changes = keys .into_iter() .map(|key| self.storage(key.clone(), Some(block.clone()).into()) @@ -506,9 +506,9 @@ impl StateApi for State where let stream = stream .map_err(|e| warn!("Error creating storage notification stream: {:?}", e)) .filter_map(move |_| { - let version = client.info().and_then(|info| { - client.runtime_version_at(&BlockId::hash(info.chain.best_hash)) - }) + let info = client.info(); + let version = client + .runtime_version_at(&BlockId::hash(info.chain.best_hash)) .map_err(error::Error::from) .map_err(Into::into); if previous_version != version { diff --git a/core/service/src/chain_ops.rs b/core/service/src/chain_ops.rs index 4df3b06cdf..3be3b9b17a 100644 --- a/core/service/src/chain_ops.rs +++ b/core/service/src/chain_ops.rs @@ -52,7 +52,7 @@ pub fn export_blocks( let last = match to { Some(v) if v.is_zero() => One::one(), Some(v) => v, - None => client.info()?.chain.best_number, + None => client.info().chain.best_number, }; if last < block { @@ -186,7 +186,7 @@ pub fn import_blocks( blocks_imported += 1; } - info!("Imported {} blocks. Best: #{}", block_count, client.info()?.chain.best_number); + info!("Imported {} blocks. Best: #{}", block_count, client.info().chain.best_number); Ok(()) } @@ -200,7 +200,7 @@ pub fn revert_chain( { let client = new_client::(&config)?; let reverted = client.revert(blocks)?; - let info = client.info()?.chain; + let info = client.info().chain; if reverted.is_zero() { info!("There aren't any non-finalized blocks to revert."); diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index cb65ece34e..0e16d2e7be 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -156,7 +156,7 @@ impl Service { select_chain.clone(), )?); let finality_proof_provider = Components::build_finality_proof_provider(client.clone())?; - let chain_info = client.info()?.chain; + let chain_info = client.info().chain; let version = config.full_version(); info!("Highest known block at #{}", chain_info.best_number); @@ -479,12 +479,7 @@ pub struct TransactionPoolAdapter { impl TransactionPoolAdapter { fn best_block_id(&self) -> Option>> { - self.client.info() - .map(|info| BlockId::hash(info.chain.best_hash)) - .map_err(|e| { - debug!("Error getting best block: {:?}", e); - }) - .ok() + Some(BlockId::hash(self.client.info().chain.best_hash)) } } diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index 88425e1956..9b73cfa14c 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -250,11 +250,11 @@ where service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| - service.client().info().unwrap().chain.best_number == NUM_BLOCKS.into() + service.client().info().chain.best_number == NUM_BLOCKS.into() ); info!("Checking extrinsic propagation"); let first_service = network.full_nodes[0].1.clone(); - let best_block = BlockId::number(first_service.client().info().unwrap().chain.best_number); + let best_block = BlockId::number(first_service.client().info().chain.best_number); first_service.transaction_pool().submit_one(&best_block, extrinsic_factory(&first_service)).unwrap(); network.run_until_all_full(|_index, service| service.transaction_pool().ready().count() == 1 @@ -278,7 +278,7 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| { - service.client().info().unwrap().chain.finalized_number >= (NUM_BLOCKS / 2).into() + service.client().info().chain.finalized_number >= (NUM_BLOCKS / 2).into() }); info!("Adding more peers"); network.insert_nodes(&temp, NUM_NODES / 2, 0, vec![]); @@ -286,6 +286,6 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } network.run_until_all_full(|_index, service| - service.client().info().unwrap().chain.finalized_number >= NUM_BLOCKS.into() + service.client().info().chain.finalized_number >= NUM_BLOCKS.into() ); } diff --git a/core/sr-api-macros/benches/bench.rs b/core/sr-api-macros/benches/bench.rs index f467721789..55399fb4d8 100644 --- a/core/sr-api-macros/benches/bench.rs +++ b/core/sr-api-macros/benches/bench.rs @@ -23,14 +23,14 @@ fn sr_api_benchmark(c: &mut Criterion) { c.bench_function("add one with same runtime api", |b| { let client = test_client::new(); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); b.iter(|| runtime_api.benchmark_add_one(&block_id, &1)) }); c.bench_function("add one with recreating runtime api", |b| { let client = test_client::new(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); b.iter(|| client.runtime_api().benchmark_add_one(&block_id, &1)) }); @@ -38,7 +38,7 @@ fn sr_api_benchmark(c: &mut Criterion) { c.bench_function("vector add one with same runtime api", |b| { let client = test_client::new(); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); let data = vec![0; 1000]; b.iter_with_large_drop(|| runtime_api.benchmark_vector_add_one(&block_id, &data)) @@ -46,7 +46,7 @@ fn sr_api_benchmark(c: &mut Criterion) { c.bench_function("vector add one with recreating runtime api", |b| { let client = test_client::new(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); let data = vec![0; 1000]; b.iter_with_large_drop(|| client.runtime_api().benchmark_vector_add_one(&block_id, &data)) @@ -54,13 +54,13 @@ fn sr_api_benchmark(c: &mut Criterion) { c.bench_function("calling function by function pointer in wasm", |b| { let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); b.iter(|| client.runtime_api().benchmark_indirect_call(&block_id).unwrap()) }); c.bench_function("calling function in wasm", |b| { let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); b.iter(|| client.runtime_api().benchmark_direct_call(&block_id).unwrap()) }); } diff --git a/core/sr-api-macros/tests/runtime_calls.rs b/core/sr-api-macros/tests/runtime_calls.rs index ff462d9e2a..f4d87ca8ca 100644 --- a/core/sr-api-macros/tests/runtime_calls.rs +++ b/core/sr-api-macros/tests/runtime_calls.rs @@ -34,7 +34,7 @@ use codec::Encode; fn calling_function_with_strat(strat: ExecutionStrategy) { let client = test_client::new_with_execution_strategy(strat); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.benchmark_add_one(&block_id, &1).unwrap(), 2); } @@ -54,7 +54,7 @@ fn calling_wasm_runtime_function() { fn calling_native_runtime_function_with_non_decodable_parameter() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); runtime_api.fail_convert_parameter(&block_id, DecodeFails::new()).unwrap(); } @@ -63,7 +63,7 @@ fn calling_native_runtime_function_with_non_decodable_parameter() { fn calling_native_runtime_function_with_non_decodable_return_value() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); runtime_api.fail_convert_return_value(&block_id).unwrap(); } @@ -71,7 +71,7 @@ fn calling_native_runtime_function_with_non_decodable_return_value() { fn calling_native_runtime_signature_changed_function() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.function_signature_changed(&block_id).unwrap(), 1); } @@ -80,7 +80,7 @@ fn calling_native_runtime_signature_changed_function() { fn calling_wasm_runtime_signature_changed_old_function() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); #[allow(deprecated)] let res = runtime_api.function_signature_changed_before_version_2(&block_id).unwrap(); @@ -91,7 +91,7 @@ fn calling_wasm_runtime_signature_changed_old_function() { fn calling_with_both_strategy_and_fail_on_wasm_should_return_error() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert!(runtime_api.fail_on_wasm(&block_id).is_err()); } @@ -99,7 +99,7 @@ fn calling_with_both_strategy_and_fail_on_wasm_should_return_error() { fn calling_with_both_strategy_and_fail_on_native_should_work() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1); } @@ -108,7 +108,7 @@ fn calling_with_both_strategy_and_fail_on_native_should_work() { fn calling_with_native_else_wasm_and_faild_on_wasm_should_work() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeElseWasm); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.fail_on_wasm(&block_id).unwrap(), 1); } @@ -116,7 +116,7 @@ fn calling_with_native_else_wasm_and_faild_on_wasm_should_work() { fn calling_with_native_else_wasm_and_fail_on_native_should_work() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeElseWasm); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1); } @@ -124,7 +124,7 @@ fn calling_with_native_else_wasm_and_fail_on_native_should_work() { fn use_trie_function() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.use_trie(&block_id).unwrap(), 2); } @@ -132,7 +132,7 @@ fn use_trie_function() { fn initialize_block_works() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.get_block_number(&block_id).unwrap(), 1); } @@ -140,7 +140,7 @@ fn initialize_block_works() { fn initialize_block_is_called_only_once() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.take_block_number(&block_id).unwrap(), Some(1)); assert_eq!(runtime_api.take_block_number(&block_id).unwrap(), None); } @@ -149,7 +149,7 @@ fn initialize_block_is_called_only_once() { fn initialize_block_is_skipped() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); let runtime_api = client.runtime_api(); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); assert!(runtime_api.without_initialize_block(&block_id).unwrap()); } @@ -157,7 +157,7 @@ fn initialize_block_is_skipped() { fn record_proof_works() { let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); - let block_id = BlockId::Number(client.info().unwrap().chain.best_number); + let block_id = BlockId::Number(client.info().chain.best_number); #[allow(deprecated)] let storage_root = LongestChain::new(client.backend().clone(), client.import_lock()) .best_chain().unwrap().state_root().clone(); diff --git a/core/test-client/src/trait_tests.rs b/core/test-client/src/trait_tests.rs index c1df6ffdf8..a7ef1a01f6 100644 --- a/core/test-client/src/trait_tests.rs +++ b/core/test-client/src/trait_tests.rs @@ -43,7 +43,7 @@ pub fn test_leaves_for_backend(backend: Arc) where let client = new_with_backend(backend.clone(), false); let blockchain = backend.blockchain(); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; assert_eq!( blockchain.leaves().unwrap(), @@ -223,7 +223,7 @@ pub fn test_children_for_backend(backend: Arc) where let d2 = builder.bake().unwrap(); client.import(BlockOrigin::Own, d2.clone()).unwrap(); - let genesis_hash = client.info().unwrap().chain.genesis_hash; + let genesis_hash = client.info().chain.genesis_hash; let children1 = blockchain.children(a4.hash()).unwrap(); assert_eq!(vec![a5.hash()], children1); @@ -313,7 +313,7 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc = vec![&*alice, &*bob]; let dummy_runtime = ::tokio::runtime::Runtime::new().unwrap(); let block_factory = |service: &::FullService| { - let block_id = BlockId::number(service.client().info().unwrap().chain.best_number); + let block_id = BlockId::number(service.client().info().chain.best_number); let parent_header = service.client().header(&block_id).unwrap().unwrap(); let consensus_net = ConsensusNetwork::new(service.network(), service.client().clone()); let proposer_factory = consensus::ProposerFactory { -- GitLab From e8739300ae3f7f2e7b72f64668573275f2806ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 4 Jun 2019 18:43:55 +0200 Subject: [PATCH 079/113] JSON-RPC client generation (#2778) * Bump jsonrpc & generate clients. * Initial version of JSON-RPC client. * Re-wort * Remove spurious `#[derive(Encode, Decode)]` They did not compile, since `Encode` and `Decode` are deliberately not implemented for `usize`. Fixes #2742. * Re-write rpc-client example. * Update to jsonrpc=12.0.0 * Remove unnecessary import * Bump version. * Revert version bump. * Bump again. --- Cargo.lock | 177 ++++++++++++++++++++++++--------- Cargo.toml | 1 + core/rpc-servers/Cargo.toml | 6 +- core/rpc-servers/src/lib.rs | 6 +- core/rpc/Cargo.toml | 7 +- core/rpc/src/author/hash.rs | 6 +- core/rpc/src/author/mod.rs | 15 +-- core/rpc/src/chain/error.rs | 3 + core/rpc/src/chain/mod.rs | 23 +++-- core/rpc/src/chain/number.rs | 6 +- core/rpc/src/state/error.rs | 5 + core/rpc/src/state/mod.rs | 23 +++-- core/rpc/src/system/helpers.rs | 6 +- core/rpc/src/system/mod.rs | 4 +- core/sr-version/src/lib.rs | 4 +- node/rpc-client/Cargo.toml | 14 +++ node/rpc-client/src/main.rs | 70 +++++++++++++ node/runtime/src/lib.rs | 2 +- 18 files changed, 282 insertions(+), 96 deletions(-) create mode 100644 node/rpc-client/Cargo.toml create mode 100644 node/rpc-client/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 7f8f7bd555..a1b630d428 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1267,9 +1267,25 @@ dependencies = [ "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "jsonrpc-client-transports" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "jsonrpc-core" -version = "10.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1279,11 +1295,20 @@ dependencies = [ "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "jsonrpc-core-client" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "jsonrpc-client-transports 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "jsonrpc-derive" -version = "10.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1291,36 +1316,37 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" -version = "10.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-pubsub" -version = "10.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-server-utils" -version = "10.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1331,16 +1357,15 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" -version = "10.1.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-ws 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1832,6 +1857,14 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.3.9" @@ -2097,6 +2130,19 @@ dependencies = [ "substrate-serializer 2.0.0", ] +[[package]] +name = "node-rpc-client" +version = "2.0.0" +dependencies = [ + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "node-primitives 2.0.0", + "substrate-rpc 2.0.0", +] + [[package]] name = "node-runtime" version = "2.0.0" @@ -2383,23 +2429,6 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parity-ws" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot" version = "0.5.5" @@ -2427,6 +2456,16 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.2.14" @@ -2462,6 +2501,21 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "paste" version = "0.1.5" @@ -2952,6 +3006,11 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "security-framework" version = "0.3.1" @@ -4316,9 +4375,10 @@ dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4344,9 +4404,9 @@ dependencies = [ name = "substrate-rpc-servers" version = "2.0.0" dependencies = [ - "jsonrpc-http-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -5032,7 +5092,7 @@ name = "twox-hash" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5429,6 +5489,23 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ws" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -5643,12 +5720,14 @@ dependencies = [ "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" -"checksum jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc15eef5f8b6bef5ac5f7440a957ff95d036e2f98706947741bfc93d1976db4c" -"checksum jsonrpc-derive 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c2dae61ca8a3b047fb11309b00661bc56837085bd07e46f907b9c562c0b03e68" -"checksum jsonrpc-http-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d2a00824306155b8ef57fe957f31b8cd8ad24262f15cf911d84dcf9a3f206d" -"checksum jsonrpc-pubsub 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37fce55133ee264d0ab42bd862efcd45ae1d062cda599f4cc12ccc4be3195f2a" -"checksum jsonrpc-server-utils 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9527f01ef25f251d64082cbefc0c6d6f367349afe6848ef908a674e06b2bdd3" -"checksum jsonrpc-ws-server 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3889012aa638a2f18eb1a879f46fc8b34e7e1423cbff3247cd1531de0d51084b" +"checksum jsonrpc-client-transports 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0245e08f98d627a579cdee6a2138d05ab64f6093efbcdeec50805d121ee13c0c" +"checksum jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "288dca7f9713710a29e485076b9340156cb701edb46a881f5d0c31aa4f5b9143" +"checksum jsonrpc-core-client 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05e499e393aaa97cf5ff3a7444549c94a6d27e70be1c300b865187d722f1b426" +"checksum jsonrpc-derive 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b65eafb36286a4251c9a1d4cdf4e9a7cf8fa4f7bf991383e42f0cf26908767" +"checksum jsonrpc-http-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea8b3996f19dc6dd90d928c81d30b3ce9535840487734290da9fae3b3185db5d" +"checksum jsonrpc-pubsub 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fcdd238ecccde73faea93760b068f3fe3ca84caeb6b5414c2aabd4f008dad418" +"checksum jsonrpc-server-utils 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "036a53ffa47533dcccf1e1bb16abb0f45ef9a2dc9a63654d2d2cd199b80ad33e" +"checksum jsonrpc-ws-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "977ea40f077c027553e4112d750114b9e5cc7bcf5642512838abc2a9b322bd23" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum keccak-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "af672553b2abac1c86c29fd62c79880638b6abc91d96db4aa42a5baab2bc1ca9" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -5684,6 +5763,7 @@ dependencies = [ "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" @@ -5726,13 +5806,14 @@ dependencies = [ "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" -"checksum parity-ws 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fec5048fba72a2e01baeb0d08089db79aead4b57e2443df172fb1840075a233" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" @@ -5790,6 +5871,7 @@ dependencies = [ "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eee63d0f4a9ec776eeb30e220f0bc1e092c3ad744b2a379e3993070364d3adc2" "checksum security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9636f8989cbf61385ae4824b98c1aaa54c994d7d8b41f11c601ed799f0549a56" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -5920,6 +6002,7 @@ dependencies = [ "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" +"checksum ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ec91ea61b83ce033c43c06c52ddc7532f465c0153281610d44c58b74083aee1a" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" diff --git a/Cargo.toml b/Cargo.toml index 3ccbb1c26d..5710d08aff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,6 +82,7 @@ members = [ "node/executor", "node/primitives", "node/runtime", + "node/rpc-client", "node-template", "subkey", "test-utils/chain-spec-builder", diff --git a/core/rpc-servers/Cargo.toml b/core/rpc-servers/Cargo.toml index 41cfb6aeea..bca094b572 100644 --- a/core/rpc-servers/Cargo.toml +++ b/core/rpc-servers/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -http = { package = "jsonrpc-http-server", version = "10.0.1" } -pubsub = { package = "jsonrpc-pubsub", version = "10.0.1" } -ws = { package = "jsonrpc-ws-server", version = "10.0.1" } +http = { package = "jsonrpc-http-server", version = "12.0.0" } +pubsub = { package = "jsonrpc-pubsub", version = "12.0.0" } +ws = { package = "jsonrpc-ws-server", version = "12.0.0" } log = "0.4" serde = "1.0" substrate-rpc = { path = "../rpc" } diff --git a/core/rpc-servers/src/lib.rs b/core/rpc-servers/src/lib.rs index 2c0672ac9c..adf560ce5a 100644 --- a/core/rpc-servers/src/lib.rs +++ b/core/rpc-servers/src/lib.rs @@ -89,9 +89,9 @@ pub fn start_ws( .allowed_origins(map_cors(cors)) .start(addr) .map_err(|err| match err { - ws::Error(ws::ErrorKind::Io(io), _) => io, - ws::Error(ws::ErrorKind::ConnectionClosed, _) => io::ErrorKind::BrokenPipe.into(), - ws::Error(e, _) => { + ws::Error::Io(io) => io, + ws::Error::ConnectionClosed => io::ErrorKind::BrokenPipe.into(), + e => { error!("{}", e); io::ErrorKind::Other.into() } diff --git a/core/rpc/Cargo.toml b/core/rpc/Cargo.toml index d69d7e17be..a7337858d8 100644 --- a/core/rpc/Cargo.toml +++ b/core/rpc/Cargo.toml @@ -6,9 +6,10 @@ edition = "2018" [dependencies] derive_more = "0.14.0" -jsonrpc-core = "10.0.1" -jsonrpc-pubsub = "10.0.1" -jsonrpc-derive = "10.0.2" +jsonrpc-core = "12.0.0" +jsonrpc-core-client = "12.0.0" +jsonrpc-pubsub = "12.0.0" +jsonrpc-derive = "12.0.0" log = "0.4" parking_lot = "0.7.1" parity-codec = "3.3" diff --git a/core/rpc/src/author/hash.rs b/core/rpc/src/author/hash.rs index 96addf8ebc..a01e26de3c 100644 --- a/core/rpc/src/author/hash.rs +++ b/core/rpc/src/author/hash.rs @@ -14,13 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . +//! Extrinsic helpers for author RPC module. + use primitives::Bytes; -use serde::Deserialize; +use serde::{Serialize, Deserialize}; /// RPC Extrinsic or hash /// /// Allows to refer to extrinsic either by its raw representation or its hash. -#[derive(Debug, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum ExtrinsicOrHash { /// The hash of the extrinsic. diff --git a/core/rpc/src/author/mod.rs b/core/rpc/src/author/mod.rs index 4e3bc96ca9..5594984d0e 100644 --- a/core/rpc/src/author/mod.rs +++ b/core/rpc/src/author/mod.rs @@ -16,6 +16,12 @@ //! Substrate block-author/full-node API. +pub mod error; +pub mod hash; + +#[cfg(test)] +mod tests; + use std::sync::Arc; use client::{self, Client}; @@ -27,6 +33,7 @@ use log::warn; use parity_codec::{Encode, Decode}; use primitives::{Bytes, Blake2Hasher, H256}; use runtime_primitives::{generic, traits}; +use self::error::Result; use transaction_pool::{ txpool::{ ChainApi as PoolChainApi, @@ -38,13 +45,7 @@ use transaction_pool::{ }, }; -pub mod error; -mod hash; - -#[cfg(test)] -mod tests; - -use self::error::Result; +pub use self::gen_client::Client as AuthorClient; /// Substrate authoring RPC API #[rpc] diff --git a/core/rpc/src/chain/error.rs b/core/rpc/src/chain/error.rs index ffd94f4649..ad63af9add 100644 --- a/core/rpc/src/chain/error.rs +++ b/core/rpc/src/chain/error.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . + +//! Error helpers for Chain RPC module. + use client; use crate::rpc; use crate::errors; diff --git a/core/rpc/src/chain/mod.rs b/core/rpc/src/chain/mod.rs index 90c833e3fd..3594ed48e3 100644 --- a/core/rpc/src/chain/mod.rs +++ b/core/rpc/src/chain/mod.rs @@ -16,27 +16,28 @@ //! Substrate blockchain API. +pub mod error; +pub mod number; + +#[cfg(test)] +mod tests; + use std::sync::Arc; -use log::warn; use client::{self, Client, BlockchainEvents}; +use crate::rpc::Result as RpcResult; +use crate::rpc::futures::{stream, Future, Sink, Stream}; +use crate::subscriptions::Subscriptions; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; +use log::warn; use primitives::{H256, Blake2Hasher}; -use crate::rpc::Result as RpcResult; -use crate::rpc::futures::{stream, Future, Sink, Stream}; use runtime_primitives::generic::{BlockId, SignedBlock}; use runtime_primitives::traits::{Block as BlockT, Header, NumberFor}; - -use crate::subscriptions::Subscriptions; - -mod error; -#[cfg(test)] -mod tests; -mod number; - use self::error::Result; +pub use self::gen_client::Client as ChainClient; + /// Substrate blockchain API #[rpc] pub trait ChainApi { diff --git a/core/rpc/src/chain/number.rs b/core/rpc/src/chain/number.rs index f927d51f14..df796d5e6d 100644 --- a/core/rpc/src/chain/number.rs +++ b/core/rpc/src/chain/number.rs @@ -14,7 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use serde::Deserialize; +//! Chain RPC Block number type. + +use serde::{Serialize, Deserialize}; use std::{convert::TryFrom, fmt::Debug}; use primitives::U256; @@ -25,7 +27,7 @@ use primitives::U256; /// or we attempt to parse given hex value. /// We do that for consistency with the returned type, default generic header /// serializes block number as hex to avoid overflows in JavaScript. -#[derive(Deserialize)] +#[derive(Serialize, Deserialize)] #[serde(untagged)] pub enum NumberOrHex { /// The original header number type of block. diff --git a/core/rpc/src/state/error.rs b/core/rpc/src/state/error.rs index 30b3315b7b..4b9d30b36b 100644 --- a/core/rpc/src/state/error.rs +++ b/core/rpc/src/state/error.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . +//! State RPC errors. + use client; use crate::rpc; use crate::errors; @@ -29,8 +31,11 @@ pub enum Error { /// Provided block range couldn't be resolved to a list of blocks. #[display(fmt = "Cannot resolve a block range ['{:?}' ... '{:?}]. {}", from, to, details)] InvalidBlockRange { + /// Beginning of the block range. from: String, + /// End of the block range. to: String, + /// Details of the error message. details: String, }, } diff --git a/core/rpc/src/state/mod.rs b/core/rpc/src/state/mod.rs index ebb45d6b5f..e52d318d9f 100644 --- a/core/rpc/src/state/mod.rs +++ b/core/rpc/src/state/mod.rs @@ -16,36 +16,37 @@ //! Substrate state API. +pub mod error; + +#[cfg(test)] +mod tests; + use std::{ collections::{BTreeMap, HashMap}, ops::Range, sync::Arc, }; -use log::{warn, trace}; use client::{self, Client, CallExecutor, BlockchainEvents, runtime_api::Metadata}; +use crate::rpc::Result as RpcResult; +use crate::rpc::futures::{stream, Future, Sink, Stream}; +use crate::subscriptions::Subscriptions; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use primitives::{H256, Blake2Hasher, Bytes}; +use log::{warn, trace}; use primitives::hexdisplay::HexDisplay; use primitives::storage::{self, StorageKey, StorageData, StorageChangeSet}; -use crate::rpc::Result as RpcResult; -use crate::rpc::futures::{stream, Future, Sink, Stream}; +use primitives::{H256, Blake2Hasher, Bytes}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ Block as BlockT, Header, ProvideRuntimeApi, NumberFor, SaturatedConversion }; use runtime_version::RuntimeVersion; +use self::error::Result; use state_machine::{self, ExecutionStrategy}; -use crate::subscriptions::Subscriptions; - -mod error; -#[cfg(test)] -mod tests; - -use self::error::Result; +pub use self::gen_client::Client as StateClient; /// Substrate state API #[rpc] diff --git a/core/rpc/src/system/helpers.rs b/core/rpc/src/system/helpers.rs index 82c7773b5b..00e2ba9f40 100644 --- a/core/rpc/src/system/helpers.rs +++ b/core/rpc/src/system/helpers.rs @@ -17,7 +17,7 @@ //! Substrate system API helpers. use std::fmt; -use serde::Serialize; +use serde::{Serialize, Deserialize}; use serde_json::{Value, map::Map}; /// Node properties @@ -37,7 +37,7 @@ pub struct SystemInfo { } /// Health struct returned by the RPC -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Health { /// Number of connected peers @@ -51,7 +51,7 @@ pub struct Health { } /// Network Peer information -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct PeerInfo { /// Peer ID diff --git a/core/rpc/src/system/mod.rs b/core/rpc/src/system/mod.rs index 46cbc99fab..8aac02b77d 100644 --- a/core/rpc/src/system/mod.rs +++ b/core/rpc/src/system/mod.rs @@ -17,8 +17,8 @@ //! Substrate system API. pub mod error; +pub mod helpers; -mod helpers; #[cfg(test)] mod tests; @@ -30,6 +30,8 @@ use runtime_primitives::traits::{self, Header as HeaderT}; use self::error::Result; pub use self::helpers::{Properties, SystemInfo, Health, PeerInfo}; +pub use self::gen_client::Client as SystemClient; + /// Substrate system RPC API #[rpc] pub trait SystemApi { diff --git a/core/sr-version/src/lib.rs b/core/sr-version/src/lib.rs index 071b893404..179146cc84 100644 --- a/core/sr-version/src/lib.rs +++ b/core/sr-version/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "std")] -use serde::Serialize; +use serde::{Serialize, Deserialize}; #[cfg(feature = "std")] use std::fmt; #[cfg(feature = "std")] @@ -63,7 +63,7 @@ macro_rules! create_apis_vec { /// In particular: bug fixes should result in an increment of `spec_version` and possibly `authoring_version`, /// absolutely not `impl_version` since they change the semantics of the runtime. #[derive(Clone, PartialEq, Eq, Encode)] -#[cfg_attr(feature = "std", derive(Debug, Serialize, Decode))] +#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize, Decode))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] pub struct RuntimeVersion { /// Identifies the different Substrate runtimes. There'll be at least polkadot and node. diff --git a/node/rpc-client/Cargo.toml b/node/rpc-client/Cargo.toml new file mode 100644 index 0000000000..ea255808e4 --- /dev/null +++ b/node/rpc-client/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "node-rpc-client" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +env_logger = "0.6" +futures = "0.1.26" +hyper = "0.12" +jsonrpc-core-client = { version = "12.0.0", features = ["http", "ws"] } +log = "0.4" +node-primitives = { path = "../primitives" } +substrate-rpc = { path = "../../core/rpc", version = "2.0.0" } diff --git a/node/rpc-client/src/main.rs b/node/rpc-client/src/main.rs new file mode 100644 index 0000000000..fe057bcbea --- /dev/null +++ b/node/rpc-client/src/main.rs @@ -0,0 +1,70 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +#![warn(missing_docs)] + +//! Example substrate RPC client code. +//! +//! This module shows how you can write a Rust RPC client that connects to a running +//! substrate node and use staticly typed RPC wrappers. + +use futures::Future; +use hyper::rt; +use node_primitives::Hash; +use substrate_rpc::author::{ + AuthorClient, + hash::ExtrinsicOrHash, +}; +use jsonrpc_core_client::{ + transports::http, + RpcError, +}; + +fn main() { + env_logger::init(); + + rt::run(rt::lazy(|| { + let uri = "http://localhost:9933"; + + http::connect(uri) + .and_then(|client: AuthorClient| { + remove_all_extrinsics(client) + }) + .map_err(|e| { + println!("Error: {:?}", e); + }) + })) +} + +/// Remove all pending extrinsics from the node. +/// +/// The example code takes `AuthorClient` and first: +/// 1. Calls the `pending_extrinsics` method to get all extrinsics in the pool. +/// 2. Then calls `remove_extrinsic` passing the obtained raw extrinsics. +/// +/// As the resul of running the code the entire content of the transaction pool is going +/// to be removed and the extrinsics are going to be temporarily banned. +fn remove_all_extrinsics(client: AuthorClient) -> impl Future { + client.pending_extrinsics() + .and_then(move |pending| { + client.remove_extrinsic( + pending.into_iter().map(|tx| ExtrinsicOrHash::Extrinsic(tx.into())).collect() + ) + }) + .map(|removed| { + println!("Removed extrinsics: {:?}", removed); + }) +} diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index c31c6b41cc..bad1fb9def 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 91, - impl_version: 92, + impl_version: 93, apis: RUNTIME_API_VERSIONS, }; -- GitLab From 45cff87d6e74e813aa9ae5a0e9bf76dbbb5ee3c2 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 4 Jun 2019 12:48:50 -0400 Subject: [PATCH 080/113] WIP: Treasury reference docs (#2557) * Some initial re-organization. * Text looking decent. No Example Yet. * Clarify that using block rewards is jsut an example. * Clarify the purpose of OnDilution. * Update lib.rs --- srml/treasury/src/lib.rs | 82 ++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/srml/treasury/src/lib.rs b/srml/treasury/src/lib.rs index 39253ac4d9..cd9e781f66 100644 --- a/srml/treasury/src/lib.rs +++ b/srml/treasury/src/lib.rs @@ -15,47 +15,55 @@ // along with Substrate. If not, see . //! # Treasury Module -//! -//! The `treasury` module keeps account of currency in a `pot` and manages the subsequent -//! deployment of these funds. -//! +//! +//! The Treasury module provides a "pot" of funds that can be managed by stakeholders in the +//! system and a structure for making spending proposals from this pot. +//! +//! - [`treasury::Trait`](./trait.Trait.html) +//! - [`Call`](./enum.Call.html) +//! //! ## Overview -//! -//! Funds for treasury are raised in two ways: -//! 1. By minting new tokens, leading to inflation, and -//! 2. By channeling tokens from transaction fees and slashing. -//! -//! Treasury funds can be used to pay for developers who provide software updates, -//! any changes decided by referenda, and to generally keep the system running smoothly. -//! -//! Treasury can be used with other modules, such as to tax validator rewards in the `staking` module. -//! -//! ### Implementations -//! +//! +//! The Treasury Module itself provides the pot to store funds, and a means for stakeholders to +//! propose, approve, and deny expendatures. The chain will need to provide a method (e.g. +//! inflation, fees) for collecting funds. +//! +//! By way of example, the Council could vote to fund the Treasury with a portion of the block +//! reward and use the funds to pay developers. +//! +//! ### Terminology +//! +//! - **Proposal:** A suggestion to allocate funds from the pot to a beneficiary. +//! - **Beneficiary:** An account who will receive the funds from a proposal iff +//! the proposal is approved. +//! - **Deposit:** Funds that a proposer must lock when making a proposal. The +//! deposit will be returned or slashed if the proposal is approved or rejected +//! respectively. +//! - **Pot:** Unspent funds accumulated by the treasury module. +//! +//! ### Implementations +//! //! The treasury module provides an implementation for the following trait: -//! - `OnDilution` - Mint extra funds upon dilution; maintain the ratio of `portion` diluted to `total_issuance`. -//! +//! +//! - `OnDilution` - When new funds are minted to reward the deployment of other existing funds, +//! a corresponding amount of tokens are minted into the treasury so that the tokens being rewarded +//! do not represent a higher portion of total supply. For example, in the default substrate node, +//! when validators are rewarded new tokens for staking, they do not hold a higher portion of total +//! tokens. Rather, tokens are added to the treasury to keep the portion of tokens staked constant. +//! //! ## Interface -//! +//! //! ### Dispatchable Functions -//! -//! - `propose_spend` - Propose a spending proposal and stake a proposal deposit. +//! +//! - `propose_spend` - Make a spending proposal and stake the required deposit. //! - `set_pot` - Set the spendable balance of funds. //! - `configure` - Configure the module's proposal requirements. -//! - `reject_proposal` - Reject a proposal and slash the deposit. -//! - `approve_proposal` - Accept the proposal and return the deposit. -//! -//! Please refer to the [`Call`](./enum.Call.html) enum and its associated variants for documentation on each function. -//! -//! ### Public Functions -//! -//! See the [module](./struct.Module.html) for details on publicly available functions. -//! -//! ## Related Modules -//! -//! The treasury module depends on the `system` and `srml_support` modules as well as -//! Substrate Core libraries and the Rust standard library. -//! +//! - `reject_proposal` - Reject a proposal, slashing the deposit. +//! - `approve_proposal` - Accept the proposal, returning the deposit. +//! +//! ## GenesisConfig +//! +//! The Treasury module depends on the [`GenesisConfig`](./struct.GenesisConfig.html). #![cfg_attr(not(feature = "std"), no_std)] @@ -183,8 +191,8 @@ decl_storage! { trait Store for Module as Treasury { // Config... - /// Proportion of funds that should be bonded in order to place a proposal. An accepted - /// proposal gets these back. A rejected proposal doesn't. + /// Fraction of a proposal's value that should be bonded in order to place the proposal. + /// An accepted proposal gets these back. A rejected proposal does not. ProposalBond get(proposal_bond) config(): Permill; /// Minimum amount of funds that should be placed in a deposit for making a proposal. -- GitLab From ec62d24c602912f07bbc416711376d9b8e5782c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 4 Jun 2019 20:09:49 +0200 Subject: [PATCH 081/113] Fix tons of warnings in newest nightly (#2784) * Fix tons of warnings in newest nightly * Fix sr-api-macro doc tests --- core/basic-authorship/src/basic_authorship.rs | 6 +- core/cli/src/lib.rs | 4 +- core/cli/src/params.rs | 4 +- core/client/db/src/cache/list_storage.rs | 6 +- core/client/db/src/cache/mod.rs | 6 +- core/client/db/src/lib.rs | 23 ++++--- core/client/db/src/light.rs | 8 +-- core/client/db/src/utils.rs | 25 ++++--- core/client/src/blockchain.rs | 4 +- core/client/src/call_executor.rs | 4 +- core/client/src/children.rs | 4 +- core/client/src/client.rs | 14 ++-- core/client/src/error.rs | 6 +- core/client/src/in_mem.rs | 6 +- core/client/src/leaves.rs | 2 +- core/client/src/light/blockchain.rs | 8 +-- core/client/src/light/call_executor.rs | 2 +- core/client/src/light/fetcher.rs | 12 ++-- core/consensus/aura/src/lib.rs | 6 +- core/consensus/babe/src/lib.rs | 4 +- core/consensus/common/src/block_import.rs | 8 +-- core/consensus/common/src/error.rs | 2 +- core/consensus/common/src/import_queue.rs | 22 +++--- core/executor/src/native_executor.rs | 4 +- core/executor/src/wasm_executor.rs | 4 +- core/executor/src/wasm_utils.rs | 2 +- .../src/communication/gossip.rs | 10 +-- core/finality-grandpa/src/finality_proof.rs | 14 ++-- core/finality-grandpa/src/import.rs | 4 +- core/finality-grandpa/src/light_import.rs | 18 ++--- core/finality-grandpa/src/tests.rs | 9 ++- core/keyring/src/sr25519.rs | 2 +- core/network/src/config.rs | 6 +- core/network/src/consensus_gossip.rs | 68 ++++++++++++------- core/network/src/on_demand_layer.rs | 4 +- core/network/src/protocol.rs | 10 +-- core/network/src/service.rs | 24 +++---- core/network/src/specialization.rs | 10 +-- core/network/src/sync.rs | 40 +++++------ core/network/src/sync/extra_requests.rs | 10 +-- core/network/src/test/mod.rs | 21 +++--- core/offchain/src/lib.rs | 2 +- core/primitives/src/hexdisplay.rs | 4 +- core/primitives/src/lib.rs | 2 +- core/primitives/src/offchain.rs | 8 +-- core/primitives/src/sr25519.rs | 18 +++-- core/rpc/src/author/error.rs | 2 +- core/rpc/src/system/mod.rs | 4 +- core/service/src/chain_ops.rs | 2 +- core/service/src/components.rs | 12 ++-- core/service/src/lib.rs | 4 +- core/sr-api-macros/src/lib.rs | 15 +++- core/sr-api-macros/tests/decl_and_impl.rs | 6 +- core/sr-io/with_std.rs | 4 +- core/sr-primitives/src/generic/mod.rs | 4 +- core/state-machine/src/basic.rs | 6 +- core/state-machine/src/changes_trie/mod.rs | 2 +- core/state-machine/src/ext.rs | 2 +- core/state-machine/src/lib.rs | 61 +++++++++-------- core/state-machine/src/proving_backend.rs | 10 +-- core/state-machine/src/testing.rs | 4 +- .../state-machine/src/trie_backend_essence.rs | 10 +-- core/telemetry/src/lib.rs | 10 +-- core/transaction-pool/graph/src/error.rs | 2 +- core/trie/src/lib.rs | 6 +- core/trie/src/node_header.rs | 4 +- core/trie/src/trie_stream.rs | 4 +- core/util/fork-tree/src/lib.rs | 2 +- srml/aura/src/lib.rs | 1 - srml/contract/src/exec.rs | 2 +- srml/contract/src/tests.rs | 8 +-- srml/indices/src/address.rs | 2 +- subkey/src/vanity.rs | 6 +- 73 files changed, 359 insertions(+), 316 deletions(-) diff --git a/core/basic-authorship/src/basic_authorship.rs b/core/basic-authorship/src/basic_authorship.rs index 87d0b8f92b..166a89447e 100644 --- a/core/basic-authorship/src/basic_authorship.rs +++ b/core/basic-authorship/src/basic_authorship.rs @@ -56,7 +56,7 @@ pub trait AuthoringApi: Send + Sync + ProvideRuntimeApi where /// Build a block on top of the given block, with inherent extrinsics and /// inherent digests pre-pushed. - fn build_block) -> ()>( + fn build_block) -> ()>( &self, at: &BlockId, inherent_data: InherentData, @@ -91,7 +91,7 @@ impl AuthoringApi for SubstrateClient where type Block = Block; type Error = client::error::Error; - fn build_block) -> ()>( + fn build_block) -> ()>( &self, at: &BlockId, inherent_data: InherentData, @@ -162,7 +162,7 @@ pub struct Proposer { parent_id: BlockId, parent_number: <::Header as HeaderT>::Number, transaction_pool: Arc>, - now: Box time::Instant>, + now: Box time::Instant>, } impl consensus_common::Proposer<::Block> for Proposer where diff --git a/core/cli/src/lib.rs b/core/cli/src/lib.rs index 3619e6491a..c14c962591 100644 --- a/core/cli/src/lib.rs +++ b/core/cli/src/lib.rs @@ -617,7 +617,7 @@ where let to = cli.to; let json = cli.json; - let file: Box = match cli.output { + let file: Box = match cli.output { Some(filename) => Box::new(File::create(filename)?), None => Box::new(stdout()), }; @@ -640,7 +640,7 @@ where { let config = create_config_with_db_path::(spec_factory, &cli.shared_params, version)?; - let file: Box = match cli.input { + let file: Box = match cli.input { Some(filename) => Box::new(File::open(filename)?), None => Box::new(stdin()), }; diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index 7439cc02c0..0cdc633188 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -476,7 +476,7 @@ impl Keyring { } /// Default to verbosity level 0, if none is provided. -fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box> { +fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box> { let pos = s.find(' '); match pos { None => { @@ -512,7 +512,7 @@ impl From for Option> { } /// Parse cors origins -fn parse_cors(s: &str) -> Result> { +fn parse_cors(s: &str) -> Result> { let mut is_all = false; let mut origins = Vec::new(); for part in s.split(',') { diff --git a/core/client/db/src/cache/list_storage.rs b/core/client/db/src/cache/list_storage.rs index 6271f892bc..af0b74066c 100644 --- a/core/client/db/src/cache/list_storage.rs +++ b/core/client/db/src/cache/list_storage.rs @@ -97,19 +97,19 @@ pub struct DbColumns { pub struct DbStorage { name: Vec, meta_key: Vec, - db: Arc, + db: Arc, columns: DbColumns, } impl DbStorage { /// Create new database-backed list cache storage. - pub fn new(name: Vec, db: Arc, columns: DbColumns) -> Self { + pub fn new(name: Vec, db: Arc, columns: DbColumns) -> Self { let meta_key = meta::key(&name); DbStorage { name, meta_key, db, columns } } /// Get reference to the database. - pub fn db(&self) -> &Arc { &self.db } + pub fn db(&self) -> &Arc { &self.db } /// Get reference to the database columns. pub fn columns(&self) -> &DbColumns { &self.columns } diff --git a/core/client/db/src/cache/mod.rs b/core/client/db/src/cache/mod.rs index d79b01ab6b..64d3c4a25e 100644 --- a/core/client/db/src/cache/mod.rs +++ b/core/client/db/src/cache/mod.rs @@ -77,7 +77,7 @@ impl CacheItemT for T where T: Clone + Decode + Encode + PartialEq {} /// Database-backed blockchain data cache. pub struct DbCache { cache_at: HashMap, self::list_storage::DbStorage>>, - db: Arc, + db: Arc, key_lookup_column: Option, header_column: Option, authorities_column: Option, @@ -88,7 +88,7 @@ pub struct DbCache { impl DbCache { /// Create new cache. pub fn new( - db: Arc, + db: Arc, key_lookup_column: Option, header_column: Option, authorities_column: Option, @@ -150,7 +150,7 @@ impl DbCache { fn get_cache_helper<'a, Block: BlockT>( cache_at: &'a mut HashMap, self::list_storage::DbStorage>>, name: CacheKeyId, - db: &Arc, + db: &Arc, key_lookup: Option, header: Option, cache: Option, diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index a253cc6783..302cdfd083 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -70,7 +70,7 @@ const CANONICALIZATION_DELAY: u64 = 4096; const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768; /// DB-backed patricia trie state, transaction type is an overlay of changes to commit. -pub type DbState = state_machine::TrieBackend>, Blake2Hasher>; +pub type DbState = state_machine::TrieBackend>, Blake2Hasher>; pub struct RefTrackingState { state: DbState, @@ -213,7 +213,7 @@ struct PendingBlock { } // wrapper that implements trait required for state_db -struct StateMetaDb<'a>(&'a KeyValueDB); +struct StateMetaDb<'a>(&'a dyn KeyValueDB); impl<'a> state_db::MetaDb for StateMetaDb<'a> { type Error = io::Error; @@ -225,13 +225,13 @@ impl<'a> state_db::MetaDb for StateMetaDb<'a> { /// Block database pub struct BlockchainDb { - db: Arc, + db: Arc, meta: Arc, Block::Hash>>>, leaves: RwLock>>, } impl BlockchainDb { - fn new(db: Arc) -> Result { + fn new(db: Arc) -> Result { let meta = read_meta::(&*db, columns::META, columns::HEADER)?; let leaves = LeafSet::read_from_db(&*db, columns::META, meta_keys::LEAF_PREFIX)?; Ok(BlockchainDb { @@ -340,7 +340,7 @@ impl client::blockchain::Backend for BlockchainDb { Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } @@ -354,7 +354,7 @@ impl client::blockchain::Backend for BlockchainDb { } impl client::blockchain::ProvideCache for BlockchainDb { - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } } @@ -473,7 +473,7 @@ where Block: BlockT, } struct StorageDb { - pub db: Arc, + pub db: Arc, pub state_db: StateDb>, } @@ -512,7 +512,7 @@ impl state_machine::Storage for DbGenesisStorage { } pub struct DbChangesTrieStorage { - db: Arc, + db: Arc, meta: Arc, Block::Hash>>>, min_blocks_to_keep: Option, _phantom: ::std::marker::PhantomData, @@ -693,7 +693,12 @@ impl> Backend { ).expect("failed to create test-db") } - fn from_kvdb(db: Arc, pruning: PruningMode, canonicalization_delay: u64, state_cache_size: usize) -> Result { + fn from_kvdb( + db: Arc, + pruning: PruningMode, + canonicalization_delay: u64, + state_cache_size: usize + ) -> Result { let is_archive_pruning = pruning.is_archive(); let blockchain = BlockchainDb::new(db.clone())?; let meta = blockchain.meta.clone(); diff --git a/core/client/db/src/light.rs b/core/client/db/src/light.rs index e0f2153a13..b3398bfdff 100644 --- a/core/client/db/src/light.rs +++ b/core/client/db/src/light.rs @@ -59,7 +59,7 @@ const CHANGES_TRIE_CHT_PREFIX: u8 = 1; /// Light blockchain storage. Stores most recent headers + CHTs for older headers. /// Locks order: meta, leaves, cache. pub struct LightStorage { - db: Arc, + db: Arc, meta: RwLock, Block::Hash>>, leaves: RwLock>>, cache: Arc>, @@ -96,7 +96,7 @@ impl LightStorage Self::from_kvdb(db as Arc<_>).expect("failed to create test-db") } - fn from_kvdb(db: Arc) -> ClientResult { + fn from_kvdb(db: Arc) -> ClientResult { let meta = read_meta::(&*db, columns::META, columns::HEADER)?; let leaves = LeafSet::read_from_db(&*db, columns::META, meta_keys::LEAF_PREFIX)?; let cache = DbCache::new( @@ -557,7 +557,7 @@ impl LightBlockchainStorage for LightStorage Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { Some(self.cache.clone()) } } @@ -888,7 +888,7 @@ pub(crate) mod tests { map } - fn get_authorities(cache: &BlockchainCache, at: BlockId) -> Option> { + fn get_authorities(cache: &dyn BlockchainCache, at: BlockId) -> Option> { cache.get_at(&well_known_cache_keys::AUTHORITIES, &at).and_then(|val| Decode::decode(&mut &val[..])) } diff --git a/core/client/db/src/utils.rs b/core/client/db/src/utils.rs index 846bf05f3c..bd7cf660ea 100644 --- a/core/client/db/src/utils.rs +++ b/core/client/db/src/utils.rs @@ -17,9 +17,7 @@ //! Db-based backend utility structures and functions, used by both //! full and light storages. -use std::sync::Arc; -use std::io; -use std::convert::TryInto; +use std::{io, convert::TryInto, sync::Arc}; use kvdb::{KeyValueDB, DBTransaction}; #[cfg(feature = "kvdb-rocksdb")] @@ -171,7 +169,7 @@ pub fn insert_hash_to_key_mapping, H: AsRef<[u8]> + Clone>( /// block lookup key is the DB-key header, block and justification are stored under. /// looks up lookup key by hash from DB as necessary. pub fn block_id_to_lookup_key( - db: &KeyValueDB, + db: &dyn KeyValueDB, key_lookup_col: Option, id: BlockId ) -> Result>, client::error::Error> where @@ -197,7 +195,11 @@ pub fn db_err(err: io::Error) -> client::error::Error { /// Open RocksDB database. #[cfg(feature = "kvdb-rocksdb")] -pub fn open_database(config: &DatabaseSettings, col_meta: Option, db_type: &str) -> client::error::Result> { +pub fn open_database( + config: &DatabaseSettings, + col_meta: Option, + db_type: &str +) -> client::error::Result> { let mut db_config = DatabaseConfig::with_columns(Some(NUM_COLUMNS)); db_config.memory_budget = config.cache_size; let path = config.path.to_str().ok_or_else(|| client::error::Error::Backend("Invalid database path".into()))?; @@ -222,7 +224,12 @@ pub fn open_database(config: &DatabaseSettings, col_meta: Option, db_type: } /// Read database column entry for the given block. -pub fn read_db(db: &KeyValueDB, col_index: Option, col: Option, id: BlockId) -> client::error::Result> +pub fn read_db( + db: &dyn KeyValueDB, + col_index: Option, + col: Option, + id: BlockId +) -> client::error::Result> where Block: BlockT, { @@ -234,7 +241,7 @@ pub fn read_db(db: &KeyValueDB, col_index: Option, col: Option, /// Read a header from the database. pub fn read_header( - db: &KeyValueDB, + db: &dyn KeyValueDB, col_index: Option, col: Option, id: BlockId, @@ -252,7 +259,7 @@ pub fn read_header( /// Required header from the database. pub fn require_header( - db: &KeyValueDB, + db: &dyn KeyValueDB, col_index: Option, col: Option, id: BlockId, @@ -262,7 +269,7 @@ pub fn require_header( } /// Read meta from the database. -pub fn read_meta(db: &KeyValueDB, col_meta: Option, col_header: Option) -> Result< +pub fn read_meta(db: &dyn KeyValueDB, col_meta: Option, col_header: Option) -> Result< Meta<<::Header as HeaderT>::Number, Block::Hash>, client::error::Error, > diff --git a/core/client/src/blockchain.rs b/core/client/src/blockchain.rs index 05210fc9ad..b07e26396e 100644 --- a/core/client/src/blockchain.rs +++ b/core/client/src/blockchain.rs @@ -81,7 +81,7 @@ pub trait Backend: HeaderBackend { /// Get last finalized block hash. fn last_finalized(&self) -> Result; /// Returns data cache reference, if it is enabled on this backend. - fn cache(&self) -> Option>>; + fn cache(&self) -> Option>>; /// Returns hashes of all blocks that are leaves of the block tree. /// in other words, that have no children, are chain heads. @@ -95,7 +95,7 @@ pub trait Backend: HeaderBackend { /// Provides access to the optional cache. pub trait ProvideCache { /// Returns data cache reference, if it is enabled on this backend. - fn cache(&self) -> Option>>; + fn cache(&self) -> Option>>; } /// Blockchain optional data cache. diff --git a/core/client/src/call_executor.rs b/core/client/src/call_executor.rs index bb59be44c3..f956f27b50 100644 --- a/core/client/src/call_executor.rs +++ b/core/client/src/call_executor.rs @@ -125,7 +125,7 @@ where let trie_state = state.as_trie_backend() .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) - as Box + as Box )?; self.prove_at_trie_state(trie_state, overlay, method, call_data) } @@ -246,7 +246,7 @@ where let trie_state = state.as_trie_backend() .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) - as Box + as Box )?; let backend = state_machine::ProvingBackend::new_with_recorder( diff --git a/core/client/src/children.rs b/core/client/src/children.rs index 3a9f0a6bea..4423ad8939 100644 --- a/core/client/src/children.rs +++ b/core/client/src/children.rs @@ -26,7 +26,7 @@ use std::hash::Hash; pub fn read_children< K: Eq + Hash + Clone + Encode + Decode, V: Eq + Hash + Clone + Encode + Decode, ->(db: &KeyValueDB, column: Option, prefix: &[u8], parent_hash: K) -> error::Result> { +>(db: &dyn KeyValueDB, column: Option, prefix: &[u8], parent_hash: K) -> error::Result> { let mut buf = prefix.to_vec(); parent_hash.using_encoded(|s| buf.extend(s)); @@ -116,6 +116,6 @@ mod tests { let r2: Vec = read_children(&db, None, PREFIX, 1_2).unwrap(); assert_eq!(r1, vec![1_3, 1_5]); - assert_eq!(r2.len(), 0); + assert_eq!(r2.len(), 0); } } diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 0d8f8aa548..f4183e4958 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -564,7 +564,7 @@ impl Client where cht_size: NumberFor, ) -> error::Result> { struct AccessedRootsRecorder<'a, Block: BlockT> { - storage: &'a ChangesTrieStorage>, + storage: &'a dyn ChangesTrieStorage>, min: NumberFor, required_roots_proofs: Mutex, H256>>, }; @@ -695,7 +695,7 @@ impl Client where /// Create a new block, built on the head of the chain. pub fn new_block( - &self, + &self, inherent_digests: DigestFor, ) -> error::Result> where E: Clone + Send + Sync, @@ -708,8 +708,8 @@ impl Client where /// Create a new block, built on top of `parent`. pub fn new_block_at( - &self, - parent: &BlockId, + &self, + parent: &BlockId, inherent_digests: DigestFor, ) -> error::Result> where E: Clone + Send + Sync, @@ -726,8 +726,8 @@ impl Client where /// These recorded trie nodes can be used by a third party to proof the /// output of this block builder without having access to the full storage. pub fn new_block_at_with_proof_recording( - &self, - parent: &BlockId, + &self, + parent: &BlockId, inherent_digests: DigestFor, ) -> error::Result> where E: Clone + Send + Sync, @@ -1319,7 +1319,7 @@ impl ProvideCache for Client where B: backend::Backend, Block: BlockT, { - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { self.backend.blockchain().cache() } } diff --git a/core/client/src/error.rs b/core/client/src/error.rs index bad279f2e4..b807d5e11c 100644 --- a/core/client/src/error.rs +++ b/core/client/src/error.rs @@ -42,7 +42,7 @@ pub enum Error { ApplyExtrinsicFailed(ApplyError), /// Execution error. #[display(fmt = "Execution: {}", _0)] - Execution(Box), + Execution(Box), /// Blockchain error. #[display(fmt = "Blockchain: {}", _0)] Blockchain(Box), @@ -100,7 +100,7 @@ pub enum Error { } impl error::Error for Error { - fn source(&self) -> Option<&(error::Error + 'static)> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { Error::Consensus(e) => Some(e), Error::Blockchain(e) => Some(e), @@ -128,7 +128,7 @@ impl Error { } /// Chain a state error. - pub fn from_state(e: Box) -> Self { + pub fn from_state(e: Box) -> Self { Error::Execution(e) } } diff --git a/core/client/src/in_mem.rs b/core/client/src/in_mem.rs index 6c11d0ed57..92d04230dd 100644 --- a/core/client/src/in_mem.rs +++ b/core/client/src/in_mem.rs @@ -343,7 +343,7 @@ impl blockchain::Backend for Blockchain { Ok(self.storage.read().finalized_hash.clone()) } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } @@ -357,7 +357,7 @@ impl blockchain::Backend for Blockchain { } impl blockchain::ProvideCache for Blockchain { - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } } @@ -433,7 +433,7 @@ impl light::blockchain::Storage for Blockchain .ok_or_else(|| error::Error::Backend(format!("Changes trie CHT for block {} not exists", block))) } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } } diff --git a/core/client/src/leaves.rs b/core/client/src/leaves.rs index 144237f777..b0e49ead80 100644 --- a/core/client/src/leaves.rs +++ b/core/client/src/leaves.rs @@ -77,7 +77,7 @@ impl LeafSet where } /// Read the leaf list from the DB, using given prefix for keys. - pub fn read_from_db(db: &KeyValueDB, column: Option, prefix: &[u8]) -> error::Result { + pub fn read_from_db(db: &dyn KeyValueDB, column: Option, prefix: &[u8]) -> error::Result { let mut storage = BTreeMap::new(); for (key, value) in db.iter_from_prefix(column, prefix) { diff --git a/core/client/src/light/blockchain.rs b/core/client/src/light/blockchain.rs index 62c13db5a4..e3d9c55a6a 100644 --- a/core/client/src/light/blockchain.rs +++ b/core/client/src/light/blockchain.rs @@ -70,7 +70,7 @@ pub trait Storage: AuxStore + BlockchainHeaderBackend { ) -> ClientResult; /// Get storage cache. - fn cache(&self) -> Option>>; + fn cache(&self) -> Option>>; } /// Light client blockchain. @@ -175,7 +175,7 @@ impl BlockchainBackend for Blockchain where Block: Blo self.storage.last_finalized() } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { self.storage.cache() } @@ -189,7 +189,7 @@ impl BlockchainBackend for Blockchain where Block: Blo } impl, F, Block: BlockT> ProvideCache for Blockchain { - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { self.storage.cache() } } @@ -303,7 +303,7 @@ pub mod tests { ).into()) } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } } diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index 5b6d1b3a29..a6b381a8b1 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -400,7 +400,7 @@ pub fn prove_execution( E: CallExecutor, { let trie_state = state.as_trie_backend() - .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box)?; + .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box)?; // prepare execution environment + record preparation proof let mut changes = Default::default(); diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index f25a2acd30..985aa5bdaa 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -620,7 +620,7 @@ pub mod tests { #[test] fn storage_read_proof_is_generated_and_checked() { let (local_checker, remote_block_header, remote_read_proof, authorities_len) = prepare_for_read_proof_check(); - assert_eq!((&local_checker as &FetchChecker).check_read_proof(&RemoteReadRequest::

{ + assert_eq!((&local_checker as &dyn FetchChecker).check_read_proof(&RemoteReadRequest::
{ block: remote_block_header.hash(), header: remote_block_header, key: well_known_keys::AUTHORITY_COUNT.to_vec(), @@ -631,7 +631,7 @@ pub mod tests { #[test] fn header_proof_is_generated_and_checked() { let (local_checker, local_cht_root, remote_block_header, remote_header_proof) = prepare_for_header_proof_check(true); - assert_eq!((&local_checker as &FetchChecker).check_header_proof(&RemoteHeaderRequest::
{ + assert_eq!((&local_checker as &dyn FetchChecker).check_header_proof(&RemoteHeaderRequest::
{ cht_root: local_cht_root, block: 1, retry_count: None, @@ -642,7 +642,7 @@ pub mod tests { fn check_header_proof_fails_if_cht_root_is_invalid() { let (local_checker, _, mut remote_block_header, remote_header_proof) = prepare_for_header_proof_check(true); remote_block_header.number = 100; - assert!((&local_checker as &FetchChecker).check_header_proof(&RemoteHeaderRequest::
{ + assert!((&local_checker as &dyn FetchChecker).check_header_proof(&RemoteHeaderRequest::
{ cht_root: Default::default(), block: 1, retry_count: None, @@ -653,7 +653,7 @@ pub mod tests { fn check_header_proof_fails_if_invalid_header_provided() { let (local_checker, local_cht_root, mut remote_block_header, remote_header_proof) = prepare_for_header_proof_check(true); remote_block_header.number = 100; - assert!((&local_checker as &FetchChecker).check_header_proof(&RemoteHeaderRequest::
{ + assert!((&local_checker as &dyn FetchChecker).check_header_proof(&RemoteHeaderRequest::
{ cht_root: local_cht_root, block: 1, retry_count: None, @@ -667,7 +667,7 @@ pub mod tests { Arc::new(DummyBlockchain::new(DummyStorage::new())), test_client::LocalExecutor::new(None) ); - let local_checker = &local_checker as &FetchChecker; + let local_checker = &local_checker as &dyn FetchChecker; let max = remote_client.info().chain.best_number; let max_hash = remote_client.info().chain.best_hash; @@ -763,7 +763,7 @@ pub mod tests { Arc::new(DummyBlockchain::new(DummyStorage::new())), test_client::LocalExecutor::new(None) ); - let local_checker = &local_checker as &FetchChecker; + let local_checker = &local_checker as &dyn FetchChecker; let max = remote_client.info().chain.best_number; let max_hash = remote_client.info().chain.best_hash; diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 263381d5f1..f0d982c36e 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -206,7 +206,7 @@ impl SlotWorker for AuraWorker w DigestItemFor: CompatibleDigestItem

+ DigestItem, Hash=B::Hash>, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, { - type OnSlot = Box + Send>; + type OnSlot = Box + Send>; fn on_start( &self, @@ -578,7 +578,7 @@ impl Verifier for AuraVerifier where // skip the inherents verification if the runtime API is old. if self.client .runtime_api() - .has_api_with::, _>(&BlockId::Hash(parent_hash), |v| v >= 2) + .has_api_with::, _>(&BlockId::Hash(parent_hash), |v| v >= 2) .map_err(|e| format!("{:?}", e))? { self.check_inherents( @@ -681,7 +681,7 @@ fn authorities(client: &C, at: &BlockId) -> Result>(at).unwrap_or(false) { + if client.runtime_api().has_api::>(at).unwrap_or(false) { AuthoritiesApi::authorities(&*client.runtime_api(), at).ok() } else { CoreApi::authorities(&*client.runtime_api(), at).ok() diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 969c7b8593..12c388d329 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -251,7 +251,7 @@ impl SlotWorker for BabeWorker w SO: SyncOracle + Send + Clone, Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, { - type OnSlot = Box + Send>; + type OnSlot = Box + Send>; fn on_start( &self, @@ -715,7 +715,7 @@ fn authorities(client: &C, at: &BlockId) -> Result< .and_then(|cache| cache.get_at(&well_known_cache_keys::AUTHORITIES, at) .and_then(|v| Decode::decode(&mut &v[..]))) .or_else(|| { - if client.runtime_api().has_api::>(at).unwrap_or(false) { + if client.runtime_api().has_api::>(at).unwrap_or(false) { AuthoritiesApi::authorities(&*client.runtime_api(), at).ok() } else { panic!("We don’t support deprecated code with new consensus algorithms, \ diff --git a/core/consensus/common/src/block_import.rs b/core/consensus/common/src/block_import.rs index 1a6a8d1f50..8ce6019131 100644 --- a/core/consensus/common/src/block_import.rs +++ b/core/consensus/common/src/block_import.rs @@ -197,7 +197,7 @@ pub trait JustificationImport { type Error: ::std::error::Error + Send + 'static; /// Called by the import queue when it is started. - fn on_start(&self, _link: &crate::import_queue::Link) { } + fn on_start(&self, _link: &dyn crate::import_queue::Link) { } /// Import a Block justification and finalize the given block. fn import_justification( @@ -210,10 +210,10 @@ pub trait JustificationImport { /// Finality proof import trait. pub trait FinalityProofImport { - type Error: ::std::error::Error + Send + 'static; + type Error: std::error::Error + Send + 'static; /// Called by the import queue when it is started. - fn on_start(&self, _link: &crate::import_queue::Link) { } + fn on_start(&self, _link: &dyn crate::import_queue::Link) { } /// Import a Block justification and finalize the given block. Returns finalized block or error. fn import_finality_proof( @@ -221,7 +221,7 @@ pub trait FinalityProofImport { hash: B::Hash, number: NumberFor, finality_proof: Vec, - verifier: &Verifier, + verifier: &dyn Verifier, ) -> Result<(B::Hash, NumberFor), Self::Error>; } diff --git a/core/consensus/common/src/error.rs b/core/consensus/common/src/error.rs index a923c5f555..d8683d0b68 100644 --- a/core/consensus/common/src/error.rs +++ b/core/consensus/common/src/error.rs @@ -64,7 +64,7 @@ pub enum Error { InvalidJustification, /// Some other error. #[display(fmt="Other error: {}", _0)] - Other(Box), + Other(Box), /// Error from the client while importing #[display(fmt="Import failed: {}", _0)] ClientImport(String), diff --git a/core/consensus/common/src/import_queue.rs b/core/consensus/common/src/import_queue.rs index d44aa0b93a..118bc641b2 100644 --- a/core/consensus/common/src/import_queue.rs +++ b/core/consensus/common/src/import_queue.rs @@ -103,7 +103,7 @@ pub trait ImportQueue: Send + Sync { /// /// This is called automatically by the network service when synchronization /// begins. - fn start(&self, _link: Box>) -> Result<(), std::io::Error> { + fn start(&self, _link: Box>) -> Result<(), std::io::Error> { Ok(()) } /// Import bunch of blocks. @@ -120,7 +120,7 @@ pub struct BasicSyncQueue> { } struct BasicSyncQueueData> { - link: Mutex>>>, + link: Mutex>>>, block_import: SharedBlockImport, verifier: Arc, justification_import: Option>, @@ -147,7 +147,7 @@ impl> BasicSyncQueue { } impl> ImportQueue for BasicSyncQueue { - fn start(&self, link: Box>) -> Result<(), std::io::Error> { + fn start(&self, link: Box>) -> Result<(), std::io::Error> { if let Some(justification_import) = self.data.justification_import.as_ref() { justification_import.on_start(&*link); } @@ -287,7 +287,7 @@ impl BasicQueue { } impl ImportQueue for BasicQueue { - fn start(&self, link: Box>) -> Result<(), std::io::Error> { + fn start(&self, link: Box>) -> Result<(), std::io::Error> { let connect_err = || Err(std::io::Error::new( std::io::ErrorKind::Other, "Failed to connect import queue threads", @@ -328,7 +328,7 @@ pub enum BlockImportMsg { ImportBlocks(BlockOrigin, Vec>), ImportJustification(Origin, B::Hash, NumberFor, Justification), ImportFinalityProof(Origin, B::Hash, NumberFor, Vec), - Start(Box>, Sender>), + Start(Box>, Sender>), Shutdown(Sender<()>), #[cfg(any(test, feature = "test-helpers"))] Synchronize, @@ -360,7 +360,7 @@ struct BlockImporter { result_port: Receiver>, worker_sender: Option>>, link: Option>>, - verifier: Arc>, + verifier: Arc>, justification_import: Option>, finality_proof_import: Option>, finality_proof_request_builder: Option>, @@ -370,7 +370,7 @@ impl BlockImporter { fn new( result_port: Receiver>, worker_sender: Sender>, - verifier: Arc>, + verifier: Arc>, justification_import: Option>, finality_proof_import: Option>, finality_proof_request_builder: Option>, @@ -667,7 +667,7 @@ pub enum BlockImportError { /// Imports single notification and send notification to the link (if provided). fn import_single_justification( - link: &Option>>, + link: &Option>>, justification_import: &Option>, who: Origin, hash: B::Hash, @@ -723,7 +723,7 @@ fn import_single_finality_proof>( /// Process result of block(s) import. fn process_import_results( - link: &Link, + link: &dyn Link, results: Vec<( Result>, BlockImportError>, B::Hash, @@ -801,7 +801,7 @@ fn process_import_results( /// Import several blocks at once, returning import result for each block. fn import_many_blocks>( - import_handle: &BlockImport, + import_handle: &dyn BlockImport, blocks_origin: BlockOrigin, blocks: Vec>, verifier: Arc, @@ -854,7 +854,7 @@ fn import_many_blocks>( /// Single block import function. pub fn import_single_block>( - import_handle: &BlockImport, + import_handle: &dyn BlockImport, block_origin: BlockOrigin, block: IncomingBlock, verifier: Arc, diff --git a/core/executor/src/native_executor.rs b/core/executor/src/native_executor.rs index 729346cbee..c4f3511c9c 100644 --- a/core/executor/src/native_executor.rs +++ b/core/executor/src/native_executor.rs @@ -107,7 +107,7 @@ fn safe_call(f: F) -> Result /// Set up the externalities and safe calling environment to execute calls to a native runtime. /// /// If the inner closure panics, it will be caught and return an error. -pub fn with_native_environment(ext: &mut Externalities, f: F) -> Result +pub fn with_native_environment(ext: &mut dyn Externalities, f: F) -> Result where F: UnwindSafe + FnOnce() -> U { ::runtime_io::with_externalities(ext, move || safe_call(f)) @@ -121,7 +121,7 @@ pub trait NativeExecutionDispatch: Send + Sync { /// Dispatch a method and input data to be executed natively. Returns `Some` result or `None` /// if the `method` is unknown. Panics if there's an unrecoverable error. // fn dispatch(ext: &mut Externalities, method: &str, data: &[u8]) -> Result>; - fn dispatch(ext: &mut Externalities, method: &str, data: &[u8]) -> Result>; + fn dispatch(ext: &mut dyn Externalities, method: &str, data: &[u8]) -> Result>; /// Provide native runtime version. fn native_version() -> NativeVersion; diff --git a/core/executor/src/wasm_executor.rs b/core/executor/src/wasm_executor.rs index 6a3c92b755..920639c0a2 100644 --- a/core/executor/src/wasm_executor.rs +++ b/core/executor/src/wasm_executor.rs @@ -1101,7 +1101,7 @@ impl WasmExecutor { /// This should be used for tests only. pub fn call_with_custom_signature< E: Externalities, - F: FnOnce(&mut FnMut(&[u8]) -> Result) -> Result>, + F: FnOnce(&mut dyn FnMut(&[u8]) -> Result) -> Result>, FR: FnOnce(Option, &MemoryRef) -> Result>, R, >( @@ -1158,7 +1158,7 @@ impl WasmExecutor { /// Call a given method in the given wasm-module runtime. fn call_in_wasm_module_with_custom_signature< E: Externalities, - F: FnOnce(&mut FnMut(&[u8]) -> Result) -> Result>, + F: FnOnce(&mut dyn FnMut(&[u8]) -> Result) -> Result>, FR: FnOnce(Option, &MemoryRef) -> Result>, R, >( diff --git a/core/executor/src/wasm_utils.rs b/core/executor/src/wasm_utils.rs index a9fbca7f6c..7384f91944 100644 --- a/core/executor/src/wasm_utils.rs +++ b/core/executor/src/wasm_utils.rs @@ -174,7 +174,7 @@ macro_rules! impl_function_executor { => $($pre:tt)+ ) => ( impl $( $pre ) + $structname { #[allow(unused)] - fn resolver() -> &'static $crate::wasmi::ModuleImportResolver { + fn resolver() -> &'static dyn $crate::wasmi::ModuleImportResolver { struct Resolver; impl $crate::wasmi::ModuleImportResolver for Resolver { fn resolve_func(&self, name: &str, signature: &$crate::wasmi::Signature) -> ::std::result::Result<$crate::wasmi::FuncRef, $crate::wasmi::Error> { diff --git a/core/finality-grandpa/src/communication/gossip.rs b/core/finality-grandpa/src/communication/gossip.rs index 79f98e5bdb..460998e707 100644 --- a/core/finality-grandpa/src/communication/gossip.rs +++ b/core/finality-grandpa/src/communication/gossip.rs @@ -657,7 +657,7 @@ impl GossipValidator { } impl network_gossip::Validator for GossipValidator { - fn new_peer(&self, context: &mut ValidatorContext, who: &PeerId, _roles: Roles) { + fn new_peer(&self, context: &mut dyn ValidatorContext, who: &PeerId, _roles: Roles) { let packet_data = { let mut inner = self.inner.write(); inner.peers.new_peer(who.clone()); @@ -673,11 +673,11 @@ impl network_gossip::Validator for GossipValidator context.send_message(who, packet_data); } - fn peer_disconnected(&self, _context: &mut ValidatorContext, who: &PeerId) { + fn peer_disconnected(&self, _context: &mut dyn ValidatorContext, who: &PeerId) { self.inner.write().peers.peer_disconnected(who); } - fn validate(&self, context: &mut ValidatorContext, who: &PeerId, data: &[u8]) + fn validate(&self, context: &mut dyn ValidatorContext, who: &PeerId, data: &[u8]) -> network_gossip::ValidationResult { let (action, broadcast_topics) = self.do_validate(who, data); @@ -705,7 +705,7 @@ impl network_gossip::Validator for GossipValidator } fn message_allowed<'a>(&'a self) - -> Box bool + 'a> + -> Box bool + 'a> { let (inner, do_rebroadcast) = { use parking_lot::RwLockWriteGuard; @@ -763,7 +763,7 @@ impl network_gossip::Validator for GossipValidator }) } - fn message_expired<'a>(&'a self) -> Box bool + 'a> { + fn message_expired<'a>(&'a self) -> Box bool + 'a> { let inner = self.inner.read(); Box::new(move |topic, mut data| { // if the topic is not one of the ones that we are keeping at the moment, diff --git a/core/finality-grandpa/src/finality_proof.rs b/core/finality-grandpa/src/finality_proof.rs index e8af599279..875a60e8e0 100644 --- a/core/finality-grandpa/src/finality_proof.rs +++ b/core/finality-grandpa/src/finality_proof.rs @@ -103,7 +103,7 @@ pub trait AuthoritySetForFinalityChecker: Send + Sync { } /// FetchChecker-based implementation of AuthoritySetForFinalityChecker. -impl AuthoritySetForFinalityChecker for Arc> { +impl AuthoritySetForFinalityChecker for Arc> { fn check_authorities_proof( &self, hash: Block::Hash, @@ -132,7 +132,7 @@ impl AuthoritySetForFinalityChecker for Arc, RA> { client: Arc>, - authority_provider: Arc>, + authority_provider: Arc>, } impl, RA> FinalityProofProvider @@ -147,7 +147,7 @@ impl, RA> FinalityProofProvider /// - authority_provider for calling and proving runtime methods. pub fn new( client: Arc>, - authority_provider: Arc>, + authority_provider: Arc>, ) -> Self { FinalityProofProvider { client, authority_provider } } @@ -256,7 +256,7 @@ pub(crate) fn make_finality_proof_request(last_finalized: H, /// Returns None if there are no finalized blocks unknown to the caller. pub(crate) fn prove_finality, B: BlockchainBackend, J>( blockchain: &B, - authorities_provider: &AuthoritySetForFinalityProver, + authorities_provider: &dyn AuthoritySetForFinalityProver, authorities_set_id: u64, begin: Block::Hash, end: Block::Hash, @@ -416,7 +416,7 @@ pub(crate) fn check_finality_proof, B>( blockchain: &B, current_set_id: u64, current_authorities: Vec<(AuthorityId, u64)>, - authorities_provider: &AuthoritySetForFinalityChecker, + authorities_provider: &dyn AuthoritySetForFinalityChecker, remote_proof: Vec, ) -> ClientResult> where @@ -435,7 +435,7 @@ fn do_check_finality_proof, B, J>( blockchain: &B, current_set_id: u64, current_authorities: Vec<(AuthorityId, u64)>, - authorities_provider: &AuthoritySetForFinalityChecker, + authorities_provider: &dyn AuthoritySetForFinalityChecker, remote_proof: Vec, ) -> ClientResult> where @@ -489,7 +489,7 @@ fn do_check_finality_proof, B, J>( fn check_finality_proof_fragment, B, J>( blockchain: &B, authority_set: AuthoritiesOrEffects, - authorities_provider: &AuthoritySetForFinalityChecker, + authorities_provider: &dyn AuthoritySetForFinalityChecker, proof_fragment: FinalityProofFragment, ) -> ClientResult> where diff --git a/core/finality-grandpa/src/import.rs b/core/finality-grandpa/src/import.rs index d68793c047..ed57c68250 100644 --- a/core/finality-grandpa/src/import.rs +++ b/core/finality-grandpa/src/import.rs @@ -76,7 +76,7 @@ impl, RA, PRA, SC> JustificationImport { type Error = ConsensusError; - fn on_start(&self, link: &::consensus_common::import_queue::Link) { + fn on_start(&self, link: &dyn consensus_common::import_queue::Link) { let chain_info = self.inner.info().chain; // request justifications for all pending changes for which change blocks have already been imported @@ -183,7 +183,7 @@ where ); match maybe_change { - Err(e) => match api.has_api_with::, _>(&at, |v| v >= 2) { + Err(e) => match api.has_api_with::, _>(&at, |v| v >= 2) { Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()), Ok(true) => { // API version is high enough to support forced changes diff --git a/core/finality-grandpa/src/light_import.rs b/core/finality-grandpa/src/light_import.rs index 73bc3411fe..c70f91d0f3 100644 --- a/core/finality-grandpa/src/light_import.rs +++ b/core/finality-grandpa/src/light_import.rs @@ -53,7 +53,7 @@ const LIGHT_CONSENSUS_CHANGES_KEY: &[u8] = b"grandpa_consensus_changes"; /// Create light block importer. pub fn light_block_import, RA, PRA>( client: Arc>, - authority_set_provider: Arc>, + authority_set_provider: Arc>, api: Arc, ) -> Result, ClientError> where @@ -80,7 +80,7 @@ pub fn light_block_import, RA, PRA>( /// - fetching finality proofs for blocks that are enacting consensus changes. pub struct GrandpaLightBlockImport, RA> { client: Arc>, - authority_set_provider: Arc>, + authority_set_provider: Arc>, data: Arc>>, } @@ -144,7 +144,7 @@ impl, RA> FinalityProofImport { type Error = ConsensusError; - fn on_start(&self, link: &::consensus_common::import_queue::Link) { + fn on_start(&self, link: &dyn consensus_common::import_queue::Link) { let chain_info = self.client.info().chain; let data = self.data.read(); @@ -160,7 +160,7 @@ impl, RA> FinalityProofImport hash: Block::Hash, number: NumberFor, finality_proof: Vec, - verifier: &Verifier, + verifier: &dyn Verifier, ) -> Result<(Block::Hash, NumberFor), Self::Error> { do_import_finality_proof::<_, _, _, _, GrandpaJustification>( &*self.client, @@ -271,12 +271,12 @@ fn do_import_block, RA, J>( /// Try to import finality proof. fn do_import_finality_proof, RA, J>( client: &Client, - authority_set_provider: &AuthoritySetForFinalityChecker, + authority_set_provider: &dyn AuthoritySetForFinalityChecker, data: &mut LightImportData, _hash: Block::Hash, _number: NumberFor, finality_proof: Vec, - verifier: &Verifier, + verifier: &dyn Verifier, ) -> Result<(Block::Hash, NumberFor), ConsensusError> where B: Backend + 'static, @@ -572,7 +572,7 @@ pub mod tests { { type Error = ConsensusError; - fn on_start(&self, link: &::consensus_common::import_queue::Link) { + fn on_start(&self, link: &dyn consensus_common::import_queue::Link) { self.0.on_start(link) } @@ -581,7 +581,7 @@ pub mod tests { hash: Block::Hash, number: NumberFor, finality_proof: Vec, - verifier: &Verifier, + verifier: &dyn Verifier, ) -> Result<(Block::Hash, NumberFor), Self::Error> { self.0.import_finality_proof(hash, number, finality_proof, verifier) } @@ -590,7 +590,7 @@ pub mod tests { /// Creates light block import that ignores justifications that came outside of finality proofs. pub fn light_block_import_without_justifications, RA, PRA>( client: Arc>, - authority_set_provider: Arc>, + authority_set_provider: Arc>, api: Arc, ) -> Result, ClientError> where diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index ef04396b5f..51028fad84 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -150,7 +150,10 @@ impl TestNetFactory for GrandpaTestNet { } } - fn make_finality_proof_provider(&self, client: PeersClient) -> Option>> { + fn make_finality_proof_provider( + &self, + client: PeersClient + ) -> Option>> { match client { PeersClient::Full(ref client) => { let authorities_provider = Arc::new(self.test_config.clone()); @@ -201,7 +204,7 @@ impl MessageRouting { } impl Network for MessageRouting { - type In = Box + Send>; + type In = Box + Send>; /// Get a stream of messages for a specific gossip topic. fn messages_for(&self, topic: Hash) -> Self::In { @@ -463,7 +466,7 @@ fn run_to_completion_with( peers: &[AuthorityKeyring], with: F, ) -> u64 where - F: FnOnce(current_thread::Handle) -> Option>> + F: FnOnce(current_thread::Handle) -> Option>> { use parking_lot::RwLock; diff --git a/core/keyring/src/sr25519.rs b/core/keyring/src/sr25519.rs index 0097d7b2f9..24a83ab798 100644 --- a/core/keyring/src/sr25519.rs +++ b/core/keyring/src/sr25519.rs @@ -68,7 +68,7 @@ impl Keyring { } pub fn to_raw_public_vec(self) -> Vec { - Public::from(self).to_raw_vec() + Public::from(self).into_raw_vec() } pub fn sign(self, msg: &[u8]) -> Signature { diff --git a/core/network/src/config.rs b/core/network/src/config.rs index e6c1a4ddd5..d8fd0f68c7 100644 --- a/core/network/src/config.rs +++ b/core/network/src/config.rs @@ -35,9 +35,9 @@ pub struct Params { /// Network layer configuration. pub network_config: NetworkConfiguration, /// Substrate relay chain access point. - pub chain: Arc>, + pub chain: Arc>, /// Finality proof provider. - pub finality_proof_provider: Option>>, + pub finality_proof_provider: Option>>, /// On-demand service reference. pub on_demand: Option>>, /// Transaction pool. @@ -45,7 +45,7 @@ pub struct Params { /// Name of the protocol to use on the wire. Should be different for each chain. pub protocol_id: ProtocolId, /// Import queue to use. - pub import_queue: Box>, + pub import_queue: Box>, /// Protocol specialization. pub specialization: S, } diff --git a/core/network/src/consensus_gossip.rs b/core/network/src/consensus_gossip.rs index c5f1a2d927..9d654b5bfa 100644 --- a/core/network/src/consensus_gossip.rs +++ b/core/network/src/consensus_gossip.rs @@ -110,7 +110,7 @@ pub trait ValidatorContext { struct NetworkContext<'g, 'p, B: BlockT> { gossip: &'g mut ConsensusGossip, - protocol: &'p mut Context, + protocol: &'p mut dyn Context, engine_id: ConsensusEngineId, } @@ -145,11 +145,11 @@ impl<'g, 'p, B: BlockT> ValidatorContext for NetworkContext<'g, 'p, B> { } fn propagate<'a, B: BlockT, I>( - protocol: &mut Context, + protocol: &mut dyn Context, messages: I, intent: MessageIntent, peers: &mut HashMap>, - validators: &HashMap>>, + validators: &HashMap>>, ) where I: IntoIterator, // (msg_hash, topic, message) { @@ -200,23 +200,23 @@ fn propagate<'a, B: BlockT, I>( /// Validates consensus messages. pub trait Validator: Send + Sync { /// New peer is connected. - fn new_peer(&self, _context: &mut ValidatorContext, _who: &PeerId, _roles: Roles) { + fn new_peer(&self, _context: &mut dyn ValidatorContext, _who: &PeerId, _roles: Roles) { } /// New connection is dropped. - fn peer_disconnected(&self, _context: &mut ValidatorContext, _who: &PeerId) { + fn peer_disconnected(&self, _context: &mut dyn ValidatorContext, _who: &PeerId) { } /// Validate consensus message. - fn validate(&self, context: &mut ValidatorContext, sender: &PeerId, data: &[u8]) -> ValidationResult; + fn validate(&self, context: &mut dyn ValidatorContext, sender: &PeerId, data: &[u8]) -> ValidationResult; /// Produce a closure for validating messages on a given topic. - fn message_expired<'a>(&'a self) -> Box bool + 'a> { + fn message_expired<'a>(&'a self) -> Box bool + 'a> { Box::new(move |_topic, _data| false) } /// Produce a closure for filtering egress messages. - fn message_allowed<'a>(&'a self) -> Box bool + 'a> { + fn message_allowed<'a>(&'a self) -> Box bool + 'a> { Box::new(move |_who, _intent, _topic, _data| true) } } @@ -227,7 +227,7 @@ pub struct ConsensusGossip { live_message_sinks: HashMap<(ConsensusEngineId, B::Hash), Vec>>, messages: Vec>, known_messages: LruCache, - validators: HashMap>>, + validators: HashMap>>, next_broadcast: time::Instant, } @@ -250,7 +250,12 @@ impl ConsensusGossip { } /// Register message validator for a message type. - pub fn register_validator(&mut self, protocol: &mut Context, engine_id: ConsensusEngineId, validator: Arc>) { + pub fn register_validator( + &mut self, + protocol: &mut dyn Context, + engine_id: ConsensusEngineId, + validator: Arc> + ) { self.register_validator_internal(engine_id, validator.clone()); let peers: Vec<_> = self.peers.iter().map(|(id, peer)| (id.clone(), peer.roles)).collect(); for (id, roles) in peers { @@ -259,12 +264,12 @@ impl ConsensusGossip { } } - fn register_validator_internal(&mut self, engine_id: ConsensusEngineId, validator: Arc>) { + fn register_validator_internal(&mut self, engine_id: ConsensusEngineId, validator: Arc>) { self.validators.insert(engine_id, validator.clone()); } /// Handle new connected peer. - pub fn new_peer(&mut self, protocol: &mut Context, who: PeerId, roles: Roles) { + pub fn new_peer(&mut self, protocol: &mut dyn Context, who: PeerId, roles: Roles) { // light nodes are not valid targets for consensus gossip messages if !roles.is_full() { return; @@ -311,7 +316,7 @@ impl ConsensusGossip { } /// Call when a peer has been disconnected to stop tracking gossip status. - pub fn peer_disconnected(&mut self, protocol: &mut Context, who: PeerId) { + pub fn peer_disconnected(&mut self, protocol: &mut dyn Context, who: PeerId) { for (engine_id, v) in self.validators.clone() { let mut context = NetworkContext { gossip: self, protocol, engine_id: engine_id.clone() }; v.peer_disconnected(&mut context, &who); @@ -319,7 +324,7 @@ impl ConsensusGossip { } /// Perform periodic maintenance - pub fn tick(&mut self, protocol: &mut Context) { + pub fn tick(&mut self, protocol: &mut dyn Context) { self.collect_garbage(); if time::Instant::now() >= self.next_broadcast { self.rebroadcast(protocol); @@ -328,14 +333,14 @@ impl ConsensusGossip { } /// Rebroadcast all messages to all peers. - fn rebroadcast(&mut self, protocol: &mut Context) { + fn rebroadcast(&mut self, protocol: &mut dyn Context) { let messages = self.messages.iter() .map(|entry| (&entry.message_hash, &entry.topic, &entry.message)); propagate(protocol, messages, MessageIntent::PeriodicRebroadcast, &mut self.peers, &self.validators); } /// Broadcast all messages with given topic. - pub fn broadcast_topic(&mut self, protocol: &mut Context, topic: B::Hash, force: bool) { + pub fn broadcast_topic(&mut self, protocol: &mut dyn Context, topic: B::Hash, force: bool) { let messages = self.messages.iter() .filter_map(|entry| if entry.topic == topic { Some((&entry.message_hash, &entry.topic, &entry.message)) } else { None } @@ -409,7 +414,7 @@ impl ConsensusGossip { /// in all other cases. pub fn on_incoming( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, who: PeerId, message: ConsensusMessage, ) { @@ -473,7 +478,14 @@ impl ConsensusGossip { } /// Send all messages with given topic to a peer. - pub fn send_topic(&mut self, protocol: &mut Context, who: &PeerId, topic: B::Hash, engine_id: ConsensusEngineId, force: bool) { + pub fn send_topic( + &mut self, + protocol: &mut dyn Context, + who: &PeerId, + topic: B::Hash, + engine_id: ConsensusEngineId, + force: bool + ) { let validator = self.validators.get(&engine_id); let mut message_allowed = match validator { None => return, // treat all messages with no validator as not allowed @@ -503,7 +515,7 @@ impl ConsensusGossip { /// Multicast a message to all peers. pub fn multicast( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, topic: B::Hash, message: ConsensusMessage, force: bool, @@ -518,7 +530,7 @@ impl ConsensusGossip { /// later on. pub fn send_message( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, who: &PeerId, message: ConsensusMessage, ) { @@ -559,7 +571,12 @@ mod tests { struct AllowAll; impl Validator for AllowAll { - fn validate(&self, _context: &mut ValidatorContext, _sender: &PeerId, _data: &[u8]) -> ValidationResult { + fn validate( + &self, + _context: &mut dyn ValidatorContext, + _sender: &PeerId, + _data: &[u8], + ) -> ValidationResult { ValidationResult::ProcessAndKeep(H256::default()) } } @@ -568,7 +585,12 @@ mod tests { fn collects_garbage() { struct AllowOne; impl Validator for AllowOne { - fn validate(&self, _context: &mut ValidatorContext, _sender: &PeerId, data: &[u8]) -> ValidationResult { + fn validate( + &self, + _context: &mut dyn ValidatorContext, + _sender: &PeerId, + data: &[u8], + ) -> ValidationResult { if data[0] == 1 { ValidationResult::ProcessAndKeep(H256::default()) } else { @@ -576,7 +598,7 @@ mod tests { } } - fn message_expired<'a>(&'a self) -> Box bool + 'a> { + fn message_expired<'a>(&'a self) -> Box bool + 'a> { Box::new(move |_topic, data| data[0] != 1 ) } } diff --git a/core/network/src/on_demand_layer.rs b/core/network/src/on_demand_layer.rs index 95f9f4d67b..e58e045f2e 100644 --- a/core/network/src/on_demand_layer.rs +++ b/core/network/src/on_demand_layer.rs @@ -50,7 +50,7 @@ impl OnDemand where B::Header: HeaderT, { /// Creates new on-demand service. - pub fn new(checker: Arc>) -> Self { + pub fn new(checker: Arc>) -> Self { let (requests_send, requests_queue) = mpsc::unbounded(); let requests_queue = Mutex::new(Some(requests_queue)); @@ -62,7 +62,7 @@ impl OnDemand where } /// Get checker reference. - pub fn checker(&self) -> &Arc> { + pub fn checker(&self) -> &Arc> { &self.checker } diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index b660e097a1..569f1df030 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -346,7 +346,7 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SyncContext for ProtocolContext<'a, self.context_data.peers.get(who).map(|p| p.info.clone()) } - fn client(&self) -> &Client { + fn client(&self) -> &dyn Client { &*self.context_data.chain } @@ -373,7 +373,7 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SyncContext for ProtocolContext<'a, struct ContextData { // All connected peers peers: HashMap>, - pub chain: Arc>, + pub chain: Arc>, } /// Configuration for the Substrate-specific part of the networking layer. @@ -395,7 +395,7 @@ impl, H: ExHashT> Protocol { /// Create a new instance. pub fn new( config: ProtocolConfig, - chain: Arc>, + chain: Arc>, checker: Arc>, specialization: S, ) -> error::Result> { @@ -510,7 +510,7 @@ impl, H: ExHashT> Protocol { transaction_pool: &(impl TransactionPool + ?Sized), who: PeerId, message: Message, - finality_proof_provider: Option<&FinalityProofProvider> + finality_proof_provider: Option<&dyn FinalityProofProvider> ) -> CustomMessageOutcome { match message { GenericMessage::Status(s) => self.on_status_message(network_out, who, s), @@ -1399,7 +1399,7 @@ impl, H: ExHashT> Protocol { network_out: &mut dyn NetworkOut, who: PeerId, request: message::FinalityProofRequest, - finality_proof_provider: Option<&FinalityProofProvider> + finality_proof_provider: Option<&dyn FinalityProofProvider> ) { trace!(target: "sync", "Finality proof request from {} for {}", who, request.block); let finality_proof = finality_proof_provider.as_ref() diff --git a/core/network/src/service.rs b/core/network/src/service.rs index c7a32d472f..88c13b4806 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -358,7 +358,7 @@ impl> NetworkService { /// Execute a closure with the chain-specific network specialization. pub fn with_spec(&self, f: F) - where F: FnOnce(&mut S, &mut Context) + Send + 'static + where F: FnOnce(&mut S, &mut dyn Context) + Send + 'static { let _ = self .protocol_sender @@ -367,7 +367,7 @@ impl> NetworkService { /// Execute a closure with the consensus gossip. pub fn with_gossip(&self, f: F) - where F: FnOnce(&mut ConsensusGossip, &mut Context) + Send + 'static + where F: FnOnce(&mut ConsensusGossip, &mut dyn Context) + Send + 'static { let _ = self .protocol_sender @@ -489,9 +489,9 @@ pub enum ProtocolMsg> { /// A block has been finalized (sent by the client). BlockFinalized(B::Hash, B::Header), /// Execute a closure with the chain-specific network specialization. - ExecuteWithSpec(Box + Send + 'static>), + ExecuteWithSpec(Box + Send + 'static>), /// Execute a closure with the consensus gossip. - ExecuteWithGossip(Box + Send + 'static>), + ExecuteWithGossip(Box + Send + 'static>), /// Incoming gossip consensus message. GossipConsensusMessage(B::Hash, ConsensusEngineId, Vec, GossipMessageRecipient), /// Tell protocol to perform regular maintenance. @@ -504,22 +504,22 @@ pub enum ProtocolMsg> { /// A task, consisting of a user-provided closure, to be executed on the Protocol thread. pub trait SpecTask> { - fn call_box(self: Box, spec: &mut S, context: &mut Context); + fn call_box(self: Box, spec: &mut S, context: &mut dyn Context); } -impl, F: FnOnce(&mut S, &mut Context)> SpecTask for F { - fn call_box(self: Box, spec: &mut S, context: &mut Context) { +impl, F: FnOnce(&mut S, &mut dyn Context)> SpecTask for F { + fn call_box(self: Box, spec: &mut S, context: &mut dyn Context) { (*self)(spec, context) } } /// A task, consisting of a user-provided closure, to be executed on the Protocol thread. pub trait GossipTask { - fn call_box(self: Box, gossip: &mut ConsensusGossip, context: &mut Context); + fn call_box(self: Box, gossip: &mut ConsensusGossip, context: &mut dyn Context); } -impl, &mut Context)> GossipTask for F { - fn call_box(self: Box, gossip: &mut ConsensusGossip, context: &mut Context) { +impl, &mut dyn Context)> GossipTask for F { + fn call_box(self: Box, gossip: &mut ConsensusGossip, context: &mut dyn Context) { (*self)(gossip, context) } } @@ -535,9 +535,9 @@ pub struct NetworkWorker, H: Ex service: Arc>, network_service: Arc>>>, peers: Arc>>>, - import_queue: Box>, + import_queue: Box>, transaction_pool: Arc>, - finality_proof_provider: Option>>, + finality_proof_provider: Option>>, network_port: mpsc::UnboundedReceiver>, protocol_rx: mpsc::UnboundedReceiver>, status_sinks: Arc>>>>, diff --git a/core/network/src/specialization.rs b/core/network/src/specialization.rs index 2778146b52..772a1bcbe1 100644 --- a/core/network/src/specialization.rs +++ b/core/network/src/specialization.rs @@ -25,15 +25,15 @@ pub trait NetworkSpecialization: Send + Sync + 'static { fn status(&self) -> Vec; /// Called when a peer successfully handshakes. - fn on_connect(&mut self, ctx: &mut Context, who: PeerId, status: crate::message::Status); + fn on_connect(&mut self, ctx: &mut dyn Context, who: PeerId, status: crate::message::Status); /// Called when a peer is disconnected. If the peer ID is unknown, it should be ignored. - fn on_disconnect(&mut self, ctx: &mut Context, who: PeerId); + fn on_disconnect(&mut self, ctx: &mut dyn Context, who: PeerId); /// Called when a network-specific message arrives. fn on_message( &mut self, - ctx: &mut Context, + ctx: &mut dyn Context, who: PeerId, message: &mut Option> ); @@ -43,11 +43,11 @@ pub trait NetworkSpecialization: Send + Sync + 'static { fn on_abort(&mut self) { } /// Called periodically to maintain peers and handle timeouts. - fn maintain_peers(&mut self, _ctx: &mut Context) { } + fn maintain_peers(&mut self, _ctx: &mut dyn Context) { } /// Called when a block is _imported_ at the head of the chain (not during major sync). /// Not guaranteed to be called for every block, but will be most of the after major sync. - fn on_block_imported(&mut self, _ctx: &mut Context, _hash: B::Hash, _header: &B::Header) { } + fn on_block_imported(&mut self, _ctx: &mut dyn Context, _hash: B::Hash, _header: &B::Header) { } } /// Context for a network-specific handler. diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index 27a412ca0e..9b327c1a20 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -72,7 +72,7 @@ const GENESIS_MISMATCH_REPUTATION_CHANGE: i32 = i32::min_value() + 1; /// Context for a network-specific handler. pub trait Context { /// Get a reference to the client. - fn client(&self) -> &crate::chain::Client; + fn client(&self) -> &dyn crate::chain::Client; /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or /// irresponsible or appeared lazy. @@ -131,7 +131,7 @@ pub(crate) enum PeerSyncState { /// Relay chain sync strategy. pub struct ChainSync { - genesis_hash: B::Hash, + _genesis_hash: B::Hash, peers: HashMap>, blocks: BlockCollection, best_queued_number: NumberFor, @@ -191,7 +191,7 @@ impl ChainSync { } ChainSync { - genesis_hash: info.chain.genesis_hash, + _genesis_hash: info.chain.genesis_hash, peers: HashMap::new(), blocks: BlockCollection::new(), best_queued_hash: info.best_queued_hash.unwrap_or(info.chain.best_hash), @@ -230,14 +230,14 @@ impl ChainSync { let best_seen = self.best_seen_block(); let state = self.state(&best_seen); Status { - state: state, + state, best_seen_block: best_seen, num_peers: self.peers.len() as u32, } } /// Handle new connected peer. Call this method whenever we connect to a new peer. - pub(crate) fn new_peer(&mut self, protocol: &mut Context, who: PeerId) { + pub(crate) fn new_peer(&mut self, protocol: &mut dyn Context, who: PeerId) { if let Some(info) = protocol.peer_info(&who) { // there's nothing sync can get from the node that has no blockchain data // (the opposite is not true, but all requests are served at protocol level) @@ -366,7 +366,7 @@ impl ChainSync { #[must_use] pub(crate) fn on_block_data( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, who: PeerId, request: message::BlockRequest, response: message::BlockResponse @@ -483,7 +483,7 @@ impl ChainSync { #[must_use] pub(crate) fn on_block_justification_data( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, who: PeerId, _request: message::BlockRequest, response: message::BlockResponse, @@ -528,7 +528,7 @@ impl ChainSync { /// Handle new finality proof data. pub(crate) fn on_block_finality_proof_data( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, who: PeerId, response: message::FinalityProofResponse, ) -> Option<(PeerId, B::Hash, NumberFor, Vec)> { @@ -573,7 +573,7 @@ impl ChainSync { } /// Maintain the sync process (download new blocks, fetch justifications). - pub fn maintain_sync(&mut self, protocol: &mut Context) { + pub fn maintain_sync(&mut self, protocol: &mut dyn Context) { let peers: Vec = self.peers.keys().map(|p| p.clone()).collect(); for peer in peers { self.download_new(protocol, peer); @@ -583,7 +583,7 @@ impl ChainSync { /// Called periodically to perform any time-based actions. Must be called at a regular /// interval. - pub fn tick(&mut self, protocol: &mut Context) { + pub fn tick(&mut self, protocol: &mut dyn Context) { self.extra_requests.dispatch(&mut self.peers, protocol); } @@ -591,7 +591,7 @@ impl ChainSync { /// /// Uses `protocol` to queue a new justification request and tries to dispatch all pending /// requests. - pub fn request_justification(&mut self, hash: &B::Hash, number: NumberFor, protocol: &mut Context) { + pub fn request_justification(&mut self, hash: &B::Hash, number: NumberFor, protocol: &mut dyn Context) { self.extra_requests.justifications().queue_request( (*hash, number), |base, block| protocol.client().is_descendent_of(base, block), @@ -620,7 +620,7 @@ impl ChainSync { /// Request a finality proof for the given block. /// /// Queues a new finality proof request and tries to dispatch all pending requests. - pub fn request_finality_proof(&mut self, hash: &B::Hash, number: NumberFor, protocol: &mut Context) { + pub fn request_finality_proof(&mut self, hash: &B::Hash, number: NumberFor, protocol: &mut dyn Context) { self.extra_requests.finality_proofs().queue_request( (*hash, number), |base, block| protocol.client().is_descendent_of(base, block), @@ -647,7 +647,7 @@ impl ChainSync { } /// Notify about finalization of the given block. - pub fn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor, protocol: &mut Context) { + pub fn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor, protocol: &mut dyn Context) { if let Err(err) = self.extra_requests.on_block_finalized( hash, number, @@ -699,7 +699,7 @@ impl ChainSync { #[must_use] pub(crate) fn on_block_announce( &mut self, - protocol: &mut Context, + protocol: &mut dyn Context, who: PeerId, hash: B::Hash, header: &B::Header, @@ -812,12 +812,12 @@ impl ChainSync { self.peers.iter().any(|(_, p)| p.state == PeerSyncState::DownloadingStale(*hash)) } - fn is_known(&self, protocol: &mut Context, hash: &B::Hash) -> bool { + fn is_known(&self, protocol: &mut dyn Context, hash: &B::Hash) -> bool { block_status(&*protocol.client(), &self.queue_blocks, *hash).ok().map_or(false, |s| s != BlockStatus::Unknown) } /// Call when a peer has disconnected. - pub(crate) fn peer_disconnected(&mut self, protocol: &mut Context, who: PeerId) { + pub(crate) fn peer_disconnected(&mut self, protocol: &mut dyn Context, who: PeerId) { self.blocks.clear_peer_download(&who); self.peers.remove(&who); self.extra_requests.peer_disconnected(who); @@ -825,7 +825,7 @@ impl ChainSync { } /// Restart the sync process. - pub(crate) fn restart(&mut self, protocol: &mut Context) { + pub(crate) fn restart(&mut self, protocol: &mut dyn Context) { self.queue_blocks.clear(); self.best_importing_number = Zero::zero(); self.blocks.clear(); @@ -886,7 +886,7 @@ impl ChainSync { } // Issue a request for a peer to download new blocks, if any are available. - fn download_new(&mut self, protocol: &mut Context, who: PeerId) { + fn download_new(&mut self, protocol: &mut dyn Context, who: PeerId) { if let Some((_, request)) = self.select_new_blocks(who.clone()) { protocol.send_block_request(who, request); } @@ -942,7 +942,7 @@ impl ChainSync { } } - fn request_ancestry(protocol: &mut Context, who: PeerId, block: NumberFor) { + fn request_ancestry(protocol: &mut dyn Context, who: PeerId, block: NumberFor) { trace!(target: "sync", "Requesting ancestry block #{} from {}", block, who); let request = message::generic::BlockRequest { id: 0, @@ -958,7 +958,7 @@ impl ChainSync { /// Get block status, taking into account import queue. fn block_status( - chain: &crate::chain::Client, + chain: &dyn crate::chain::Client, queue_blocks: &HashSet, hash: B::Hash) -> Result { diff --git a/core/network/src/sync/extra_requests.rs b/core/network/src/sync/extra_requests.rs index 3ebf2b2509..ff8323166b 100644 --- a/core/network/src/sync/extra_requests.rs +++ b/core/network/src/sync/extra_requests.rs @@ -39,7 +39,7 @@ pub(crate) trait ExtraRequestsEssence { /// Name of request type to display in logs. fn type_name(&self) -> &'static str; /// Send network message corresponding to the request. - fn send_network_request(&self, protocol: &mut Context, peer: PeerId, request: ExtraRequest); + fn send_network_request(&self, protocol: &mut dyn Context, peer: PeerId, request: ExtraRequest); /// Create peer state for peer that is downloading extra data. fn peer_downloading_state(&self, block: B::Hash) -> PeerSyncState; } @@ -69,7 +69,7 @@ impl ExtraRequestsAggregator { } /// Dispatches all possible pending requests to the given peers. - pub(crate) fn dispatch(&mut self, peers: &mut HashMap>, protocol: &mut Context) { + pub(crate) fn dispatch(&mut self, peers: &mut HashMap>, protocol: &mut dyn Context) { self.justifications.dispatch(peers, protocol); self.finality_proofs.dispatch(peers, protocol); } @@ -132,7 +132,7 @@ impl> ExtraRequests { /// extra request for block #10 to a peer at block #2), and we also /// throttle requests to the same peer if a previous justification request /// yielded no results. - pub(crate) fn dispatch(&mut self, peers: &mut HashMap>, protocol: &mut Context) { + pub(crate) fn dispatch(&mut self, peers: &mut HashMap>, protocol: &mut dyn Context) { if self.pending_requests.is_empty() { return; } @@ -373,7 +373,7 @@ impl ExtraRequestsEssence for JustificationsRequestsEssence { "justification" } - fn send_network_request(&self, protocol: &mut Context, peer: PeerId, request: ExtraRequest) { + fn send_network_request(&self, protocol: &mut dyn Context, peer: PeerId, request: ExtraRequest) { protocol.send_block_request(peer, message::generic::BlockRequest { id: 0, fields: message::BlockAttributes::JUSTIFICATION, @@ -398,7 +398,7 @@ impl ExtraRequestsEssence for FinalityProofRequestsEssence { "finality proof" } - fn send_network_request(&self, protocol: &mut Context, peer: PeerId, request: ExtraRequest) { + fn send_network_request(&self, protocol: &mut dyn Context, peer: PeerId, request: ExtraRequest) { protocol.send_finality_proof_request(peer, message::generic::FinalityProofRequest { id: 0, block: request.0, diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index b47cef11ac..b9703d71e0 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -103,22 +103,19 @@ impl NetworkSpecialization for DummySpecialization { fn on_connect( &mut self, - _ctx: &mut SpecializationContext, + _ctx: &mut dyn SpecializationContext, _peer_id: PeerId, _status: crate::message::Status - ) { - } + ) {} - fn on_disconnect(&mut self, _ctx: &mut SpecializationContext, _peer_id: PeerId) { - } + fn on_disconnect(&mut self, _ctx: &mut dyn SpecializationContext, _peer_id: PeerId) {} fn on_message( &mut self, - _ctx: &mut SpecializationContext, + _ctx: &mut dyn SpecializationContext, _peer_id: PeerId, _message: &mut Option>, - ) { - } + ) {} } pub type PeersFullClient = @@ -292,7 +289,7 @@ pub struct Peer> { finalized_hash: Mutex>, } -type MessageFilter = Fn(&NetworkMsg) -> bool; +type MessageFilter = dyn Fn(&NetworkMsg) -> bool; pub enum FromNetworkMsg { /// A peer connected, with debug info. @@ -605,7 +602,7 @@ impl> Peer { /// Execute a closure with the consensus gossip. pub fn with_gossip(&self, f: F) - where F: FnOnce(&mut ConsensusGossip, &mut Context) + Send + 'static + where F: FnOnce(&mut ConsensusGossip, &mut dyn Context) + Send + 'static { self.net_proto_channel.send_from_client(ProtocolMsg::ExecuteWithGossip(Box::new(f))); } @@ -767,7 +764,7 @@ pub trait TestNetFactory: Sized { } /// Get finality proof provider (if supported). - fn make_finality_proof_provider(&self, _client: PeersClient) -> Option>> { + fn make_finality_proof_provider(&self, _client: PeersClient) -> Option>> { None } @@ -799,7 +796,7 @@ pub trait TestNetFactory: Sized { protocol_status: Arc>>, import_queue: Box>, tx_pool: EmptyTransactionPool, - finality_proof_provider: Option>>, + finality_proof_provider: Option>>, mut protocol: Protocol, network_sender: mpsc::UnboundedSender>, mut network_to_protocol_rx: mpsc::UnboundedReceiver>, diff --git a/core/offchain/src/lib.rs b/core/offchain/src/lib.rs index 376f41b445..081ae61a5b 100644 --- a/core/offchain/src/lib.rs +++ b/core/offchain/src/lib.rs @@ -91,7 +91,7 @@ impl OffchainWorkers where { let runtime = self.client.runtime_api(); let at = BlockId::number(*number); - let has_api = runtime.has_api::>(&at); + let has_api = runtime.has_api::>(&at); debug!("Checking offchain workers at {:?}: {:?}", at, has_api); if has_api.unwrap_or(false) { diff --git a/core/primitives/src/hexdisplay.rs b/core/primitives/src/hexdisplay.rs index d748208d0e..cd2b6c18cb 100644 --- a/core/primitives/src/hexdisplay.rs +++ b/core/primitives/src/hexdisplay.rs @@ -21,7 +21,7 @@ pub struct HexDisplay<'a>(&'a [u8]); impl<'a> HexDisplay<'a> { /// Create new instance that will display `d` as a hex string when displayed. - pub fn from(d: &'a AsBytesRef) -> Self { HexDisplay(d.as_bytes_ref()) } + pub fn from(d: &'a dyn AsBytesRef) -> Self { HexDisplay(d.as_bytes_ref()) } } impl<'a> ::core::fmt::Display for HexDisplay<'a> { @@ -79,7 +79,7 @@ pub fn ascii_format(asciish: &[u8]) -> String { let mut latch = false; for c in asciish { match (latch, *c) { - (false, 32...127) => r.push(*c as char), + (false, 32..=127) => r.push(*c as char), _ => { if !latch { r.push('#'); diff --git a/core/primitives/src/lib.rs b/core/primitives/src/lib.rs index 69b9f1a960..7c0fd324fe 100644 --- a/core/primitives/src/lib.rs +++ b/core/primitives/src/lib.rs @@ -86,7 +86,7 @@ pub enum ExecutionContext { /// Context used for block construction. BlockConstruction, /// Offchain worker context. - OffchainWorker(Box), + OffchainWorker(Box), /// Context used for other calls. Other, } diff --git a/core/primitives/src/offchain.rs b/core/primitives/src/offchain.rs index 764837d7b4..7d54c9d61e 100644 --- a/core/primitives/src/offchain.rs +++ b/core/primitives/src/offchain.rs @@ -35,8 +35,8 @@ impl TryFrom for CryptoKind { fn try_from(kind: u32) -> Result { match kind { - e if e == CryptoKind::Sr25519 as u8 as u32 => Ok(CryptoKind::Sr25519), - e if e == CryptoKind::Ed25519 as u8 as u32 => Ok(CryptoKind::Ed25519), + e if e == u32::from(CryptoKind::Sr25519 as u8) => Ok(CryptoKind::Sr25519), + e if e == u32::from(CryptoKind::Ed25519 as u8) => Ok(CryptoKind::Ed25519), _ => Err(()) } } @@ -103,7 +103,7 @@ impl From for u32 { HttpRequestStatus::Unknown => 0, HttpRequestStatus::DeadlineReached => 10, HttpRequestStatus::Timeout => 20, - HttpRequestStatus::Finished(code) => code as u32, + HttpRequestStatus::Finished(code) => u32::from(code), } } } @@ -116,7 +116,7 @@ impl TryFrom for HttpRequestStatus { 0 => Ok(HttpRequestStatus::Unknown), 10 => Ok(HttpRequestStatus::DeadlineReached), 20 => Ok(HttpRequestStatus::Timeout), - 100...999 => Ok(HttpRequestStatus::Finished(status as u16)), + 100..=999 => u16::try_from(status).map(HttpRequestStatus::Finished).map_err(|_| ()), _ => Err(()), } } diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 8f309ec030..876dcb7078 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -204,16 +204,16 @@ impl From for Signature { } #[cfg(feature = "std")] -impl ::std::fmt::Debug for Signature { +impl std::fmt::Debug for Signature { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, "{}", crate::hexdisplay::HexDisplay::from(&self.0)) } } #[cfg(feature = "std")] -impl ::std::hash::Hash for Signature { - fn hash(&self, state: &mut H) { - ::std::hash::Hash::hash(&self.0[..], state); +impl std::hash::Hash for Signature { + fn hash(&self, state: &mut H) { + std::hash::Hash::hash(&self.0[..], state); } } @@ -304,15 +304,13 @@ impl Public { /// Return a `Vec` filled with raw data. #[cfg(feature = "std")] - pub fn to_raw_vec(self) -> Vec { - let r: &[u8; 32] = self.as_ref(); - r.to_vec() + pub fn into_raw_vec(self) -> Vec { + self.0.to_vec() } /// Return a slice filled with raw data. pub fn as_slice(&self) -> &[u8] { - let r: &[u8; 32] = self.as_ref(); - &r[..] + &self.0 } /// Return a slice filled with raw data. @@ -637,7 +635,7 @@ mod test { #[test] fn verify_from_wasm_works() { // The values in this test case are compared to the output of `node-test.js` in schnorrkel-js. - // + // // This is to make sure that the wasm library is compatible. let pk = Pair::from_seed(hex!("0000000000000000000000000000000000000000000000000000000000000000")); let public = pk.public(); diff --git a/core/rpc/src/author/error.rs b/core/rpc/src/author/error.rs index 5955108249..008a70b674 100644 --- a/core/rpc/src/author/error.rs +++ b/core/rpc/src/author/error.rs @@ -34,7 +34,7 @@ pub enum Error { Pool(txpool::error::Error), /// Verification error #[display(fmt="Extrinsic verification error: {}", "_0.description()")] - Verification(Box<::std::error::Error + Send>), + Verification(Box), /// Incorrect extrinsic format. #[display(fmt="Invalid extrinsic format")] BadFormat, diff --git a/core/rpc/src/system/mod.rs b/core/rpc/src/system/mod.rs index 8aac02b77d..d6f2b75515 100644 --- a/core/rpc/src/system/mod.rs +++ b/core/rpc/src/system/mod.rs @@ -74,7 +74,7 @@ pub trait SystemApi { /// System API implementation pub struct System { info: SystemInfo, - sync: Arc>, + sync: Arc>, should_have_peers: bool, } @@ -82,7 +82,7 @@ impl System { /// Creates new `System` given the `SystemInfo`. pub fn new( info: SystemInfo, - sync: Arc>, + sync: Arc>, should_have_peers: bool, ) -> Self { System { diff --git a/core/service/src/chain_ops.rs b/core/service/src/chain_ops.rs index 3be3b9b17a..83f103ec8f 100644 --- a/core/service/src/chain_ops.rs +++ b/core/service/src/chain_ops.rs @@ -151,7 +151,7 @@ pub fn import_blocks( let (header, extrinsics) = signed.block.deconstruct(); let hash = header.hash(); let block = message::BlockData:: { - hash: hash, + hash, justification: signed.justification, header: Some(header), body: Some(extrinsics), diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 3876279cc7..a314588d0a 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -139,7 +139,7 @@ pub trait StartRPC { fn start_rpc( client: Arc>, - network: Arc>>, + network: Arc>>, should_have_peers: bool, system_info: SystemInfo, rpc_http: Option, @@ -159,7 +159,7 @@ impl StartRPC for C where fn start_rpc( client: Arc>, - network: Arc>>, + network: Arc>>, should_have_peers: bool, rpc_system_info: SystemInfo, rpc_http: Option, @@ -339,7 +339,7 @@ pub trait ServiceFactory: 'static + Sized { /// Build finality proof provider for serving network requests on full node. fn build_finality_proof_provider( client: Arc> - ) -> Result>>, error::Error>; + ) -> Result>>, error::Error>; /// Build the Fork Choice algorithm for full client fn build_select_chain( @@ -435,7 +435,7 @@ pub trait Components: Sized + 'static { /// Finality proof provider for serving network requests. fn build_finality_proof_provider( client: Arc> - ) -> Result::Block>>>, error::Error>; + ) -> Result::Block>>>, error::Error>; /// Build fork choice selector fn build_select_chain( @@ -536,7 +536,7 @@ impl Components for FullComponents { fn build_finality_proof_provider( client: Arc> - ) -> Result::Block>>>, error::Error> { + ) -> Result::Block>>>, error::Error> { Factory::build_finality_proof_provider(client) } } @@ -619,7 +619,7 @@ impl Components for LightComponents { fn build_finality_proof_provider( _client: Arc> - ) -> Result::Block>>>, error::Error> { + ) -> Result::Block>>>, error::Error> { Ok(None) } fn build_select_chain( diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 0e16d2e7be..bc40d6008b 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -80,7 +80,7 @@ pub struct Service { signal: Option, /// Configuration of this Service pub config: FactoryFullConfiguration, - _rpc: Box<::std::any::Any + Send + Sync>, + _rpc: Box, _telemetry: Option>, _offchain_workers: Option, ComponentBlock>>>, _telemetry_on_connect_sinks: Arc>>>, @@ -104,7 +104,7 @@ pub type TelemetryOnConnectNotifications = mpsc::UnboundedReceiver<()>; /// Used to hook on telemetry connection established events. pub struct TelemetryOnConnect<'a> { /// Handle to a future that will resolve on exit. - pub on_exit: Box + Send + 'static>, + pub on_exit: Box + Send + 'static>, /// Event stream. pub telemetry_connection_sinks: TelemetryOnConnectNotifications, /// Executor to which the hook is spawned. diff --git a/core/sr-api-macros/src/lib.rs b/core/sr-api-macros/src/lib.rs index c5f8941002..7399da0794 100644 --- a/core/sr-api-macros/src/lib.rs +++ b/core/sr-api-macros/src/lib.rs @@ -54,11 +54,11 @@ mod utils; /// # extern crate substrate_primitives; /// # /// # use runtime_primitives::traits::GetNodeBlockType; -/// # use test_client::runtime::Block; +/// # use test_client::runtime::{Block, Header}; /// # /// # /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// # /// trait are done by the `construct_runtime!` macro in a real runtime. -/// # struct Runtime {} +/// # pub struct Runtime {} /// # impl GetNodeBlockType for Runtime { /// # type NodeBlock = Block; /// # } @@ -78,6 +78,15 @@ mod utils; /// /// /// All runtime api implementations need to be done in one call of the macro! /// impl_runtime_apis! { +/// # impl client::runtime_api::Core for Runtime { +/// # fn version() -> client::runtime_api::RuntimeVersion { +/// # unimplemented!() +/// # } +/// # fn execute_block(_block: Block) {} +/// # fn initialize_block(_header: &Header) {} +/// # fn authorities() -> Vec> { unimplemented!() } +/// # } +/// /// impl self::Balance for Runtime { /// fn get_balance() -> u64 { /// 1 @@ -176,7 +185,7 @@ pub fn impl_runtime_apis(input: TokenStream) -> TokenStream { /// /// /// /// Is callable by `set_balance_before_version_2`. /// #[changed_in(2)] -/// fn set_balance(val: u8); +/// fn set_balance(val: u16); /// /// In version 2, we added this new function. /// fn increase_balance(val: u64); /// } diff --git a/core/sr-api-macros/tests/decl_and_impl.rs b/core/sr-api-macros/tests/decl_and_impl.rs index 51f95d51b1..44db8021d4 100644 --- a/core/sr-api-macros/tests/decl_and_impl.rs +++ b/core/sr-api-macros/tests/decl_and_impl.rs @@ -122,7 +122,7 @@ fn check_runtime_api_versions_contains() { #[test] fn check_runtime_api_versions() { - check_runtime_api_versions_contains::>(); - check_runtime_api_versions_contains::>(); - check_runtime_api_versions_contains::>(); + check_runtime_api_versions_contains::>(); + check_runtime_api_versions_contains::>(); + check_runtime_api_versions_contains::>(); } diff --git a/core/sr-io/with_std.rs b/core/sr-io/with_std.rs index 01e7614de6..0ba833bd9f 100644 --- a/core/sr-io/with_std.rs +++ b/core/sr-io/with_std.rs @@ -251,7 +251,7 @@ impl HashingApi for () { } } -fn with_offchain(f: impl FnOnce(&mut offchain::Externalities) -> R, msg: &'static str) -> R { +fn with_offchain(f: impl FnOnce(&mut dyn offchain::Externalities) -> R, msg: &'static str) -> R { ext::with(|ext| ext .offchain() .map(|ext| f(ext)) @@ -395,7 +395,7 @@ impl Api for () {} /// Execute the given closure with global function available whose functionality routes into the /// externalities `ext`. Forwards the value that the closure returns. // NOTE: need a concrete hasher here due to limitations of the `environmental!` macro, otherwise a type param would have been fine I think. -pub fn with_externalities R>(ext: &mut Externalities, f: F) -> R { +pub fn with_externalities R>(ext: &mut dyn Externalities, f: F) -> R { ext::using(ext, f) } diff --git a/core/sr-primitives/src/generic/mod.rs b/core/sr-primitives/src/generic/mod.rs index 3d7682407e..89c4291d79 100644 --- a/core/sr-primitives/src/generic/mod.rs +++ b/core/sr-primitives/src/generic/mod.rs @@ -44,8 +44,8 @@ use rstd::prelude::*; fn encode_with_vec_prefix)>(encoder: F) -> Vec { let size = ::rstd::mem::size_of::(); let reserve = match size { - 0...0b00111111 => 1, - 0...0b00111111_11111111 => 2, + 0..=0b00111111 => 1, + 0..=0b00111111_11111111 => 2, _ => 4, }; let mut v = Vec::with_capacity(reserve + size); diff --git a/core/state-machine/src/basic.rs b/core/state-machine/src/basic.rs index 0eb0b84b27..e9939711f1 100644 --- a/core/state-machine/src/basic.rs +++ b/core/state-machine/src/basic.rs @@ -156,7 +156,7 @@ impl Externalities for BasicExternalities where H::Out: Ord { Ok(None) } - fn offchain(&mut self) -> Option<&mut offchain::Externalities> { + fn offchain(&mut self) -> Option<&mut dyn offchain::Externalities> { warn!("Call to non-existent out offchain externalities set."); None } @@ -171,7 +171,7 @@ mod tests { #[test] fn commit_should_work() { let mut ext = BasicExternalities::default(); - let ext = &mut ext as &mut Externalities; + let ext = &mut ext as &mut dyn Externalities; ext.set_storage(b"doe".to_vec(), b"reindeer".to_vec()); ext.set_storage(b"dog".to_vec(), b"puppy".to_vec()); ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); @@ -182,7 +182,7 @@ mod tests { #[test] fn set_and_retrieve_code() { let mut ext = BasicExternalities::default(); - let ext = &mut ext as &mut Externalities; + let ext = &mut ext as &mut dyn Externalities; let code = vec![1, 2, 3]; ext.set_storage(CODE.to_vec(), code.clone()); diff --git a/core/state-machine/src/changes_trie/mod.rs b/core/state-machine/src/changes_trie/mod.rs index 15ea1b474f..7dc95fb5a7 100644 --- a/core/state-machine/src/changes_trie/mod.rs +++ b/core/state-machine/src/changes_trie/mod.rs @@ -112,7 +112,7 @@ pub trait Storage: RootsStorage { } /// Changes trie storage -> trie backend essence adapter. -pub struct TrieBackendStorageAdapter<'a, H: Hasher, Number: BlockNumber>(pub &'a Storage); +pub struct TrieBackendStorageAdapter<'a, H: Hasher, Number: BlockNumber>(pub &'a dyn Storage); impl<'a, H: Hasher, N: BlockNumber> crate::TrieBackendStorage for TrieBackendStorageAdapter<'a, H, N> { type Overlay = trie::MemoryDB; diff --git a/core/state-machine/src/ext.rs b/core/state-machine/src/ext.rs index 6ec1ce77e6..5a0daeb348 100644 --- a/core/state-machine/src/ext.rs +++ b/core/state-machine/src/ext.rs @@ -343,7 +343,7 @@ where Ok(root) } - fn offchain(&mut self) -> Option<&mut offchain::Externalities> { + fn offchain(&mut self) -> Option<&mut dyn offchain::Externalities> { self.offchain_externalities.as_mut().map(|x| &mut **x as _) } } diff --git a/core/state-machine/src/lib.rs b/core/state-machine/src/lib.rs index 9f0e20ce01..93d70423d5 100644 --- a/core/state-machine/src/lib.rs +++ b/core/state-machine/src/lib.rs @@ -222,7 +222,7 @@ pub trait Externalities { fn storage_changes_root(&mut self, parent: H::Out) -> Result, ()> where H::Out: Ord; /// Returns offchain externalities extension if present. - fn offchain(&mut self) -> Option<&mut offchain::Externalities>; + fn offchain(&mut self) -> Option<&mut dyn offchain::Externalities>; } /// An implementation of offchain extensions that should never be triggered. @@ -502,7 +502,7 @@ impl<'a, H, N, B, T, O, Exec> StateMachine<'a, H, N, B, T, O, Exec> where pub fn execute( &mut self, strategy: ExecutionStrategy, - ) -> Result<(Vec, B::Transaction, Option>), Box> { + ) -> Result<(Vec, B::Transaction, Option>), Box> { // We are not giving a native call and thus we are sure that the result can never be a native // value. self.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>( @@ -613,7 +613,7 @@ impl<'a, H, N, B, T, O, Exec> StateMachine<'a, H, N, B, T, O, Exec> where manager: ExecutionManager, compute_tx: bool, mut native_call: Option, - ) -> Result<(NativeOrEncoded, Option, Option>), Box> where + ) -> Result<(NativeOrEncoded, Option, Option>), Box> where R: Decode + Encode + PartialEq, NC: FnOnce() -> result::Result + UnwindSafe, Handler: FnOnce( @@ -674,7 +674,7 @@ pub fn prove_execution( exec: &Exec, method: &str, call_data: &[u8], -) -> Result<(Vec, Vec>), Box> +) -> Result<(Vec, Vec>), Box> where B: Backend, H: Hasher, @@ -682,7 +682,7 @@ where H::Out: Ord + 'static, { let trie_backend = backend.as_trie_backend() - .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; + .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; prove_execution_on_trie_backend(trie_backend, overlay, exec, method, call_data) } @@ -701,7 +701,7 @@ pub fn prove_execution_on_trie_backend( exec: &Exec, method: &str, call_data: &[u8], -) -> Result<(Vec, Vec>), Box> +) -> Result<(Vec, Vec>), Box> where S: trie_backend_essence::TrieBackendStorage, H: Hasher, @@ -736,7 +736,7 @@ pub fn execution_proof_check( exec: &Exec, method: &str, call_data: &[u8], -) -> Result, Box> +) -> Result, Box> where H: Hasher, Exec: CodeExecutor, @@ -753,7 +753,7 @@ pub fn execution_proof_check_on_trie_backend( exec: &Exec, method: &str, call_data: &[u8], -) -> Result, Box> +) -> Result, Box> where H: Hasher, Exec: CodeExecutor, @@ -780,7 +780,7 @@ where pub fn prove_read( mut backend: B, key: &[u8] -) -> Result<(Option>, Vec>), Box> +) -> Result<(Option>, Vec>), Box> where B: Backend, H: Hasher, @@ -788,7 +788,7 @@ where { let trie_backend = backend.as_trie_backend() .ok_or_else( - ||Box::new(ExecutionError::UnableToGenerateProof) as Box + ||Box::new(ExecutionError::UnableToGenerateProof) as Box )?; prove_read_on_trie_backend(trie_backend, key) } @@ -798,14 +798,14 @@ pub fn prove_child_read( mut backend: B, storage_key: &[u8], key: &[u8], -) -> Result<(Option>, Vec>), Box> +) -> Result<(Option>, Vec>), Box> where B: Backend, H: Hasher, H::Out: Ord { let trie_backend = backend.as_trie_backend() - .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; + .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; prove_child_read_on_trie_backend(trie_backend, storage_key, key) } @@ -814,14 +814,14 @@ where pub fn prove_read_on_trie_backend( trie_backend: &TrieBackend, key: &[u8] -) -> Result<(Option>, Vec>), Box> +) -> Result<(Option>, Vec>), Box> where S: trie_backend_essence::TrieBackendStorage, H: Hasher, H::Out: Ord { let proving_backend = proving_backend::ProvingBackend::<_, H>::new(trie_backend); - let result = proving_backend.storage(key).map_err(|e| Box::new(e) as Box)?; + let result = proving_backend.storage(key).map_err(|e| Box::new(e) as Box)?; Ok((result, proving_backend.extract_proof())) } @@ -830,15 +830,14 @@ pub fn prove_child_read_on_trie_backend( trie_backend: &TrieBackend, storage_key: &[u8], key: &[u8] -) -> Result<(Option>, Vec>), Box> +) -> Result<(Option>, Vec>), Box> where S: trie_backend_essence::TrieBackendStorage, H: Hasher, H::Out: Ord { let proving_backend = proving_backend::ProvingBackend::<_, H>::new(trie_backend); - let result = proving_backend.child_storage(storage_key, key) - .map_err(|e| Box::new(e) as Box)?; + let result = proving_backend.child_storage(storage_key, key).map_err(|e| Box::new(e) as Box)?; Ok((result, proving_backend.extract_proof())) } @@ -847,7 +846,7 @@ pub fn read_proof_check( root: H::Out, proof: Vec>, key: &[u8], -) -> Result>, Box> +) -> Result>, Box> where H: Hasher, H::Out: Ord @@ -862,7 +861,7 @@ pub fn read_child_proof_check( proof: Vec>, storage_key: &[u8], key: &[u8], -) -> Result>, Box> +) -> Result>, Box> where H: Hasher, H::Out: Ord @@ -876,12 +875,12 @@ where pub fn read_proof_check_on_proving_backend( proving_backend: &TrieBackend, H>, key: &[u8], -) -> Result>, Box> +) -> Result>, Box> where H: Hasher, H::Out: Ord { - proving_backend.storage(key).map_err(|e| Box::new(e) as Box) + proving_backend.storage(key).map_err(|e| Box::new(e) as Box) } /// Check child storage read proof on pre-created proving backend. @@ -889,20 +888,24 @@ pub fn read_child_proof_check_on_proving_backend( proving_backend: &TrieBackend, H>, storage_key: &[u8], key: &[u8], -) -> Result>, Box> +) -> Result>, Box> where H: Hasher, H::Out: Ord { - proving_backend.child_storage(storage_key, key).map_err(|e| Box::new(e) as Box) + proving_backend.child_storage(storage_key, key).map_err(|e| Box::new(e) as Box) } /// Sets overlayed changes' changes trie configuration. Returns error if configuration /// differs from previous OR config decode has failed. -pub(crate) fn set_changes_trie_config(overlay: &mut OverlayedChanges, config: Option>, final_check: bool) -> Result<(), Box> { +pub(crate) fn set_changes_trie_config( + overlay: &mut OverlayedChanges, + config: Option>, + final_check: bool, +) -> Result<(), Box> { let config = match config { Some(v) => Some(Decode::decode(&mut &v[..]) - .ok_or_else(|| Box::new("Failed to decode changes trie configuration".to_owned()) as Box)?), + .ok_or_else(|| Box::new("Failed to decode changes trie configuration".to_owned()) as Box)?), None => None, }; @@ -920,16 +923,16 @@ pub(crate) fn set_changes_trie_config(overlay: &mut OverlayedChanges, config: Op /// Reads storage value from overlay or from the backend. fn try_read_overlay_value(overlay: &OverlayedChanges, backend: &B, key: &[u8]) - -> Result>, Box> + -> Result>, Box> where H: Hasher, - B: Backend, { match overlay.storage(key).map(|x| x.map(|x| x.to_vec())) { Some(value) => Ok(value), - None => backend.storage(key) - .map_err(|err| Box::new(ExecutionError::Backend(format!("{}", err))) as Box), + None => backend + .storage(key) + .map_err(|err| Box::new(ExecutionError::Backend(format!("{}", err))) as Box), } } diff --git a/core/state-machine/src/proving_backend.rs b/core/state-machine/src/proving_backend.rs index f9472ed747..60178ff899 100644 --- a/core/state-machine/src/proving_backend.rs +++ b/core/state-machine/src/proving_backend.rs @@ -193,17 +193,17 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> pub fn create_proof_check_backend( root: H::Out, proof: Vec> -) -> Result, H>, Box> +) -> Result, H>, Box> where H: Hasher, { let db = create_proof_check_backend_storage(proof); - if !db.contains(&root, &[]) { - return Err(Box::new(ExecutionError::InvalidProof) as Box); + if db.contains(&root, &[]) { + Ok(TrieBackend::new(db, root)) + } else { + Err(Box::new(ExecutionError::InvalidProof)) } - - Ok(TrieBackend::new(db, root)) } /// Create in-memory storage of proof check backend. diff --git a/core/state-machine/src/testing.rs b/core/state-machine/src/testing.rs index 3934e726af..68b9d28752 100644 --- a/core/state-machine/src/testing.rs +++ b/core/state-machine/src/testing.rs @@ -37,7 +37,7 @@ pub struct TestExternalities { overlay: OverlayedChanges, backend: InMemory, changes_trie_storage: ChangesTrieInMemoryStorage, - offchain: Option>, + offchain: Option>, } impl TestExternalities { @@ -234,7 +234,7 @@ impl Externalities for TestExternalities )?.map(|(root, _)| root.clone())) } - fn offchain(&mut self) -> Option<&mut offchain::Externalities> { + fn offchain(&mut self) -> Option<&mut dyn offchain::Externalities> { self.offchain .as_mut() .map(|x| &mut **x as _) diff --git a/core/state-machine/src/trie_backend_essence.rs b/core/state-machine/src/trie_backend_essence.rs index 89a5b42a84..fc30f94f05 100644 --- a/core/state-machine/src/trie_backend_essence.rs +++ b/core/state-machine/src/trie_backend_essence.rs @@ -153,8 +153,8 @@ impl<'a, > hash_db::AsPlainDB for Ephemeral<'a, S, H> { - fn as_plain_db<'b>(&'b self) -> &'b (hash_db::PlainDB + 'b) { self } - fn as_plain_db_mut<'b>(&'b mut self) -> &'b mut (hash_db::PlainDB + 'b) { self } + fn as_plain_db<'b>(&'b self) -> &'b (dyn hash_db::PlainDB + 'b) { self } + fn as_plain_db_mut<'b>(&'b mut self) -> &'b mut (dyn hash_db::PlainDB + 'b) { self } } impl<'a, @@ -163,8 +163,8 @@ impl<'a, > hash_db::AsHashDB for Ephemeral<'a, S, H> { - fn as_hash_db<'b>(&'b self) -> &'b (hash_db::HashDB + 'b) { self } - fn as_hash_db_mut<'b>(&'b mut self) -> &'b mut (hash_db::HashDB + 'b) { self } + fn as_hash_db<'b>(&'b self) -> &'b (dyn hash_db::HashDB + 'b) { self } + fn as_hash_db_mut<'b>(&'b mut self) -> &'b mut (dyn hash_db::HashDB + 'b) { self } } impl<'a, S: TrieBackendStorage, H: Hasher> Ephemeral<'a, S, H> { @@ -275,7 +275,7 @@ pub trait TrieBackendStorage: Send + Sync { } // This implementation is used by normal storage trie clients. -impl TrieBackendStorage for Arc> { +impl TrieBackendStorage for Arc> { type Overlay = PrefixedMemoryDB; fn get(&self, key: &H::Out, prefix: &[u8]) -> Result, String> { diff --git a/core/telemetry/src/lib.rs b/core/telemetry/src/lib.rs index 16bc69ec00..3f980c5929 100644 --- a/core/telemetry/src/lib.rs +++ b/core/telemetry/src/lib.rs @@ -38,14 +38,14 @@ pub struct TelemetryConfig { pub endpoints: TelemetryEndpoints, /// What do do when we connect to the servers. /// Note that this closure is executed each time we connect to a telemetry endpoint. - pub on_connect: Box, + pub on_connect: Box, } /// Telemetry service guard. pub type Telemetry = slog_scope::GlobalLoggerGuard; /// Size of the channel for passing messages to telemetry thread. -const CHANNEL_SIZE: usize = 262144; +const CHANNEL_SIZE: usize = 262_144; /// Log levels. pub const SUBSTRATE_DEBUG: &str = "9"; @@ -154,7 +154,7 @@ pub fn init_telemetry(config: TelemetryConfig) -> slog_scope::GlobalLoggerGuard }); }); - return logger_guard; + logger_guard } /// Translates to `slog_scope::info`, but contains an additional verbosity @@ -172,7 +172,7 @@ macro_rules! telemetry { struct Connection { out: ws::Sender, out_sync: Arc>>, - on_connect: Arc>, + on_connect: Arc>, url: String, } @@ -180,7 +180,7 @@ impl Connection { fn new( out: ws::Sender, out_sync: Arc>>, - on_connect: Arc>, + on_connect: Arc>, url: String ) -> Self { Connection { diff --git a/core/transaction-pool/graph/src/error.rs b/core/transaction-pool/graph/src/error.rs index acf3fa4514..07e0324354 100644 --- a/core/transaction-pool/graph/src/error.rs +++ b/core/transaction-pool/graph/src/error.rs @@ -35,7 +35,7 @@ pub enum Error { TemporarilyBanned, /// The transaction is already in the pool. #[display(fmt="[{:?}] Already imported", _0)] - AlreadyImported(Box), + AlreadyImported(Box), /// The transaction cannot be imported cause it's a replacement and has too low priority. #[display(fmt="Too low priority ({} > {})", old, new)] TooLowPriority { diff --git a/core/trie/src/lib.rs b/core/trie/src/lib.rs index 1322038d78..6298f10bf4 100644 --- a/core/trie/src/lib.rs +++ b/core/trie/src/lib.rs @@ -43,9 +43,9 @@ pub type TrieError = trie_db::TrieError; pub trait AsHashDB: hash_db::AsHashDB {} impl> AsHashDB for T {} /// As in `hash_db`, but less generic, trait exposed. -pub type HashDB<'a, H> = hash_db::HashDB + 'a; +pub type HashDB<'a, H> = dyn hash_db::HashDB + 'a; /// As in `hash_db`, but less generic, trait exposed. -pub type PlainDB<'a, K> = hash_db::PlainDB + 'a; +pub type PlainDB<'a, K> = dyn hash_db::PlainDB + 'a; /// As in `memory_db::MemoryDB` that uses prefixed storage key scheme. pub type PrefixedMemoryDB = memory_db::MemoryDB, trie_db::DBValue>; /// As in `memory_db::MemoryDB` that uses prefixed storage key scheme. @@ -471,7 +471,7 @@ mod tests { } fn populate_trie<'db>( - db: &'db mut HashDB, + db: &'db mut dyn HashDB, root: &'db mut ::Out, v: &[(Vec, Vec)] ) -> TrieDBMut<'db, Blake2Hasher> { diff --git a/core/trie/src/node_header.rs b/core/trie/src/node_header.rs index 4f7617c068..2c01189f8a 100644 --- a/core/trie/src/node_header.rs +++ b/core/trie/src/node_header.rs @@ -60,12 +60,12 @@ impl Decode for NodeHeader { Some(match input.read_byte()? { EMPTY_TRIE => NodeHeader::Null, // 0 - i @ LEAF_NODE_OFFSET ... LEAF_NODE_SMALL_MAX => // 1 ... (127 - 1) + i @ LEAF_NODE_OFFSET ..= LEAF_NODE_SMALL_MAX => // 1 ... (127 - 1) NodeHeader::Leaf((i - LEAF_NODE_OFFSET) as usize), LEAF_NODE_BIG => // 127 NodeHeader::Leaf(input.read_byte()? as usize + LEAF_NODE_THRESHOLD as usize), - i @ EXTENSION_NODE_OFFSET ... EXTENSION_NODE_SMALL_MAX =>// 128 ... (253 - 1) + i @ EXTENSION_NODE_OFFSET ..= EXTENSION_NODE_SMALL_MAX =>// 128 ... (253 - 1) NodeHeader::Extension((i - EXTENSION_NODE_OFFSET) as usize), EXTENSION_NODE_BIG => // 253 NodeHeader::Extension(input.read_byte()? as usize + EXTENSION_NODE_THRESHOLD as usize), diff --git a/core/trie/src/trie_stream.rs b/core/trie/src/trie_stream.rs index 123ab1ea16..913cff2c5a 100644 --- a/core/trie/src/trie_stream.rs +++ b/core/trie/src/trie_stream.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -//! `TrieStream` implementation for Substrate's trie format. +//! `TrieStream` implementation for Substrate's trie format. use rstd::iter::once; use hash_db::Hasher; @@ -83,7 +83,7 @@ impl trie_root::TrieStream for TrieStream { fn append_substream(&mut self, other: Self) { let data = other.out(); match data.len() { - 0...31 => { + 0..=31 => { data.encode_to(&mut self.buffer) }, _ => { diff --git a/core/util/fork-tree/src/lib.rs b/core/util/fork-tree/src/lib.rs index cba5a1535b..4b6745a354 100644 --- a/core/util/fork-tree/src/lib.rs +++ b/core/util/fork-tree/src/lib.rs @@ -52,7 +52,7 @@ impl std::error::Error for Error { } } - fn cause(&self) -> Option<&std::error::Error> { + fn cause(&self) -> Option<&dyn std::error::Error> { None } } diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index bc46e98ec2..597618c142 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -150,7 +150,6 @@ impl ProvideInherentData for InherentDataProvider { } fn error_to_string(&self, error: &[u8]) -> Option { - use parity_codec::Decode; RuntimeString::decode(&mut &error[..]).map(Into::into) } } diff --git a/srml/contract/src/exec.rs b/srml/contract/src/exec.rs index 1ab59fa0c2..7a16c9d60d 100644 --- a/srml/contract/src/exec.rs +++ b/srml/contract/src/exec.rs @@ -703,7 +703,7 @@ mod tests { } #[derive(Clone)] - struct MockExecutable<'a>(Rc VmExecResult + 'a>); + struct MockExecutable<'a>(Rc VmExecResult + 'a>); impl<'a> MockExecutable<'a> { fn new(f: impl Fn(MockCtx) -> VmExecResult + 'a) -> Self { diff --git a/srml/contract/src/tests.rs b/srml/contract/src/tests.rs index 29fc1d3a6d..7a19fdb1d6 100644 --- a/srml/contract/src/tests.rs +++ b/srml/contract/src/tests.rs @@ -300,15 +300,15 @@ fn account_removal_removes_storage() { // Verify that all entries from account 1 is removed, while // entries from account 2 is in place. { - assert!(>::get_storage(&DirectAccountDb, &1, Some(&trie_id1), key1).is_none()); - assert!(>::get_storage(&DirectAccountDb, &1, Some(&trie_id1), key2).is_none()); + assert!(>::get_storage(&DirectAccountDb, &1, Some(&trie_id1), key1).is_none()); + assert!(>::get_storage(&DirectAccountDb, &1, Some(&trie_id1), key2).is_none()); assert_eq!( - >::get_storage(&DirectAccountDb, &2, Some(&trie_id2), key1), + >::get_storage(&DirectAccountDb, &2, Some(&trie_id2), key1), Some(b"3".to_vec()) ); assert_eq!( - >::get_storage(&DirectAccountDb, &2, Some(&trie_id2), key2), + >::get_storage(&DirectAccountDb, &2, Some(&trie_id2), key2), Some(b"4".to_vec()) ); } diff --git a/srml/indices/src/address.rs b/srml/indices/src/address.rs index 123b8bca89..c76585d216 100644 --- a/srml/indices/src/address.rs +++ b/srml/indices/src/address.rs @@ -64,7 +64,7 @@ impl Decode for Address where { fn decode(input: &mut I) -> Option { Some(match input.read_byte()? { - x @ 0x00...0xef => Address::Index(AccountIndex::from(x as u32)), + x @ 0x00..=0xef => Address::Index(AccountIndex::from(x as u32)), 0xfc => Address::Index(AccountIndex::from( need_more_than(0xef, u16::decode(input)?)? as u32 )), diff --git a/subkey/src/vanity.rs b/subkey/src/vanity.rs index 400b3bae82..2399197e99 100644 --- a/subkey/src/vanity.rs +++ b/subkey/src/vanity.rs @@ -19,9 +19,9 @@ use super::Crypto; fn good_waypoint(done: u64) -> u64 { match done { - 0 ... 1_000_000 => 100_000, - 0 ... 10_000_000 => 1_000_000, - 0 ... 100_000_000 => 10_000_000, + 0 ..= 1_000_000 => 100_000, + 0 ..= 10_000_000 => 1_000_000, + 0 ..= 100_000_000 => 10_000_000, _ => 100_000_000, } } -- GitLab From 9a8e8b7d8064a7b48025184939edacd805b07a04 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 4 Jun 2019 20:11:18 +0200 Subject: [PATCH 082/113] Update to libp2p 0.9 (#2783) * Update to libp2p 0.9 * Fix browser-WASM --- Cargo.lock | 446 +++++++++++++++++---------- core/consensus/common/Cargo.toml | 2 +- core/network-libp2p/Cargo.toml | 2 +- core/network-libp2p/src/behaviour.rs | 12 +- core/network-libp2p/src/transport.rs | 8 +- core/peerset/Cargo.toml | 2 +- 6 files changed, 306 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1b630d428..da3ae1f4dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aes-ctr" version = "0.3.0" @@ -142,11 +147,6 @@ dependencies = [ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "base58" version = "0.1.0" @@ -278,6 +278,11 @@ dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "build_const" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bumpalo" version = "2.4.3" @@ -432,6 +437,22 @@ name = "core-foundation-sys" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "criterion" version = "0.2.11" @@ -703,11 +724,6 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dns-parser" version = "0.8.0" @@ -845,6 +861,19 @@ dependencies = [ "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fnv" version = "1.0.6" @@ -1246,6 +1275,11 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ipnet" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itertools" version = "0.8.0" @@ -1457,33 +1491,34 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1493,7 +1528,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1507,9 +1542,9 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1528,20 +1563,31 @@ dependencies = [ [[package]] name = "libp2p-core-derive" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-deflate" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-dns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1549,7 +1595,7 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1557,7 +1603,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1568,16 +1614,16 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1589,7 +1635,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1599,13 +1645,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1616,16 +1663,16 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1637,15 +1684,15 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1653,14 +1700,14 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1668,21 +1715,21 @@ dependencies = [ "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1692,23 +1739,23 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1716,7 +1763,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1727,7 +1774,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1745,13 +1792,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1760,23 +1808,23 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-wasm-ext" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1785,27 +1833,29 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "soketto 0.1.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-yamux" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1941,6 +1991,34 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miniz-sys" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide_c_api" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio" version = "0.6.19" @@ -2389,7 +2467,7 @@ dependencies = [ [[package]] name = "parity-multiaddr" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2398,6 +2476,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2939,6 +3018,19 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustls" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rw-stream-sink" version = "0.1.2" @@ -3011,6 +3103,15 @@ name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sct" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "security-framework" version = "0.3.1" @@ -3213,6 +3314,24 @@ dependencies = [ "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "soketto" +version = "0.1.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sourcefile" version = "0.1.4" @@ -3725,51 +3844,6 @@ name = "static_slice" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stdweb" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stream-cipher" version = "0.3.0" @@ -4075,7 +4149,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4268,7 +4342,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4327,7 +4401,7 @@ name = "substrate-peerset" version = "2.0.0" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4890,6 +4964,19 @@ dependencies = [ "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-rustls" +version = "0.10.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-sync" version = "0.1.5" @@ -5092,7 +5179,7 @@ name = "twox-hash" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5385,6 +5472,24 @@ dependencies = [ "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "webpki" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webpki-roots" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "websocket" version = "0.22.4" @@ -5564,6 +5669,14 @@ dependencies = [ "zeroize_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "zeroize" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "zeroize_derive" version = "0.1.0" @@ -5574,7 +5687,19 @@ dependencies = [ "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "zeroize_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" @@ -5591,7 +5716,6 @@ dependencies = [ "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" @@ -5607,6 +5731,7 @@ dependencies = [ "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" "checksum bstr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "59604ece62a407dc9164732e5adea02467898954c3a5811fd2dc140af14ef15b" +"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" @@ -5627,6 +5752,8 @@ dependencies = [ "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" +"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" @@ -5655,7 +5782,6 @@ dependencies = [ "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" @@ -5671,6 +5797,7 @@ dependencies = [ "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" "checksum finality-grandpa 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5cdd9ef7c48777665dacc9657c272778121d4d09848100bcc2bd9c773c6cf837" "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" +"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -5717,6 +5844,7 @@ dependencies = [ "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +"checksum ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e61c2da0d0f700c77d2d313dbf4f93e41d235fa12c6681fee06621036df4c2af" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" @@ -5739,25 +5867,26 @@ dependencies = [ "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" -"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" -"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" -"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" -"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" -"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" -"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" -"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" -"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" -"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" -"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" -"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" -"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" -"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" -"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" -"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" -"checksum libp2p-websocket 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04451aa166aa2040293f44c1c27144b65500e4a2ebbb723dfe732f39436eccbd" -"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" +"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" +"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" +"checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" +"checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" +"checksum libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fced4da0c31e0dc8a759472c65fab41db40c01de2d93bc45e1431c13f0564f0" +"checksum libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba5e882d72c71cdf77f45ab68dd715451d3b78a23085f8d385c7a31ec1b4272" +"checksum libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d71966dbbb4cedcfcdb1d4c87d5dbb6f3f07b465d1ca74f2624256669997d1f2" +"checksum libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdbdaea6f0049cc09ba5db00308f5b93105a8a33b65ba2e36bd35da707850ea2" +"checksum libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b351bfd67e97154e7b60f62402237671486c8a89f83eabdb6838f37d4d5f006" +"checksum libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44324032b2f9260d2b862c741d79d250dc02298dbba56354a992528a826ee2d5" +"checksum libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ac43ffd01de4210cf1b969bbb55a008c77f9ec22b74df26a6590bb6bd4c93f" +"checksum libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0506e10770bcbcb59f2a6154ce93c8fd5cb9730b6ceb5aa1463164af1fd0b9c6" +"checksum libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3886b79a35c0348497bab763517a9a2b4965173f4b4c7438d59f1e4dcf5122ff" +"checksum libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b811272e5cd86d39bd71fb94687025d9802b13daf0998ebe0d3f2885c636c51a" +"checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" +"checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" +"checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-websocket 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a837bca8813fec5bd7dcb849d2f5f673ddca36e079ac485edfb8fa221a9d752" +"checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" @@ -5774,6 +5903,9 @@ dependencies = [ "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" +"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" +"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" @@ -5802,7 +5934,7 @@ dependencies = [ "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" @@ -5863,6 +5995,7 @@ dependencies = [ "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" "checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" @@ -5872,6 +6005,7 @@ dependencies = [ "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" "checksum security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eee63d0f4a9ec776eeb30e220f0bc1e092c3ad744b2a379e3993070364d3adc2" "checksum security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9636f8989cbf61385ae4824b98c1aaa54c994d7d8b41f11c601ed799f0549a56" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -5894,15 +6028,12 @@ dependencies = [ "checksum slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" +"checksum soketto 0.1.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe8baac924db1b5f020050d7c8f8475c09d5ff11676101500fd0d3fdd184e67e" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" -"checksum stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c34362bb10ac1a9439674795cc0e1bdcb0c46444c8fd4874ef39a01d9a8a8f24" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e68f7d08b76979a43e93fe043b66d2626e35d41d68b0b85519202c6dd8ac59fa" -"checksum stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d52317523542cc0af5b7e31017ad0f7d1e78da50455e38d5657cd17754f617da" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" @@ -5938,6 +6069,7 @@ dependencies = [ "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" +"checksum tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "316fdbc899efec48b3b492bd0f339e6d81c4ee96a409257572147ec341943452" "checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" @@ -5991,6 +6123,8 @@ dependencies = [ "checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" "checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f7e1cd7900a3a6b65a3e8780c51a3e6b59c0e2c55c6dc69578c288d69f7d082" +"checksum webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c10fa4212003ba19a564f25cd8ab572c6791f99a03cc219c13ed35ccab00de0e" "checksum websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0adcd2a64c5746c9702b354a1b992802b0c363df1dfa324a74cb7aebe10e0cbf" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" @@ -6010,4 +6144,6 @@ dependencies = [ "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" "checksum zeroize 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e68403b858b6af538b11614e62dfe9ab2facba9f13a0cafb974855cfb495ec95" +"checksum zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b60a6c572b91d8ecb0a460950d84fe5b40699edd07d65f73789b31237afc8f66" "checksum zeroize_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3f07490820219949839d0027b965ffdd659d75be9220c00798762e36c6cd281" +"checksum zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9dac4b660d969bff9c3fe1847a891cacaa8b21dd5f2aae6e0a3e0975aea96431" diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index a64ae120f4..c2fc7cf231 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] derive_more = "0.14.0" crossbeam-channel = "0.3.4" -libp2p = { version = "0.8.1", default-features = false } +libp2p = { version = "0.9.0", default-features = false } log = "0.4" primitives = { package = "substrate-primitives", path= "../../primitives" } inherents = { package = "substrate-inherents", path = "../../inherents" } diff --git a/core/network-libp2p/Cargo.toml b/core/network-libp2p/Cargo.toml index a2ea8660a2..e92738b902 100644 --- a/core/network-libp2p/Cargo.toml +++ b/core/network-libp2p/Cargo.toml @@ -12,7 +12,7 @@ byteorder = "1.3" bytes = "0.4" fnv = "1.0" futures = "0.1" -libp2p = { version = "0.8.1", default-features = false, features = ["secp256k1", "libp2p-websocket"] } +libp2p = { version = "0.9.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] } parking_lot = "0.7.1" lazy_static = "1.2" log = "0.4" diff --git a/core/network-libp2p/src/behaviour.rs b/core/network-libp2p/src/behaviour.rs index a180a34064..379983a3fb 100644 --- a/core/network-libp2p/src/behaviour.rs +++ b/core/network-libp2p/src/behaviour.rs @@ -67,7 +67,7 @@ impl Behaviour Behaviour impl Iterator { + pub fn known_peers(&mut self) -> impl Iterator { self.discovery.kademlia.kbuckets_entries() } @@ -165,7 +165,7 @@ impl NetworkBehaviourEventProcess NetworkBehaviourEventProcess () + // We never start any other type of query. + KademliaOut::GetProvidersResult { .. } => {} + KademliaOut::GetValueResult(_) => {} + KademliaOut::PutValueResult(_) => {} } } } diff --git a/core/network-libp2p/src/transport.rs b/core/network-libp2p/src/transport.rs index f2860c7856..e1843476d9 100644 --- a/core/network-libp2p/src/transport.rs +++ b/core/network-libp2p/src/transport.rs @@ -17,10 +17,10 @@ use futures::prelude::*; use libp2p::{ InboundUpgradeExt, OutboundUpgradeExt, PeerId, Transport, - mplex, identity, secio, yamux, websocket, bandwidth, wasm_ext + mplex, identity, secio, yamux, bandwidth, wasm_ext }; #[cfg(not(target_os = "unknown"))] -use libp2p::{tcp, dns}; +use libp2p::{tcp, dns, websocket}; use libp2p::core::{self, transport::boxed::Boxed, transport::OptionalTransport, muxing::StreamMuxerBox}; use std::{io, sync::Arc, time::Duration, usize}; @@ -68,7 +68,9 @@ pub fn build_transport( .map(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer))) }) .with_timeout(Duration::from_secs(20)) - .map_err(|err| io::Error::new(io::ErrorKind::Other, err)) + // TODO: pass the error directly, instead of calling `to_string()` + // https://github.com/libp2p/rust-libp2p/issues/1162 + .map_err(|err| io::Error::new(io::ErrorKind::Other, err.to_string())) .boxed(); (transport, sinks) diff --git a/core/peerset/Cargo.toml b/core/peerset/Cargo.toml index d878485203..aa08c8ca99 100644 --- a/core/peerset/Cargo.toml +++ b/core/peerset/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] futures = "0.1" -libp2p = { version = "0.8.1", default-features = false } +libp2p = { version = "0.9.0", default-features = false } linked-hash-map = "0.5" log = "0.4" lru-cache = "0.1.2" -- GitLab From 94236e5d98516c365533ad608c36062eab51d936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 4 Jun 2019 22:28:18 +0200 Subject: [PATCH 083/113] Remove deprecated authorities function (#2785) * Remove deprecated authorities function * Bump spec * Fixes compilation * Remove last piece --- core/client/src/runtime_api.rs | 3 - core/consensus/aura/src/lib.rs | 15 +- core/finality-grandpa/src/tests.rs | 9 - core/sr-api-macros/src/lib.rs | 1 - core/sr-api-macros/tests/decl_and_impl.rs | 5 +- core/test-runtime/src/lib.rs | 8 - core/test-runtime/wasm/Cargo.lock | 328 ++++++++++++++++------ node-template/runtime/src/lib.rs | 4 - node-template/runtime/wasm/Cargo.lock | 328 ++++++++++++++++------ node/runtime/src/lib.rs | 8 +- node/runtime/wasm/Cargo.lock | 328 ++++++++++++++++------ 11 files changed, 741 insertions(+), 296 deletions(-) diff --git a/core/client/src/runtime_api.rs b/core/client/src/runtime_api.rs index 987138e69a..e456c166dc 100644 --- a/core/client/src/runtime_api.rs +++ b/core/client/src/runtime_api.rs @@ -171,9 +171,6 @@ decl_runtime_apis! { #[skip_initialize_block] #[initialize_block] fn initialize_block(header: &::Header); - /// Returns the authorities. - #[deprecated(since = "1.0", note = "Please switch to `AuthoritiesApi`.")] - fn authorities() -> Vec>; } /// The `Metadata` api trait that returns metadata for the runtime. diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index f0d982c36e..901d8b6f35 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -678,15 +678,12 @@ fn authorities(client: &C, at: &BlockId) -> Result>(at).unwrap_or(false) { - AuthoritiesApi::authorities(&*client.runtime_api(), at).ok() - } else { - CoreApi::authorities(&*client.runtime_api(), at).ok() - } - }).ok_or_else(|| consensus_common::Error::InvalidAuthoritiesSet.into()) + .and_then(|cache| cache + .get_at(&well_known_cache_keys::AUTHORITIES, at) + .and_then(|v| Decode::decode(&mut &v[..])) + ) + .or_else(|| AuthoritiesApi::authorities(&*client.runtime_api(), at).ok()) + .ok_or_else(|| consensus_common::Error::InvalidAuthoritiesSet.into()) } /// The Aura import queue type. diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 51028fad84..7fc2509f41 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -342,15 +342,6 @@ impl Core for RuntimeApi { ) -> Result> { unimplemented!("Not required for testing!") } - fn Core_authorities_runtime_api_impl( - &self, - _: &BlockId, - _: ExecutionContext, - _: Option<()>, - _: Vec, - ) -> Result>> { - unimplemented!("Not required for testing!") - } } impl ApiExt for RuntimeApi { diff --git a/core/sr-api-macros/src/lib.rs b/core/sr-api-macros/src/lib.rs index 7399da0794..1a315f44dd 100644 --- a/core/sr-api-macros/src/lib.rs +++ b/core/sr-api-macros/src/lib.rs @@ -84,7 +84,6 @@ mod utils; /// # } /// # fn execute_block(_block: Block) {} /// # fn initialize_block(_header: &Header) {} -/// # fn authorities() -> Vec> { unimplemented!() } /// # } /// /// impl self::Balance for Runtime { diff --git a/core/sr-api-macros/tests/decl_and_impl.rs b/core/sr-api-macros/tests/decl_and_impl.rs index 44db8021d4..ba7ef23b99 100644 --- a/core/sr-api-macros/tests/decl_and_impl.rs +++ b/core/sr-api-macros/tests/decl_and_impl.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use runtime_primitives::traits::{GetNodeBlockType, Block as BlockT, AuthorityIdFor}; +use runtime_primitives::traits::{GetNodeBlockType, Block as BlockT}; use runtime_primitives::generic::BlockId; use client::runtime_api::{self, RuntimeApiInfo}; use client::{error::Result, decl_runtime_apis, impl_runtime_apis}; @@ -74,9 +74,6 @@ impl_runtime_apis! { fn initialize_block(_: &::Header) { unimplemented!() } - fn authorities() -> Vec> { - unimplemented!() - } } } diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index e582fd4dc7..2e8981c524 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -352,10 +352,6 @@ cfg_if! { fn initialize_block(header: &::Header) { system::initialize_block(header) } - - fn authorities() -> Vec { - panic!("Deprecated, please use `AuthoritiesApi`.") - } } impl client_api::Metadata for Runtime { @@ -500,10 +496,6 @@ cfg_if! { fn initialize_block(header: &::Header) { system::initialize_block(header) } - - fn authorities() -> Vec { - panic!("Deprecated, please use `AuthoritiesApi`.") - } } impl client_api::Metadata for Runtime { diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index 2f05852a50..8763845ab7 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -1,5 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aes-ctr" version = "0.3.0" @@ -203,6 +208,11 @@ name = "bs58" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "build_const" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bumpalo" version = "2.4.3" @@ -283,6 +293,22 @@ name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam" version = "0.6.0" @@ -573,6 +599,19 @@ dependencies = [ "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fnv" version = "1.0.6" @@ -822,6 +861,11 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ipnet" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itoa" version = "0.4.4" @@ -875,32 +919,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -910,7 +955,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -924,9 +969,9 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -945,20 +990,31 @@ dependencies = [ [[package]] name = "libp2p-core-derive" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-deflate" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-dns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -966,7 +1022,7 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -974,7 +1030,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -985,16 +1041,16 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1006,7 +1062,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,13 +1072,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1033,16 +1090,16 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1054,15 +1111,15 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1070,14 +1127,14 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1085,21 +1142,21 @@ dependencies = [ "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1109,23 +1166,23 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1133,7 +1190,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1144,7 +1201,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1162,13 +1219,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1177,23 +1235,23 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-wasm-ext" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1202,11 +1260,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1234,6 +1292,14 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.6" @@ -1283,6 +1349,34 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miniz-sys" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide_c_api" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio" version = "0.6.19" @@ -1487,7 +1581,7 @@ dependencies = [ [[package]] name = "parity-multiaddr" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1496,6 +1590,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1554,6 +1649,16 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.2.14" @@ -1589,6 +1694,21 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "paste" version = "0.1.5" @@ -1969,6 +2089,11 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "semver" version = "0.9.0" @@ -2403,7 +2528,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3266,7 +3391,27 @@ name = "zeroize" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "zeroize" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zeroize_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" @@ -3291,6 +3436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" +"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" @@ -3304,6 +3450,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" +"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" @@ -3336,6 +3484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" +"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -3369,6 +3518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +"checksum ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e61c2da0d0f700c77d2d313dbf4f93e41d235fa12c6681fee06621036df4c2af" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" @@ -3377,26 +3527,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" -"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" -"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" -"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" -"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" -"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" -"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" -"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" -"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" -"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" -"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" -"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" -"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" -"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" -"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" -"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" +"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" +"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" +"checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" +"checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" +"checksum libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fced4da0c31e0dc8a759472c65fab41db40c01de2d93bc45e1431c13f0564f0" +"checksum libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba5e882d72c71cdf77f45ab68dd715451d3b78a23085f8d385c7a31ec1b4272" +"checksum libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d71966dbbb4cedcfcdb1d4c87d5dbb6f3f07b465d1ca74f2624256669997d1f2" +"checksum libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdbdaea6f0049cc09ba5db00308f5b93105a8a33b65ba2e36bd35da707850ea2" +"checksum libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b351bfd67e97154e7b60f62402237671486c8a89f83eabdb6838f37d4d5f006" +"checksum libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44324032b2f9260d2b862c741d79d250dc02298dbba56354a992528a826ee2d5" +"checksum libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ac43ffd01de4210cf1b969bbb55a008c77f9ec22b74df26a6590bb6bd4c93f" +"checksum libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0506e10770bcbcb59f2a6154ce93c8fd5cb9730b6ceb5aa1463164af1fd0b9c6" +"checksum libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3886b79a35c0348497bab763517a9a2b4965173f4b4c7438d59f1e4dcf5122ff" +"checksum libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b811272e5cd86d39bd71fb94687025d9802b13daf0998ebe0d3f2885c636c51a" +"checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" +"checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" +"checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -3404,6 +3556,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" +"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" +"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" @@ -3426,16 +3581,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" @@ -3480,6 +3637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3577,3 +3735,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" +"checksum zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b60a6c572b91d8ecb0a460950d84fe5b40699edd07d65f73789b31237afc8f66" +"checksum zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9dac4b660d969bff9c3fe1847a891cacaa8b21dd5f2aae6e0a3e0975aea96431" diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 19f5f36862..6193fd8e71 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -240,10 +240,6 @@ impl_runtime_apis! { fn initialize_block(header: &::Header) { Executive::initialize_block(header) } - - fn authorities() -> Vec { - panic!("Deprecated, please use `AuthoritiesApi`.") - } } impl runtime_api::Metadata for Runtime { diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index 2473762307..2dc001522c 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -1,5 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aes-ctr" version = "0.3.0" @@ -203,6 +208,11 @@ name = "bs58" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "build_const" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bumpalo" version = "2.4.3" @@ -283,6 +293,22 @@ name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam" version = "0.6.0" @@ -573,6 +599,19 @@ dependencies = [ "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fnv" version = "1.0.6" @@ -822,6 +861,11 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ipnet" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itoa" version = "0.4.4" @@ -875,32 +919,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -910,7 +955,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -924,9 +969,9 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -945,20 +990,31 @@ dependencies = [ [[package]] name = "libp2p-core-derive" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-deflate" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-dns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -966,7 +1022,7 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -974,7 +1030,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -985,16 +1041,16 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1006,7 +1062,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,13 +1072,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1033,16 +1090,16 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1054,15 +1111,15 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1070,14 +1127,14 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1085,21 +1142,21 @@ dependencies = [ "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1109,23 +1166,23 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1133,7 +1190,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1144,7 +1201,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1162,13 +1219,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1177,23 +1235,23 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-wasm-ext" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1202,11 +1260,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1234,6 +1292,14 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.6" @@ -1283,6 +1349,34 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miniz-sys" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide_c_api" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio" version = "0.6.19" @@ -1521,7 +1615,7 @@ dependencies = [ [[package]] name = "parity-multiaddr" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1530,6 +1624,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1588,6 +1683,16 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.2.14" @@ -1623,6 +1728,21 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "paste" version = "0.1.5" @@ -2003,6 +2123,11 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "semver" version = "0.9.0" @@ -2546,7 +2671,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3359,7 +3484,27 @@ name = "zeroize" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "zeroize" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zeroize_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" @@ -3384,6 +3529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" +"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" @@ -3397,6 +3543,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" +"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" @@ -3429,6 +3577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" +"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -3462,6 +3611,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +"checksum ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e61c2da0d0f700c77d2d313dbf4f93e41d235fa12c6681fee06621036df4c2af" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" @@ -3470,26 +3620,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" -"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" -"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" -"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" -"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" -"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" -"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" -"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" -"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" -"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" -"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" -"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" -"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" -"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" -"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" -"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" +"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" +"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" +"checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" +"checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" +"checksum libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fced4da0c31e0dc8a759472c65fab41db40c01de2d93bc45e1431c13f0564f0" +"checksum libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba5e882d72c71cdf77f45ab68dd715451d3b78a23085f8d385c7a31ec1b4272" +"checksum libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d71966dbbb4cedcfcdb1d4c87d5dbb6f3f07b465d1ca74f2624256669997d1f2" +"checksum libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdbdaea6f0049cc09ba5db00308f5b93105a8a33b65ba2e36bd35da707850ea2" +"checksum libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b351bfd67e97154e7b60f62402237671486c8a89f83eabdb6838f37d4d5f006" +"checksum libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44324032b2f9260d2b862c741d79d250dc02298dbba56354a992528a826ee2d5" +"checksum libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ac43ffd01de4210cf1b969bbb55a008c77f9ec22b74df26a6590bb6bd4c93f" +"checksum libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0506e10770bcbcb59f2a6154ce93c8fd5cb9730b6ceb5aa1463164af1fd0b9c6" +"checksum libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3886b79a35c0348497bab763517a9a2b4965173f4b4c7438d59f1e4dcf5122ff" +"checksum libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b811272e5cd86d39bd71fb94687025d9802b13daf0998ebe0d3f2885c636c51a" +"checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" +"checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" +"checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -3497,6 +3649,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" +"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" +"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" @@ -3519,16 +3674,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" @@ -3573,6 +3730,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3670,3 +3828,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" +"checksum zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b60a6c572b91d8ecb0a460950d84fe5b40699edd07d65f73789b31237afc8f66" +"checksum zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9dac4b660d969bff9c3fe1847a891cacaa8b21dd5f2aae6e0a3e0975aea96431" diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index bad1fb9def..5daeccf72c 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 91, - impl_version: 93, + spec_version: 92, + impl_version: 92, apis: RUNTIME_API_VERSIONS, }; @@ -277,10 +277,6 @@ impl_runtime_apis! { fn initialize_block(header: &::Header) { Executive::initialize_block(header) } - - fn authorities() -> Vec> { - panic!("Deprecated, please use `AuthoritiesApi`.") - } } impl client_api::Metadata for Runtime { diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index 58b59ba4fc..8ec68521c2 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -1,5 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aes-ctr" version = "0.3.0" @@ -203,6 +208,11 @@ name = "bs58" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "build_const" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bumpalo" version = "2.4.3" @@ -283,6 +293,22 @@ name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam" version = "0.6.0" @@ -573,6 +599,19 @@ dependencies = [ "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fnv" version = "1.0.6" @@ -822,6 +861,11 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ipnet" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itoa" version = "0.4.4" @@ -875,32 +919,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -910,7 +955,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -924,9 +969,9 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -945,20 +990,31 @@ dependencies = [ [[package]] name = "libp2p-core-derive" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-deflate" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-dns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -966,7 +1022,7 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -974,7 +1030,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -985,16 +1041,16 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1006,7 +1062,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,13 +1072,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1033,16 +1090,16 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1054,15 +1111,15 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1070,14 +1127,14 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1085,21 +1142,21 @@ dependencies = [ "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1109,23 +1166,23 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ratelimit" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1133,7 +1190,7 @@ dependencies = [ [[package]] name = "libp2p-secio" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1144,7 +1201,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1162,13 +1219,14 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1177,23 +1235,23 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-wasm-ext" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1202,11 +1260,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1234,6 +1292,14 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.6" @@ -1283,6 +1349,34 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miniz-sys" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide_c_api" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio" version = "0.6.19" @@ -1543,7 +1637,7 @@ dependencies = [ [[package]] name = "parity-multiaddr" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1552,6 +1646,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1610,6 +1705,16 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.2.14" @@ -1645,6 +1750,21 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "paste" version = "0.1.5" @@ -2035,6 +2155,11 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "semver" version = "0.9.0" @@ -2681,7 +2806,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3506,7 +3631,27 @@ name = "zeroize" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "zeroize" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zeroize_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" @@ -3531,6 +3676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" "checksum bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0de79cfb98e7aa9988188784d8664b4b5dad6eaaa0863b91d9a4ed871d4f7a42" +"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" @@ -3544,6 +3690,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" +"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" @@ -3576,6 +3724,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" +"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -3609,6 +3758,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1" "checksum integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ea155abb3ba6f382a75f1418988c05fe82959ed9ce727de427f9cfd425b0c903" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +"checksum ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e61c2da0d0f700c77d2d313dbf4f93e41d235fa12c6681fee06621036df4c2af" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" @@ -3617,26 +3767,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libp2p 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141ab3f96adc87c8cb847b1cf790e0fbce0b03e3dabfdd3b72fe23d36fc005de" -"checksum libp2p-core 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1514593f2aced40b257565cf2edc63b4cc2f06241a2f3e5a4fe275e0c4d55e85" -"checksum libp2p-core-derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f6f5543deedf4d89931a74d3897b63be19a62d5cb675efaa4c669a4aa0ab12" -"checksum libp2p-dns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9db88ba58601f4528ef5e5e5414e142b19d5813bdaa685e683ef5a44ed23606b" -"checksum libp2p-floodsub 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "260689f26ab2161a1fde9617c53699f78e4ab25fd77c4b07a25b97fca74c5c6d" -"checksum libp2p-identify 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1281e58168ed62cf2e9bfe127908a0ec277cf48cbb3dec5b1a68b58ea6332171" -"checksum libp2p-kad 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd8ab542edc493fa7a9f9b7f93dc4ee0b384e1f9e2a3397ce0056ffe30a0ea21" -"checksum libp2p-mdns 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f009594f78d952c57f452be237650025acd4ef17c5cc8eda4c6466ba196e5688" -"checksum libp2p-mplex 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccfb9869daccfb9d3938eda8821146e85105a8c874f14393cdb57543afeceb38" -"checksum libp2p-noise 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d3dce2ec4fcb3a2cc748c02d61f7e76486df9c7b09e8ccb4d9f81befce207de" -"checksum libp2p-ping 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b3bb3328d206ad3061e863f179a211fc978d7bce05f90440ed6b8a6a9d17ced" -"checksum libp2p-plaintext 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b23a8ece138f448572c5ff781d62323a954f1f681c303e6553368026764b0ae" -"checksum libp2p-ratelimit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55918f058f118d72d83f9a976f12e02e54c8616ddfc795c779c4801a5042a44f" -"checksum libp2p-secio 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea5c0636053e01575d6269b6112f9239e9d35ca861e3e5c7d6970a07f9e1682a" -"checksum libp2p-tcp 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3629f9a667d9f5acb5876df59cf3b547250e340131c47587f9ace7c517f21327" -"checksum libp2p-uds 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d65c15f89c0607d4a334664d759e54e847e1856a73ea78e7bb6a75e6f4039010" -"checksum libp2p-wasm-ext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "318d727d5e8e0fe3bb70aacbf99bde57334eae9559deff447edd993422dc0f03" -"checksum libp2p-yamux 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369165359bea84e7ebe73f37b6240f31f8d924ce6710be3d8e1fa678985c9b8" +"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" +"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" +"checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" +"checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" +"checksum libp2p-floodsub 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fced4da0c31e0dc8a759472c65fab41db40c01de2d93bc45e1431c13f0564f0" +"checksum libp2p-identify 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ba5e882d72c71cdf77f45ab68dd715451d3b78a23085f8d385c7a31ec1b4272" +"checksum libp2p-kad 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d71966dbbb4cedcfcdb1d4c87d5dbb6f3f07b465d1ca74f2624256669997d1f2" +"checksum libp2p-mdns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdbdaea6f0049cc09ba5db00308f5b93105a8a33b65ba2e36bd35da707850ea2" +"checksum libp2p-mplex 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b351bfd67e97154e7b60f62402237671486c8a89f83eabdb6838f37d4d5f006" +"checksum libp2p-noise 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44324032b2f9260d2b862c741d79d250dc02298dbba56354a992528a826ee2d5" +"checksum libp2p-ping 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ac43ffd01de4210cf1b969bbb55a008c77f9ec22b74df26a6590bb6bd4c93f" +"checksum libp2p-plaintext 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0506e10770bcbcb59f2a6154ce93c8fd5cb9730b6ceb5aa1463164af1fd0b9c6" +"checksum libp2p-ratelimit 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3886b79a35c0348497bab763517a9a2b4965173f4b4c7438d59f1e4dcf5122ff" +"checksum libp2p-secio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b811272e5cd86d39bd71fb94687025d9802b13daf0998ebe0d3f2885c636c51a" +"checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" +"checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" +"checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -3644,6 +3796,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7623b01a4f1b7acb7cf8e3f678f05e15e6ae26cb0b738dfeb5cc186fd6b82ef4" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c39467de91b004f5b9c06fac5bbc8e7d28309a205ee66905166b70804a71fea" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" +"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" +"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" @@ -3666,16 +3821,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" -"checksum parity-multiaddr 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b574ca9f0c0235c04de4c5110542959f64c9b8882f638b70f6c6be52c75bdc46" +"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79" "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" @@ -3721,6 +3878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3818,3 +3976,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" "checksum zeroize 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ddfeb6eee2fb3b262ef6e0898a52b7563bb8e0d5955a313b3cf2f808246ea14" +"checksum zeroize 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b60a6c572b91d8ecb0a460950d84fe5b40699edd07d65f73789b31237afc8f66" +"checksum zeroize_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9dac4b660d969bff9c3fe1847a891cacaa8b21dd5f2aae6e0a3e0975aea96431" -- GitLab From 3ec6f452dd00ed3dc2a92ef21de59e4c6e1505ce Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 5 Jun 2019 09:15:54 +0200 Subject: [PATCH 084/113] Minor sync refactoring (#2767) * Make maintain_sync private * Remove sync::Context::peer_info * Print errors if sync state mismatch * Line width --- core/network/src/protocol.rs | 18 +-- core/network/src/sync.rs | 294 +++++++++++++++++++---------------- 2 files changed, 166 insertions(+), 146 deletions(-) diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 569f1df030..2281b9da7f 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -119,7 +119,7 @@ pub struct ProtocolStatus { } /// Peer information -#[derive(Debug)] +#[derive(Debug, Clone)] struct Peer { info: PeerInfo, /// Current block request, if any. @@ -342,10 +342,6 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SyncContext for ProtocolContext<'a, self.network_out.disconnect_peer(who) } - fn peer_info(&self, who: &PeerId) -> Option> { - self.context_data.peers.get(who).map(|p| p.info.clone()) - } - fn client(&self) -> &dyn Client { &*self.context_data.chain } @@ -906,9 +902,10 @@ impl, H: ExHashT> Protocol { status.version }; + let info = self.context_data.peers.get(&who).expect("We just inserted above; QED").info.clone(); self.on_demand_core.on_connect(&mut network_out, who.clone(), status.roles, status.best_number); let mut context = ProtocolContext::new(&mut self.context_data, network_out); - self.sync.new_peer(&mut context, who.clone()); + self.sync.new_peer(&mut context, who.clone(), info); if protocol_version > 2 { self.consensus_gossip.new_peer(&mut context, who.clone(), status.roles); } @@ -1188,16 +1185,15 @@ impl, H: ExHashT> Protocol { processed_blocks: Vec, has_error: bool ) { - self.sync.blocks_processed(processed_blocks, has_error); - let mut context = - ProtocolContext::new(&mut self.context_data, network_out); - self.sync.maintain_sync(&mut context); + let mut context = ProtocolContext::new(&mut self.context_data, network_out); + self.sync.blocks_processed(&mut context, processed_blocks, has_error); } /// Restart the sync process. pub fn restart(&mut self, network_out: &mut dyn NetworkOut) { + let peers = self.context_data.peers.clone(); let mut context = ProtocolContext::new(&mut self.context_data, network_out); - self.sync.restart(&mut context); + self.sync.restart(&mut context, |peer_id| peers.get(peer_id).map(|i| i.info.clone())); } /// Notify about successful import of the given block. diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index 9b327c1a20..62cb0ce14d 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -33,7 +33,7 @@ use std::cmp::max; use std::ops::Range; use std::collections::{HashMap, VecDeque}; -use log::{debug, trace, warn, info}; +use log::{debug, trace, warn, info, error}; use crate::protocol::PeerInfo as ProtocolPeerInfo; use network_libp2p::PeerId; use client::{BlockStatus, ClientInfo}; @@ -81,9 +81,6 @@ pub trait Context { /// Force disconnecting from a peer. Use this when a peer misbehaved. fn disconnect_peer(&mut self, who: PeerId); - /// Get peer info. - fn peer_info(&self, peer: &PeerId) -> Option>; - /// Request a finality proof from a peer. fn send_finality_proof_request(&mut self, who: PeerId, request: message::FinalityProofRequest); @@ -237,82 +234,90 @@ impl ChainSync { } /// Handle new connected peer. Call this method whenever we connect to a new peer. - pub(crate) fn new_peer(&mut self, protocol: &mut dyn Context, who: PeerId) { - if let Some(info) = protocol.peer_info(&who) { - // there's nothing sync can get from the node that has no blockchain data - // (the opposite is not true, but all requests are served at protocol level) - if !info.roles.is_full() { - return; - } + pub(crate) fn new_peer( + &mut self, + protocol: &mut dyn Context, + who: PeerId, + info: ProtocolPeerInfo + ) { + // there's nothing sync can get from the node that has no blockchain data + // (the opposite is not true, but all requests are served at protocol level) + if !info.roles.is_full() { + return; + } - let status = block_status(&*protocol.client(), &self.queue_blocks, info.best_hash); - match (status, info.best_number) { - (Err(e), _) => { - debug!(target:"sync", "Error reading blockchain: {:?}", e); - protocol.report_peer(who.clone(), BLOCKCHAIN_STATUS_READ_ERROR_REPUTATION_CHANGE); - protocol.disconnect_peer(who); - }, - (Ok(BlockStatus::KnownBad), _) => { - info!("New peer with known bad best block {} ({}).", info.best_hash, info.best_number); - protocol.report_peer(who.clone(), i32::min_value()); - protocol.disconnect_peer(who); - }, - (Ok(BlockStatus::Unknown), b) if b.is_zero() => { - info!("New peer with unknown genesis hash {} ({}).", info.best_hash, info.best_number); - protocol.report_peer(who.clone(), i32::min_value()); - protocol.disconnect_peer(who); - }, - (Ok(BlockStatus::Unknown), _) if self.queue_blocks.len() > MAJOR_SYNC_BLOCKS => { - // when actively syncing the common point moves too fast. - debug!(target:"sync", "New peer with unknown best hash {} ({}), assuming common block.", self.best_queued_hash, self.best_queued_number); - self.peers.insert(who, PeerSync { - common_number: self.best_queued_number, + let status = block_status(&*protocol.client(), &self.queue_blocks, info.best_hash); + match (status, info.best_number) { + (Err(e), _) => { + debug!(target:"sync", "Error reading blockchain: {:?}", e); + protocol.report_peer(who.clone(), BLOCKCHAIN_STATUS_READ_ERROR_REPUTATION_CHANGE); + protocol.disconnect_peer(who); + }, + (Ok(BlockStatus::KnownBad), _) => { + info!("New peer with known bad best block {} ({}).", info.best_hash, info.best_number); + protocol.report_peer(who.clone(), i32::min_value()); + protocol.disconnect_peer(who); + }, + (Ok(BlockStatus::Unknown), b) if b.is_zero() => { + info!("New peer with unknown genesis hash {} ({}).", info.best_hash, info.best_number); + protocol.report_peer(who.clone(), i32::min_value()); + protocol.disconnect_peer(who); + }, + (Ok(BlockStatus::Unknown), _) if self.queue_blocks.len() > MAJOR_SYNC_BLOCKS => { + // when actively syncing the common point moves too fast. + debug!( + target:"sync", + "New peer with unknown best hash {} ({}), assuming common block.", + self.best_queued_hash, + self.best_queued_number + ); + self.peers.insert(who, PeerSync { + common_number: self.best_queued_number, + best_hash: info.best_hash, + best_number: info.best_number, + state: PeerSyncState::Available, + recently_announced: Default::default(), + }); + } + (Ok(BlockStatus::Unknown), _) => { + let our_best = self.best_queued_number; + if our_best.is_zero() { + // We are at genesis, just start downloading + debug!(target:"sync", "New peer with best hash {} ({}).", info.best_hash, info.best_number); + self.peers.insert(who.clone(), PeerSync { + common_number: Zero::zero(), best_hash: info.best_hash, best_number: info.best_number, state: PeerSyncState::Available, recently_announced: Default::default(), }); - } - (Ok(BlockStatus::Unknown), _) => { - let our_best = self.best_queued_number; - if our_best.is_zero() { - // We are at genesis, just start downloading - debug!(target:"sync", "New peer with best hash {} ({}).", info.best_hash, info.best_number); - self.peers.insert(who.clone(), PeerSync { - common_number: Zero::zero(), - best_hash: info.best_hash, - best_number: info.best_number, - state: PeerSyncState::Available, - recently_announced: Default::default(), - }); - self.download_new(protocol, who) - } else { - let common_best = ::std::cmp::min(our_best, info.best_number); - debug!(target:"sync", - "New peer with unknown best hash {} ({}), searching for common ancestor.", - info.best_hash, - info.best_number - ); - self.peers.insert(who.clone(), PeerSync { - common_number: Zero::zero(), - best_hash: info.best_hash, - best_number: info.best_number, - state: PeerSyncState::AncestorSearch(common_best, AncestorSearchState::ExponentialBackoff(One::one())), - recently_announced: Default::default(), - }); - Self::request_ancestry(protocol, who, common_best) - } - }, - (Ok(BlockStatus::Queued), _) | (Ok(BlockStatus::InChainWithState), _) | (Ok(BlockStatus::InChainPruned), _) => { - debug!(target:"sync", "New peer with known best hash {} ({}).", info.best_hash, info.best_number); + self.download_new(protocol, who) + } else { + let common_best = ::std::cmp::min(our_best, info.best_number); + debug!(target:"sync", + "New peer with unknown best hash {} ({}), searching for common ancestor.", + info.best_hash, + info.best_number + ); self.peers.insert(who.clone(), PeerSync { - common_number: info.best_number, + common_number: Zero::zero(), best_hash: info.best_hash, best_number: info.best_number, - state: PeerSyncState::Available, + state: PeerSyncState::AncestorSearch(common_best, AncestorSearchState::ExponentialBackoff(One::one())), recently_announced: Default::default(), }); + Self::request_ancestry(protocol, who, common_best) } + }, + (Ok(BlockStatus::Queued), _) | (Ok(BlockStatus::InChainWithState), _) | (Ok(BlockStatus::InChainPruned), _) => { + debug!(target:"sync", "New peer with known best hash {} ({}).", info.best_hash, info.best_number); + self.peers.insert(who.clone(), PeerSync { + common_number: info.best_number, + best_hash: info.best_hash, + best_number: info.best_number, + state: PeerSyncState::Available, + recently_announced: Default::default(), + }); } } } @@ -488,36 +493,41 @@ impl ChainSync { _request: message::BlockRequest, response: message::BlockResponse, ) -> Option<(PeerId, B::Hash, NumberFor, Justification)> { - if let Some(ref mut peer) = self.peers.get_mut(&who) { - if let PeerSyncState::DownloadingJustification(hash) = peer.state { - peer.state = PeerSyncState::Available; + let peer = if let Some(peer) = self.peers.get_mut(&who) { + peer + } else { + error!(target: "sync", "Called on_block_justification_data with a bad peer ID"); + return None; + }; - // we only request one justification at a time - match response.blocks.into_iter().next() { - Some(response) => { - if hash != response.hash { - info!("Invalid block justification provided by {}: requested: {:?} got: {:?}", - who, hash, response.hash); - protocol.report_peer(who.clone(), i32::min_value()); - protocol.disconnect_peer(who); - return None; - } + if let PeerSyncState::DownloadingJustification(hash) = peer.state { + peer.state = PeerSyncState::Available; - return self.extra_requests.justifications().on_response( - who, - response.justification, - ); - }, - None => { - // we might have asked the peer for a justification on a block that we thought it had - // (regardless of whether it had a justification for it or not). - trace!(target: "sync", "Peer {:?} provided empty response for justification request {:?}", - who, - hash, - ); + // we only request one justification at a time + match response.blocks.into_iter().next() { + Some(response) => { + if hash != response.hash { + info!("Invalid block justification provided by {}: requested: {:?} got: {:?}", + who, hash, response.hash); + protocol.report_peer(who.clone(), i32::min_value()); + protocol.disconnect_peer(who); return None; - }, - } + } + + return self.extra_requests.justifications().on_response( + who, + response.justification, + ); + }, + None => { + // we might have asked the peer for a justification on a block that we thought it had + // (regardless of whether it had a justification for it or not). + trace!(target: "sync", "Peer {:?} provided empty response for justification request {:?}", + who, + hash, + ); + return None; + }, } } @@ -532,28 +542,33 @@ impl ChainSync { who: PeerId, response: message::FinalityProofResponse, ) -> Option<(PeerId, B::Hash, NumberFor, Vec)> { - if let Some(ref mut peer) = self.peers.get_mut(&who) { - if let PeerSyncState::DownloadingFinalityProof(hash) = peer.state { - peer.state = PeerSyncState::Available; - - // we only request one finality proof at a time - if hash != response.block { - info!( - "Invalid block finality proof provided: requested: {:?} got: {:?}", - hash, - response.block, - ); + let peer = if let Some(peer) = self.peers.get_mut(&who) { + peer + } else { + error!(target: "sync", "Called on_block_finality_proof_data with a bad peer ID"); + return None; + }; - protocol.report_peer(who.clone(), i32::min_value()); - protocol.disconnect_peer(who); - return None; - } + if let PeerSyncState::DownloadingFinalityProof(hash) = peer.state { + peer.state = PeerSyncState::Available; - return self.extra_requests.finality_proofs().on_response( - who, - response.proof, + // we only request one finality proof at a time + if hash != response.block { + info!( + "Invalid block finality proof provided: requested: {:?} got: {:?}", + hash, + response.block, ); + + protocol.report_peer(who.clone(), i32::min_value()); + protocol.disconnect_peer(who); + return None; } + + return self.extra_requests.finality_proofs().on_response( + who, + response.proof, + ); } self.maintain_sync(protocol); @@ -563,17 +578,18 @@ impl ChainSync { /// A batch of blocks have been processed, with or without errors. /// Call this when a batch of blocks have been processed by the import queue, with or without /// errors. - pub fn blocks_processed(&mut self, processed_blocks: Vec, has_error: bool) { + pub fn blocks_processed(&mut self, protocol: &mut Context, processed_blocks: Vec, has_error: bool) { for hash in processed_blocks { self.queue_blocks.remove(&hash); } if has_error { self.best_importing_number = Zero::zero(); } + self.maintain_sync(protocol) } /// Maintain the sync process (download new blocks, fetch justifications). - pub fn maintain_sync(&mut self, protocol: &mut dyn Context) { + fn maintain_sync(&mut self, protocol: &mut dyn Context) { let peers: Vec = self.peers.keys().map(|p| p.clone()).collect(); for peer in peers { self.download_new(protocol, peer); @@ -716,26 +732,28 @@ impl ChainSync { let ancient_parent = parent_status == BlockStatus::InChainPruned; let known = self.is_known(protocol, &hash); - if let Some(ref mut peer) = self.peers.get_mut(&who) { - while peer.recently_announced.len() >= ANNOUNCE_HISTORY_SIZE { - peer.recently_announced.pop_front(); - } - peer.recently_announced.push_back(hash.clone()); - if number > peer.best_number { - // update their best block - peer.best_number = number; - peer.best_hash = hash; - } - if let PeerSyncState::AncestorSearch(_, _) = peer.state { - return false; - } - if header.parent_hash() == &self.best_queued_hash || known_parent { - peer.common_number = number - One::one(); - } else if known { - peer.common_number = number - } + let peer = if let Some(peer) = self.peers.get_mut(&who) { + peer } else { + error!(target: "sync", "Called on_block_announce with a bad peer ID"); return false; + }; + while peer.recently_announced.len() >= ANNOUNCE_HISTORY_SIZE { + peer.recently_announced.pop_front(); + } + peer.recently_announced.push_back(hash.clone()); + if number > peer.best_number { + // update their best block + peer.best_number = number; + peer.best_hash = hash; + } + if let PeerSyncState::AncestorSearch(_, _) = peer.state { + return false; + } + if header.parent_hash() == &self.best_queued_hash || known_parent { + peer.common_number = number - One::one(); + } else if known { + peer.common_number = number } // known block case @@ -825,7 +843,11 @@ impl ChainSync { } /// Restart the sync process. - pub(crate) fn restart(&mut self, protocol: &mut dyn Context) { + pub(crate) fn restart( + &mut self, + protocol: &mut dyn Context, + mut peer_info: impl FnMut(&PeerId) -> Option> + ) { self.queue_blocks.clear(); self.best_importing_number = Zero::zero(); self.blocks.clear(); @@ -835,7 +857,9 @@ impl ChainSync { debug!(target:"sync", "Restarted with {} ({})", self.best_queued_number, self.best_queued_hash); let ids: Vec = self.peers.drain().map(|(id, _)| id).collect(); for id in ids { - self.new_peer(protocol, id); + if let Some(info) = peer_info(&id) { + self.new_peer(protocol, id, info); + } } } -- GitLab From f7ec159adedf6198c67153c8b7fddaf83a2dbd9f Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 5 Jun 2019 10:16:14 +0300 Subject: [PATCH 085/113] Restore integration tests (#2620) * restored test_consensus * restored test_sync * run integration tests only on CI * use single test-thread for integration tests * post-merge fix * panic when integration test runs for too long * add some traces to integration logs * manual wait -> timeout * post-merge fix * post-merge fix --- .gitlab-ci.yml | 28 ++++++++ Cargo.lock | 1 + core/consensus/aura/src/lib.rs | 2 +- core/service/test/src/lib.rs | 43 ++++++++---- node/cli/Cargo.toml | 1 + node/cli/src/chain_spec.rs | 34 +++++++++- node/cli/src/service.rs | 120 +++++++++++++++++++++++++++++++++ node/primitives/src/lib.rs | 5 +- 8 files changed, 214 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f29e1b0dc8..b82a3f1392 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -96,6 +96,34 @@ test-linux-stable: &test - time cargo test --all --release --verbose --locked - sccache -s +test-linux-stable-int: &test + stage: test + variables: + RUST_TOOLCHAIN: stable + # Enable debug assertions since we are running optimized builds for testing + # but still want to have debug assertions. + RUSTFLAGS: -Cdebug-assertions=y + TARGET: native + tags: + - linux-docker + only: + - tags + - master + - schedules + - web + - /^[0-9]+$/ + except: + variables: + - $DEPLOY_TAG + before_script: + - sccache -s + - ./scripts/build.sh + script: + - time RUST_LOG=sync=trace,consensus=trace,client=trace,state-db=trace,db=trace,forks=trace,state_db=trace,storage_cache=trace cargo test -p node-cli --release --verbose --locked -- --ignored --test-threads=1 + - sccache -s + allow_failure: true + + check-web-wasm: stage: test <<: *compiler_info diff --git a/Cargo.lock b/Cargo.lock index da3ae1f4dc..0246844271 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2152,6 +2152,7 @@ dependencies = [ "substrate-cli 2.0.0", "substrate-client 2.0.0", "substrate-consensus-aura 2.0.0", + "substrate-consensus-common 2.0.0", "substrate-finality-grandpa 2.0.0", "substrate-inherents 2.0.0", "substrate-keyring 2.0.0", diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 901d8b6f35..6f73c6ed65 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -69,9 +69,9 @@ use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible, slot_now, check pub use aura_primitives::*; pub use consensus_common::{SyncOracle, ExtraVerification}; +pub use digest::CompatibleDigestItem; mod digest; -use digest::CompatibleDigestItem; type AuthorityId

=

::Public; diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index 9b73cfa14c..7a6d530030 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -24,7 +24,7 @@ use std::collections::HashMap; use log::info; use futures::{Future, Stream}; use tempdir::TempDir; -use tokio::runtime::Runtime; +use tokio::{runtime::Runtime, prelude::FutureExt}; use tokio::timer::Interval; use service::{ ServiceFactory, @@ -39,6 +39,9 @@ use network::config::{NetworkConfiguration, NodeKeyConfig, Secret, NonReservedPe use sr_primitives::generic::BlockId; use consensus::{ImportBlock, BlockImport}; +/// Maximum duration of single wait call. +const MAX_WAIT_TIME: Duration = Duration::from_secs(60 * 3); + struct TestNet { runtime: Runtime, authority_nodes: Vec<(u32, Arc, Multiaddr)>, @@ -52,14 +55,22 @@ struct TestNet { impl TestNet { pub fn run_until_all_full bool + 'static>(&mut self, predicate: P) { let full_nodes = self.full_nodes.clone(); - let interval = Interval::new_interval(Duration::from_millis(100)).map_err(|_| ()).for_each(move |_| { - if full_nodes.iter().all(|&(ref id, ref service, _)| predicate(*id, service)) { - Err(()) - } else { - Ok(()) - } - }); - self.runtime.block_on(interval).ok(); + let interval = Interval::new_interval(Duration::from_millis(100)) + .map_err(|_| ()) + .for_each(move |_| { + if full_nodes.iter().all(|&(ref id, ref service, _)| predicate(*id, service)) { + Err(()) + } else { + Ok(()) + } + }) + .timeout(MAX_WAIT_TIME); + + match self.runtime.block_on(interval) { + Ok(()) => unreachable!("interval always fails; qed"), + Err(ref err) if err.is_inner() => (), + Err(_) => panic!("Waited for too long"), + } } } @@ -223,11 +234,15 @@ pub fn connectivity(spec: FactoryChainSpec) { } } -pub fn sync(spec: FactoryChainSpec, block_factory: B, extrinsic_factory: E) +pub fn sync( + spec: FactoryChainSpec, + mut block_factory: B, + mut extrinsic_factory: E, +) where F: ServiceFactory, - B: Fn(&F::FullService) -> ImportBlock, - E: Fn(&F::FullService) -> FactoryExtrinsic, + B: FnMut(&F::FullService) -> ImportBlock, + E: FnMut(&F::FullService) -> FactoryExtrinsic, { const NUM_NODES: u32 = 10; const NUM_BLOCKS: u32 = 512; @@ -265,8 +280,8 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) where F: ServiceFactory, { - const NUM_NODES: u32 = 20; - const NUM_BLOCKS: u32 = 200; + const NUM_NODES: u32 = 10; + const NUM_BLOCKS: u32 = 10; // 10 * 2 sec block production time = ~20 seconds let temp = TempDir::new("substrate-conensus-test").expect("Error creating test dir"); let mut network = TestNet::::new(&temp, spec.clone(), NUM_NODES / 2, 0, authorities, 30600); info!("Checking consensus"); diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index 3c46f48f3f..24234fd271 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -39,6 +39,7 @@ rand = "0.6" finality_tracker = { package = "srml-finality-tracker", path = "../../srml/finality-tracker", default-features = false } [dev-dependencies] +consensus-common = { package = "substrate-consensus-common", path = "../../core/consensus/common" } service-test = { package = "substrate-service-test", path = "../../core/service/test" } [build-dependencies] diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 18238eaa12..2ce4a3e656 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -370,7 +370,7 @@ pub fn local_testnet_config() -> ChainSpec { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use service_test; use crate::service::Factory; @@ -381,13 +381,41 @@ mod tests { genesis } + fn local_testnet_genesis_instant_single() -> GenesisConfig { + let mut genesis = testnet_genesis( + vec![ + get_authority_keys_from_seed("Alice"), + ], + get_account_id_from_seed("Alice"), + None, + false, + ); + genesis.timestamp = Some(TimestampConfig { minimum_period: 1 }); + genesis + } + + /// Local testnet config (single validator - Alice) + pub fn integration_test_config_with_single_authority() -> ChainSpec { + ChainSpec::from_genesis( + "Integration Test", + "test", + local_testnet_genesis_instant_single, + vec![], + None, + None, + None, + None, + ) + } + /// Local testnet config (multivalidator Alice + Bob) - pub fn integration_test_config() -> ChainSpec { + pub fn integration_test_config_with_two_authorities() -> ChainSpec { ChainSpec::from_genesis("Integration Test", "test", local_testnet_genesis_instant, vec![], None, None, None, None) } #[test] + #[ignore] fn test_connectivity() { - service_test::connectivity::(integration_test_config()); + service_test::connectivity::(integration_test_config_with_two_authorities()); } } diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index fa7beb6421..d9db310724 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -220,6 +220,23 @@ construct_service_factory! { #[cfg(test)] mod tests { + use std::sync::Arc; + use consensus::CompatibleDigestItem; + use consensus_common::{Environment, Proposer, ImportBlock, BlockOrigin, ForkChoiceStrategy}; + use node_primitives::DigestItem; + use node_runtime::{Call, BalancesCall, UncheckedExtrinsic}; + use parity_codec::{Compact, Encode, Decode}; + use primitives::{ + crypto::Pair as CryptoPair, ed25519::Pair, blake2_256, + sr25519::Public as AddressPublic, + }; + use sr_primitives::{generic::{BlockId, Era, Digest}, traits::{Block, Digest as DigestT}, OpaqueExtrinsic}; + use timestamp; + use finality_tracker; + use keyring::{ed25519::Keyring as AuthorityKeyring, sr25519::Keyring as AccountKeyring}; + use substrate_service::ServiceFactory; + use crate::service::Factory; + #[cfg(feature = "rhd")] fn test_sync() { use {service_test, Factory}; @@ -267,4 +284,107 @@ mod tests { service_test::sync::(chain_spec::integration_test_config(), block_factory, extrinsic_factory); } + #[test] + #[ignore] + fn test_sync() { + let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); + + let alice = Arc::new(AuthorityKeyring::Alice.pair()); + let mut slot_num = 1u64; + let block_factory = |service: &::FullService| { + let mut inherent_data = service.config.custom.inherent_data_providers + .create_inherent_data().unwrap(); + inherent_data.replace_data(finality_tracker::INHERENT_IDENTIFIER, &1u64); + inherent_data.replace_data(timestamp::INHERENT_IDENTIFIER, &(slot_num * 10)); + + let parent_id = BlockId::number(service.client().info().unwrap().chain.best_number); + let parent_header = service.client().header(&parent_id).unwrap().unwrap(); + let proposer_factory = Arc::new(substrate_basic_authorship::ProposerFactory { + client: service.client(), + transaction_pool: service.transaction_pool(), + }); + let mut digest = Digest::::default(); + digest.push(>::aura_pre_digest(slot_num * 10 / 2)); + let proposer = proposer_factory.init(&parent_header, &[]).unwrap(); + let new_block = proposer.propose( + inherent_data, + digest, + ::std::time::Duration::from_secs(1), + ).expect("Error making test block"); + + let (new_header, new_body) = new_block.deconstruct(); + let pre_hash = new_header.hash(); + // sign the pre-sealed hash of the block and then + // add it to a digest item. + let to_sign = pre_hash.encode(); + let signature = alice.sign(&to_sign[..]); + let item = >::aura_seal( + signature, + ); + slot_num += 1; + + ImportBlock { + origin: BlockOrigin::File, + header: new_header, + justification: None, + post_digests: vec![item], + body: Some(new_body), + finalized: true, + auxiliary: Vec::new(), + fork_choice: ForkChoiceStrategy::LongestChain, + } + }; + + let bob = Arc::new(AccountKeyring::Bob.pair()); + let charlie = Arc::new(AccountKeyring::Charlie.pair()); + + let mut index = 0; + let extrinsic_factory = |service: &::FullService| { + let amount = 1000; + let to = AddressPublic::from_raw(bob.public().0); + let from = AddressPublic::from_raw(charlie.public().0); + let genesis_hash = service.client().block_hash(0).unwrap().unwrap(); + let signer = charlie.clone(); + + let function = Call::Balances(BalancesCall::transfer(to.into(), amount)); + let era = Era::immortal(); + let raw_payload = (Compact(index), function, era, genesis_hash); + let signature = raw_payload.using_encoded(|payload| if payload.len() > 256 { + signer.sign(&blake2_256(payload)[..]) + } else { + signer.sign(payload) + }); + let xt = UncheckedExtrinsic::new_signed( + index, + raw_payload.1, + from.into(), + signature.into(), + era, + ).encode(); + let v: Vec = Decode::decode(&mut xt.as_slice()).unwrap(); + + index += 1; + OpaqueExtrinsic(v) + }; + + service_test::sync::( + chain_spec, + block_factory, + extrinsic_factory, + ); + } + + #[test] + #[ignore] + fn test_consensus() { + use super::Factory; + + service_test::consensus::( + crate::chain_spec::tests::integration_test_config_with_two_authorities(), + vec![ + "//Alice".into(), + "//Bob".into(), + ], + ) + } } diff --git a/node/primitives/src/lib.rs b/node/primitives/src/lib.rs index 4dde59296f..2135ad672f 100644 --- a/node/primitives/src/lib.rs +++ b/node/primitives/src/lib.rs @@ -57,9 +57,10 @@ pub type Hash = primitives::H256; /// A timestamp: seconds since the unix epoch. pub type Timestamp = u64; +/// Digest item type. +pub type DigestItem = generic::DigestItem; /// Header type. -/// -pub type Header = generic::Header>; +pub type Header = generic::Header; /// Block type. pub type Block = generic::Block; /// Block ID. -- GitLab From bfabed51cf2c4ead5aca08634ddcaf4b3ba837a9 Mon Sep 17 00:00:00 2001 From: Kian Peymani Date: Wed, 5 Jun 2019 11:42:29 +0200 Subject: [PATCH 086/113] Some benchmarks for phragmen (#2650) * Add some benchmarks for phragmen * Fix dep. import. * Clean up with some macros. * more details. * Fix dual import. * Remove wrong assertions. * Add a few more. --- Cargo.lock | 1 + srml/staking/Cargo.toml | 2 + srml/staking/src/benches.rs | 114 +++++++++++++++++++++++++++++++++++ srml/staking/src/lib.rs | 29 ++++++--- srml/staking/src/mock.rs | 36 +++++++++-- srml/staking/src/phragmen.rs | 46 +++++++------- srml/staking/src/tests.rs | 39 +----------- 7 files changed, 193 insertions(+), 74 deletions(-) create mode 100644 srml/staking/src/benches.rs diff --git a/Cargo.lock b/Cargo.lock index 0246844271..37e52797fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3692,6 +3692,7 @@ name = "srml-staking" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", diff --git a/srml/staking/Cargo.toml b/srml/staking/Cargo.toml index 857ea73ee4..62fc187176 100644 --- a/srml/staking/Cargo.toml +++ b/srml/staking/Cargo.toml @@ -21,8 +21,10 @@ session = { package = "srml-session", path = "../session", default-features = fa substrate-primitives = { path = "../../core/primitives" } timestamp = { package = "srml-timestamp", path = "../timestamp" } balances = { package = "srml-balances", path = "../balances" } +rand = "0.6.5" [features] +bench = [] default = ["std"] std = [ "serde", diff --git a/srml/staking/src/benches.rs b/srml/staking/src/benches.rs new file mode 100644 index 0000000000..e3ee00b9e9 --- /dev/null +++ b/srml/staking/src/benches.rs @@ -0,0 +1,114 @@ +// Copyright 2019 Parity Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Benchmarks of the phragmen election algorithm. +//! Note that execution times will not be accurate in an absolute scale, since +//! - Everything is executed in the context of `TestExternalities` +//! - Everything is executed in native environment. +//! +//! Run using: +//! +//! ```zsh +//! cargo bench --features bench --color always +//! ``` + +use test::Bencher; +use runtime_io::with_externalities; +use mock::*; +use super::*; +use rand::{self, Rng}; + +const VALIDATORS: u64 = 1000; +const NOMINATORS: u64 = 10_000; +const EDGES: u64 = 2; +const TO_ELECT: usize = 100; +const STAKE: u64 = 1000; + +fn do_phragmen(b: &mut Bencher, num_vals: u64, num_noms: u64, count: usize, votes_per: u64) { + with_externalities(&mut ExtBuilder::default().nominate(false).build(), || { + assert!(num_vals > votes_per); + let rr = |a, b| rand::thread_rng().gen_range(a as usize, b as usize) as u64; + + // prefix to distinguish the validator and nominator account ranges. + let np = 10_000; + + (1 ..= 2*num_vals) + .step_by(2) + .for_each(|acc| bond_validator(acc, STAKE + rr(10, 50))); + + (np ..= (np + 2*num_noms)) + .step_by(2) + .for_each(|acc| { + let mut stashes_to_vote = (1 ..= 2*num_vals) + .step_by(2) + .map(|ctrl| ctrl + 1) + .collect::>(); + let votes = (0 .. votes_per) + .map(|_| { + stashes_to_vote.remove(rr(0, stashes_to_vote.len()) as usize) + }) + .collect::>(); + bond_nominator(acc, STAKE + rr(10, 50), votes); + }); + + b.iter(|| { + let _ = phragmen::elect::( + count, + 1_usize, + >::enumerate(), + >::enumerate(), + Staking::slashable_balance_of + ); + }) + }) +} + +macro_rules! phragmen_benches { + ($($name:ident: $tup:expr,)*) => { + $( + #[bench] + fn $name(b: &mut Bencher) { + let (v, n, t, e) = $tup; + println!(""); + println!( + "++ Benchmark: {} Validators // {} Nominators // {} Edges-per-nominator // {} total edges // electing {}", + v, n, e, e * n, t + ); + do_phragmen(b, v, n, t, e); + } + )* + } +} + +phragmen_benches! { + bench_1_1: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES), + bench_1_2: (VALIDATORS*2, NOMINATORS, TO_ELECT, EDGES), + bench_1_3: (VALIDATORS*4, NOMINATORS, TO_ELECT, EDGES), + bench_1_4: (VALIDATORS*8, NOMINATORS, TO_ELECT, EDGES), + + bench_0_1: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES), + bench_0_2: (VALIDATORS, NOMINATORS, TO_ELECT * 4, EDGES), + bench_0_3: (VALIDATORS, NOMINATORS, TO_ELECT * 8, EDGES), + bench_0_4: (VALIDATORS, NOMINATORS, TO_ELECT * 16, EDGES), + + bench_2_1: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES), + bench_2_2: (VALIDATORS, NOMINATORS*2, TO_ELECT, EDGES), + bench_2_3: (VALIDATORS, NOMINATORS*4, TO_ELECT, EDGES), + bench_2_4: (VALIDATORS, NOMINATORS*8, TO_ELECT, EDGES), + + bench_3_1: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES), + bench_3_2: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES*2), + bench_3_3: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES*4), + bench_3_4: (VALIDATORS, NOMINATORS, TO_ELECT, EDGES*8), +} diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index f84bf0a9ce..3f6905f654 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -240,16 +240,31 @@ //! stored in the Session module's `Validators` at the end of each era. #![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(all(feature = "bench", test), feature(test))] + +#[cfg(all(feature = "bench", test))] +extern crate test; + +#[cfg(any(feature = "bench", test))] +mod mock; + +#[cfg(test)] +mod tests; + +mod phragmen; + +#[cfg(all(feature = "bench", test))] +mod benches; #[cfg(feature = "std")] use runtime_io::with_storage; use rstd::{prelude::*, result, collections::btree_map::BTreeMap}; use parity_codec::{HasCompact, Encode, Decode}; -use srml_support::{StorageValue, StorageMap, EnumerableStorageMap, dispatch::Result}; -use srml_support::{decl_module, decl_event, decl_storage, ensure}; -use srml_support::traits::{ - Currency, OnFreeBalanceZero, OnDilution, LockIdentifier, LockableCurrency, WithdrawReasons, - OnUnbalanced, Imbalance, +use srml_support::{ StorageValue, StorageMap, EnumerableStorageMap, dispatch::Result, + decl_module, decl_event, decl_storage, ensure, + traits::{Currency, OnFreeBalanceZero, OnDilution, LockIdentifier, LockableCurrency, + WithdrawReasons, OnUnbalanced, Imbalance + } }; use session::OnSessionChange; use primitives::Perbill; @@ -261,10 +276,6 @@ use primitives::traits::{ use primitives::{Serialize, Deserialize}; use system::ensure_signed; -mod mock; -mod tests; -mod phragmen; - use phragmen::{elect, ACCURACY, ExtendedBalance}; const RECENT_OFFLINE_COUNT: usize = 32; diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index 88b401b19e..5b3b22dda5 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -16,14 +16,12 @@ //! Test utilities -#![cfg(test)] - use primitives::{traits::{IdentityLookup, Convert}, BuildStorage, Perbill}; use primitives::testing::{Digest, DigestItem, Header, UintAuthorityId, ConvertUintAuthorityId}; use substrate_primitives::{H256, Blake2Hasher}; use runtime_io; -use srml_support::impl_outer_origin; -use crate::{GenesisConfig, Module, Trait, StakerStatus}; +use srml_support::{impl_outer_origin, assert_ok, traits::Currency}; +use crate::{GenesisConfig, Module, Trait, StakerStatus, ValidatorPrefs, RewardDestination}; /// The AccountId alias in this test module. pub type AccountIdType = u64; @@ -241,3 +239,33 @@ pub type Balances = balances::Module; pub type Session = session::Module; pub type Timestamp = timestamp::Module; pub type Staking = Module; + +pub fn check_exposure(acc: u64) { + let expo = Staking::stakers(&acc); + assert_eq!(expo.total as u128, expo.own as u128 + expo.others.iter().map(|e| e.value as u128).sum::()); +} + +pub fn check_exposure_all() { + Staking::current_elected().into_iter().for_each(|acc| check_exposure(acc)); +} + +pub fn assert_total_expo(acc: u64, val: u64) { + let expo = Staking::stakers(&acc); + assert_eq!(expo.total, val); +} + +pub fn bond_validator(acc: u64, val: u64) { + // a = controller + // a + 1 = stash + let _ = Balances::make_free_balance_be(&(acc+1), val); + assert_ok!(Staking::bond(Origin::signed(acc+1), acc, val, RewardDestination::Controller)); + assert_ok!(Staking::validate(Origin::signed(acc), ValidatorPrefs::default())); +} + +pub fn bond_nominator(acc: u64, val: u64, target: Vec) { + // a = controller + // a + 1 = stash + let _ = Balances::make_free_balance_be(&(acc+1), val); + assert_ok!(Staking::bond(Origin::signed(acc+1), acc, val, RewardDestination::Controller)); + assert_ok!(Staking::nominate(Origin::signed(acc), target)); +} \ No newline at end of file diff --git a/srml/staking/src/phragmen.rs b/srml/staking/src/phragmen.rs index 888e38a7ec..ba79de4869 100644 --- a/srml/staking/src/phragmen.rs +++ b/srml/staking/src/phragmen.rs @@ -107,29 +107,29 @@ pub fn elect( // Candidates who have 0 stake => have no votes or all null-votes. Kick them out not. let mut nominators: Vec> = Vec::with_capacity(validator_iter.size_hint().0 + nominator_iter.size_hint().0); let mut candidates = validator_iter.map(|(who, _)| { - let stash_balance = stash_of(&who); - (Candidate { who, ..Default::default() }, stash_balance) - }) - .filter_map(|(mut c, s)| { - c.approval_stake += to_votes(s); - if c.approval_stake.is_zero() { - None - } else { - Some((c, s)) - } - }) - .enumerate() - .map(|(idx, (c, s))| { - nominators.push(Nominator { - who: c.who.clone(), - edges: vec![ Edge { who: c.who.clone(), candidate_index: idx, ..Default::default() }], - budget: to_votes(s), - load: Fraction::zero(), - }); - c_idx_cache.insert(c.who.clone(), idx); - c - }) - .collect::>>(); + let stash_balance = stash_of(&who); + (Candidate { who, ..Default::default() }, stash_balance) + }) + .filter_map(|(mut c, s)| { + c.approval_stake += to_votes(s); + if c.approval_stake.is_zero() { + None + } else { + Some((c, s)) + } + }) + .enumerate() + .map(|(idx, (c, s))| { + nominators.push(Nominator { + who: c.who.clone(), + edges: vec![ Edge { who: c.who.clone(), candidate_index: idx, ..Default::default() }], + budget: to_votes(s), + load: Fraction::zero(), + }); + c_idx_cache.insert(c.who.clone(), idx); + c + }) + .collect::>>(); // 2- Collect the nominators with the associated votes. // Also collect approval stake along the way. diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index fecd38bb01..eba6ce77a5 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -16,50 +16,13 @@ //! Tests for the module. -#![cfg(test)] - use super::*; use runtime_io::with_externalities; use phragmen; use srml_support::{assert_ok, assert_noop, assert_eq_uvec, EnumerableStorageMap}; -use mock::{Balances, Session, Staking, System, Timestamp, Test, ExtBuilder, Origin}; +use mock::*; use srml_support::traits::{Currency, ReservableCurrency}; -#[inline] -fn check_exposure(acc: u64) { - let expo = Staking::stakers(&acc); - assert_eq!(expo.total as u128, expo.own as u128 + expo.others.iter().map(|e| e.value as u128).sum::()); -} - -#[inline] -fn check_exposure_all() { - Staking::current_elected().into_iter().for_each(|acc| check_exposure(acc)); -} - -#[inline] -fn assert_total_expo(acc: u64, val: u64) { - let expo = Staking::stakers(&acc); - assert_eq!(expo.total, val); -} - -#[inline] -fn bond_validator(acc: u64, val: u64) { - // a = controller - // a + 1 = stash - let _ = Balances::make_free_balance_be(&(acc+1), val); - assert_ok!(Staking::bond(Origin::signed(acc+1), acc, val, RewardDestination::Controller)); - assert_ok!(Staking::validate(Origin::signed(acc), ValidatorPrefs::default())); -} - -#[inline] -fn bond_nominator(acc: u64, val: u64, target: Vec) { - // a = controller - // a + 1 = stash - let _ = Balances::make_free_balance_be(&(acc+1), val); - assert_ok!(Staking::bond(Origin::signed(acc+1), acc, val, RewardDestination::Controller)); - assert_ok!(Staking::nominate(Origin::signed(acc), target)); -} - #[test] fn basic_setup_works() { // Verifies initial conditions of mock -- GitLab From 54d028551b11f40266628ceeb35bec0595d360c3 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 5 Jun 2019 11:56:36 +0200 Subject: [PATCH 087/113] Revert #2745 (#2791) * Revert #2745 * Fix error in merge resolve * Fix compilation --- core/network/src/lib.rs | 3 +-- core/network/src/protocol.rs | 15 ++++----------- core/network/src/specialization.rs | 18 +----------------- core/network/src/test/mod.rs | 8 ++++---- node/cli/src/service.rs | 2 +- 5 files changed, 11 insertions(+), 35 deletions(-) diff --git a/core/network/src/lib.rs b/core/network/src/lib.rs index 5b438135ed..e2def15425 100644 --- a/core/network/src/lib.rs +++ b/core/network/src/lib.rs @@ -46,8 +46,7 @@ pub use service::{ NetworkService, NetworkWorker, FetchFuture, TransactionPool, ManageNetwork, NetworkMsg, SyncProvider, ExHashT, ReportHandle, }; -pub use protocol::{ProtocolStatus, PeerInfo}; -pub use specialization::Context; +pub use protocol::{ProtocolStatus, PeerInfo, Context}; pub use sync::{Status as SyncStatus, SyncState}; pub use network_libp2p::{ identity, multiaddr, diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 2281b9da7f..a824bd58d3 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -32,7 +32,7 @@ use crate::message::{BlockAttributes, Direction, FromBlock, RequestId}; use crate::message::generic::{Message as GenericMessage, ConsensusMessage}; use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; -use crate::specialization::{NetworkSpecialization, Context as SpecializationContext}; +use crate::specialization::NetworkSpecialization; use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; use crate::service::{TransactionPool, ExHashT}; use crate::config::Roles; @@ -281,6 +281,9 @@ pub trait Context { /// Send a consensus message to a peer. fn send_consensus(&mut self, who: PeerId, consensus: ConsensusMessage); + + /// Send a chain-specific message to a peer. + fn send_chain_specific(&mut self, who: PeerId, message: Vec); } /// Protocol context. @@ -312,16 +315,6 @@ impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, GenericMessage::Consensus(consensus) ) } -} - -impl<'a, B: BlockT + 'a, H: ExHashT + 'a> SpecializationContext for ProtocolContext<'a, B, H> { - fn report_peer(&mut self, who: PeerId, reputation: i32) { - self.network_out.report_peer(who, reputation) - } - - fn disconnect_peer(&mut self, who: PeerId) { - self.network_out.disconnect_peer(who) - } fn send_chain_specific(&mut self, who: PeerId, message: Vec) { send_message( diff --git a/core/network/src/specialization.rs b/core/network/src/specialization.rs index 772a1bcbe1..e8a0a0c949 100644 --- a/core/network/src/specialization.rs +++ b/core/network/src/specialization.rs @@ -18,6 +18,7 @@ use crate::PeerId; use runtime_primitives::traits::Block as BlockT; +use crate::protocol::Context; /// A specialization of the substrate network protocol. Handles events and sends messages. pub trait NetworkSpecialization: Send + Sync + 'static { @@ -50,23 +51,6 @@ pub trait NetworkSpecialization: Send + Sync + 'static { fn on_block_imported(&mut self, _ctx: &mut dyn Context, _hash: B::Hash, _header: &B::Header) { } } -/// Context for a network-specific handler. -pub trait Context { - /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or - /// irresponsible or appeared lazy. - fn report_peer(&mut self, who: PeerId, reputation: i32); - - /// Force disconnecting from a peer. Use this when a peer misbehaved. - fn disconnect_peer(&mut self, who: PeerId); - - /// Send a consensus message to a peer. - #[deprecated(note = "This method shouldn't have been part of the specialization API")] - fn send_consensus(&mut self, _who: PeerId, _consensus: crate::message::generic::ConsensusMessage) {} - - /// Send a chain-specific message to a peer. - fn send_chain_specific(&mut self, who: PeerId, message: Vec); -} - /// Construct a simple protocol that is composed of several sub protocols. /// Each "sub protocol" needs to implement `Specialization` and needs to provide a `new()` function. /// For more fine grained implementations, this macro is not usable. diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index b9703d71e0..886a09fa2a 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -50,7 +50,7 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{AuthorityIdFor, Block as BlockT, Digest, DigestItem, Header, NumberFor}; use runtime_primitives::{Justification, ConsensusEngineId}; use crate::service::{NetworkLink, NetworkMsg, ProtocolMsg, TransactionPool}; -use crate::specialization::{NetworkSpecialization, Context as SpecializationContext}; +use crate::specialization::NetworkSpecialization; use test_client::{self, AccountKeyring}; pub use test_client::runtime::{Block, Extrinsic, Hash, Transfer}; @@ -103,16 +103,16 @@ impl NetworkSpecialization for DummySpecialization { fn on_connect( &mut self, - _ctx: &mut dyn SpecializationContext, + _ctx: &mut dyn Context, _peer_id: PeerId, _status: crate::message::Status ) {} - fn on_disconnect(&mut self, _ctx: &mut dyn SpecializationContext, _peer_id: PeerId) {} + fn on_disconnect(&mut self, _ctx: &mut dyn Context, _peer_id: PeerId) {} fn on_message( &mut self, - _ctx: &mut dyn SpecializationContext, + _ctx: &mut dyn Context, _peer_id: PeerId, _message: &mut Option>, ) {} diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index d9db310724..2991bfe377 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -297,7 +297,7 @@ mod tests { inherent_data.replace_data(finality_tracker::INHERENT_IDENTIFIER, &1u64); inherent_data.replace_data(timestamp::INHERENT_IDENTIFIER, &(slot_num * 10)); - let parent_id = BlockId::number(service.client().info().unwrap().chain.best_number); + let parent_id = BlockId::number(service.client().info().chain.best_number); let parent_header = service.client().header(&parent_id).unwrap().unwrap(); let proposer_factory = Arc::new(substrate_basic_authorship::ProposerFactory { client: service.client(), -- GitLab From 9687db56516ef573f650dadc030315b78d708cc4 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 5 Jun 2019 12:36:28 +0200 Subject: [PATCH 088/113] Sensible scheduling for referenda (#2753) * Nonlinear locking and cleanups * Bump runtime version * Minor cleanup * Fix tests * Fix council tests * Fix flaw in turnout counting * Initial work on referendum schedules * Refactor council-democracy interface. * Fix build * Update srml/democracy/src/lib.rs Co-Authored-By: Luke Schoen * Update srml/democracy/src/lib.rs Co-Authored-By: Luke Schoen * Tests compile again * Tests! * Update todo * Fix build * Ensure votes arer not double-counted on member-transitions * Extra logic for normal council changes * Typo * A few grumbles addressed. --- core/primitives/src/u32_trait.rs | 154 ++++++ core/sr-primitives/src/traits.rs | 6 +- node/cli/src/chain_spec.rs | 12 +- node/executor/src/lib.rs | 1 - node/runtime/src/lib.rs | 25 +- srml/contract/src/lib.rs | 4 +- srml/council/src/lib.rs | 44 +- srml/council/src/motions.rs | 299 +++++++++--- srml/council/src/seats.rs | 30 +- srml/council/src/voting.rs | 494 ------------------- srml/democracy/src/lib.rs | 725 ++++++++++++++++++++++++---- srml/support/src/metadata.rs | 3 +- srml/support/src/origin.rs | 22 +- srml/support/src/traits.rs | 16 +- srml/support/test/tests/instance.rs | 10 +- srml/system/src/lib.rs | 88 +++- 16 files changed, 1186 insertions(+), 747 deletions(-) delete mode 100644 srml/council/src/voting.rs diff --git a/core/primitives/src/u32_trait.rs b/core/primitives/src/u32_trait.rs index 3fcdceac4c..d8fac34c30 100644 --- a/core/primitives/src/u32_trait.rs +++ b/core/primitives/src/u32_trait.rs @@ -21,6 +21,7 @@ pub trait Value { /// The actual value represented by the impl'ing type. const VALUE: u32; } + /// Type representing the value 0 for the `Value` trait. pub struct _0; impl Value for _0 { const VALUE: u32 = 0; } /// Type representing the value 1 for the `Value` trait. @@ -55,22 +56,174 @@ pub struct _14; impl Value for _14 { const VALUE: u32 = 14; } pub struct _15; impl Value for _15 { const VALUE: u32 = 15; } /// Type representing the value 16 for the `Value` trait. pub struct _16; impl Value for _16 { const VALUE: u32 = 16; } +/// Type representing the value 17 for the `Value` trait. +pub struct _17; impl Value for _17 { const VALUE: u32 = 17; } +/// Type representing the value 18 for the `Value` trait. +pub struct _18; impl Value for _18 { const VALUE: u32 = 18; } +/// Type representing the value 19 for the `Value` trait. +pub struct _19; impl Value for _19 { const VALUE: u32 = 19; } +/// Type representing the value 20 for the `Value` trait. +pub struct _20; impl Value for _20 { const VALUE: u32 = 20; } +/// Type representing the value 21 for the `Value` trait. +pub struct _21; impl Value for _21 { const VALUE: u32 = 21; } +/// Type representing the value 22 for the `Value` trait. +pub struct _22; impl Value for _22 { const VALUE: u32 = 22; } +/// Type representing the value 23 for the `Value` trait. +pub struct _23; impl Value for _23 { const VALUE: u32 = 23; } /// Type representing the value 24 for the `Value` trait. pub struct _24; impl Value for _24 { const VALUE: u32 = 24; } +/// Type representing the value 25 for the `Value` trait. +pub struct _25; impl Value for _25 { const VALUE: u32 = 25; } +/// Type representing the value 26 for the `Value` trait. +pub struct _26; impl Value for _26 { const VALUE: u32 = 26; } +/// Type representing the value 27 for the `Value` trait. +pub struct _27; impl Value for _27 { const VALUE: u32 = 27; } +/// Type representing the value 28 for the `Value` trait. +pub struct _28; impl Value for _28 { const VALUE: u32 = 28; } +/// Type representing the value 29 for the `Value` trait. +pub struct _29; impl Value for _29 { const VALUE: u32 = 29; } +/// Type representing the value 30 for the `Value` trait. +pub struct _30; impl Value for _30 { const VALUE: u32 = 30; } +/// Type representing the value 31 for the `Value` trait. +pub struct _31; impl Value for _31 { const VALUE: u32 = 31; } /// Type representing the value 32 for the `Value` trait. pub struct _32; impl Value for _32 { const VALUE: u32 = 32; } +/// Type representing the value 33 for the `Value` trait. +pub struct _33; impl Value for _33 { const VALUE: u32 = 33; } +/// Type representing the value 34 for the `Value` trait. +pub struct _34; impl Value for _34 { const VALUE: u32 = 34; } +/// Type representing the value 35 for the `Value` trait. +pub struct _35; impl Value for _35 { const VALUE: u32 = 35; } +/// Type representing the value 36 for the `Value` trait. +pub struct _36; impl Value for _36 { const VALUE: u32 = 36; } +/// Type representing the value 37 for the `Value` trait. +pub struct _37; impl Value for _37 { const VALUE: u32 = 37; } +/// Type representing the value 38 for the `Value` trait. +pub struct _38; impl Value for _38 { const VALUE: u32 = 38; } +/// Type representing the value 39 for the `Value` trait. +pub struct _39; impl Value for _39 { const VALUE: u32 = 39; } /// Type representing the value 40 for the `Value` trait. pub struct _40; impl Value for _40 { const VALUE: u32 = 40; } +/// Type representing the value 41 for the `Value` trait. +pub struct _41; impl Value for _41 { const VALUE: u32 = 41; } +/// Type representing the value 42 for the `Value` trait. +pub struct _42; impl Value for _42 { const VALUE: u32 = 42; } +/// Type representing the value 43 for the `Value` trait. +pub struct _43; impl Value for _43 { const VALUE: u32 = 43; } +/// Type representing the value 44 for the `Value` trait. +pub struct _44; impl Value for _44 { const VALUE: u32 = 44; } +/// Type representing the value 45 for the `Value` trait. +pub struct _45; impl Value for _45 { const VALUE: u32 = 45; } +/// Type representing the value 46 for the `Value` trait. +pub struct _46; impl Value for _46 { const VALUE: u32 = 46; } +/// Type representing the value 47 for the `Value` trait. +pub struct _47; impl Value for _47 { const VALUE: u32 = 47; } /// Type representing the value 48 for the `Value` trait. pub struct _48; impl Value for _48 { const VALUE: u32 = 48; } +/// Type representing the value 49 for the `Value` trait. +pub struct _49; impl Value for _49 { const VALUE: u32 = 49; } +/// Type representing the value 50 for the `Value` trait. +pub struct _50; impl Value for _50 { const VALUE: u32 = 50; } +/// Type representing the value 51 for the `Value` trait. +pub struct _51; impl Value for _51 { const VALUE: u32 = 51; } +/// Type representing the value 52 for the `Value` trait. +pub struct _52; impl Value for _52 { const VALUE: u32 = 52; } +/// Type representing the value 53 for the `Value` trait. +pub struct _53; impl Value for _53 { const VALUE: u32 = 53; } +/// Type representing the value 54 for the `Value` trait. +pub struct _54; impl Value for _54 { const VALUE: u32 = 54; } +/// Type representing the value 55 for the `Value` trait. +pub struct _55; impl Value for _55 { const VALUE: u32 = 55; } /// Type representing the value 56 for the `Value` trait. pub struct _56; impl Value for _56 { const VALUE: u32 = 56; } +/// Type representing the value 57 for the `Value` trait. +pub struct _57; impl Value for _57 { const VALUE: u32 = 57; } +/// Type representing the value 58 for the `Value` trait. +pub struct _58; impl Value for _58 { const VALUE: u32 = 58; } +/// Type representing the value 59 for the `Value` trait. +pub struct _59; impl Value for _59 { const VALUE: u32 = 59; } +/// Type representing the value 60 for the `Value` trait. +pub struct _60; impl Value for _60 { const VALUE: u32 = 60; } +/// Type representing the value 61 for the `Value` trait. +pub struct _61; impl Value for _61 { const VALUE: u32 = 61; } +/// Type representing the value 62 for the `Value` trait. +pub struct _62; impl Value for _62 { const VALUE: u32 = 62; } +/// Type representing the value 63 for the `Value` trait. +pub struct _63; impl Value for _63 { const VALUE: u32 = 63; } /// Type representing the value 64 for the `Value` trait. pub struct _64; impl Value for _64 { const VALUE: u32 = 64; } +/// Type representing the value 65 for the `Value` trait. +pub struct _65; impl Value for _65 { const VALUE: u32 = 65; } +/// Type representing the value 66 for the `Value` trait. +pub struct _66; impl Value for _66 { const VALUE: u32 = 66; } +/// Type representing the value 67 for the `Value` trait. +pub struct _67; impl Value for _67 { const VALUE: u32 = 67; } +/// Type representing the value 68 for the `Value` trait. +pub struct _68; impl Value for _68 { const VALUE: u32 = 68; } +/// Type representing the value 69 for the `Value` trait. +pub struct _69; impl Value for _69 { const VALUE: u32 = 69; } +/// Type representing the value 70 for the `Value` trait. +pub struct _70; impl Value for _70 { const VALUE: u32 = 70; } +/// Type representing the value 71 for the `Value` trait. +pub struct _71; impl Value for _71 { const VALUE: u32 = 71; } +/// Type representing the value 72 for the `Value` trait. +pub struct _72; impl Value for _72 { const VALUE: u32 = 72; } +/// Type representing the value 73 for the `Value` trait. +pub struct _73; impl Value for _73 { const VALUE: u32 = 73; } +/// Type representing the value 74 for the `Value` trait. +pub struct _74; impl Value for _74 { const VALUE: u32 = 74; } +/// Type representing the value 75 for the `Value` trait. +pub struct _75; impl Value for _75 { const VALUE: u32 = 75; } +/// Type representing the value 76 for the `Value` trait. +pub struct _76; impl Value for _76 { const VALUE: u32 = 76; } +/// Type representing the value 77 for the `Value` trait. +pub struct _77; impl Value for _77 { const VALUE: u32 = 77; } +/// Type representing the value 78 for the `Value` trait. +pub struct _78; impl Value for _78 { const VALUE: u32 = 78; } +/// Type representing the value 79 for the `Value` trait. +pub struct _79; impl Value for _79 { const VALUE: u32 = 79; } /// Type representing the value 80 for the `Value` trait. pub struct _80; impl Value for _80 { const VALUE: u32 = 80; } +/// Type representing the value 81 for the `Value` trait. +pub struct _81; impl Value for _81 { const VALUE: u32 = 81; } +/// Type representing the value 82 for the `Value` trait. +pub struct _82; impl Value for _82 { const VALUE: u32 = 82; } +/// Type representing the value 83 for the `Value` trait. +pub struct _83; impl Value for _83 { const VALUE: u32 = 83; } +/// Type representing the value 84 for the `Value` trait. +pub struct _84; impl Value for _84 { const VALUE: u32 = 84; } +/// Type representing the value 85 for the `Value` trait. +pub struct _85; impl Value for _85 { const VALUE: u32 = 85; } +/// Type representing the value 86 for the `Value` trait. +pub struct _86; impl Value for _86 { const VALUE: u32 = 86; } +/// Type representing the value 87 for the `Value` trait. +pub struct _87; impl Value for _87 { const VALUE: u32 = 87; } +/// Type representing the value 88 for the `Value` trait. +pub struct _88; impl Value for _88 { const VALUE: u32 = 88; } +/// Type representing the value 89 for the `Value` trait. +pub struct _89; impl Value for _89 { const VALUE: u32 = 89; } +/// Type representing the value 90 for the `Value` trait. +pub struct _90; impl Value for _90 { const VALUE: u32 = 90; } +/// Type representing the value 91 for the `Value` trait. +pub struct _91; impl Value for _91 { const VALUE: u32 = 91; } +/// Type representing the value 92 for the `Value` trait. +pub struct _92; impl Value for _92 { const VALUE: u32 = 92; } +/// Type representing the value 93 for the `Value` trait. +pub struct _93; impl Value for _93 { const VALUE: u32 = 93; } +/// Type representing the value 94 for the `Value` trait. +pub struct _94; impl Value for _94 { const VALUE: u32 = 94; } +/// Type representing the value 95 for the `Value` trait. +pub struct _95; impl Value for _95 { const VALUE: u32 = 95; } /// Type representing the value 96 for the `Value` trait. pub struct _96; impl Value for _96 { const VALUE: u32 = 96; } +/// Type representing the value 97 for the `Value` trait. +pub struct _97; impl Value for _97 { const VALUE: u32 = 97; } +/// Type representing the value 98 for the `Value` trait. +pub struct _98; impl Value for _98 { const VALUE: u32 = 98; } +/// Type representing the value 99 for the `Value` trait. +pub struct _99; impl Value for _99 { const VALUE: u32 = 99; } +/// Type representing the value 100 for the `Value` trait. +pub struct _100; impl Value for _100 { const VALUE: u32 = 100; } /// Type representing the value 112 for the `Value` trait. pub struct _112; impl Value for _112 { const VALUE: u32 = 112; } /// Type representing the value 128 for the `Value` trait. @@ -87,3 +240,4 @@ pub struct _256; impl Value for _256 { const VALUE: u32 = 256; } pub struct _384; impl Value for _384 { const VALUE: u32 = 384; } /// Type representing the value 512 for the `Value` trait. pub struct _512; impl Value for _512 { const VALUE: u32 = 512; } + diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index 5963450360..f412ede0af 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -73,7 +73,11 @@ pub trait EnsureOrigin { /// A return type. type Success; /// Perform the origin check. - fn ensure_origin(o: OuterOrigin) -> result::Result; + fn ensure_origin(o: OuterOrigin) -> result::Result { + Self::try_origin(o).map_err(|_| "Invalid origin") + } + /// Perform the origin check. + fn try_origin(o: OuterOrigin) -> result::Result; } /// Means of changing one type into another in a manner dependent on the source type. diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 2ce4a3e656..bc24de9ddf 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -18,7 +18,7 @@ use primitives::{ed25519::Public as AuthorityId, ed25519, sr25519, Pair, crypto::UncheckedInto}; use node_primitives::AccountId; -use node_runtime::{ConsensusConfig, CouncilSeatsConfig, CouncilVotingConfig, DemocracyConfig, +use node_runtime::{ConsensusConfig, CouncilSeatsConfig, DemocracyConfig, SessionConfig, StakingConfig, StakerStatus, TimestampConfig, BalancesConfig, TreasuryConfig, SudoConfig, ContractConfig, GrandpaConfig, IndicesConfig, Permill, Perbill}; pub use node_runtime::GenesisConfig; @@ -132,11 +132,6 @@ fn staging_testnet_config_genesis() -> GenesisConfig { desired_seats: 0, inactive_grace_period: 1, // one additional vote should go by before an inactive voter can be reaped. }), - council_voting: Some(CouncilVotingConfig { - cooloff_period: 4 * DAYS, - voting_period: 1 * DAYS, - enact_delay_period: 0, - }), timestamp: Some(TimestampConfig { minimum_period: SECS_PER_BLOCK / 2, // due to the nature of aura the slots are 2*period }), @@ -312,11 +307,6 @@ pub fn testnet_genesis( desired_seats: (endowed_accounts.len() / 2 - initial_authorities.len()) as u32, inactive_grace_period: 1, }), - council_voting: Some(CouncilVotingConfig { - cooloff_period: 75, - voting_period: 20, - enact_delay_period: 0, - }), timestamp: Some(TimestampConfig { minimum_period: 2, // 2*2=4 second block time. }), diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index 8813850bbd..05dc424d49 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -316,7 +316,6 @@ mod tests { }), democracy: Some(Default::default()), council_seats: Some(Default::default()), - council_voting: Some(Default::default()), timestamp: Some(Default::default()), treasury: Some(Default::default()), contract: Some(Default::default()), diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 5daeccf72c..f0c1a8ae7d 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -22,7 +22,7 @@ use rstd::prelude::*; use support::{construct_runtime, parameter_types}; -use substrate_primitives::u32_trait::{_2, _4}; +use substrate_primitives::u32_trait::{_1, _2, _3, _4}; use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, AuthorityId, Signature, AuthoritySignature }; @@ -37,7 +37,7 @@ use runtime_primitives::traits::{ BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup, AuthorityIdFor, Convert, }; use version::RuntimeVersion; -use council::{motions as council_motions, voting as council_voting}; +use council::{motions as council_motions}; #[cfg(feature = "std")] use council::seats as council_seats; #[cfg(any(feature = "std", test))] @@ -156,8 +156,10 @@ const BUCKS: Balance = 1_000_000_000_000; parameter_types! { pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + pub const EmergencyVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES; pub const MinimumDeposit: Balance = 100 * BUCKS; pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES; + pub const CooloffPeriod: BlockNumber = 30 * 24 * 60 * MINUTES; } impl democracy::Trait for Runtime { type Proposal = Call; @@ -166,17 +168,21 @@ impl democracy::Trait for Runtime { type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; + type EmergencyVotingPeriod = EmergencyVotingPeriod; type MinimumDeposit = MinimumDeposit; + type ExternalOrigin = council_motions::EnsureProportionAtLeast<_1, _2, AccountId>; + type ExternalMajorityOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>; + type EmergencyOrigin = council_motions::EnsureProportionAtLeast<_1, _1, AccountId>; + type CancellationOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>; + type VetoOrigin = council_motions::EnsureMember; + type CooloffPeriod = CooloffPeriod; } impl council::Trait for Runtime { type Event = Event; type BadPresentation = (); type BadReaper = (); -} - -impl council::voting::Trait for Runtime { - type Event = Event; + type OnMembersChanged = CouncilMotions; } impl council::motions::Trait for Runtime { @@ -187,8 +193,8 @@ impl council::motions::Trait for Runtime { impl treasury::Trait for Runtime { type Currency = Balances; - type ApproveOrigin = council_motions::EnsureMembers<_4>; - type RejectOrigin = council_motions::EnsureMembers<_2>; + type ApproveOrigin = council_motions::EnsureMembers<_4, AccountId>; + type RejectOrigin = council_motions::EnsureMembers<_2, AccountId>; type Event = Event; type MintedForSpending = (); type ProposalRejection = (); @@ -236,8 +242,7 @@ construct_runtime!( Staking: staking::{default, OfflineWorker}, Democracy: democracy, Council: council::{Module, Call, Storage, Event}, - CouncilVoting: council_voting, - CouncilMotions: council_motions::{Module, Call, Storage, Event, Origin}, + CouncilMotions: council_motions::{Module, Call, Storage, Event, Origin}, CouncilSeats: council_seats::{Config}, FinalityTracker: finality_tracker::{Module, Call, Inherent}, Grandpa: grandpa::{Module, Call, Storage, Config, Log(), Event}, diff --git a/srml/contract/src/lib.rs b/srml/contract/src/lib.rs index 3f05bb8a8f..0111ce7840 100644 --- a/srml/contract/src/lib.rs +++ b/srml/contract/src/lib.rs @@ -506,10 +506,10 @@ decl_module! { fn claim_surcharge(origin, dest: T::AccountId, aux_sender: Option) { let origin = origin.into(); let (signed, rewarded) = match origin { - Some(system::RawOrigin::Signed(ref account)) if aux_sender.is_none() => { + Ok(system::RawOrigin::Signed(ref account)) if aux_sender.is_none() => { (true, account) }, - Some(system::RawOrigin::None) if aux_sender.is_some() => { + Ok(system::RawOrigin::None) if aux_sender.is_some() => { (false, aux_sender.as_ref().expect("checked above")) }, _ => return Err("Invalid surcharge claim: origin must be signed or \ diff --git a/srml/council/src/lib.rs b/srml/council/src/lib.rs index ac5396e4da..a72e93c9eb 100644 --- a/srml/council/src/lib.rs +++ b/srml/council/src/lib.rs @@ -18,34 +18,42 @@ #![cfg_attr(not(feature = "std"), no_std)] -pub mod voting; pub mod motions; pub mod seats; pub use crate::seats::{Trait, Module, RawEvent, Event, VoteIndex}; +/// Trait for type that can handle incremental changes to a set of account IDs. +pub trait OnMembersChanged { + /// A number of members `new` just joined the set and replaced some `old` ones. + fn on_members_changed(new: &[AccountId], old: &[AccountId]); +} + +impl OnMembersChanged for () { + fn on_members_changed(_new: &[T], _old: &[T]) {} +} + #[cfg(test)] mod tests { // These re-exports are here for a reason, edit with care pub use super::*; pub use runtime_io::with_externalities; use srml_support::{impl_outer_origin, impl_outer_event, impl_outer_dispatch, parameter_types}; - pub use substrate_primitives::H256; - pub use primitives::BuildStorage; - pub use primitives::traits::{BlakeTwo256, IdentityLookup}; - pub use primitives::testing::{Digest, DigestItem, Header}; - pub use substrate_primitives::{Blake2Hasher}; - pub use {seats, motions, voting}; + pub use substrate_primitives::{H256, Blake2Hasher, u32_trait::{_1, _2, _3, _4}}; + pub use primitives::{ + BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::{Digest, DigestItem, Header} + }; + pub use {seats, motions}; impl_outer_origin! { pub enum Origin for Test { - motions + motions } } impl_outer_event! { pub enum Event for Test { - balances, democracy, seats, voting, motions, + balances, democracy, seats, motions, } } @@ -86,6 +94,7 @@ mod tests { pub const VotingPeriod: u64 = 3; pub const MinimumDeposit: u64 = 1; pub const EnactmentPeriod: u64 = 0; + pub const CooloffPeriod: u64 = 2; } impl democracy::Trait for Test { type Proposal = Call; @@ -93,22 +102,27 @@ mod tests { type Currency = balances::Module; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; + type EmergencyVotingPeriod = VotingPeriod; type VotingPeriod = VotingPeriod; type MinimumDeposit = MinimumDeposit; + type ExternalOrigin = motions::EnsureProportionAtLeast<_1, _2, u64>; + type ExternalMajorityOrigin = motions::EnsureProportionAtLeast<_2, _3, u64>; + type EmergencyOrigin = motions::EnsureProportionAtLeast<_1, _1, u64>; + type CancellationOrigin = motions::EnsureProportionAtLeast<_2, _3, u64>; + type VetoOrigin = motions::EnsureMember; + type CooloffPeriod = CooloffPeriod; } impl seats::Trait for Test { type Event = Event; type BadPresentation = (); type BadReaper = (); + type OnMembersChanged = CouncilMotions; } impl motions::Trait for Test { type Origin = Origin; type Proposal = Call; type Event = Event; } - impl voting::Trait for Test { - type Event = Event; - } pub fn new_test_ext(with_council: bool) -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap().0; @@ -138,11 +152,6 @@ mod tests { desired_seats: 2, term_duration: 5, }.build_storage().unwrap().0); - t.extend(voting::GenesisConfig:: { - cooloff_period: 2, - voting_period: 1, - enact_delay_period: 0, - }.build_storage().unwrap().0); runtime_io::TestExternalities::new(t) } @@ -150,6 +159,5 @@ mod tests { pub type Balances = balances::Module; pub type Democracy = democracy::Module; pub type Council = seats::Module; - pub type CouncilVoting = voting::Module; pub type CouncilMotions = motions::Module; } diff --git a/srml/council/src/motions.rs b/srml/council/src/motions.rs index e560fadb9c..4ab4e84c12 100644 --- a/srml/council/src/motions.rs +++ b/srml/council/src/motions.rs @@ -16,21 +16,27 @@ //! Council voting system. -use rstd::prelude::*; -use rstd::result; +use rstd::{prelude::*, result}; use substrate_primitives::u32_trait::Value as U32; use primitives::traits::{Hash, EnsureOrigin}; -use srml_support::dispatch::{Dispatchable, Parameter}; -use srml_support::{StorageValue, StorageMap, decl_module, decl_event, decl_storage, ensure}; -use super::{Trait as CouncilTrait, Module as Council}; +use srml_support::{ + dispatch::{Dispatchable, Parameter}, codec::{Encode, Decode}, + StorageValue, StorageMap, decl_module, decl_event, decl_storage, ensure +}; +use super::{Trait as CouncilTrait, Module as Council, OnMembersChanged}; use system::{self, ensure_signed}; /// Simple index type for proposal counting. pub type ProposalIndex = u32; +/// A number of council members. +/// +/// This also serves as a number of voting members, and since for motions, each council member may +/// vote exactly once, therefore also the number of votes for any given motion. +pub type MemberCount = u32; pub trait Trait: CouncilTrait { /// The outer origin type. - type Origin: From; + type Origin: From>; /// The outer call dispatch type. type Proposal: Parameter + Dispatchable::Origin>; @@ -42,31 +48,79 @@ pub trait Trait: CouncilTrait { /// Origin for the council module. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Debug))] -pub enum Origin { - /// It has been condoned by a given number of council members. - Members(u32), +pub enum RawOrigin { + /// It has been condoned by a given number of council members from a given total. + Members(MemberCount, MemberCount), + /// It has been condoned by a single council member. + Member(AccountId), +} + +/// Origin for the council module. +pub type Origin = RawOrigin<::AccountId>; + +#[derive(PartialEq, Eq, Clone, Encode, Decode)] +#[cfg_attr(feature = "std", derive(Debug))] +/// Info for keeping track of a motion being voted on. +pub struct Votes { + /// The proposal's unique index. + index: ProposalIndex, + /// The number of approval votes that are needed to pass the motion. + threshold: MemberCount, + /// The current set of voters that approved it. + ayes: Vec, + /// The current set of voters that rejected it. + nays: Vec, +} + +decl_storage! { + trait Store for Module as CouncilMotions { + /// The hashes of the active proposals. + pub Proposals get(proposals): Vec; + /// Actual proposal for a given hash, if it's current. + pub ProposalOf get(proposal_of): map T::Hash => Option<::Proposal>; + /// Votes on a given proposal, if it is ongoing. + pub Voting get(voting): map T::Hash => Option>; + /// Proposals so far. + pub ProposalCount get(proposal_count): u32; + } } decl_event!( pub enum Event where ::Hash, ::AccountId { - /// A motion (given hash) has been proposed (by given account) with a threshold (given u32). - Proposed(AccountId, ProposalIndex, Hash, u32), + /// A motion (given hash) has been proposed (by given account) with a threshold (given + /// `MemberCount`). + Proposed(AccountId, ProposalIndex, Hash, MemberCount), /// A motion (given hash) has been voted on by given account, leaving - /// a tally (yes votes and no votes given as u32s respectively). - Voted(AccountId, Hash, bool, u32, u32), + /// a tally (yes votes and no votes given respectively as `MemberCount`). + Voted(AccountId, Hash, bool, MemberCount, MemberCount), /// A motion was approved by the required threshold. Approved(Hash), /// A motion was not approved by the required threshold. Disapproved(Hash), /// A motion was executed; `bool` is true if returned without error. Executed(Hash, bool), + /// A single councillor did some action; `bool` is true if returned without error. + MemberExecuted(Hash, bool), } ); decl_module! { pub struct Module for enum Call where origin: ::Origin { fn deposit_event() = default; - fn propose(origin, #[compact] threshold: u32, proposal: Box<::Proposal>) { + + /// Dispatch a proposal from a councilor using the `Member` origin. + /// + /// Origin must be a council member. + fn execute(origin, proposal: Box<::Proposal>) { + let who = ensure_signed(origin)?; + ensure!(Self::is_councillor(&who), "proposer not on council"); + + let proposal_hash = T::Hashing::hash_of(&proposal); + let ok = proposal.dispatch(RawOrigin::Member(who).into()).is_ok(); + Self::deposit_event(RawEvent::MemberExecuted(proposal_hash, ok)); + } + + fn propose(origin, #[compact] threshold: MemberCount, proposal: Box<::Proposal>) { let who = ensure_signed(origin)?; ensure!(Self::is_councillor(&who), "proposer not on council"); @@ -76,14 +130,16 @@ decl_module! { ensure!(!>::exists(proposal_hash), "duplicate proposals not allowed"); if threshold < 2 { - let ok = proposal.dispatch(Origin::Members(1).into()).is_ok(); + let seats = >::active_council().len() as MemberCount; + let ok = proposal.dispatch(RawOrigin::Members(1, seats).into()).is_ok(); Self::deposit_event(RawEvent::Executed(proposal_hash, ok)); } else { let index = Self::proposal_count(); >::mutate(|i| *i += 1); >::mutate(|proposals| proposals.push(proposal_hash)); >::insert(proposal_hash, *proposal); - >::insert(proposal_hash, (index, threshold, vec![who.clone()], vec![])); + let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![] }; + >::insert(proposal_hash, votes); Self::deposit_event(RawEvent::Proposed(who, index, proposal_hash, threshold)); } @@ -95,46 +151,46 @@ decl_module! { ensure!(Self::is_councillor(&who), "voter not on council"); let mut voting = Self::voting(&proposal).ok_or("proposal must exist")?; - ensure!(voting.0 == index, "mismatched index"); + ensure!(voting.index == index, "mismatched index"); - let position_yes = voting.2.iter().position(|a| a == &who); - let position_no = voting.3.iter().position(|a| a == &who); + let position_yes = voting.ayes.iter().position(|a| a == &who); + let position_no = voting.nays.iter().position(|a| a == &who); if approve { if position_yes.is_none() { - voting.2.push(who.clone()); + voting.ayes.push(who.clone()); } else { return Err("duplicate vote ignored") } if let Some(pos) = position_no { - voting.3.swap_remove(pos); + voting.nays.swap_remove(pos); } } else { if position_no.is_none() { - voting.3.push(who.clone()); + voting.nays.push(who.clone()); } else { return Err("duplicate vote ignored") } if let Some(pos) = position_yes { - voting.2.swap_remove(pos); + voting.ayes.swap_remove(pos); } } - let yes_votes = voting.2.len() as u32; - let no_votes = voting.3.len() as u32; + let yes_votes = voting.ayes.len() as MemberCount; + let no_votes = voting.nays.len() as MemberCount; Self::deposit_event(RawEvent::Voted(who, proposal, approve, yes_votes, no_votes)); - let threshold = voting.1; - let potential_votes = >::active_council().len() as u32; - let approved = yes_votes >= threshold; - let disapproved = potential_votes.saturating_sub(no_votes) < threshold; + let seats = >::active_council().len() as MemberCount; + let approved = yes_votes >= voting.threshold; + let disapproved = seats.saturating_sub(no_votes) < voting.threshold; if approved || disapproved { if approved { Self::deposit_event(RawEvent::Approved(proposal)); // execute motion, assuming it exists. if let Some(p) = >::take(&proposal) { - let ok = p.dispatch(Origin::Members(threshold).into()).is_ok(); + let origin = RawOrigin::Members(voting.threshold, seats).into(); + let ok = p.dispatch(origin).is_ok(); Self::deposit_event(RawEvent::Executed(proposal, ok)); } } else { @@ -153,22 +209,6 @@ decl_module! { } } -decl_storage! { - trait Store for Module as CouncilMotions { - /// The (hashes of) the active proposals. - pub Proposals get(proposals): Vec; - /// Actual proposal for a given hash, if it's current. - pub ProposalOf get(proposal_of): map T::Hash => Option< ::Proposal >; - /// Votes for a given proposal: (required_yes_votes, yes_voters, no_voters). - pub Voting get(voting): map T::Hash => Option<(ProposalIndex, u32, Vec, Vec)>; - /// Proposals so far. - pub ProposalCount get(proposal_count): u32; - } - add_extra_genesis { - build(|_, _, _| {}); - } -} - impl Module { pub fn is_councillor(who: &T::AccountId) -> bool { >::active_council().iter() @@ -176,24 +216,101 @@ impl Module { } } -/// Ensure that the origin `o` represents at least `n` council members. Returns -/// `Ok` or an `Err` otherwise. -pub fn ensure_council_members(o: OuterOrigin, n: u32) -> result::Result - where OuterOrigin: Into> +impl OnMembersChanged for Module { + fn on_members_changed(_new: &[T::AccountId], old: &[T::AccountId]) { + // remove accounts from all current voting in motions. + let mut old = old.to_vec(); + old.sort_unstable(); + for h in Self::proposals().into_iter() { + >::mutate(h, |v| + if let Some(mut votes) = v.take() { + votes.ayes = votes.ayes.into_iter() + .filter(|i| old.binary_search(i).is_err()) + .collect(); + votes.nays = votes.nays.into_iter() + .filter(|i| old.binary_search(i).is_err()) + .collect(); + *v = Some(votes); + } + ); + } + } +} + +/// Ensure that the origin `o` represents at least `n` council members. Returns `Ok` or an `Err` +/// otherwise. +pub fn ensure_council_members(o: OuterOrigin, n: MemberCount) + -> result::Result + where OuterOrigin: Into, OuterOrigin>> { match o.into() { - Some(Origin::Members(x)) if x >= n => Ok(n), + Ok(RawOrigin::Members(x, _)) if x >= n => Ok(n), _ => Err("bad origin: expected to be a threshold number of council members"), } } -pub struct EnsureMembers(::rstd::marker::PhantomData); -impl EnsureOrigin for EnsureMembers - where O: Into> -{ - type Success = u32; - fn ensure_origin(o: O) -> result::Result { - ensure_council_members(o, N::VALUE) +pub struct EnsureMember(::rstd::marker::PhantomData); +impl< + O: Into, O>> + From>, + AccountId +> EnsureOrigin for EnsureMember { + type Success = AccountId; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Member(id) => Ok(id), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureMembers(::rstd::marker::PhantomData<(N, AccountId)>); +impl< + O: Into, O>> + From>, + N: U32, + AccountId, +> EnsureOrigin for EnsureMembers { + type Success = (MemberCount, MemberCount); + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Members(n, m) if n >= N::VALUE => Ok((n, m)), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureProportionMoreThan( + ::rstd::marker::PhantomData<(N, D, AccountId)> +); +impl< + O: Into, O>> + From>, + N: U32, + D: U32, + AccountId, +> EnsureOrigin for EnsureProportionMoreThan { + type Success = (); + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Members(n, m) if n * D::VALUE > N::VALUE * m => Ok(()), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureProportionAtLeast( + ::rstd::marker::PhantomData<(N, D, AccountId)> +); +impl< + O: Into, O>> + From>, + N: U32, + D: U32, + AccountId, +> EnsureOrigin for EnsureProportionAtLeast { + type Success = (); + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Members(n, m) if n * D::VALUE >= N::VALUE * m => Ok(()), + r => Err(O::from(r)), + }) } } @@ -203,12 +320,13 @@ mod tests { use super::RawEvent; use crate::tests::*; use crate::tests::{Call, Origin, Event as OuterEvent}; + use primitives::traits::BlakeTwo256; use srml_support::{Hashable, assert_ok, assert_noop}; use system::{EventRecord, Phase}; use hex_literal::hex; #[test] - fn motions_basic_environment_works() { + fn basic_environment_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); assert_eq!(Balances::free_balance(&42), 0); @@ -221,7 +339,41 @@ mod tests { } #[test] - fn motions_propose_works() { + fn removal_of_old_voters_votes_works() { + with_externalities(&mut new_test_ext(true), || { + System::set_block_number(1); + let proposal = set_balance_proposal(42); + let hash = BlakeTwo256::hash_of(&proposal); + assert_ok!(CouncilMotions::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); + assert_ok!(CouncilMotions::vote(Origin::signed(2), hash.clone(), 0, true)); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 0, threshold: 3, ayes: vec![1, 2], nays: vec![] }) + ); + CouncilMotions::on_members_changed(&[], &[1]); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 0, threshold: 3, ayes: vec![2], nays: vec![] }) + ); + + let proposal = set_balance_proposal(69); + let hash = BlakeTwo256::hash_of(&proposal); + assert_ok!(CouncilMotions::propose(Origin::signed(2), 2, Box::new(proposal.clone()))); + assert_ok!(CouncilMotions::vote(Origin::signed(3), hash.clone(), 1, false)); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![3] }) + ); + CouncilMotions::on_members_changed(&[], &[3]); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![] }) + ); + }); + } + + #[test] + fn propose_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); let proposal = set_balance_proposal(42); @@ -229,7 +381,10 @@ mod tests { assert_ok!(CouncilMotions::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); assert_eq!(CouncilMotions::proposals(), vec![hash]); assert_eq!(CouncilMotions::proposal_of(&hash), Some(proposal)); - assert_eq!(CouncilMotions::voting(&hash), Some((0, 3, vec![1], Vec::::new()))); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 0, threshold: 3, ayes: vec![1], nays: vec![] }) + ); assert_eq!(System::events(), vec![ EventRecord { @@ -242,7 +397,7 @@ mod tests { } #[test] - fn motions_ignoring_non_council_proposals_works() { + fn ignoring_non_council_proposals_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); let proposal = set_balance_proposal(42); @@ -251,7 +406,7 @@ mod tests { } #[test] - fn motions_ignoring_non_council_votes_works() { + fn ignoring_non_council_votes_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); let proposal = set_balance_proposal(42); @@ -262,7 +417,7 @@ mod tests { } #[test] - fn motions_ignoring_bad_index_council_vote_works() { + fn ignoring_bad_index_council_vote_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(3); let proposal = set_balance_proposal(42); @@ -273,16 +428,22 @@ mod tests { } #[test] - fn motions_revoting_works() { + fn revoting_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash: H256 = proposal.blake2_256().into(); assert_ok!(CouncilMotions::propose(Origin::signed(1), 2, Box::new(proposal.clone()))); - assert_eq!(CouncilMotions::voting(&hash), Some((0, 2, vec![1], Vec::::new()))); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![] }) + ); assert_noop!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0, true), "duplicate vote ignored"); assert_ok!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0, false)); - assert_eq!(CouncilMotions::voting(&hash), Some((0, 2, Vec::::new(), vec![1]))); + assert_eq!( + CouncilMotions::voting(&hash), + Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![1] }) + ); assert_noop!(CouncilMotions::vote(Origin::signed(1), hash.clone(), 0, false), "duplicate vote ignored"); assert_eq!(System::events(), vec![ @@ -301,7 +462,7 @@ mod tests { } #[test] - fn motions_disapproval_works() { + fn disapproval_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); let proposal = set_balance_proposal(42); @@ -330,7 +491,7 @@ mod tests { } #[test] - fn motions_approval_works() { + fn approval_works() { with_externalities(&mut new_test_ext(true), || { System::set_block_number(1); let proposal = set_balance_proposal(42); diff --git a/srml/council/src/seats.rs b/srml/council/src/seats.rs index fb93157981..584a2fb800 100644 --- a/srml/council/src/seats.rs +++ b/srml/council/src/seats.rs @@ -25,6 +25,7 @@ use srml_support::{ }; use democracy; use system::{self, ensure_signed}; +use super::OnMembersChanged; // no polynomial attacks: // @@ -95,6 +96,9 @@ pub trait Trait: democracy::Trait { /// Handler for the unbalanced reduction when slashing an invalid reaping attempt. type BadReaper: OnUnbalanced>; + + /// What to do when the members change. + type OnMembersChanged: OnMembersChanged; } decl_module! { @@ -269,15 +273,16 @@ decl_module! { } /// Set the desired member count; if lower than the current count, then seats will not be up - /// election when they expire. If more, then a new vote will be started if one is not already - /// in progress. + /// election when they expire. If more, then a new vote will be started if one is not + /// already in progress. fn set_desired_seats(#[compact] count: u32) { >::put(count); } - /// Remove a particular member. A tally will happen instantly (if not already in a presentation + /// Remove a particular member from the council. This is effective immediately. + /// + /// Note: A tally should happen instantly (if not already in a presentation /// period) to fill the seat if removal means that the desired members are not met. - /// This is effective immediately. fn remove_member(who: ::Source) { let who = T::Lookup::lookup(who)?; let new_council: Vec<(T::AccountId, T::BlockNumber)> = Self::active_council() @@ -285,6 +290,7 @@ decl_module! { .filter(|i| i.0 != who) .collect(); >::put(new_council); + T::OnMembersChanged::on_members_changed(&[], &[who]); } /// Set the presentation duration. If there is currently a vote being presented for, will @@ -392,6 +398,14 @@ impl Module { >::exists(who) } + /// Iff the councillor `who` still has a seat at blocknumber `n` returns `true`. + pub fn will_still_be_councillor_at(who: &T::AccountId, n: T::BlockNumber) -> bool { + Self::active_council().iter() + .find(|&&(ref a, _)| a == who) + .map(|&(_, expires)| expires > n) + .unwrap_or(false) + } + /// Determine the block that a vote can happen on which is no less than `n`. pub fn next_vote_from(n: T::BlockNumber) -> T::BlockNumber { let voting_period = Self::voting_period(); @@ -514,7 +528,7 @@ impl Module { // return bond to winners. let candidacy_bond = Self::candidacy_bond(); - let incoming: Vec = leaderboard.iter() + let incoming: Vec<_> = leaderboard.iter() .rev() .take_while(|&&(b, _)| !b.is_zero()) .take(coming as usize) @@ -523,7 +537,9 @@ impl Module { .inspect(|a| {T::Currency::unreserve(a, candidacy_bond);}) .collect(); let active_council = Self::active_council(); - let outgoing = active_council.iter().take(expiring.len()).map(|a| a.0.clone()).collect(); + let outgoing: Vec<_> = active_council.iter() + .take(expiring.len()) + .map(|a| a.0.clone()).collect(); // set the new council. let mut new_council: Vec<_> = active_council @@ -534,6 +550,8 @@ impl Module { new_council.sort_by_key(|&(_, expiry)| expiry); >::put(new_council); + T::OnMembersChanged::on_members_changed(&incoming, &outgoing); + // clear all except runners-up from candidate list. let candidates = Self::candidates(); let mut new_candidates = vec![T::AccountId::default(); candidates.len()]; // shrink later. diff --git a/srml/council/src/voting.rs b/srml/council/src/voting.rs deleted file mode 100644 index 0137cd6d2f..0000000000 --- a/srml/council/src/voting.rs +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright 2017-2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Council voting system. - -use rstd::prelude::*; -use rstd::borrow::Borrow; -use primitives::traits::{Hash, Zero}; -use runtime_io::print; -use srml_support::dispatch::Result; -use srml_support::{StorageValue, StorageMap, IsSubType, decl_module, decl_storage, decl_event, ensure}; -use {system, democracy}; -use super::{Trait as CouncilTrait, Module as Council}; -use system::ensure_signed; - -pub trait Trait: CouncilTrait { - type Event: From> + Into<::Event>; -} - -decl_module! { - pub struct Module for enum Call where origin: T::Origin { - fn deposit_event() = default; - - fn propose(origin, proposal: Box) { - let who = ensure_signed(origin)?; - - let expiry = >::block_number() + Self::voting_period(); - ensure!(Self::will_still_be_councillor_at(&who, expiry), "proposer would not be on council"); - - let proposal_hash = T::Hashing::hash_of(&proposal); - - ensure!(!>::exists(proposal_hash), "duplicate proposals not allowed"); - ensure!(!Self::is_vetoed(&proposal_hash), "proposal is vetoed"); - - let mut proposals = Self::proposals(); - proposals.push((expiry, proposal_hash)); - proposals.sort_by_key(|&(expiry, _)| expiry); - Self::set_proposals(&proposals); - - >::insert(proposal_hash, *proposal); - >::insert(proposal_hash, vec![who.clone()]); - >::insert((proposal_hash, who.clone()), true); - } - - fn vote(origin, proposal: T::Hash, approve: bool) { - let who = ensure_signed(origin)?; - - ensure!(Self::is_councillor(&who), "only councillors may vote on council proposals"); - - if Self::vote_of((proposal, who.clone())).is_none() { - >::mutate(proposal, |voters| voters.push(who.clone())); - } - >::insert((proposal, who), approve); - } - - fn veto(origin, proposal_hash: T::Hash) { - let who = ensure_signed(origin)?; - - ensure!(Self::is_councillor(&who), "only councillors may veto council proposals"); - ensure!(>::exists(&proposal_hash), "proposal must exist to be vetoed"); - - let mut existing_vetoers = Self::veto_of(&proposal_hash) - .map(|pair| pair.1) - .unwrap_or_else(Vec::new); - let insert_position = existing_vetoers.binary_search(&who) - .err().ok_or("a councillor may not veto a proposal twice")?; - existing_vetoers.insert(insert_position, who); - Self::set_veto_of( - &proposal_hash, - >::block_number() + Self::cooloff_period(), - existing_vetoers - ); - - Self::set_proposals( - &Self::proposals().into_iter().filter(|&(_, h)| h != proposal_hash - ).collect::>()); - >::remove(proposal_hash); - >::remove(proposal_hash); - for (c, _) in >::active_council() { - >::remove((proposal_hash, c)); - } - } - - fn set_cooloff_period(#[compact] blocks: T::BlockNumber) { - >::put(blocks); - } - - fn set_voting_period(#[compact] blocks: T::BlockNumber) { - >::put(blocks); - } - - fn on_finalize(n: T::BlockNumber) { - if let Err(e) = Self::end_block(n) { - print("Guru meditation"); - print(e); - } - } - } -} - -decl_storage! { - trait Store for Module as CouncilVoting { - pub CooloffPeriod get(cooloff_period) config(): T::BlockNumber = 1000.into(); - pub VotingPeriod get(voting_period) config(): T::BlockNumber = 3.into(); - /// Number of blocks by which to delay enactment of successful, non-unanimous-council-instigated referendum proposals. - pub EnactDelayPeriod get(enact_delay_period) config(): T::BlockNumber = 0.into(); - pub Proposals get(proposals) build(|_| vec![]): Vec<(T::BlockNumber, T::Hash)>; // ordered by expiry. - pub ProposalOf get(proposal_of): map T::Hash => Option; - pub ProposalVoters get(proposal_voters): map T::Hash => Vec; - pub CouncilVoteOf get(vote_of): map (T::Hash, T::AccountId) => Option; - pub VetoedProposal get(veto_of): map T::Hash => Option<(T::BlockNumber, Vec)>; - } -} - -decl_event!( - pub enum Event where ::Hash { - /// A voting tally has happened for a referendum cancellation vote. - /// Last three are yes, no, abstain counts. - TallyCancelation(Hash, u32, u32, u32), - /// A voting tally has happened for a referendum vote. - /// Last three are yes, no, abstain counts. - TallyReferendum(Hash, u32, u32, u32), - } -); - -impl Module { - pub fn is_vetoed>(proposal: B) -> bool { - Self::veto_of(proposal.borrow()) - .map(|(expiry, _): (T::BlockNumber, Vec)| >::block_number() < expiry) - .unwrap_or(false) - } - - pub fn will_still_be_councillor_at(who: &T::AccountId, n: T::BlockNumber) -> bool { - >::active_council().iter() - .find(|&&(ref a, _)| a == who) - .map(|&(_, expires)| expires > n) - .unwrap_or(false) - } - - pub fn is_councillor(who: &T::AccountId) -> bool { - >::active_council().iter() - .any(|&(ref a, _)| a == who) - } - - pub fn tally(proposal_hash: &T::Hash) -> (u32, u32, u32) { - Self::generic_tally(proposal_hash, |w: &T::AccountId, p: &T::Hash| Self::vote_of((*p, w.clone()))) - } - - // Private - fn set_veto_of(proposal: &T::Hash, expiry: T::BlockNumber, vetoers: Vec) { - >::insert(proposal, (expiry, vetoers)); - } - - fn kill_veto_of(proposal: &T::Hash) { - >::remove(proposal); - } - - fn take_tally(proposal_hash: &T::Hash) -> (u32, u32, u32) { - Self::generic_tally(proposal_hash, |w: &T::AccountId, p: &T::Hash| >::take((*p, w.clone()))) - } - - fn generic_tally Option>(proposal_hash: &T::Hash, vote_of: F) -> (u32, u32, u32) { - let c = >::active_council(); - let (approve, reject) = c.iter() - .filter_map(|&(ref a, _)| vote_of(a, proposal_hash)) - .map(|approve| if approve { (1, 0) } else { (0, 1) }) - .fold((0, 0), |(a, b), (c, d)| (a + c, b + d)); - (approve, reject, c.len() as u32 - approve - reject) - } - - fn set_proposals(p: &Vec<(T::BlockNumber, T::Hash)>) { - >::put(p); - } - - fn take_proposal_if_expiring_at(n: T::BlockNumber) -> Option<(T::Proposal, T::Hash)> { - let proposals = Self::proposals(); - match proposals.first() { - Some(&(expiry, hash)) if expiry == n => { - // yes this is horrible, but fixing it will need substantial work in storage. - Self::set_proposals(&proposals[1..].to_vec()); - >::take(hash).map(|p| (p, hash)) /* defensive only: all queued proposal hashes must have associated proposals*/ - } - _ => None, - } - } - - fn end_block(now: T::BlockNumber) -> Result { - while let Some((proposal, proposal_hash)) = Self::take_proposal_if_expiring_at(now) { - let tally = Self::take_tally(&proposal_hash); - if let Some(&democracy::Call::cancel_referendum(ref_index)) = IsSubType::>::is_aux_sub_type(&proposal) { - Self::deposit_event(RawEvent::TallyCancelation(proposal_hash, tally.0, tally.1, tally.2)); - if let (_, 0, 0) = tally { - >::internal_cancel_referendum(ref_index.into()); - } - } else { - Self::deposit_event(RawEvent::TallyReferendum(proposal_hash.clone(), tally.0, tally.1, tally.2)); - if tally.0 > tally.1 + tally.2 { - Self::kill_veto_of(&proposal_hash); - // If there were no nay-votes from the council, then it's weakly uncontroversial; we enact immediately. - let period = match tally.1 { - 0 => Zero::zero(), - _ => Self::enact_delay_period(), - }; - // If all council members voted yes, then it's strongly uncontroversial; we require a negative - // super-majority at referendum in order to defeat it. - let threshold = match tally { - (_, 0, 0) => democracy::VoteThreshold::SuperMajorityAgainst, - _ => democracy::VoteThreshold::SimpleMajority, - }; - >::internal_start_referendum(proposal, threshold, period).map(|_| ())?; - } - } - } - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::tests::*; - use crate::tests::{Call, Origin}; - use srml_support::{Hashable, assert_ok, assert_noop}; - use democracy::{ReferendumInfo, VoteThreshold}; - - #[test] - fn basic_environment_works() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - assert_eq!(Balances::free_balance(&42), 0); - assert_eq!(CouncilVoting::cooloff_period(), 2); - assert_eq!(CouncilVoting::voting_period(), 1); - assert_eq!(CouncilVoting::will_still_be_councillor_at(&1, 1), true); - assert_eq!(CouncilVoting::will_still_be_councillor_at(&1, 10), false); - assert_eq!(CouncilVoting::will_still_be_councillor_at(&4, 10), false); - assert_eq!(CouncilVoting::is_councillor(&1), true); - assert_eq!(CouncilVoting::is_councillor(&4), false); - assert_eq!(CouncilVoting::proposals(), Vec::<(u64, H256)>::new()); - assert_eq!(CouncilVoting::proposal_voters(H256::default()), Vec::::new()); - assert_eq!(CouncilVoting::is_vetoed(&H256::default()), false); - assert_eq!(CouncilVoting::vote_of((H256::default(), 1)), None); - assert_eq!(CouncilVoting::tally(&H256::default()), (0, 0, 3)); - }); - } - - fn set_balance_proposal(value: u64) -> Call { - Call::Balances(balances::Call::set_balance(42, value.into(), 0)) - } - - fn cancel_referendum_proposal(id: u32) -> Call { - Call::Democracy(democracy::Call::cancel_referendum(id.into())) - } - - #[test] - fn referendum_cancellation_should_work_when_unanimous() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(Democracy::internal_start_referendum(proposal.clone(), VoteThreshold::SuperMajorityApprove, 0), 0); - assert_eq!(Democracy::active_referenda(), vec![(0, ReferendumInfo::new(4, proposal, VoteThreshold::SuperMajorityApprove, 0))]); - - let cancellation = cancel_referendum_proposal(0); - let hash = cancellation.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(cancellation))); - assert_ok!(CouncilVoting::vote(Origin::signed(2), hash, true)); - assert_ok!(CouncilVoting::vote(Origin::signed(3), hash, true)); - assert_eq!(CouncilVoting::proposals(), vec![(2, hash)]); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(2); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(Democracy::active_referenda(), vec![]); - assert_eq!(Balances::free_balance(&42), 0); - }); - } - - #[test] - fn referendum_cancellation_should_fail_when_not_unanimous() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(Democracy::internal_start_referendum(proposal.clone(), VoteThreshold::SuperMajorityApprove, 0), 0); - - let cancellation = cancel_referendum_proposal(0); - let hash = cancellation.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(cancellation))); - assert_ok!(CouncilVoting::vote(Origin::signed(2), hash, true)); - assert_ok!(CouncilVoting::vote(Origin::signed(3), hash, false)); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(2); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(Democracy::active_referenda(), vec![(0, ReferendumInfo::new(4, proposal, VoteThreshold::SuperMajorityApprove, 0))]); - }); - } - - #[test] - fn referendum_cancellation_should_fail_when_abstentions() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(Democracy::internal_start_referendum(proposal.clone(), VoteThreshold::SuperMajorityApprove, 0), 0); - - let cancellation = cancel_referendum_proposal(0); - let hash = cancellation.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(cancellation))); - assert_ok!(CouncilVoting::vote(Origin::signed(2), hash, true)); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(2); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(Democracy::active_referenda(), vec![(0, ReferendumInfo::new(4, proposal, VoteThreshold::SuperMajorityApprove, 0))]); - }); - } - - #[test] - fn veto_should_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - let hash = proposal.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::veto(Origin::signed(2), hash)); - assert_eq!(CouncilVoting::proposals().len(), 0); - assert_eq!(Democracy::active_referenda().len(), 0); - }); - } - - #[test] - fn double_veto_should_not_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - let hash = proposal.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::veto(Origin::signed(2), hash)); - - System::set_block_number(3); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_noop!(CouncilVoting::veto(Origin::signed(2), hash), "a councillor may not veto a proposal twice"); - }); - } - - #[test] - fn retry_in_cooloff_should_not_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - let hash = proposal.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::veto(Origin::signed(2), hash)); - - System::set_block_number(2); - assert_noop!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone())), "proposal is vetoed"); - }); - } - - #[test] - fn retry_after_cooloff_should_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - let hash = proposal.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::veto(Origin::signed(2), hash)); - - System::set_block_number(3); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::vote(Origin::signed(2), hash, false)); - assert_ok!(CouncilVoting::vote(Origin::signed(3), hash, true)); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(4); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(CouncilVoting::proposals().len(), 0); - assert_eq!(Democracy::active_referenda(), vec![(0, ReferendumInfo::new(7, set_balance_proposal(42), VoteThreshold::SimpleMajority, 0))]); - }); - } - - #[test] - fn alternative_double_veto_should_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - let hash = proposal.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::veto(Origin::signed(2), hash)); - - System::set_block_number(3); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::veto(Origin::signed(3), hash)); - assert_eq!(CouncilVoting::proposals().len(), 0); - assert_eq!(Democracy::active_referenda().len(), 0); - }); - } - - #[test] - fn simple_propose_should_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - let hash = proposal.blake2_256().into(); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_eq!(CouncilVoting::proposals().len(), 1); - assert_eq!(CouncilVoting::proposal_voters(&hash), vec![1]); - assert_eq!(CouncilVoting::vote_of((hash, 1)), Some(true)); - assert_eq!(CouncilVoting::tally(&hash), (1, 0, 2)); - }); - } - - #[test] - fn unvoted_proposal_should_expire_without_action() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_eq!(CouncilVoting::tally(&proposal.blake2_256().into()), (1, 0, 2)); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(2); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(CouncilVoting::proposals().len(), 0); - assert_eq!(Democracy::active_referenda().len(), 0); - }); - } - - #[test] - fn unanimous_proposal_should_expire_with_biased_referendum() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::vote(Origin::signed(2), proposal.blake2_256().into(), true)); - assert_ok!(CouncilVoting::vote(Origin::signed(3), proposal.blake2_256().into(), true)); - assert_eq!(CouncilVoting::tally(&proposal.blake2_256().into()), (3, 0, 0)); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(2); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(CouncilVoting::proposals().len(), 0); - assert_eq!(Democracy::active_referenda(), vec![(0, ReferendumInfo::new(5, proposal, VoteThreshold::SuperMajorityAgainst, 0))]); - }); - } - - #[test] - fn majority_proposal_should_expire_with_unbiased_referendum() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_ok!(CouncilVoting::vote(Origin::signed(2), proposal.blake2_256().into(), true)); - assert_ok!(CouncilVoting::vote(Origin::signed(3), proposal.blake2_256().into(), false)); - assert_eq!(CouncilVoting::tally(&proposal.blake2_256().into()), (2, 1, 0)); - assert_ok!(CouncilVoting::end_block(System::block_number())); - - System::set_block_number(2); - assert_ok!(CouncilVoting::end_block(System::block_number())); - assert_eq!(CouncilVoting::proposals().len(), 0); - assert_eq!(Democracy::active_referenda(), vec![(0, ReferendumInfo::new(5, proposal, VoteThreshold::SimpleMajority, 0))]); - }); - } - - #[test] - fn propose_by_public_should_not_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_noop!(CouncilVoting::propose(Origin::signed(4), Box::new(proposal)), "proposer would not be on council"); - }); - } - - #[test] - fn vote_by_public_should_not_work() { - with_externalities(&mut new_test_ext(true), || { - System::set_block_number(1); - let proposal = set_balance_proposal(42); - assert_ok!(CouncilVoting::propose(Origin::signed(1), Box::new(proposal.clone()))); - assert_noop!(CouncilVoting::vote(Origin::signed(4), proposal.blake2_256().into(), true), "only councillors may vote on council proposals"); - }); - } -} diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index 1846f3462d..96d51849c9 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -20,7 +20,7 @@ use rstd::prelude::*; use rstd::{result, convert::TryFrom}; -use primitives::traits::{Zero, Bounded, CheckedMul, CheckedDiv}; +use primitives::traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash}; use parity_codec::{Encode, Decode, Input, Output}; use srml_support::{ decl_module, decl_storage, decl_event, ensure, @@ -31,7 +31,7 @@ use srml_support::{ } }; use srml_support::dispatch::Result; -use system::ensure_signed; +use system::{ensure_signed, ensure_root}; mod vote_threshold; pub use vote_threshold::{Approved, VoteThreshold}; @@ -188,6 +188,29 @@ pub trait Trait: system::Trait + Sized { /// The minimum amount to be used as a deposit for a public referendum proposal. type MinimumDeposit: Get>; + + /// Origin from which the next tabled referendum may be forced. This is a normal + /// "super-majority-required" referendum. + type ExternalOrigin: EnsureOrigin; + + /// Origin from which the next tabled referendum may be forced; this allows for the tabling of + /// a majority-carries referendum. + type ExternalMajorityOrigin: EnsureOrigin; + + /// Origin from which emergency referenda may be scheduled. + type EmergencyOrigin: EnsureOrigin; + + /// Minimum voting period allowed for an emergency referendum. + type EmergencyVotingPeriod: Get; + + /// Origin from which any referenda may be cancelled in an emergency. + type CancellationOrigin: EnsureOrigin; + + /// Origin for anyone able to veto proposals. + type VetoOrigin: EnsureOrigin; + + /// Period in blocks where an external proposal may not be re-submitted after being vetoed. + type CooloffPeriod: Get; } /// Info regarding an ongoing referendum. @@ -252,13 +275,36 @@ decl_storage! { /// Get the account (and lock periods) to which another account is delegating vote. pub Delegations get(delegations): linked_map T::AccountId => (T::AccountId, Conviction); + + /// True if the last referendum tabled was submitted externally. False if it was a public + /// proposal. + pub LastTabledWasExternal: bool; + + /// The referendum to be tabled whenever it would be valid to table an external proposal. + /// This happens when a referendum needs to be tabled and one of two conditions are met: + /// - `LastTabledWasExternal` is `false`; or + /// - `PublicProps` is empty. + pub NextExternal: Option<(T::Proposal, VoteThreshold)>; + + /// A record of who vetoed what. Maps proposal hash to a possible existent block number + /// (until when it may not be resubmitted) and who vetoed it. + pub Blacklist get(blacklist): map T::Hash => Option<(T::BlockNumber, Vec)>; + + /// Record of all proposals that have been subject to emergency cancellation. + pub Cancellations: map T::Hash => bool; } } decl_event!( - pub enum Event where Balance = BalanceOf, ::AccountId { + pub enum Event where + Balance = BalanceOf, + ::AccountId, + ::Hash, + ::BlockNumber, + { Proposed(PropIndex, Balance), Tabled(PropIndex, Balance, Vec), + ExternalTabled, Started(ReferendumIndex, VoteThreshold), Passed(ReferendumIndex), NotPassed(ReferendumIndex), @@ -266,6 +312,7 @@ decl_event!( Executed(ReferendumIndex, bool), Delegated(AccountId, AccountId), Undelegated(AccountId), + Vetoed(AccountId, Hash, BlockNumber), } ); @@ -274,8 +321,7 @@ decl_module! { fn deposit_event() = default; /// Propose a sensitive action to be taken. - fn propose( - origin, + fn propose(origin, proposal: Box, #[compact] value: BalanceOf ) { @@ -307,7 +353,7 @@ decl_module! { >::insert(proposal, deposit); } - /// Vote in a referendum. If vote is aye, the vote is to enact the proposal; + /// Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; /// otherwise it is a vote to keep the status quo. fn vote(origin, #[compact] ref_index: ReferendumIndex, @@ -317,8 +363,8 @@ decl_module! { Self::do_vote(who, ref_index, vote) } - /// Vote in a referendum on behalf of a stash. If vote is aye, the vote is to enact - /// the proposal; otherwise it is a vote to keep the status quo. + /// Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact + /// the proposal; otherwise it is a vote to keep the status quo. fn proxy_vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote @@ -327,18 +373,95 @@ decl_module! { Self::do_vote(who, ref_index, vote) } - /// Start a referendum. - fn start_referendum( + /// Schedule an emergency referendum. + /// + /// This will create a new referendum for the `proposal`, approved as long as counted votes + /// exceed `threshold` and, if approved, enacted after the given `delay`. + /// + /// It may be called from either the Root or the Emergency origin. + fn emergency_propose(origin, proposal: Box, threshold: VoteThreshold, + voting_period: T::BlockNumber, delay: T::BlockNumber - ) -> Result { + ) { + T::EmergencyOrigin::try_origin(origin) + .map(|_| ()) + .or_else(|origin| ensure_root(origin))?; + let now = >::block_number(); + // We don't consider it an error if `vote_period` is too low, but we do enforce the + // minimum. This is primarily due to practicality. If it's an emergency, we don't want + // to introduce more delays than is strictly needed by requiring a potentially costly + // resubmission in the case of a mistakenly low `vote_period`; better to just let the + // referendum take place with the lowest valid value. + let period = voting_period.max(T::EmergencyVotingPeriod::get()); Self::inject_referendum( - >::block_number() + T::VotingPeriod::get(), + now + period, *proposal, threshold, delay, - ).map(|_| ()) + ).map(|_| ())?; + } + + /// Schedule an emergency cancellation of a referendum. Cannot happen twice to the same + /// referendum. + fn emergency_cancel(origin, ref_index: ReferendumIndex) { + T::CancellationOrigin::ensure_origin(origin)?; + + let info = Self::referendum_info(ref_index).ok_or("unknown index")?; + let h = T::Hashing::hash_of(&info.proposal); + ensure!(!>::exists(h), "cannot cancel the same proposal twice"); + + >::insert(h, true); + Self::clear_referendum(ref_index); + } + + /// Schedule a referendum to be tabled once it is legal to schedule an external + /// referendum. + fn external_propose(origin, proposal: Box) { + T::ExternalOrigin::ensure_origin(origin)?; + ensure!(!>::exists(), "proposal already made"); + let proposal_hash = T::Hashing::hash_of(&proposal); + if let Some((until, _)) = >::get(proposal_hash) { + ensure!(>::block_number() >= until, "proposal still blacklisted"); + } + >::put((*proposal, VoteThreshold::SuperMajorityApprove)); + } + + /// Schedule a majority-carries referendum to be tabled next once it is legal to schedule + /// an external referendum. + fn external_propose_majority(origin, proposal: Box) { + T::ExternalMajorityOrigin::ensure_origin(origin)?; + ensure!(!>::exists(), "proposal already made"); + let proposal_hash = T::Hashing::hash_of(&proposal); + if let Some((until, _)) = >::get(proposal_hash) { + ensure!(>::block_number() >= until, "proposal still blacklisted"); + } + >::put((*proposal, VoteThreshold::SimpleMajority)); + } + + /// Veto and blacklist the external proposal hash. + fn veto_external(origin, proposal_hash: T::Hash) { + let who = T::VetoOrigin::ensure_origin(origin)?; + + if let Some((proposal, _)) = >::get() { + ensure!(proposal_hash == T::Hashing::hash_of(&proposal), "unknown proposal"); + } else { + Err("no external proposal")?; + } + + let mut existing_vetoers = >::get(&proposal_hash) + .map(|pair| pair.1) + .unwrap_or_else(Vec::new); + let insert_position = existing_vetoers.binary_search(&who) + .err().ok_or("identity may not veto a proposal twice")?; + + existing_vetoers.insert(insert_position, who.clone()); + let until = >::block_number() + T::CooloffPeriod::get(); + >::insert(&proposal_hash, (until, existing_vetoers)); + + Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until)); + >::kill(); } /// Remove a referendum. @@ -347,12 +470,19 @@ decl_module! { } /// Cancel a proposal queued for enactment. - pub fn cancel_queued(#[compact] when: T::BlockNumber, #[compact] which: u32) { + fn cancel_queued( + #[compact] when: T::BlockNumber, + #[compact] which: u32, + #[compact] what: ReferendumIndex + ) { let which = which as usize; - >::mutate( - when, - |items| if items.len() > which { items[which] = None } - ); + let mut items = >::get(when); + if items.get(which).and_then(Option::as_ref).map_or(false, |x| x.1 == what) { + items[which] = None; + >::insert(when, items); + } else { + Err("proposal not found")? + } } fn on_finalize(n: T::BlockNumber) { @@ -603,7 +733,34 @@ impl Module { Self::deposit_event(RawEvent::Executed(index, ok)); } + /// Table the next waiting proposal for a vote. fn launch_next(now: T::BlockNumber) -> Result { + if >::take() { + Self::launch_public(now).or_else(|_| Self::launch_external(now)) + } else { + Self::launch_external(now).or_else(|_| Self::launch_public(now)) + }.map_err(|_| "No proposals waiting") + } + + /// Table the waiting external proposal for a vote, if there is one. + fn launch_external(now: T::BlockNumber) -> Result { + if let Some((proposal, threshold)) = >::take() { + >::put(true); + Self::deposit_event(RawEvent::ExternalTabled); + Self::inject_referendum( + now + T::VotingPeriod::get(), + proposal, + threshold, + T::EnactmentPeriod::get(), + )?; + Ok(()) + } else { + Err("No external proposal waiting") + } + } + + /// Table the waiting public proposal with the highest backing for a vote. + fn launch_public(now: T::BlockNumber) -> Result { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter() .enumerate() @@ -626,9 +783,11 @@ impl Module { T::EnactmentPeriod::get(), )?; } + Ok(()) + } else { + Err("No public proposals waiting") } - Ok(()) } fn bake_referendum( @@ -682,11 +841,13 @@ impl Module { } /// Current era is ending; we should finish up any proposals. - // TODO: move to `initialize_block + // TODO: move to initialize_block #2779 fn end_block(now: T::BlockNumber) -> Result { // pick out another public referendum if it's time. if (now % T::LaunchPeriod::get()).is_zero() { - Self::launch_next(now.clone())?; + // Errors come from the queue being empty. we don't really care about that, and even if + // we did, there is nothing we can do here. + let _ = Self::launch_next(now.clone()); } // tally up votes for any expiring referenda. @@ -712,13 +873,15 @@ mod tests { use super::*; use runtime_io::with_externalities; use srml_support::{ - impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types + impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types, + traits::Contains }; use substrate_primitives::{H256, Blake2Hasher}; use primitives::BuildStorage; use primitives::traits::{BlakeTwo256, IdentityLookup, Bounded}; use primitives::testing::{Digest, DigestItem, Header}; use balances::BalanceLock; + use system::EnsureSignedBy; const AYE: Vote = Vote{ aye: true, conviction: Conviction::None }; const NAY: Vote = Vote{ aye: false, conviction: Conviction::None }; @@ -762,19 +925,39 @@ mod tests { type DustRemoval = (); } parameter_types! { - pub const LaunchPeriod: u64 = 1; - pub const VotingPeriod: u64 = 1; + pub const LaunchPeriod: u64 = 2; + pub const VotingPeriod: u64 = 2; + pub const EmergencyVotingPeriod: u64 = 1; pub const MinimumDeposit: u64 = 1; - pub const EnactmentPeriod: u64 = 1; + pub const EnactmentPeriod: u64 = 2; + pub const CooloffPeriod: u64 = 2; + pub const One: u64 = 1; + pub const Two: u64 = 2; + pub const Three: u64 = 3; + pub const Four: u64 = 4; + pub const Five: u64 = 5; + } + pub struct OneToFive; + impl Contains for OneToFive { + fn contains(n: &u64) -> bool { + *n >= 1 && *n <= 5 + } } - impl Trait for Test { + impl super::Trait for Test { type Proposal = Call; type Event = (); type Currency = balances::Module; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; + type EmergencyVotingPeriod = EmergencyVotingPeriod; type MinimumDeposit = MinimumDeposit; + type EmergencyOrigin = EnsureSignedBy; + type ExternalOrigin = EnsureSignedBy; + type ExternalMajorityOrigin = EnsureSignedBy; + type CancellationOrigin = EnsureSignedBy; + type VetoOrigin = EnsureSignedBy; + type CooloffPeriod = CooloffPeriod; } fn new_test_ext() -> runtime_io::TestExternalities { @@ -806,13 +989,14 @@ mod tests { } fn set_balance_proposal(value: u64) -> Call { - Call::Balances(balances::Call::set_balance(42, value.into(), 0)) + Call::Balances(balances::Call::set_balance(42, value, 0)) } - fn propose_set_balance(who: u64, value: u64, locked: u64) -> super::Result { + fn propose_set_balance(who: u64, value: u64, delay: u64) -> super::Result { Democracy::propose( Origin::signed(who), - Box::new(set_balance_proposal(value)), locked.into() + Box::new(set_balance_proposal(value)), + delay ) } @@ -821,6 +1005,326 @@ mod tests { System::set_block_number(System::block_number() + 1); } + fn fast_forward_to(n: u64) { + while System::block_number() < n { + next_block(); + } + } + + #[test] + fn external_and_public_interleaving_works() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(1)), + )); + assert_ok!(propose_set_balance(6, 2, 2)); + + fast_forward_to(1); + + // both waiting: external goes first. + assert_eq!( + Democracy::referendum_info(0), + Some(ReferendumInfo { + end: 2, + proposal: set_balance_proposal(1), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + // replenish external + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(3)), + )); + + fast_forward_to(3); + + // both waiting: public goes next. + assert_eq!( + Democracy::referendum_info(1), + Some(ReferendumInfo { + end: 4, + proposal: set_balance_proposal(2), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + // don't replenish public + + fast_forward_to(5); + + // it's external "turn" again, though since public is empty that doesn't really matter + assert_eq!( + Democracy::referendum_info(2), + Some(ReferendumInfo { + end: 6, + proposal: set_balance_proposal(3), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + // replenish external + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(5)), + )); + + fast_forward_to(7); + + // external goes again because there's no public waiting. + assert_eq!( + Democracy::referendum_info(3), + Some(ReferendumInfo { + end: 8, + proposal: set_balance_proposal(5), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + // replenish both + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(7)), + )); + assert_ok!(propose_set_balance(6, 4, 2)); + + fast_forward_to(9); + + // public goes now since external went last time. + assert_eq!( + Democracy::referendum_info(4), + Some(ReferendumInfo { + end: 10, + proposal: set_balance_proposal(4), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + // replenish public again + assert_ok!(propose_set_balance(6, 6, 2)); + // cancel external + let h = BlakeTwo256::hash_of(&set_balance_proposal(7)); + assert_ok!(Democracy::veto_external(Origin::signed(3), h)); + + fast_forward_to(11); + + // public goes again now since there's no external waiting. + assert_eq!( + Democracy::referendum_info(5), + Some(ReferendumInfo { + end: 12, + proposal: set_balance_proposal(6), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + }); + } + + + #[test] + fn emergency_cancel_should_work() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + let r = Democracy::inject_referendum( + 2, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 2 + ).unwrap(); + assert!(Democracy::referendum_info(r).is_some()); + + assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), "Invalid origin"); + assert_ok!(Democracy::emergency_cancel(Origin::signed(4), r)); + assert!(Democracy::referendum_info(r).is_none()); + + // some time later... + + let r = Democracy::inject_referendum( + 2, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 2 + ).unwrap(); + assert!(Democracy::referendum_info(r).is_some()); + assert_noop!(Democracy::emergency_cancel(Origin::signed(4), r), "cannot cancel the same proposal twice"); + }); + } + + #[test] + fn veto_external_works() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(2)), + )); + assert!(>::exists()); + + let h = BlakeTwo256::hash_of(&set_balance_proposal(2)); + assert_ok!(Democracy::veto_external(Origin::signed(3), h.clone())); + // cancelled. + assert!(!>::exists()); + // fails - same proposal can't be resubmitted. + assert_noop!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(2)), + ), "proposal still blacklisted"); + + fast_forward_to(1); + // fails as we're still in cooloff period. + assert_noop!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(2)), + ), "proposal still blacklisted"); + + fast_forward_to(2); + // works; as we're out of the cooloff period. + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(2)), + )); + assert!(>::exists()); + + // 3 can't veto the same thing twice. + assert_noop!( + Democracy::veto_external(Origin::signed(3), h.clone()), + "identity may not veto a proposal twice" + ); + + // 4 vetoes. + assert_ok!(Democracy::veto_external(Origin::signed(4), h.clone())); + // cancelled again. + assert!(!>::exists()); + + fast_forward_to(3); + // same proposal fails as we're still in cooloff + assert_noop!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(2)), + ), "proposal still blacklisted"); + // different proposal works fine. + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(3)), + )); + }); + } + + #[test] + fn emergency_referendum_works() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + assert_noop!(Democracy::emergency_propose( + Origin::signed(6), // invalid + Box::new(set_balance_proposal(2)), + VoteThreshold::SuperMajorityAgainst, + 0, + 0, + ), "bad origin: expected to be a root origin"); + assert_ok!(Democracy::emergency_propose( + Origin::signed(1), + Box::new(set_balance_proposal(2)), + VoteThreshold::SuperMajorityAgainst, + 0, + 0, + )); + assert_eq!( + Democracy::referendum_info(0), + Some(ReferendumInfo { + end: 1, + proposal: set_balance_proposal(2), + threshold: VoteThreshold::SuperMajorityAgainst, + delay: 0 + }) + ); + + assert_ok!(Democracy::vote(Origin::signed(1), 0, AYE)); + fast_forward_to(1); + assert_eq!(Balances::free_balance(&42), 0); + fast_forward_to(2); + assert_eq!(Balances::free_balance(&42), 2); + + assert_ok!(Democracy::emergency_propose( + Origin::signed(1), + Box::new(set_balance_proposal(4)), + VoteThreshold::SuperMajorityAgainst, + 3, + 3 + )); + assert_eq!( + Democracy::referendum_info(1), + Some(ReferendumInfo { + end: 5, + proposal: set_balance_proposal(4), + threshold: VoteThreshold::SuperMajorityAgainst, + delay: 3 + }) + ); + assert_ok!(Democracy::vote(Origin::signed(1), 1, AYE)); + fast_forward_to(8); + assert_eq!(Balances::free_balance(&42), 2); + fast_forward_to(9); + assert_eq!(Balances::free_balance(&42), 4); + }); + } + + #[test] + fn external_referendum_works() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + assert_noop!(Democracy::external_propose( + Origin::signed(1), + Box::new(set_balance_proposal(2)), + ), "Invalid origin"); + assert_ok!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(2)), + )); + assert_noop!(Democracy::external_propose( + Origin::signed(2), + Box::new(set_balance_proposal(1)), + ), "proposal already made"); + fast_forward_to(1); + assert_eq!( + Democracy::referendum_info(0), + Some(ReferendumInfo { + end: 2, + proposal: set_balance_proposal(2), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); + }); + } + + #[test] + fn external_majority_referendum_works() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + assert_noop!(Democracy::external_propose_majority( + Origin::signed(1), + Box::new(set_balance_proposal(2)) + ), "Invalid origin"); + assert_ok!(Democracy::external_propose_majority( + Origin::signed(3), + Box::new(set_balance_proposal(2)) + )); + fast_forward_to(1); + assert_eq!( + Democracy::referendum_info(0), + Some(ReferendumInfo { + end: 2, + proposal: set_balance_proposal(2), + threshold: VoteThreshold::SimpleMajority, + delay: 2, + }) + ); + }); + } + #[test] fn locked_for_should_work() { with_externalities(&mut new_test_ext(), || { @@ -837,25 +1341,74 @@ mod tests { #[test] fn single_proposal_should_work() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + assert!(Democracy::referendum_info(0).is_none()); + + // end of 0 => next referendum scheduled. + fast_forward_to(1); - System::set_block_number(2); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_eq!(Democracy::referendum_count(), 1); + assert_eq!( + Democracy::referendum_info(0), + Some(ReferendumInfo { + end: 2, + proposal: set_balance_proposal(2), + threshold: VoteThreshold::SuperMajorityApprove, + delay: 2 + }) + ); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); assert_eq!(Democracy::tally(r), (1, 0, 1)); - next_block(); - next_block(); + fast_forward_to(2); + + // referendum still running + assert!(Democracy::referendum_info(0).is_some()); + + // referendum runs during 1 and 2, ends @ end of 2. + fast_forward_to(3); + + assert!(Democracy::referendum_info(0).is_none()); + assert_eq!(Democracy::dispatch_queue(4), vec![ + Some((set_balance_proposal(2), 0)) + ]); + + // referendum passes and wait another two blocks for enactment. + fast_forward_to(5); + assert_eq!(Balances::free_balance(&42), 2); }); } + #[test] + fn cancel_queued_should_work() { + with_externalities(&mut new_test_ext(), || { + System::set_block_number(0); + assert_ok!(propose_set_balance(1, 2, 1)); + + // end of 0 => next referendum scheduled. + fast_forward_to(1); + + assert_ok!(Democracy::vote(Origin::signed(1), 0, AYE)); + + fast_forward_to(3); + + assert_eq!(Democracy::dispatch_queue(4), vec![ + Some((set_balance_proposal(2), 0)) + ]); + + assert_noop!(Democracy::cancel_queued(3, 0, 0), "proposal not found"); + assert_noop!(Democracy::cancel_queued(4, 1, 0), "proposal not found"); + assert_ok!(Democracy::cancel_queued(4, 0, 0)); + assert_eq!(Democracy::dispatch_queue(4), vec![None]); + }); + } + #[test] fn proxy_should_work() { with_externalities(&mut new_test_ext(), || { @@ -889,22 +1442,19 @@ mod tests { #[test] fn single_proposal_should_work_with_proxy() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); - System::set_block_number(2); + fast_forward_to(1); let r = 0; assert_ok!(Democracy::set_proxy(Origin::signed(1), 10)); assert_ok!(Democracy::proxy_vote(Origin::signed(10), r, AYE)); - assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); assert_eq!(Democracy::tally(r), (1, 0, 1)); - next_block(); - next_block(); + fast_forward_to(5); assert_eq!(Balances::free_balance(&42), 2); }); } @@ -912,27 +1462,23 @@ mod tests { #[test] fn single_proposal_should_work_with_delegation() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); - next_block(); - let r = 0; + fast_forward_to(1); // Delegate vote. assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); + let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); - - assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); - // Delegated vote is counted. assert_eq!(Democracy::tally(r), (3, 0, 3)); - next_block(); - next_block(); + fast_forward_to(5); assert_eq!(Balances::free_balance(&42), 2); }); @@ -941,27 +1487,24 @@ mod tests { #[test] fn single_proposal_should_work_with_cyclic_delegation() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); - next_block(); - let r = 0; + fast_forward_to(1); // Check behavior with cycle. assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); assert_ok!(Democracy::delegate(Origin::signed(3), 2, Conviction::max_value())); assert_ok!(Democracy::delegate(Origin::signed(1), 3, Conviction::max_value())); - + let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); - - assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1]); // Delegated vote is counted. assert_eq!(Democracy::tally(r), (6, 0, 6)); - next_block(); - next_block(); + + fast_forward_to(5); assert_eq!(Balances::free_balance(&42), 2); }); @@ -971,30 +1514,24 @@ mod tests { /// If transactor already voted, delegated vote is overwriten. fn single_proposal_should_work_with_vote_and_delegation() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); - next_block(); - let r = 0; + fast_forward_to(1); + let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); - // Vote. assert_ok!(Democracy::vote(Origin::signed(2), r, AYE)); - // Delegate vote. assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); - - assert_eq!(Democracy::referendum_count(), 1); assert_eq!(Democracy::voters_for(r), vec![1, 2]); assert_eq!(Democracy::vote_of((r, 1)), AYE); - // Delegated vote is not counted. assert_eq!(Democracy::tally(r), (3, 0, 3)); - next_block(); - next_block(); + fast_forward_to(5); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1003,7 +1540,7 @@ mod tests { #[test] fn single_proposal_should_work_with_undelegation() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); @@ -1011,7 +1548,7 @@ mod tests { assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); assert_ok!(Democracy::undelegate(Origin::signed(2))); - next_block(); + fast_forward_to(1); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -1022,8 +1559,7 @@ mod tests { // Delegated vote is not counted. assert_eq!(Democracy::tally(r), (1, 0, 1)); - next_block(); - next_block(); + fast_forward_to(5); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1033,11 +1569,11 @@ mod tests { /// If transactor voted, delegated vote is overwriten. fn single_proposal_should_work_with_delegation_and_vote() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); assert_ok!(propose_set_balance(1, 2, 1)); - next_block(); + fast_forward_to(1); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -1055,8 +1591,7 @@ mod tests { // Delegated vote is not counted. assert_eq!(Democracy::tally(r), (3, 0, 3)); - next_block(); - next_block(); + fast_forward_to(5); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1086,7 +1621,7 @@ mod tests { assert_ok!(Democracy::second(Origin::signed(5), 0)); assert_ok!(Democracy::second(Origin::signed(5), 0)); assert_ok!(Democracy::second(Origin::signed(5), 0)); - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); + fast_forward_to(3); assert_eq!(Balances::free_balance(&1), 10); assert_eq!(Balances::free_balance(&2), 20); assert_eq!(Balances::free_balance(&5), 50); @@ -1125,11 +1660,11 @@ mod tests { assert_ok!(propose_set_balance(1, 2, 2)); assert_ok!(propose_set_balance(1, 4, 4)); assert_ok!(propose_set_balance(1, 3, 3)); - next_block(); + fast_forward_to(1); assert_ok!(Democracy::vote(Origin::signed(1), 0, AYE)); - next_block(); + fast_forward_to(3); assert_ok!(Democracy::vote(Origin::signed(1), 1, AYE)); - next_block(); + fast_forward_to(5); assert_ok!(Democracy::vote(Origin::signed(1), 2, AYE)); }); } @@ -1305,7 +1840,7 @@ mod tests { #[test] fn lock_voting_should_work() { with_externalities(&mut new_test_ext(), || { - System::set_block_number(1); + System::set_block_number(0); let r = Democracy::inject_referendum( 1, set_balance_proposal(2), @@ -1335,31 +1870,29 @@ mod tests { assert_eq!(Democracy::tally(r), (250, 100, 150)); - next_block(); + fast_forward_to(2); assert_eq!(Balances::locks(1), vec![]); assert_eq!(Balances::locks(2), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), - until: 9, + until: 17, reasons: WithdrawReason::Transfer.into() }]); assert_eq!(Balances::locks(3), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), - until: 5, + until: 9, reasons: WithdrawReason::Transfer.into() }]); assert_eq!(Balances::locks(4), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), - until: 3, + until: 5, reasons: WithdrawReason::Transfer.into() }]); assert_eq!(Balances::locks(5), vec![]); - next_block(); - assert_eq!(Balances::free_balance(&42), 2); }); } @@ -1395,28 +1928,6 @@ mod tests { assert_eq!(Democracy::tally(r), (250, 100, 150)); next_block(); - - assert_eq!(Balances::locks(1), vec![]); - assert_eq!(Balances::locks(2), vec![BalanceLock { - id: DEMOCRACY_ID, - amount: u64::max_value(), - until: 9, - reasons: WithdrawReason::Transfer.into() - }]); - assert_eq!(Balances::locks(3), vec![BalanceLock { - id: DEMOCRACY_ID, - amount: u64::max_value(), - until: 5, - reasons: WithdrawReason::Transfer.into() - }]); - assert_eq!(Balances::locks(4), vec![BalanceLock { - id: DEMOCRACY_ID, - amount: u64::max_value(), - until: u64::max_value(), - reasons: WithdrawReason::Transfer.into() - }]); - assert_eq!(Balances::locks(5), vec![]); - next_block(); assert_eq!(Balances::free_balance(&42), 2); diff --git a/srml/support/src/metadata.rs b/srml/support/src/metadata.rs index b1da7587be..ed3e443afd 100644 --- a/srml/support/src/metadata.rs +++ b/srml/support/src/metadata.rs @@ -246,7 +246,8 @@ mod tests { mod system { pub trait Trait { - type Origin: Into>> + From>; + type Origin: Into, Self::Origin>> + + From>; type AccountId; type BlockNumber; } diff --git a/srml/support/src/origin.rs b/srml/support/src/origin.rs index 48d4be80c6..9bc2cab8b9 100644 --- a/srml/support/src/origin.rs +++ b/srml/support/src/origin.rs @@ -112,12 +112,12 @@ macro_rules! impl_outer_origin { $name::system(x) } } - impl Into>> for $name { - fn into(self) -> Option<$system::Origin<$runtime>> { + impl Into<$crate::rstd::result::Result<$system::Origin<$runtime>, $name>> for $name { + fn into(self) -> $crate::rstd::result::Result<$system::Origin<$runtime>, Self> { if let $name::system(l) = self { - Some(l) + Ok(l) } else { - None + Err(self) } } } @@ -132,12 +132,18 @@ macro_rules! impl_outer_origin { $name::$module(x) } } - impl Into )*>> for $name { - fn into(self) -> Option<$module::Origin $( <$generic_param $(, $generic_instance )? > )*> { + impl Into<$crate::rstd::result::Result< + $module::Origin $( <$generic_param $(, $generic_instance )? > )*, + $name + >> for $name { + fn into(self) -> $crate::rstd::result::Result< + $module::Origin $( <$generic_param $(, $generic_instance )? > )*, + Self + > { if let $name::$module(l) = self { - Some(l) + Ok(l) } else { - None + Err(self) } } } diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index 599de27c2e..3b3c63e223 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -26,12 +26,26 @@ use crate::runtime_primitives::traits::{ use super::for_each_tuple; -/// New trait for querying a single fixed value from a type. +/// A trait for querying a single fixed value from a type. pub trait Get { /// Return a constant value. fn get() -> T; } +/// A trait for querying whether a type can be said to statically "contain" a value. Similar +/// in nature to `Get`, except it is designed to be lazy rather than active (you can't ask it to +/// enumerate all values that it contains) and work for multiple values rather than just one. +pub trait Contains { + /// Return `true` if this "contains" the given value `t`. + fn contains(t: &T) -> bool; +} + +impl> Contains for T { + fn contains(t: &V) -> bool { + &Self::get() == t + } +} + /// The account with the given id was killed. pub trait OnFreeBalanceZero { /// The account was the given id was killed. diff --git a/srml/support/test/tests/instance.rs b/srml/support/test/tests/instance.rs index 641ad9f4b5..796934777d 100644 --- a/srml/support/test/tests/instance.rs +++ b/srml/support/test/tests/instance.rs @@ -39,7 +39,8 @@ mod system { use super::*; pub trait Trait: 'static + Eq + Clone { - type Origin: Into>> + From>; + type Origin: Into, Self::Origin>> + + From>; type BlockNumber; type Digest: Digest; type Hash; @@ -100,12 +101,9 @@ mod system { } pub fn ensure_root(o: OuterOrigin) -> Result<(), &'static str> - where OuterOrigin: Into>> + where OuterOrigin: Into, OuterOrigin>> { - match o.into() { - Some(RawOrigin::Root) => Ok(()), - _ => Err("bad origin: expected to be a root origin"), - } + o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin") } } diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index 5a3094d821..b08321f860 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -78,14 +78,14 @@ use rstd::prelude::*; use rstd::map; use primitives::traits::{self, CheckEqual, SimpleArithmetic, SimpleBitOps, One, Bounded, Lookup, Hash, Member, MaybeDisplay, EnsureOrigin, Digest as DigestT, CurrentHeight, BlockNumberToHash, - MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup, + MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup }; #[cfg(any(feature = "std", test))] use primitives::traits::Zero; use substrate_primitives::storage::well_known_keys; use srml_support::{ storage, decl_module, decl_event, decl_storage, StorageDoubleMap, StorageValue, - StorageMap, Parameter, for_each_tuple, + StorageMap, Parameter, for_each_tuple, traits::Contains }; use safe_mix::TripletMix; use parity_codec::{Encode, Decode}; @@ -145,7 +145,7 @@ pub fn extrinsics_data_root(xts: Vec>) -> H::Output { pub trait Trait: 'static + Eq + Clone { /// The aggregated `Origin` type used by dispatchable calls. - type Origin: Into>> + From>; + type Origin: Into, Self::Origin>> + From>; /// Account index (aka nonce) type. This stores the number of previous transactions associated with a sender /// account. @@ -376,40 +376,97 @@ decl_storage! { } pub struct EnsureRoot(::rstd::marker::PhantomData); -impl>>, AccountId> EnsureOrigin for EnsureRoot { +impl< + O: Into, O>> + From>, + AccountId, +> EnsureOrigin for EnsureRoot { type Success = (); - fn ensure_origin(o: O) -> Result { - ensure_root(o) + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Root => Ok(()), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureSigned(::rstd::marker::PhantomData); +impl< + O: Into, O>> + From>, + AccountId, +> EnsureOrigin for EnsureSigned { + type Success = AccountId; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Signed(who) => Ok(who), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureSignedBy(::rstd::marker::PhantomData<(Who, AccountId)>); +impl< + O: Into, O>> + From>, + Who: Contains, + AccountId: PartialEq + Clone, +> EnsureOrigin for EnsureSignedBy { + type Success = AccountId; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::Signed(ref who) if Who::contains(who) => Ok(who.clone()), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureNone(::rstd::marker::PhantomData); +impl< + O: Into, O>> + From>, + AccountId, +> EnsureOrigin for EnsureNone { + type Success = (); + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + RawOrigin::None => Ok(()), + r => Err(O::from(r)), + }) + } +} + +pub struct EnsureNever(::rstd::marker::PhantomData); +impl EnsureOrigin for EnsureNever { + type Success = T; + fn try_origin(o: O) -> Result { + Err(o) } } /// Ensure that the origin `o` represents a signed extrinsic (i.e. transaction). /// Returns `Ok` with the account that signed the extrinsic or an `Err` otherwise. pub fn ensure_signed(o: OuterOrigin) -> Result - where OuterOrigin: Into>> + where OuterOrigin: Into, OuterOrigin>> { match o.into() { - Some(RawOrigin::Signed(t)) => Ok(t), + Ok(RawOrigin::Signed(t)) => Ok(t), _ => Err("bad origin: expected to be a signed origin"), } } /// Ensure that the origin `o` represents the root. Returns `Ok` or an `Err` otherwise. pub fn ensure_root(o: OuterOrigin) -> Result<(), &'static str> - where OuterOrigin: Into>> + where OuterOrigin: Into, OuterOrigin>> { match o.into() { - Some(RawOrigin::Root) => Ok(()), + Ok(RawOrigin::Root) => Ok(()), _ => Err("bad origin: expected to be a root origin"), } } /// Ensure that the origin `o` represents an unsigned extrinsic. Returns `Ok` or an `Err` otherwise. pub fn ensure_none(o: OuterOrigin) -> Result<(), &'static str> - where OuterOrigin: Into>> + where OuterOrigin: Into, OuterOrigin>> { match o.into() { - Some(RawOrigin::None) => Ok(()), + Ok(RawOrigin::None) => Ok(()), _ => Err("bad origin: expected to be no origin"), } } @@ -753,6 +810,13 @@ mod tests { GenesisConfig::::default().build_storage().unwrap().0.into() } + #[test] + fn origin_works() { + let o = Origin::from(RawOrigin::::Signed(1u64)); + let x: Result, Origin> = o.into(); + assert_eq!(x, Ok(RawOrigin::::Signed(1u64))); + } + #[test] fn deposit_event_should_work() { with_externalities(&mut new_test_ext(), || { -- GitLab From 70cf5b0fab30626bc721c4eedba51405bd2afcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 5 Jun 2019 13:45:18 +0200 Subject: [PATCH 089/113] Build `LongestChain` with `TestClientBuilder` (#2792) * Switch to `TestClientBuilder` and support generating LongestChain * Make sure test-client works without the wasm blob * Use `TestClientBuilder` in more places --- Cargo.lock | 343 +++++++++++----------- core/client/src/client.rs | 80 ++--- core/executor/src/native_executor.rs | 2 +- core/rpc/src/state/tests.rs | 4 +- core/service/src/components.rs | 10 +- core/service/src/lib.rs | 9 +- core/sr-api-macros/tests/runtime_calls.rs | 37 ++- core/test-client/Cargo.toml | 2 +- core/test-client/src/lib.rs | 158 +++++----- core/test-client/src/trait_tests.rs | 8 +- 10 files changed, 320 insertions(+), 333 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37e52797fe..ba81460ca3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,7 +116,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -128,14 +128,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -144,7 +144,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -375,8 +375,8 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -429,7 +429,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -465,15 +465,15 @@ dependencies = [ "csv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -628,7 +628,7 @@ dependencies = [ "csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -767,7 +767,7 @@ dependencies = [ "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -780,7 +780,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -788,7 +788,7 @@ name = "error-chain" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -806,7 +806,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -831,7 +831,7 @@ name = "fdlimit" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -855,7 +855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -868,7 +868,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -905,8 +905,8 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -972,7 +972,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -982,7 +982,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1009,7 +1009,7 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.20" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1020,7 +1020,7 @@ dependencies = [ "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1195,7 +1195,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1205,7 +1205,7 @@ dependencies = [ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1240,7 +1240,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1248,7 +1248,7 @@ name = "impl-serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1271,7 +1271,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1311,9 +1311,9 @@ dependencies = [ "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1324,8 +1324,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1370,7 +1370,7 @@ dependencies = [ "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1384,7 +1384,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1477,12 +1477,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.55" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libloading" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1545,7 +1545,7 @@ dependencies = [ "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1604,7 +1604,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1624,7 +1624,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1650,7 +1650,7 @@ dependencies = [ "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1709,7 +1709,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1777,7 +1777,7 @@ dependencies = [ "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1869,7 +1869,7 @@ dependencies = [ "bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1949,7 +1949,7 @@ name = "memchr" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1997,7 +1997,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2015,7 +2015,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2028,7 +2028,7 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2053,7 +2053,7 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2096,7 +2096,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2113,7 +2113,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2125,7 +2125,7 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2147,7 +2147,7 @@ dependencies = [ "srml-finality-tracker 2.0.0", "srml-indices 2.0.0", "srml-timestamp 2.0.0", - "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-basic-authorship 2.0.0", "substrate-cli 2.0.0", "substrate-client 2.0.0", @@ -2163,7 +2163,7 @@ dependencies = [ "substrate-service-test 2.0.0", "substrate-telemetry 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-factory 0.0.1", ] @@ -2202,7 +2202,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2231,7 +2231,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -2283,7 +2283,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2294,7 +2294,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2356,7 +2356,7 @@ name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2395,7 +2395,7 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2411,7 +2411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2452,7 +2452,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2478,7 +2478,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2551,7 +2551,7 @@ name = "parking_lot_core" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2562,7 +2562,7 @@ name = "parking_lot_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2574,7 +2574,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2588,7 +2588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2713,7 +2713,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.6.1" +version = "2.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2749,7 +2749,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2759,7 +2759,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2772,7 +2772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2783,7 +2783,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2838,7 +2838,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2850,7 +2850,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2899,7 +2899,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2976,7 +2976,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2987,7 +2987,7 @@ name = "rocksdb" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2997,13 +2997,13 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3120,7 +3120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3152,15 +3152,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3175,7 +3175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3268,7 +3268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3390,7 +3390,7 @@ dependencies = [ "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", @@ -3423,7 +3423,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -3433,7 +3433,7 @@ name = "srml-assets" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3449,7 +3449,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3471,7 +3471,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3492,7 +3492,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3507,7 +3507,7 @@ name = "srml-consensus" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3527,7 +3527,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-sandbox 2.0.0", @@ -3549,7 +3549,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3566,7 +3566,7 @@ version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3581,7 +3581,7 @@ name = "srml-example" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "srml-balances 2.0.0", @@ -3596,7 +3596,7 @@ version = "2.0.0" dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3614,7 +3614,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3629,7 +3629,7 @@ name = "srml-grandpa" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3649,7 +3649,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3664,7 +3664,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -3676,7 +3676,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3694,7 +3694,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3713,7 +3713,7 @@ name = "srml-sudo" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3732,7 +3732,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3778,7 +3778,7 @@ name = "srml-support-test" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "srml-support 2.0.0", "substrate-inherents 2.0.0", @@ -3793,7 +3793,7 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3806,7 +3806,7 @@ name = "srml-timestamp" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3821,7 +3821,7 @@ name = "srml-treasury" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3856,8 +3856,11 @@ dependencies = [ [[package]] name = "string" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "strsim" @@ -3866,16 +3869,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3977,7 +3980,7 @@ dependencies = [ "rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", - "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-client 2.0.0", "substrate-keyring 2.0.0", "substrate-network 2.0.0", @@ -3989,7 +3992,7 @@ dependencies = [ "sysinfo 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4074,7 +4077,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4131,7 +4134,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4186,7 +4189,7 @@ dependencies = [ "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4203,7 +4206,7 @@ dependencies = [ "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4256,7 +4259,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4329,7 +4332,7 @@ dependencies = [ "substrate-peerset 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4348,14 +4351,14 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-peerset 2.0.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4379,7 +4382,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4394,7 +4397,7 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4409,7 +4412,7 @@ dependencies = [ "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4434,7 +4437,7 @@ dependencies = [ "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)", @@ -4459,7 +4462,7 @@ dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4473,7 +4476,7 @@ dependencies = [ "substrate-test-client 2.0.0", "substrate-test-runtime 2.0.0", "substrate-transaction-pool 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4484,7 +4487,7 @@ dependencies = [ "jsonrpc-pubsub 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-ws-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-rpc 2.0.0", ] @@ -4493,7 +4496,7 @@ dependencies = [ name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4511,7 +4514,7 @@ dependencies = [ "node-runtime 2.0.0", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4530,7 +4533,7 @@ dependencies = [ "substrate-test-client 2.0.0", "substrate-transaction-pool 2.0.0", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4548,7 +4551,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4587,7 +4590,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4621,7 +4624,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4653,7 +4656,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime 2.0.0", @@ -4731,7 +4734,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4761,7 +4764,7 @@ version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4770,7 +4773,7 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4781,7 +4784,7 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4808,7 +4811,7 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4840,7 +4843,7 @@ name = "tinytemplate" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4851,13 +4854,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4874,7 +4877,7 @@ dependencies = [ "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4916,7 +4919,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5040,7 +5043,7 @@ dependencies = [ [[package]] name = "tokio-trace-core" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5068,7 +5071,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5082,7 +5085,7 @@ name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5160,9 +5163,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5321,8 +5324,8 @@ name = "wabt" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5529,7 +5532,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5716,7 +5719,7 @@ dependencies = [ "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" +"checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -5817,7 +5820,7 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4feaabe24a0a658fd9cf4a9acf6ed284f045c77df0f49020ba3245cfb7b454" -"checksum h2 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "2b53def7bb0253af7718036fe9338c15defd209136819464384f3a553e07481b" +"checksum h2 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "09ae3ecbdc15e379c7356430d7c0c6a44d3a937324999429dcf89e970297e54f" "checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" "checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" @@ -5867,8 +5870,8 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" +"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" +"checksum libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5692f82b51823e27c4118b3e5c0d98aee9be90633ebc71ad12afef380b50219" "checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" "checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" "checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" @@ -5962,7 +5965,7 @@ dependencies = [ "checksum proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1dd4172a1e1f96f709341418f49b11ea6c2d95d53dca08c0f74cbd332d9cf3" "checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a151c11a92df0059d6ab446fafa3b21a1210aad4bc2293e1c946e8132b10db01" +"checksum protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e9076cae823584ab4d8fab3a111658d1232faf106611dc8378161b7d062b628" "checksum pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "efb0dcbddbb600f47a7098d33762a00552c671992171637f5bb310b37fe1f0e4" "checksum quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb6ccf8db7bbcb9c2eae558db5ab4f3da1c2a87e4e597ed394726bc8ea6ca1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -5994,7 +5997,7 @@ dependencies = [ "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" "checksum rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e" "checksum rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c34fa7bcae7fca3c8471e8417088bbc3ad9af8066b0ecf4f3c0d98a0d772716e" -"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" +"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" @@ -6013,8 +6016,8 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" -"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" +"checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" +"checksum serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" @@ -6037,10 +6040,10 @@ dependencies = [ "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" -"checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b" +"checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" -"checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" +"checksum structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c767a8971f53d7324583085deee2e230903be09e52fb27df9af94c5cb2b43c31" +"checksum structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c57a30c87454ced2186f62f940e981746e8cbbe026d52090c8c4352b636f8235" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" "checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" @@ -6053,7 +6056,7 @@ dependencies = [ "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" -"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" +"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" @@ -6062,7 +6065,7 @@ dependencies = [ "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" "checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" -"checksum tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "94a1f9396aec29d31bb16c24d155cfa144d1af91c40740125db3131bdaf76da8" +"checksum tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ec2ffcf4bcfc641413fa0f1427bf8f91dfc78f56a6559cbf50e04837ae442a87" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" @@ -6077,7 +6080,7 @@ dependencies = [ "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" "checksum tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" -"checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" +"checksum tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9c8a256d6956f7cb5e2bdfe8b1e8022f1a09206c6c2b1ba00f3b746b260c613" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" "checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" diff --git a/core/client/src/client.rs b/core/client/src/client.rs index f4183e4958..aa236d1580 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -1728,11 +1728,11 @@ pub(crate) mod tests { use primitives::blake2_256; use runtime_primitives::traits::DigestItem as DigestItemT; use runtime_primitives::generic::DigestItem; - use test_client::{self, TestClient, AccountKeyring}; use consensus::{BlockOrigin, SelectChain}; - use test_client::client::backend::Backend as TestBackend; - use test_client::BlockBuilderExt; - use test_client::runtime::{self, Block, Transfer, RuntimeApi, TestAPI}; + use test_client::{ + TestClient, AccountKeyring, client::backend::Backend as TestBackend, TestClientBuilder, + BlockBuilderExt, runtime::{self, Block, Transfer, RuntimeApi, TestAPI} + }; /// Returns tuple, consisting of: /// 1) test client pre-filled with blocks changing balances; @@ -1753,7 +1753,7 @@ pub(crate) mod tests { // prepare client ang import blocks let mut local_roots = Vec::new(); - let remote_client = test_client::new_with_changes_trie(); + let remote_client = TestClientBuilder::new().set_support_changes_trie(true).build(); let mut nonces: HashMap<_, u64> = Default::default(); for (i, block_transfers) in blocks_transfers.into_iter().enumerate() { let mut builder = remote_client.new_block(Default::default()).unwrap(); @@ -1854,7 +1854,10 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); assert_eq!(client.info().chain.best_number, 1); - assert!(client.state_at(&BlockId::Number(1)).unwrap().pairs() != client.state_at(&BlockId::Number(0)).unwrap().pairs()); + assert_ne!( + client.state_at(&BlockId::Number(1)).unwrap().pairs(), + client.state_at(&BlockId::Number(0)).unwrap().pairs() + ); assert_eq!( client.runtime_api().balance_of( &BlockId::Number(client.info().chain.best_number), @@ -1894,7 +1897,10 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); assert_eq!(client.info().chain.best_number, 1); - assert!(client.state_at(&BlockId::Number(1)).unwrap().pairs() != client.state_at(&BlockId::Number(0)).unwrap().pairs()); + assert_ne!( + client.state_at(&BlockId::Number(1)).unwrap().pairs(), + client.state_at(&BlockId::Number(0)).unwrap().pairs() + ); assert_eq!(client.body(&BlockId::Number(1)).unwrap().unwrap().len(), 1) } @@ -1903,18 +1909,14 @@ pub(crate) mod tests { // block tree: // G - let client = test_client::new(); + let (client, longest_chain_select) = TestClientBuilder::new().build_with_longest_chain(); let genesis_hash = client.info().chain.genesis_hash; - #[allow(deprecated)] - let longest_chain_select = test_client::client::LongestChain::new( - client.backend().clone(), - client.import_lock() - ); - - assert_eq!(genesis_hash.clone(), longest_chain_select.finality_target( - genesis_hash.clone(), None).unwrap().unwrap()); + assert_eq!( + genesis_hash.clone(), + longest_chain_select.finality_target(genesis_hash.clone(), None).unwrap().unwrap() + ); } #[test] @@ -1922,18 +1924,14 @@ pub(crate) mod tests { // block tree: // G - let client = test_client::new(); + let (client, longest_chain_select) = TestClientBuilder::new().build_with_longest_chain(); let uninserted_block = client.new_block(Default::default()).unwrap().bake().unwrap(); - #[allow(deprecated)] - let backend = client.backend().as_in_memory(); - #[allow(deprecated)] - let longest_chain_select = test_client::client::LongestChain::new( - Arc::new(backend), - client.import_lock()); - assert_eq!(None, longest_chain_select.finality_target( - uninserted_block.hash().clone(), None).unwrap()); + assert_eq!( + None, + longest_chain_select.finality_target(uninserted_block.hash().clone(), None).unwrap() + ); } #[test] @@ -2052,7 +2050,7 @@ pub(crate) mod tests { // block tree: // G -> A1 -> A2 - let client = test_client::new(); + let (client, longest_chain_select) = TestClientBuilder::new().build_with_longest_chain(); // G -> A1 let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -2063,17 +2061,10 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, a2.clone()).unwrap(); let genesis_hash = client.info().chain.genesis_hash; - #[allow(deprecated)] - let longest_chain_select = test_client::client::LongestChain::new( - Arc::new(client.backend().as_in_memory()), - client.import_lock()); - assert_eq!(a2.hash(), longest_chain_select.finality_target( - genesis_hash, None).unwrap().unwrap()); - assert_eq!(a2.hash(), longest_chain_select.finality_target( - a1.hash(), None).unwrap().unwrap()); - assert_eq!(a2.hash(), longest_chain_select.finality_target( - a2.hash(), None).unwrap().unwrap()); + assert_eq!(a2.hash(), longest_chain_select.finality_target(genesis_hash, None).unwrap().unwrap()); + assert_eq!(a2.hash(), longest_chain_select.finality_target(a1.hash(), None).unwrap().unwrap()); + assert_eq!(a2.hash(), longest_chain_select.finality_target(a2.hash(), None).unwrap().unwrap()); } #[test] @@ -2083,7 +2074,7 @@ pub(crate) mod tests { // A1 -> B2 -> B3 -> B4 // B2 -> C3 // A1 -> D2 - let client = test_client::new(); + let (client, longest_chain_select) = TestClientBuilder::new().build_with_longest_chain(); // G -> A1 let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -2152,11 +2143,6 @@ pub(crate) mod tests { assert_eq!(client.info().chain.best_hash, a5.hash()); let genesis_hash = client.info().chain.genesis_hash; - #[allow(deprecated)] - let longest_chain_select = test_client::client::LongestChain::new( - Arc::new(client.backend().as_in_memory()), - client.import_lock()); - let leaves = longest_chain_select.leaves().unwrap(); assert!(leaves.contains(&a5.hash())); @@ -2372,7 +2358,7 @@ pub(crate) mod tests { // block tree: // G -> A1 -> A2 - let client = test_client::new(); + let (client, longest_chain_select) = TestClientBuilder::new().build_with_longest_chain(); // G -> A1 let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -2383,14 +2369,8 @@ pub(crate) mod tests { client.import(BlockOrigin::Own, a2.clone()).unwrap(); let genesis_hash = client.info().chain.genesis_hash; - #[allow(deprecated)] - let longest_chain_select = test_client::client::LongestChain::new( - Arc::new(client.backend().as_in_memory()), - client.import_lock() - ); - assert_eq!(a2.hash(), longest_chain_select.finality_target( - genesis_hash, Some(10)).unwrap().unwrap()); + assert_eq!(a2.hash(), longest_chain_select.finality_target(genesis_hash, Some(10)).unwrap().unwrap()); } #[test] diff --git a/core/executor/src/native_executor.rs b/core/executor/src/native_executor.rs index c4f3511c9c..e4a65c811b 100644 --- a/core/executor/src/native_executor.rs +++ b/core/executor/src/native_executor.rs @@ -133,7 +133,7 @@ pub trait NativeExecutionDispatch: Send + Sync { /// A generic `CodeExecutor` implementation that uses a delegate to determine wasm code equivalence /// and dispatch to native code when possible, falling back on `WasmExecutor` when not. #[derive(Debug)] -pub struct NativeExecutor { +pub struct NativeExecutor { /// Dummy field to avoid the compiler complaining about us not using `D`. _dummy: ::std::marker::PhantomData, /// The fallback executor in case native isn't available. diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 889c181415..b40ac06c60 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -21,7 +21,7 @@ use assert_matches::assert_matches; use consensus::BlockOrigin; use primitives::storage::well_known_keys; use sr_io::blake2_256; -use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt, LocalExecutor}; +use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt, LocalExecutor, TestClientBuilder}; use substrate_executor::NativeExecutionDispatch; #[test] @@ -236,7 +236,7 @@ fn should_query_storage() { } run_tests(Arc::new(test_client::new())); - run_tests(Arc::new(test_client::new_with_changes_trie())); + run_tests(Arc::new(TestClientBuilder::new().set_support_changes_trie(true).build())); } #[test] diff --git a/core/service/src/components.rs b/core/service/src/components.rs index a314588d0a..30cb1cb764 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -634,12 +634,12 @@ impl Components for LightComponents { mod tests { use super::*; use consensus_common::BlockOrigin; - use client::LongestChain; - use substrate_test_client::{TestClient, AccountKeyring, runtime::Transfer}; + use substrate_test_client::{TestClient, AccountKeyring, runtime::Transfer, TestClientBuilder}; #[test] fn should_remove_transactions_from_the_pool() { - let client = Arc::new(substrate_test_client::new()); + let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); + let client = Arc::new(client); let pool = TransactionPool::new(Default::default(), ::transaction_pool::ChainApi::new(client.clone())); let transaction = Transfer { amount: 5, @@ -647,9 +647,7 @@ mod tests { from: AccountKeyring::Alice.into(), to: Default::default(), }.into_signed_tx(); - #[allow(deprecated)] - let best = LongestChain::new(client.backend().clone(), client.import_lock()) - .best_chain().unwrap(); + let best = longest_chain.best_chain().unwrap(); // store the transaction in the pool pool.submit_one(&BlockId::hash(best.hash()), transaction.clone()).unwrap(); diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index bc40d6008b..92b7a06d38 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -749,21 +749,20 @@ macro_rules! construct_service_factory { #[cfg(test)] mod tests { use super::*; - use client::LongestChain; use consensus_common::SelectChain; use runtime_primitives::traits::BlindCheckable; - use substrate_test_client::{AccountKeyring, runtime::{Extrinsic, Transfer}}; + use substrate_test_client::{AccountKeyring, runtime::{Extrinsic, Transfer}, TestClientBuilder}; #[test] fn should_not_propagate_transactions_that_are_marked_as_such() { // given - let client = Arc::new(substrate_test_client::new()); + let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); + let client = Arc::new(client); let pool = Arc::new(TransactionPool::new( Default::default(), transaction_pool::ChainApi::new(client.clone()) )); - let best = LongestChain::new(client.backend().clone(), client.import_lock()) - .best_chain().unwrap(); + let best = longest_chain.best_chain().unwrap(); let transaction = Transfer { amount: 5, nonce: 0, diff --git a/core/sr-api-macros/tests/runtime_calls.rs b/core/sr-api-macros/tests/runtime_calls.rs index f4d87ca8ca..0671c4f41d 100644 --- a/core/sr-api-macros/tests/runtime_calls.rs +++ b/core/sr-api-macros/tests/runtime_calls.rs @@ -16,7 +16,7 @@ use test_client::{ AccountKeyring, runtime::{TestAPI, DecodeFails, Transfer, Header}, - NativeExecutor, LocalExecutor, + NativeExecutor, LocalExecutor, TestClientBuilder }; use runtime_primitives::{ generic::BlockId, @@ -27,12 +27,11 @@ use state_machine::{ execution_proof_check_on_trie_backend, }; -use client::LongestChain; use consensus_common::SelectChain; use codec::Encode; fn calling_function_with_strat(strat: ExecutionStrategy) { - let client = test_client::new_with_execution_strategy(strat); + let client = TestClientBuilder::new().set_execution_strategy(strat).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); @@ -52,7 +51,7 @@ fn calling_wasm_runtime_function() { #[test] #[should_panic(expected = "Could not convert parameter `param` between node and runtime!")] fn calling_native_runtime_function_with_non_decodable_parameter() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeWhenPossible).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); runtime_api.fail_convert_parameter(&block_id, DecodeFails::new()).unwrap(); @@ -61,7 +60,7 @@ fn calling_native_runtime_function_with_non_decodable_parameter() { #[test] #[should_panic(expected = "Could not convert return value from runtime to node!")] fn calling_native_runtime_function_with_non_decodable_return_value() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeWhenPossible).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); runtime_api.fail_convert_return_value(&block_id).unwrap(); @@ -69,7 +68,7 @@ fn calling_native_runtime_function_with_non_decodable_return_value() { #[test] fn calling_native_runtime_signature_changed_function() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeWhenPossible).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); @@ -78,7 +77,7 @@ fn calling_native_runtime_signature_changed_function() { #[test] fn calling_wasm_runtime_signature_changed_old_function() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::AlwaysWasm).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); @@ -89,7 +88,7 @@ fn calling_wasm_runtime_signature_changed_old_function() { #[test] fn calling_with_both_strategy_and_fail_on_wasm_should_return_error() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::Both).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert!(runtime_api.fail_on_wasm(&block_id).is_err()); @@ -97,7 +96,7 @@ fn calling_with_both_strategy_and_fail_on_wasm_should_return_error() { #[test] fn calling_with_both_strategy_and_fail_on_native_should_work() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::Both).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1); @@ -106,7 +105,7 @@ fn calling_with_both_strategy_and_fail_on_native_should_work() { #[test] fn calling_with_native_else_wasm_and_faild_on_wasm_should_work() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeElseWasm); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeElseWasm).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.fail_on_wasm(&block_id).unwrap(), 1); @@ -114,7 +113,7 @@ fn calling_with_native_else_wasm_and_faild_on_wasm_should_work() { #[test] fn calling_with_native_else_wasm_and_fail_on_native_should_work() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeElseWasm); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeElseWasm).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1); @@ -122,7 +121,7 @@ fn calling_with_native_else_wasm_and_fail_on_native_should_work() { #[test] fn use_trie_function() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::AlwaysWasm).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.use_trie(&block_id).unwrap(), 2); @@ -130,7 +129,7 @@ fn use_trie_function() { #[test] fn initialize_block_works() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::Both).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.get_block_number(&block_id).unwrap(), 1); @@ -138,7 +137,7 @@ fn initialize_block_works() { #[test] fn initialize_block_is_called_only_once() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::Both).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert_eq!(runtime_api.take_block_number(&block_id).unwrap(), Some(1)); @@ -147,7 +146,7 @@ fn initialize_block_is_called_only_once() { #[test] fn initialize_block_is_skipped() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); + let client = TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::Both).build(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); assert!(runtime_api.without_initialize_block(&block_id).unwrap()); @@ -155,12 +154,12 @@ fn initialize_block_is_skipped() { #[test] fn record_proof_works() { - let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both); + let (client, longest_chain) = TestClientBuilder::new() + .set_execution_strategy(ExecutionStrategy::Both) + .build_with_longest_chain(); let block_id = BlockId::Number(client.info().chain.best_number); - #[allow(deprecated)] - let storage_root = LongestChain::new(client.backend().clone(), client.import_lock()) - .best_chain().unwrap().state_root().clone(); + let storage_root = longest_chain.best_chain().unwrap().state_root().clone(); let transaction = Transfer { amount: 1000, diff --git a/core/test-client/Cargo.toml b/core/test-client/Cargo.toml index 7628125df4..8de313f9cb 100644 --- a/core/test-client/Cargo.toml +++ b/core/test-client/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" client = { package = "substrate-client", path = "../client" } client-db = { package = "substrate-client-db", path = "../client/db", features = ["test-helpers"] } futures = { version = "0.1.17" } -parity-codec = "3.3" +parity-codec = "3.5.1" executor = { package = "substrate-executor", path = "../executor" } consensus = { package = "substrate-consensus-common", path = "../consensus/common" } keyring = { package = "substrate-keyring", path = "../../core/keyring" } diff --git a/core/test-client/src/lib.rs b/core/test-client/src/lib.rs index 5154fb0c1d..7a176a6c31 100644 --- a/core/test-client/src/lib.rs +++ b/core/test-client/src/lib.rs @@ -104,22 +104,78 @@ pub type LightExecutor = client::light::call_executor::RemoteOrLocalCallExecutor >; /// A builder for creating a test client instance. -pub struct TestClientBuilder { +pub struct TestClientBuilder { execution_strategies: ExecutionStrategies, genesis_extension: HashMap, Vec>, support_changes_trie: bool, + backend: Arc, + _phantom: std::marker::PhantomData, } -impl TestClientBuilder { +#[cfg(feature = "include-wasm-blob")] +impl TestClientBuilder where + B: backend::LocalBackend, +{ + /// Create a new instance of the test client builder using the given backend. + pub fn new_with_backend(backend: Arc) -> Self { + TestClientBuilder { + execution_strategies: ExecutionStrategies::default(), + genesis_extension: HashMap::default(), + support_changes_trie: false, + backend, + _phantom: Default::default(), + } + } +} + +#[cfg(feature = "include-wasm-blob")] +impl TestClientBuilder { /// Create a new instance of the test client builder. pub fn new() -> Self { TestClientBuilder { execution_strategies: ExecutionStrategies::default(), genesis_extension: HashMap::default(), support_changes_trie: false, + backend: Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)), + _phantom: Default::default(), + } + } +} + +#[cfg(not(feature = "include-wasm-blob"))] +impl TestClientBuilder where + B: backend::LocalBackend, +{ + /// Create a new instance of the test client builder using the given backend. + pub fn new_with_backend(backend: Arc) -> Self { + TestClientBuilder { + execution_strategies: ExecutionStrategies::default(), + genesis_extension: HashMap::default(), + support_changes_trie: false, + backend, + _phantom: Default::default(), } } +} +#[cfg(not(feature = "include-wasm-blob"))] +impl TestClientBuilder { + /// Create a new instance of the test client builder. + pub fn new() -> Self { + TestClientBuilder { + execution_strategies: ExecutionStrategies::default(), + genesis_extension: HashMap::default(), + support_changes_trie: false, + backend: Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)), + _phantom: Default::default(), + } + } +} + +impl TestClientBuilder where + B: backend::LocalBackend, + E: executor::NativeExecutionDispatch +{ /// Set the execution strategy that should be used by all contexts. pub fn set_execution_strategy( mut self, @@ -151,60 +207,46 @@ impl TestClientBuilder { } /// Build the test client. - #[cfg(feature = "include-wasm-blob")] pub fn build(self) -> client::Client< - Backend, Executor, runtime::Block, runtime::RuntimeApi + B, + client::LocalCallExecutor>, + runtime::Block, + runtime::RuntimeApi, > { - let backend = Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)); - self.build_with_backend(backend) + self.build_with_longest_chain().0 } - /// Build the test client with the given backend. - #[cfg(feature = "include-wasm-blob")] - pub fn build_with_backend(self, backend: Arc) -> client::Client< - B, - client::LocalCallExecutor>, - runtime::Block, - runtime::RuntimeApi - > where B: backend::LocalBackend { - let executor = NativeExecutor::new(None); - let executor = LocalCallExecutor::new(backend.clone(), executor); + /// Build the test client and longest chain as select chain. + pub fn build_with_longest_chain(self) -> ( + client::Client< + B, + client::LocalCallExecutor>, + runtime::Block, + runtime::RuntimeApi, + >, + client::LongestChain, + ) { + let executor = NativeExecutor::::new(None); + let executor = LocalCallExecutor::new(self.backend.clone(), executor); - client::Client::new( - backend, + let client = client::Client::new( + self.backend.clone(), executor, genesis_storage(self.support_changes_trie, self.genesis_extension), - self.execution_strategies - ).expect("Creates new client") - } + self.execution_strategies, + ).expect("Creates new client"); - /// Build the test client with the given native executor. - pub fn build_with_native_executor( - self, - executor: executor::NativeExecutor - ) -> client::Client< - Backend, - client::LocalCallExecutor>, - runtime::Block, - runtime::RuntimeApi - > where E: executor::NativeExecutionDispatch - { - let backend = Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)); - let executor = LocalCallExecutor::new(backend.clone(), executor); + #[allow(deprecated)] + let longest_chain = client::LongestChain::new(self.backend, client.import_lock()); - client::Client::new( - backend, - executor, - genesis_storage(self.support_changes_trie, self.genesis_extension), - self.execution_strategies - ).expect("Creates new client") + (client, longest_chain) } } /// Creates new client instance used for tests. #[cfg(feature = "include-wasm-blob")] pub fn new() -> client::Client { - new_with_backend(Arc::new(Backend::new_test(::std::u32::MAX, ::std::u64::MAX)), false) + TestClientBuilder::new().build() } /// Creates new light client instance used for tests. @@ -221,40 +263,6 @@ pub fn new_light() -> client::Client client::Client { - TestClientBuilder::new().set_execution_strategy(execution_strategy).build() -} - -/// Creates new test client instance that suports changes trie creation. -#[cfg(feature = "include-wasm-blob")] -pub fn new_with_changes_trie() - -> client::Client -{ - TestClientBuilder::new().set_support_changes_trie(true).build() -} - -/// Creates new client instance used for tests with an explicitly provided backend. -/// This is useful for testing backend implementations. -#[cfg(feature = "include-wasm-blob")] -pub fn new_with_backend( - backend: Arc, - support_changes_trie: bool -) -> client::Client< - B, - client::LocalCallExecutor>, - runtime::Block, - runtime::RuntimeApi -> where B: backend::LocalBackend -{ - TestClientBuilder::new() - .set_support_changes_trie(support_changes_trie) - .build_with_backend(backend) -} - fn genesis_config(support_changes_trie: bool) -> GenesisConfig { GenesisConfig::new(support_changes_trie, vec![ AuthorityKeyring::Alice.into(), diff --git a/core/test-client/src/trait_tests.rs b/core/test-client/src/trait_tests.rs index a7ef1a01f6..f39d85a1ca 100644 --- a/core/test-client/src/trait_tests.rs +++ b/core/test-client/src/trait_tests.rs @@ -26,7 +26,7 @@ use crate::{TestClient, AccountKeyring}; use runtime_primitives::traits::Block as BlockT; use crate::backend; use crate::blockchain::{Backend as BlockChainBackendT, HeaderBackend}; -use crate::{BlockBuilderExt, new_with_backend}; +use crate::{BlockBuilderExt, TestClientBuilder}; use runtime::{self, Transfer}; use runtime_primitives::generic::BlockId; @@ -40,7 +40,7 @@ pub fn test_leaves_for_backend(backend: Arc) where // B2 -> C3 // A1 -> D2 - let client = new_with_backend(backend.clone(), false); + let client = TestClientBuilder::new_with_backend(backend.clone()).build(); let blockchain = backend.blockchain(); let genesis_hash = client.info().chain.genesis_hash; @@ -156,7 +156,7 @@ pub fn test_children_for_backend(backend: Arc) where // B2 -> C3 // A1 -> D2 - let client = new_with_backend(backend.clone(), false); + let client = TestClientBuilder::new_with_backend(backend.clone()).build(); let blockchain = backend.blockchain(); // G -> A1 @@ -246,7 +246,7 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc B2 -> B3 -> B4 // B2 -> C3 // A1 -> D2 - let client = new_with_backend(backend.clone(), false); + let client = TestClientBuilder::new_with_backend(backend.clone()).build(); let blockchain = backend.blockchain(); // G -> A1 -- GitLab From 3c2e55bdc103b583b03fac3cdc46e88c77add513 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Wed, 5 Jun 2019 15:46:01 +0200 Subject: [PATCH 090/113] Move import lock onto backend (#2797) * Drop import_lock from client, move it into backend, impl default version via static mutex * still need to allow depcretion because of client.backend * additional docs * Remove default impl of get_import_lock, impl on instances * Bump parking_lot to 0.8.0 accross the board --- Cargo.lock | 78 +++++++++++++------------- core/client/Cargo.toml | 2 +- core/client/db/Cargo.toml | 2 +- core/client/db/src/lib.rs | 6 ++ core/client/src/backend.rs | 8 +++ core/client/src/client.rs | 21 +------ core/client/src/in_mem.rs | 8 ++- core/client/src/light/backend.rs | 8 ++- core/consensus/aura/Cargo.toml | 2 +- core/consensus/aura/src/lib.rs | 1 - core/consensus/babe/Cargo.toml | 2 +- core/consensus/babe/src/lib.rs | 2 +- core/consensus/common/Cargo.toml | 2 +- core/consensus/rhd/Cargo.toml | 2 +- core/consensus/slots/Cargo.toml | 2 +- core/executor/Cargo.toml | 2 +- core/finality-grandpa/Cargo.toml | 2 +- core/finality-grandpa/src/tests.rs | 3 +- core/inherents/Cargo.toml | 2 +- core/network-libp2p/Cargo.toml | 2 +- core/network/Cargo.toml | 2 +- core/offchain/Cargo.toml | 2 +- core/rpc/Cargo.toml | 2 +- core/service/Cargo.toml | 2 +- core/service/src/lib.rs | 3 +- core/state-db/Cargo.toml | 2 +- core/state-machine/Cargo.toml | 2 +- core/telemetry/Cargo.toml | 2 +- core/test-client/src/lib.rs | 2 +- core/transaction-pool/Cargo.toml | 2 +- core/transaction-pool/graph/Cargo.toml | 2 +- node-template/Cargo.toml | 2 +- node-template/src/service.rs | 5 +- node/cli/src/service.rs | 5 +- srml/aura/Cargo.toml | 2 +- srml/babe/Cargo.toml | 2 +- srml/finality-tracker/Cargo.toml | 2 +- 37 files changed, 101 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba81460ca3..b1b933c3a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -677,7 +677,7 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.1.4" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -739,7 +739,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1009,7 +1009,7 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1195,7 +1195,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1517,7 +1517,7 @@ dependencies = [ "libp2p-websocket 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1543,7 +1543,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1648,7 +1648,7 @@ dependencies = [ "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1704,7 +1704,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2271,7 +2271,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "node-template-runtime 2.0.0", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "substrate-basic-authorship 2.0.0", "substrate-cli 2.0.0", @@ -2476,7 +2476,7 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2485,7 +2485,7 @@ dependencies = [ [[package]] name = "parity-multihash" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3083,7 +3083,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3448,7 +3448,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3470,7 +3470,7 @@ dependencies = [ "hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3613,7 +3613,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4008,7 +4008,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4036,7 +4036,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -4057,7 +4057,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-version 2.0.0", @@ -4112,7 +4112,7 @@ dependencies = [ "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4157,7 +4157,7 @@ dependencies = [ "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -4176,7 +4176,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rhododendron 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4199,7 +4199,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -4221,7 +4221,7 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-version 2.0.0", "substrate-panic-handler 2.0.0", @@ -4244,7 +4244,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4278,7 +4278,7 @@ name = "substrate-inherents" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -4321,7 +4321,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4349,7 +4349,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4374,7 +4374,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -4460,7 +4460,7 @@ dependencies = [ "jsonrpc-pubsub 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4513,7 +4513,7 @@ dependencies = [ "node-primitives 2.0.0", "node-runtime 2.0.0", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4561,7 +4561,7 @@ dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", ] @@ -4574,7 +4574,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", "substrate-primitives 2.0.0", "substrate-trie 2.0.0", @@ -4588,7 +4588,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4655,7 +4655,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", @@ -4670,7 +4670,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-keyring 2.0.0", @@ -5631,7 +5631,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5781,7 +5781,7 @@ dependencies = [ "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5531b7f0698d9220b4729f8811931dbe0e91a05be2f7b3245fdc50dd856bae26" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "750226d75fc2f5a8daec6e7477624e258674023eb73d8d647f63b943ca182a4a" +"checksum curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440b7acc6264fde2eee18bae135625129c88ff244f3ded035e3caa585a6bf0a" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" @@ -5820,7 +5820,7 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4feaabe24a0a658fd9cf4a9acf6ed284f045c77df0f49020ba3245cfb7b454" -"checksum h2 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "09ae3ecbdc15e379c7356430d7c0c6a44d3a937324999429dcf89e970297e54f" +"checksum h2 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "1e42e3daed5a7e17b12a0c23b5b2fbff23a925a570938ebee4baca1a9a1a2240" "checksum hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba7fb417e5c470acdd61068c79767d0e65962e70836cf6c9dfd2409f06345ce0" "checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" @@ -5940,7 +5940,7 @@ dependencies = [ "checksum parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb43c05fb71c03b4ea7327bf15694da1e0f23f19d5b1e95bab6c6d74097e336" "checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c" "checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" -"checksum parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05d6a68e07ab34a9e87bd8dd4936f6bb5be21e4f6dbcdbaf04d8e854eba0af01" +"checksum parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eb83358a0c05e52c44d658981fec2d146d3516d1adffd9e553684f8c8e9e8fa5" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" diff --git a/core/client/Cargo.toml b/core/client/Cargo.toml index e295894b83..0978b897ec 100644 --- a/core/client/Cargo.toml +++ b/core/client/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" derive_more = { version = "0.14.0", optional = true } fnv = { version = "1.0", optional = true } log = { version = "0.4", optional = true } -parking_lot = { version = "0.7.1", optional = true } +parking_lot = { version = "0.8.0", optional = true } hex = { package = "hex-literal", version = "0.1", optional = true } futures = { version = "0.1.17", optional = true } consensus = { package = "substrate-consensus-common", path = "../consensus/common", optional = true } diff --git a/core/client/db/Cargo.toml b/core/client/db/Cargo.toml index 77512ec269..64051164b8 100644 --- a/core/client/db/Cargo.toml +++ b/core/client/db/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -parking_lot = "0.7.1" +parking_lot = "0.8" log = "0.4" kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } # FIXME replace with release as soon as our rocksdb changes are released upstream https://github.com/paritytech/parity-common/issues/88 diff --git a/core/client/db/src/lib.rs b/core/client/db/src/lib.rs index 302cdfd083..674e8022dc 100644 --- a/core/client/db/src/lib.rs +++ b/core/client/db/src/lib.rs @@ -656,6 +656,7 @@ pub struct Backend { blockchain: BlockchainDb, canonicalization_delay: u64, shared_cache: SharedCache, + import_lock: Mutex<()>, } impl> Backend { @@ -722,6 +723,7 @@ impl> Backend { blockchain, canonicalization_delay, shared_cache: new_shared_cache(state_cache_size), + import_lock: Default::default(), }) } @@ -1350,6 +1352,10 @@ impl client::backend::Backend for Backend whe } Ok(()) } + + fn get_import_lock(&self) -> &Mutex<()> { + &self.import_lock + } } impl client::backend::LocalBackend for Backend diff --git a/core/client/src/backend.rs b/core/client/src/backend.rs index d2cc086ecd..5028b9dde7 100644 --- a/core/client/src/backend.rs +++ b/core/client/src/backend.rs @@ -26,6 +26,7 @@ use state_machine::ChangesTrieStorage as StateChangesTrieStorage; use consensus::well_known_cache_keys; use hash_db::Hasher; use trie::MemoryDB; +use parking_lot::Mutex; /// State of a new block. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -174,6 +175,13 @@ pub trait Backend: AuxStore + Send + Sync where fn get_aux(&self, key: &[u8]) -> error::Result>> { AuxStore::get_aux(self, key) } + + /// Gain access to the import lock around this backend. + /// _Note_ Backend isn't expected to acquire the lock by itself ever. Rather + /// the using components should acquire and hold the lock whenever they do + /// something that the import of a block would interfere with, e.g. importing + /// a new block or calculating the best head. + fn get_import_lock(&self) -> &Mutex<()>; } /// Changes trie storage that supports pruning. diff --git a/core/client/src/client.rs b/core/client/src/client.rs index aa236d1580..f3040f13da 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -124,7 +124,6 @@ pub struct Client where Block: BlockT { storage_notifications: Mutex>, import_notification_sinks: Mutex>>>, finality_notification_sinks: Mutex>>>, - import_lock: Arc>, // holds the block hash currently being imported. TODO: replace this with block queue importing_block: RwLock>, execution_strategies: ExecutionStrategies, @@ -318,7 +317,6 @@ impl Client where storage_notifications: Default::default(), import_notification_sinks: Default::default(), finality_notification_sinks: Default::default(), - import_lock: Default::default(), importing_block: Default::default(), execution_strategies, _phantom: Default::default(), @@ -344,15 +342,6 @@ impl Client where &self.backend } - /// Expose reference to import lock - #[doc(hidden)] - #[deprecated(note="Rather than relying on `client` to provide this, access \ - to the backend should be handled at setup only - see #1134. This function \ - will be removed once that is in place.")] - pub fn import_lock(&self) -> Arc> { - self.import_lock.clone() - } - /// Given a `BlockId` and a key prefix, return the matching child storage keys in that block. pub fn storage_keys(&self, id: &BlockId, key_prefix: &StorageKey) -> error::Result> { let keys = self.state_at(id)?.keys(&key_prefix.0).into_iter().map(StorageKey).collect(); @@ -744,7 +733,7 @@ impl Client where Err: From, { let inner = || { - let _import_lock = self.import_lock.lock(); + let _import_lock = self.backend.get_import_lock().lock(); let mut op = ClientImportOperation { op: self.backend.begin_operation()?, @@ -1493,17 +1482,14 @@ where /// where 'longest' is defined as the highest number of blocks pub struct LongestChain { backend: Arc, - import_lock: Arc>, _phantom: PhantomData } impl Clone for LongestChain { fn clone(&self) -> Self { let backend = self.backend.clone(); - let import_lock = self.import_lock.clone(); LongestChain { backend, - import_lock, _phantom: Default::default() } } @@ -1515,10 +1501,9 @@ where Block: BlockT, { /// Instantiate a new LongestChain for Backend B - pub fn new(backend: Arc, import_lock: Arc>) -> Self { + pub fn new(backend: Arc) -> Self { LongestChain { backend, - import_lock, _phantom: Default::default() } } @@ -1564,7 +1549,7 @@ where // ensure no blocks are imported during this code block. // an import could trigger a reorg which could change the canonical chain. // we depend on the canonical chain staying the same during this code block. - let _import_lock = self.import_lock.lock(); + let _import_lock = self.backend.get_import_lock().lock(); let info = self.backend.blockchain().info(); diff --git a/core/client/src/in_mem.rs b/core/client/src/in_mem.rs index 92d04230dd..dec10d40f7 100644 --- a/core/client/src/in_mem.rs +++ b/core/client/src/in_mem.rs @@ -18,7 +18,7 @@ use std::collections::HashMap; use std::sync::Arc; -use parking_lot::RwLock; +use parking_lot::{RwLock, Mutex}; use primitives::{ChangesTrieConfiguration, storage::well_known_keys}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ @@ -541,6 +541,7 @@ where states: RwLock>>, changes_trie_storage: ChangesTrieStorage, blockchain: Blockchain, + import_lock: Mutex<()>, } impl Backend @@ -555,6 +556,7 @@ where states: RwLock::new(HashMap::new()), changes_trie_storage: ChangesTrieStorage(InMemoryChangesTrieStorage::new()), blockchain: Blockchain::new(), + import_lock: Default::default(), } } } @@ -684,6 +686,10 @@ where fn revert(&self, _n: NumberFor) -> error::Result> { Ok(Zero::zero()) } + + fn get_import_lock(&self) -> &Mutex<()> { + &self.import_lock + } } impl backend::LocalBackend for Backend diff --git a/core/client/src/light/backend.rs b/core/client/src/light/backend.rs index 0c2279bf3d..60b4c66c17 100644 --- a/core/client/src/light/backend.rs +++ b/core/client/src/light/backend.rs @@ -20,7 +20,7 @@ use std::collections::HashMap; use std::sync::{Arc, Weak}; use futures::{Future, IntoFuture}; -use parking_lot::RwLock; +use parking_lot::{RwLock, Mutex}; use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; use state_machine::{Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState}; @@ -41,6 +41,7 @@ const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type pub struct Backend { blockchain: Arc>, genesis_state: RwLock>>, + import_lock: Mutex<()>, } /// Light block (header and justification) import operation. @@ -77,6 +78,7 @@ impl Backend { Self { blockchain, genesis_state: RwLock::new(None), + import_lock: Default::default(), } } @@ -213,6 +215,10 @@ impl ClientBackend for Backend where fn revert(&self, _n: NumberFor) -> ClientResult> { Err(ClientError::NotAvailableOnLightClient.into()) } + + fn get_import_lock(&self) -> &Mutex<()> { + &self.import_lock + } } impl RemoteBackend for Backend diff --git a/core/consensus/aura/Cargo.toml b/core/consensus/aura/Cargo.toml index 6e489cf8a9..446dcbff3a 100644 --- a/core/consensus/aura/Cargo.toml +++ b/core/consensus/aura/Cargo.toml @@ -23,7 +23,7 @@ authorities = { package = "substrate-consensus-authorities", path = "../authorit runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.17" tokio = "0.1.7" -parking_lot = "0.7.1" +parking_lot = "0.8.0" log = "0.4" [dev-dependencies] diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 6f73c6ed65..36561645f0 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -886,7 +886,6 @@ mod tests { #[allow(deprecated)] let select_chain = LongestChain::new( client.backend().clone(), - client.import_lock().clone(), ); let environ = Arc::new(DummyFactory(client.clone())); import_notifications.push( diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index bc557ffb56..04cd42c680 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -24,7 +24,7 @@ slots = { package = "substrate-consensus-slots", path = "../slots" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.26" tokio = "0.1.18" -parking_lot = "0.7.1" +parking_lot = "0.8.0" log = "0.4.6" schnorrkel = "0.1.1" rand = "0.6.5" diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 12c388d329..0cb95c02df 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -975,7 +975,7 @@ mod tests { #[allow(deprecated)] - let select_chain = LongestChain::new(client.backend().clone(), client.import_lock().clone()); + let select_chain = LongestChain::new(client.backend().clone()); let babe = start_babe(BabeParams { config, diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index c2fc7cf231..3d133461e7 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -18,7 +18,7 @@ runtime_version = { package = "sr-version", path = "../../sr-version" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } tokio-timer = "0.2" parity-codec = { version = "3.3", features = ["derive"] } -parking_lot = "0.7.1" +parking_lot = "0.8.0" [dev-dependencies] test_client = { package = "substrate-test-client", path = "../../test-client" } diff --git a/core/consensus/rhd/Cargo.toml b/core/consensus/rhd/Cargo.toml index 3f0a79a863..ee1efb8d06 100644 --- a/core/consensus/rhd/Cargo.toml +++ b/core/consensus/rhd/Cargo.toml @@ -20,7 +20,7 @@ runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } runtime_version = { package = "sr-version", path = "../../sr-version" } runtime_io = { package = "sr-io", path = "../../sr-io" } tokio = "0.1.7" -parking_lot = "0.7.1" +parking_lot = "0.8.0" log = "0.4" rhododendron = { version = "0.5.0", features = ["codec"] } exit-future = "0.1" diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index 2be9133d54..7a3b487dc6 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -14,7 +14,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../common" inherents = { package = "substrate-inherents", path = "../../inherents" } futures = "0.1.17" tokio = "0.1.7" -parking_lot = "0.7.1" +parking_lot = "0.8.0" log = "0.4" [dev-dependencies] diff --git a/core/executor/Cargo.toml b/core/executor/Cargo.toml index 8f39d35c79..9cc198557d 100644 --- a/core/executor/Cargo.toml +++ b/core/executor/Cargo.toml @@ -17,7 +17,7 @@ panic-handler = { package = "substrate-panic-handler", path = "../panic-handler" wasmi = { version = "0.4.3" } byteorder = "1.1" lazy_static = "1.0" -parking_lot = "0.7.1" +parking_lot = "0.8.0" log = "0.4" libsecp256k1 = "0.2.1" tiny-keccak = "1.4.2" diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index 9d44c8ee3e..b00c646286 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" fork-tree = { path = "../../core/util/fork-tree" } futures = "0.1" log = "0.4" -parking_lot = "0.7.1" +parking_lot = "0.8.0" tokio = "0.1.7" rand = "0.6" parity-codec = { version = "3.3", features = ["derive"] } diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 7fc2509f41..18342e3a1e 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -121,8 +121,7 @@ impl TestNetFactory for GrandpaTestNet { PeersClient::Full(ref client) => { #[allow(deprecated)] let select_chain = LongestChain::new( - client.backend().clone(), - client.import_lock().clone() + client.backend().clone() ); let (import, link) = block_import( client.clone(), diff --git a/core/inherents/Cargo.toml b/core/inherents/Cargo.toml index a71661bd1d..606d9c5ae9 100644 --- a/core/inherents/Cargo.toml +++ b/core/inherents/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -parking_lot = { version = "0.7", optional = true } +parking_lot = { version = "0.8.0", optional = true } rstd = { package = "sr-std", path = "../sr-std", default-features = false } parity-codec = { version = "3.3", default-features = false, features = ["derive"] } runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } diff --git a/core/network-libp2p/Cargo.toml b/core/network-libp2p/Cargo.toml index e92738b902..8a03a1c511 100644 --- a/core/network-libp2p/Cargo.toml +++ b/core/network-libp2p/Cargo.toml @@ -13,7 +13,7 @@ bytes = "0.4" fnv = "1.0" futures = "0.1" libp2p = { version = "0.9.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] } -parking_lot = "0.7.1" +parking_lot = "0.8.0" lazy_static = "1.2" log = "0.4" rand = "0.6" diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index 6576ccabbf..8fbf7daa9c 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" [dependencies] derive_more = "0.14.0" log = "0.4" -parking_lot = "0.7.1" +parking_lot = "0.8.0" bitflags = "1.0" futures = "0.1.17" linked-hash-map = "0.5" diff --git a/core/offchain/Cargo.toml b/core/offchain/Cargo.toml index da2aeb4334..0672ebcc0c 100644 --- a/core/offchain/Cargo.toml +++ b/core/offchain/Cargo.toml @@ -13,7 +13,7 @@ futures = "0.1.25" log = "0.4" offchain-primitives = { package = "substrate-offchain-primitives", path = "./primitives" } parity-codec = { version = "3.3", features = ["derive"] } -parking_lot = "0.7.1" +parking_lot = "0.8.0" primitives = { package = "substrate-primitives", path = "../../core/primitives" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } tokio = "0.1.7" diff --git a/core/rpc/Cargo.toml b/core/rpc/Cargo.toml index a7337858d8..c621f71a43 100644 --- a/core/rpc/Cargo.toml +++ b/core/rpc/Cargo.toml @@ -11,7 +11,7 @@ jsonrpc-core-client = "12.0.0" jsonrpc-pubsub = "12.0.0" jsonrpc-derive = "12.0.0" log = "0.4" -parking_lot = "0.7.1" +parking_lot = "0.8.0" parity-codec = "3.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/core/service/Cargo.toml b/core/service/Cargo.toml index 89804166d6..0a0cd91553 100644 --- a/core/service/Cargo.toml +++ b/core/service/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] derive_more = "0.14.0" futures = "0.1.17" -parking_lot = "0.7.1" +parking_lot = "0.8.0" lazy_static = "1.0" log = "0.4" slog = {version = "^2", features = ["nested-values"]} diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 92b7a06d38..5129944c54 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -622,7 +622,8 @@ impl network::TransactionPool, ComponentBlock< /// { |_, client| Ok(BasicQueue::new(Arc::new(MyVerifier), client, None, None, None)) }, /// SelectChain = LongestChain, Self::Block> /// { |config: &FactoryFullConfiguration, client: Arc>| { -/// Ok(LongestChain::new(client.backend().clone(), client.import_lock())) +/// #[allow(deprecated)] +/// Ok(LongestChain::new(client.backend().clone())) /// }}, /// FinalityProofProvider = { |client: Arc>| { /// Ok(Some(Arc::new(grandpa::FinalityProofProvider::new(client.clone(), client)) as _)) diff --git a/core/state-db/Cargo.toml b/core/state-db/Cargo.toml index 6f2ac70a30..8c02dbc450 100644 --- a/core/state-db/Cargo.toml +++ b/core/state-db/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -parking_lot = "0.7.1" +parking_lot = "0.8.0" log = "0.4" primitives = { package = "substrate-primitives", path = "../../core/primitives" } parity-codec = { version = "3.3", features = ["derive"] } diff --git a/core/state-machine/Cargo.toml b/core/state-machine/Cargo.toml index 222c543f54..b1cb98ae80 100644 --- a/core/state-machine/Cargo.toml +++ b/core/state-machine/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] log = "0.4" -parking_lot = "0.7.1" +parking_lot = "0.8.0" hash-db = "0.12" trie-db = "0.12" trie-root = "0.12" diff --git a/core/telemetry/Cargo.toml b/core/telemetry/Cargo.toml index d1fa12abe2..f61d6bc4d3 100644 --- a/core/telemetry/Cargo.toml +++ b/core/telemetry/Cargo.toml @@ -6,7 +6,7 @@ description = "Telemetry utils" edition = "2018" [dependencies] -parking_lot = "0.7.1" +parking_lot = "0.8.0" lazy_static = "1.0" log = "0.4" rand = "0.6" diff --git a/core/test-client/src/lib.rs b/core/test-client/src/lib.rs index 7a176a6c31..f39ad86b64 100644 --- a/core/test-client/src/lib.rs +++ b/core/test-client/src/lib.rs @@ -237,7 +237,7 @@ impl TestClientBuilder where ).expect("Creates new client"); #[allow(deprecated)] - let longest_chain = client::LongestChain::new(self.backend, client.import_lock()); + let longest_chain = client::LongestChain::new(self.backend); (client, longest_chain) } diff --git a/core/transaction-pool/Cargo.toml b/core/transaction-pool/Cargo.toml index 5b2c2350af..ed2cd27833 100644 --- a/core/transaction-pool/Cargo.toml +++ b/core/transaction-pool/Cargo.toml @@ -9,7 +9,7 @@ derive_more = "0.14.0" futures = "0.1" log = "0.4" parity-codec = "3.3" -parking_lot = "0.7.1" +parking_lot = "0.8.0" sr-primitives = { path = "../sr-primitives" } client = { package = "substrate-client", path = "../client" } substrate-primitives = { path = "../primitives" } diff --git a/core/transaction-pool/graph/Cargo.toml b/core/transaction-pool/graph/Cargo.toml index 0ebc74b7da..3f918efa4a 100644 --- a/core/transaction-pool/graph/Cargo.toml +++ b/core/transaction-pool/graph/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" derive_more = "0.14.0" futures = "0.1" log = "0.4" -parking_lot = "0.7.1" +parking_lot = "0.8.0" serde = { version = "1.0", features = ["derive"] } substrate-primitives = { path = "../../primitives" } sr-primitives = { path = "../../sr-primitives" } diff --git a/node-template/Cargo.toml b/node-template/Cargo.toml index 69f9c884cd..e78bb2d27e 100644 --- a/node-template/Cargo.toml +++ b/node-template/Cargo.toml @@ -16,7 +16,7 @@ ctrlc = { version = "3.0", features = ["termination"] } log = "0.4" tokio = "0.1" exit-future = "0.1" -parking_lot = "0.7.1" +parking_lot = "0.8.0" parity-codec = "3.3" trie-root = "0.12.2" sr-io = { path = "../core/sr-io" } diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 934cf87b9c..c8f5dfc0a1 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -129,10 +129,7 @@ construct_service_factory! { SelectChain = LongestChain, Self::Block> { |config: &FactoryFullConfiguration, client: Arc>| { #[allow(deprecated)] - Ok(LongestChain::new( - client.backend().clone(), - client.import_lock() - )) + Ok(LongestChain::new(client.backend().clone())) } }, FinalityProofProvider = { |_client: Arc>| { diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 2991bfe377..415ddbe71b 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -205,10 +205,7 @@ construct_service_factory! { SelectChain = LongestChain, Self::Block> { |config: &FactoryFullConfiguration, client: Arc>| { #[allow(deprecated)] - Ok(LongestChain::new( - client.backend().clone(), - client.import_lock() - )) + Ok(LongestChain::new(client.backend().clone())) } }, FinalityProofProvider = { |client: Arc>| { diff --git a/srml/aura/Cargo.toml b/srml/aura/Cargo.toml index 6a437ce71a..82027871b4 100644 --- a/srml/aura/Cargo.toml +++ b/srml/aura/Cargo.toml @@ -18,7 +18,7 @@ session = { package = "srml-session", path = "../session", default-features = fa [dev-dependencies] lazy_static = "1.0" -parking_lot = "0.7.1" +parking_lot = "0.8.0" substrate-primitives = { path = "../../core/primitives" } runtime_io = { package = "sr-io", path = "../../core/sr-io" } consensus = { package = "srml-consensus", path = "../consensus" } diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index 0c25a98948..0f189dfcda 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -20,7 +20,7 @@ babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../ [dev-dependencies] lazy_static = "1.3.0" -parking_lot = "0.7.1" +parking_lot = "0.8.0" substrate-primitives = { path = "../../core/primitives" } runtime_io = { package = "sr-io", path = "../../core/sr-io" } consensus = { package = "srml-consensus", path = "../consensus" } diff --git a/srml/finality-tracker/Cargo.toml b/srml/finality-tracker/Cargo.toml index c7006a3c3e..e6cf47ab25 100644 --- a/srml/finality-tracker/Cargo.toml +++ b/srml/finality-tracker/Cargo.toml @@ -17,7 +17,7 @@ srml-system = { path = "../system", default-features = false } substrate-primitives = { path = "../../core/primitives", default-features = false } sr-io = { path = "../../core/sr-io", default-features = false } lazy_static = "1.0" -parking_lot = "0.7" +parking_lot = "0.8.0" [features] default = ["std"] -- GitLab From c17a54514144ae86f9c545e07638ed2ea4c893ad Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 5 Jun 2019 16:31:20 +0200 Subject: [PATCH 091/113] Small slots refactor (#2780) * Deprecate SlotWorker::on_start * start_slot_worker no longer needs an Arc * start_slot_worker now always succeeds * Removed on_exit parameter from start_*_worker * Minor doc * Fix node-template --- core/consensus/aura/src/lib.rs | 29 +++----- core/consensus/babe/src/lib.rs | 31 +++----- core/consensus/slots/src/lib.rs | 124 +++++++++++++------------------- node-template/src/service.rs | 7 +- node/cli/src/service.rs | 7 +- 5 files changed, 77 insertions(+), 121 deletions(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 36561645f0..e3fffad33f 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -65,7 +65,7 @@ use srml_aura::{ }; use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; -use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible, slot_now, check_equivocation}; +use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible, slot_now, check_equivocation}; pub use aura_primitives::*; pub use consensus_common::{SyncOracle, ExtraVerification}; @@ -125,7 +125,7 @@ impl SlotCompatible for AuraSlotCompatible { } /// Start the aura worker. The returned future should be run in a tokio runtime. -pub fn start_aura( +pub fn start_aura( slot_duration: SlotDuration, local_key: Arc

, client: Arc, @@ -133,7 +133,6 @@ pub fn start_aura( block_import: Arc, env: Arc, sync_oracle: SO, - on_exit: OnExit, inherent_data_providers: InherentDataProviders, force_authoring: bool, ) -> Result, consensus_common::Error> where @@ -156,25 +155,26 @@ pub fn start_aura( I: BlockImport + Send + Sync + 'static, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, - OnExit: Future, { let worker = AuraWorker { client: client.clone(), block_import, env, local_key, - inherent_data_providers: inherent_data_providers.clone(), sync_oracle: sync_oracle.clone(), force_authoring, }; - slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>( + register_aura_inherent_data_provider( + &inherent_data_providers, + slot_duration.0.slot_duration() + )?; + Ok(slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible>( slot_duration.0, select_chain, - Arc::new(worker), + worker, sync_oracle, - on_exit, inherent_data_providers - ) + )) } struct AuraWorker { @@ -183,7 +183,6 @@ struct AuraWorker { env: Arc, local_key: Arc

, sync_oracle: SO, - inherent_data_providers: InherentDataProviders, force_authoring: bool, } @@ -208,13 +207,6 @@ impl SlotWorker for AuraWorker w { type OnSlot = Box + Send>; - fn on_start( - &self, - slot_duration: u64 - ) -> Result<(), consensus_common::Error> { - register_aura_inherent_data_provider(&self.inherent_data_providers, slot_duration) - } - fn on_slot( &self, chain_head: B::Header, @@ -902,7 +894,7 @@ mod tests { &inherent_data_providers, slot_duration.get() ).expect("Registers aura inherent data provider"); - let aura = start_aura::<_, _, _, _, _, sr25519::Pair, _, _, _, _>( + let aura = start_aura::<_, _, _, _, _, sr25519::Pair, _, _, _>( slot_duration, Arc::new(key.clone().into()), client.clone(), @@ -910,7 +902,6 @@ mod tests { client, environ.clone(), DummyOracle, - futures::empty(), inherent_data_providers, false, ).expect("Starts aura"); diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 0cb95c02df..c66eb68137 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -82,7 +82,7 @@ use futures::{Future, IntoFuture, future}; use tokio::timer::Timeout; use log::{error, warn, debug, info, trace}; -use slots::{SlotWorker, SlotInfo, SlotCompatible, slot_now}; +use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, slot_now}; /// A slot duration. Create with `get_or_compute`. @@ -134,7 +134,7 @@ impl SlotCompatible for BabeSlotCompatible { } /// Parameters for BABE. -pub struct BabeParams { +pub struct BabeParams { /// The configuration for BABE. Includes the slot duration, threshold, and /// other parameters. @@ -158,9 +158,6 @@ pub struct BabeParams { /// A sync oracle pub sync_oracle: SO, - /// Exit callback. - pub on_exit: OnExit, - /// Providers for inherent data. pub inherent_data_providers: InherentDataProviders, @@ -169,7 +166,7 @@ pub struct BabeParams { } /// Start the babe worker. The returned future should be run in a tokio runtime. -pub fn start_babe(BabeParams { +pub fn start_babe(BabeParams { config, local_key, client, @@ -177,10 +174,9 @@ pub fn start_babe(BabeParams { block_import, env, sync_oracle, - on_exit, inherent_data_providers, force_authoring, -}: BabeParams) -> Result< +}: BabeParams) -> Result< impl Future, consensus_common::Error, > where @@ -200,26 +196,24 @@ pub fn start_babe(BabeParams { I: BlockImport + Send + Sync + 'static, Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, - OnExit: Future, { let worker = BabeWorker { client: client.clone(), block_import, env, local_key, - inherent_data_providers: inherent_data_providers.clone(), sync_oracle: sync_oracle.clone(), force_authoring, threshold: config.threshold(), }; - slots::start_slot_worker::<_, _, _, _, _, BabeSlotCompatible, _>( + register_babe_inherent_data_provider(&inherent_data_providers, config.0.slot_duration())?; + Ok(slots::start_slot_worker::<_, _, _, _, _, BabeSlotCompatible>( config.0, select_chain, - Arc::new(worker), + worker, sync_oracle, - on_exit, inherent_data_providers - ) + )) } struct BabeWorker { @@ -228,7 +222,6 @@ struct BabeWorker { env: Arc, local_key: Arc, sync_oracle: SO, - inherent_data_providers: InherentDataProviders, force_authoring: bool, threshold: u64, } @@ -253,13 +246,6 @@ impl SlotWorker for BabeWorker w { type OnSlot = Box + Send>; - fn on_start( - &self, - slot_duration: u64 - ) -> Result<(), consensus_common::Error> { - register_babe_inherent_data_provider(&self.inherent_data_providers, slot_duration) - } - fn on_slot( &self, chain_head: B::Header, @@ -985,7 +971,6 @@ mod tests { client, env: environ.clone(), sync_oracle: DummyOracle, - on_exit: futures::empty(), inherent_data_providers, force_authoring: false, }).expect("Starts babe"); diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index 783cb018b9..aee398a9ce 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -41,7 +41,7 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ApiRef, Block, ProvideRuntimeApi}; use std::fmt::Debug; use std::ops::Deref; -use std::sync::{mpsc, Arc}; +use std::sync::mpsc; use std::thread; /// A worker that should be invoked at every new slot. @@ -51,7 +51,8 @@ pub trait SlotWorker { type OnSlot: IntoFuture; /// Called when the proposer starts. - fn on_start(&self, slot_duration: u64) -> Result<(), consensus_common::Error>; + #[deprecated(note = "Not called. Please perform any initialization before calling start_slot_worker.")] + fn on_start(&self, _slot_duration: u64) -> Result<(), consensus_common::Error> { Ok(()) } /// Called when a new slot is triggered. fn on_slot(&self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot; @@ -70,7 +71,7 @@ pub trait SlotCompatible { pub fn start_slot_worker_thread( slot_duration: SlotDuration, select_chain: C, - worker: Arc, + worker: W, sync_oracle: SO, on_exit: OnExit, inherent_data_providers: InherentDataProviders, @@ -97,29 +98,19 @@ where } }; - let slot_worker_future = match start_slot_worker::<_, _, _, T, _, SC, _>( + let slot_worker_future = start_slot_worker::<_, _, _, T, _, SC>( slot_duration.clone(), select_chain, worker, sync_oracle, - on_exit, inherent_data_providers, - ) { - Ok(slot_worker_future) => { - result_sender - .send(Ok(())) - .expect("Receive is not dropped before receiving a result; qed"); - slot_worker_future - } - Err(e) => { - result_sender - .send(Err(e)) - .expect("Receive is not dropped before receiving a result; qed"); - return; - } - }; + ); + + result_sender + .send(Ok(())) + .expect("Receive is not dropped before receiving a result; qed"); - let _ = runtime.block_on(slot_worker_future); + let _ = runtime.block_on(slot_worker_future.select(on_exit).map(|_| ())); }); result_recv @@ -128,67 +119,58 @@ where } /// Start a new slot worker. -pub fn start_slot_worker( +/// +/// Every time a new slot is triggered, `worker.on_slot` is called and the future it returns is +/// polled until completion, unless we are major syncing. +pub fn start_slot_worker( slot_duration: SlotDuration, client: C, - worker: Arc, + worker: W, sync_oracle: SO, - on_exit: OnExit, inherent_data_providers: InherentDataProviders, -) -> Result, consensus_common::Error> +) -> impl Future where B: Block, C: SelectChain + Clone, W: SlotWorker, SO: SyncOracle + Send + Clone, SC: SlotCompatible, - OnExit: Future, T: SlotData + Clone, { - worker.on_start(slot_duration.slot_duration())?; - - let make_authorship = move || { - let client = client.clone(); - let worker = worker.clone(); - let sync_oracle = sync_oracle.clone(); - let SlotDuration(slot_duration) = slot_duration.clone(); - let inherent_data_providers = inherent_data_providers.clone(); - - // rather than use a timer interval, we schedule our waits ourselves - Slots::::new(slot_duration.slot_duration(), inherent_data_providers) - .map_err(|e| debug!(target: "slots", "Faulty timer: {:?}", e)) - .for_each(move |slot_info| { - let client = client.clone(); - let worker = worker.clone(); - let sync_oracle = sync_oracle.clone(); - - // only propose when we are not syncing. - if sync_oracle.is_major_syncing() { - debug!(target: "slots", "Skipping proposal slot due to sync."); + let SlotDuration(slot_duration) = slot_duration; + + // rather than use a timer interval, we schedule our waits ourselves + let mut authorship = Slots::::new(slot_duration.slot_duration(), inherent_data_providers) + .map_err(|e| debug!(target: "slots", "Faulty timer: {:?}", e)) + .for_each(move |slot_info| { + // only propose when we are not syncing. + if sync_oracle.is_major_syncing() { + debug!(target: "slots", "Skipping proposal slot due to sync."); + return Either::B(future::ok(())); + } + + let slot_num = slot_info.number; + let chain_head = match client.best_chain() { + Ok(x) => x, + Err(e) => { + warn!(target: "slots", "Unable to author block in slot {}. \ + no best block header: {:?}", slot_num, e); return Either::B(future::ok(())); } - - let slot_num = slot_info.number; - let chain_head = match client.best_chain() { - Ok(x) => x, - Err(e) => { - warn!(target: "slots", "Unable to author block in slot {}. \ - no best block header: {:?}", slot_num, e); - return Either::B(future::ok(())); - } - }; - - Either::A(worker.on_slot(chain_head, slot_info).into_future().map_err( - |e| warn!(target: "slots", "Encountered consensus error: {:?}", e), - )) - }) - }; - - let work = future::loop_fn((), move |()| { - let authorship_task = ::std::panic::AssertUnwindSafe(make_authorship()); - authorship_task.catch_unwind().then(|res| { - match res { - Ok(Ok(())) => (), + }; + + Either::A(worker.on_slot(chain_head, slot_info).into_future().map_err( + |e| warn!(target: "slots", "Encountered consensus error: {:?}", e), + )) + }); + + future::poll_fn(move || + loop { + let mut authorship = std::panic::AssertUnwindSafe(&mut authorship); + match std::panic::catch_unwind(move || authorship.poll()) { + Ok(Ok(Async::Ready(()))) => + warn!(target: "slots", "Slots stream has terminated unexpectedly."), + Ok(Ok(Async::NotReady)) => break Ok(Async::NotReady), Ok(Err(())) => warn!(target: "slots", "Authorship task terminated unexpectedly. Restarting"), Err(e) => { if let Some(s) = e.downcast_ref::<&'static str>() { @@ -198,12 +180,8 @@ where warn!(target: "slots", "Restarting authorship task"); } } - - Ok(future::Loop::Continue(())) - }) - }); - - Ok(work.select(on_exit).then(|_| Ok(()))) + } + ) } /// A header which has been checked diff --git a/node-template/src/service.rs b/node-template/src/service.rs index c8f5dfc0a1..25e7db8dec 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -14,6 +14,7 @@ use substrate_service::{ }; use basic_authorship::ProposerFactory; use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, NothingExtra}; +use futures::prelude::*; use substrate_client::{self as client, LongestChain}; use primitives::{ed25519::Pair, Pair as PairT}; use inherents::InherentDataProviders; @@ -75,7 +76,7 @@ construct_service_factory! { let client = service.client(); let select_chain = service.select_chain() .ok_or_else(|| ServiceError::SelectChainRequired)?; - executor.spawn(start_aura( + let aura = start_aura( SlotDuration::get_or_compute(&*client)?, key.clone(), client.clone(), @@ -83,10 +84,10 @@ construct_service_factory! { client, proposer, service.network(), - service.on_exit(), service.config.custom.inherent_data_providers.clone(), service.config.force_authoring, - )?); + )?; + executor.spawn(aura.select(service.on_exit()).then(|_| Ok(()))); } Ok(service) diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 415ddbe71b..1458392b0f 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -26,6 +26,7 @@ use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, Nothing use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use node_executor; use primitives::{Pair as PairT, ed25519}; +use futures::prelude::*; use node_primitives::Block; use node_runtime::{GenesisConfig, RuntimeApi}; use substrate_service::{ @@ -92,7 +93,7 @@ construct_service_factory! { let client = service.client(); let select_chain = service.select_chain() .ok_or(ServiceError::SelectChainRequired)?; - executor.spawn(start_aura( + let aura = start_aura( SlotDuration::get_or_compute(&*client)?, key.clone(), client, @@ -100,10 +101,10 @@ construct_service_factory! { block_import.clone(), proposer, service.network(), - service.on_exit(), service.config.custom.inherent_data_providers.clone(), service.config.force_authoring, - )?); + )?; + executor.spawn(aura.select(service.on_exit()).then(|_| Ok(()))); info!("Running Grandpa session as Authority {}", key.public()); } -- GitLab From 21e63bc3ee107f36b0301fff3f4fd3c3c9079577 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 5 Jun 2019 18:14:42 +0300 Subject: [PATCH 092/113] Light client integration tests (#2638) * add light nodes to test_sync && test_consensus * forbid light2light connections * add light nodes to test_connectivity * fixed light2light connection penalty * post-merge fixes * remove best_queued from Client info --- core/client/src/client.rs | 6 -- core/network/src/protocol.rs | 13 ++- core/network/src/sync.rs | 8 +- core/service/test/src/lib.rs | 159 +++++++++++++++++++++++++++-------- 4 files changed, 138 insertions(+), 48 deletions(-) diff --git a/core/client/src/client.rs b/core/client/src/client.rs index f3040f13da..b076d24b18 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -168,10 +168,6 @@ pub trait BlockBody { pub struct ClientInfo { /// Best block hash. pub chain: ChainInfo, - /// Best block number in the queue. - pub best_queued_number: Option<<::Header as HeaderT>::Number>, - /// Best queued block hash. - pub best_queued_hash: Option, } /// Block status. @@ -1171,8 +1167,6 @@ impl Client where let info = self.backend.blockchain().info(); ClientInfo { chain: info, - best_queued_hash: None, - best_queued_number: None, } } diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index a824bd58d3..651f064513 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -845,13 +845,22 @@ impl, H: ExHashT> Protocol { network_out.disconnect_peer(who); return; } + if self.config.roles.is_light() { + // we're not interested in light peers + if status.roles.is_light() { + debug!(target: "sync", "Peer {} is unable to serve light requests", who); + network_out.report_peer(who.clone(), i32::min_value()); + network_out.disconnect_peer(who); + return; + } + + // we don't interested in peers that are far behind us let self_best_block = self .context_data .chain .info() - .best_queued_number - .unwrap_or_else(|| Zero::zero()); + .chain.best_number; let blocks_difference = self_best_block .checked_sub(&status.best_number) .unwrap_or_else(Zero::zero) diff --git a/core/network/src/sync.rs b/core/network/src/sync.rs index 62cb0ce14d..f3f62cac01 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/sync.rs @@ -191,8 +191,8 @@ impl ChainSync { _genesis_hash: info.chain.genesis_hash, peers: HashMap::new(), blocks: BlockCollection::new(), - best_queued_hash: info.best_queued_hash.unwrap_or(info.chain.best_hash), - best_queued_number: info.best_queued_number.unwrap_or(info.chain.best_number), + best_queued_hash: info.chain.best_hash, + best_queued_number: info.chain.best_number, extra_requests: ExtraRequestsAggregator::new(), role, required_block_attributes, @@ -852,8 +852,8 @@ impl ChainSync { self.best_importing_number = Zero::zero(); self.blocks.clear(); let info = protocol.client().info(); - self.best_queued_hash = info.best_queued_hash.unwrap_or(info.chain.best_hash); - self.best_queued_number = info.best_queued_number.unwrap_or(info.chain.best_number); + self.best_queued_hash = info.chain.best_hash; + self.best_queued_number = info.chain.best_number; debug!(target:"sync", "Restarted with {} ({})", self.best_queued_number, self.best_queued_hash); let ids: Vec = self.peers.drain().map(|(id, _)| id).collect(); for id in ids { diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index 7a6d530030..c31196af97 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -46,23 +46,38 @@ struct TestNet { runtime: Runtime, authority_nodes: Vec<(u32, Arc, Multiaddr)>, full_nodes: Vec<(u32, Arc, Multiaddr)>, - _light_nodes: Vec<(u32, Arc)>, + light_nodes: Vec<(u32, Arc, Multiaddr)>, chain_spec: FactoryChainSpec, base_port: u16, nodes: usize, } impl TestNet { - pub fn run_until_all_full bool + 'static>(&mut self, predicate: P) { + pub fn run_until_all_full( + &mut self, + full_predicate: FP, + light_predicate: LP, + ) + where + FP: Send + Sync + Fn(u32, &F::FullService) -> bool + 'static, + LP: Send + Sync + Fn(u32, &F::LightService) -> bool + 'static, + { let full_nodes = self.full_nodes.clone(); + let light_nodes = self.light_nodes.clone(); let interval = Interval::new_interval(Duration::from_millis(100)) .map_err(|_| ()) .for_each(move |_| { - if full_nodes.iter().all(|&(ref id, ref service, _)| predicate(*id, service)) { - Err(()) - } else { - Ok(()) + let full_ready = full_nodes.iter().all(|&(ref id, ref service, _)| full_predicate(*id, service)); + if !full_ready { + return Ok(()); + } + + let light_ready = light_nodes.iter().all(|&(ref id, ref service, _)| light_predicate(*id, service)); + if !light_ready { + return Ok(()); } + + Err(()) }) .timeout(MAX_WAIT_TIME); @@ -152,7 +167,7 @@ impl TestNet { runtime, authority_nodes: Default::default(), full_nodes: Default::default(), - _light_nodes: Default::default(), + light_nodes: Default::default(), chain_spec: spec.clone(), base_port, nodes: 0, @@ -186,28 +201,46 @@ impl TestNet { })); nodes += full as usize; - self._light_nodes.extend((nodes..nodes + light as usize).map(|index| (index as u32, - Arc::new(F::new_light(node_config::(index as u32, &spec, Roles::LIGHT, None, base_port, &temp), executor.clone()) - .expect("Error creating test node service"))) - )); + self.light_nodes.extend((nodes..nodes + light as usize).map(|index| { + let node_config = node_config::(index as u32, &spec, Roles::LIGHT, None, base_port, &temp); + let addr = node_config.network.listen_addresses.iter().next().unwrap().clone(); + let service = Arc::new(F::new_light(node_config, executor.clone()) + .expect("Error creating test node service")); + let addr = addr.with(multiaddr::Protocol::P2p(service.network().local_peer_id().into())); + (index as u32, service, addr) + })); nodes += light as usize; + self.nodes = nodes; } } pub fn connectivity(spec: FactoryChainSpec) { - const NUM_NODES: u32 = 10; + const NUM_FULL_NODES: u32 = 5; + const NUM_LIGHT_NODES: u32 = 5; { let temp = TempDir::new("substrate-connectivity-test").expect("Error creating test dir"); let runtime = { - let mut network = TestNet::::new(&temp, spec.clone(), NUM_NODES, 0, vec![], 30400); + let mut network = TestNet::::new( + &temp, + spec.clone(), + NUM_FULL_NODES, + NUM_LIGHT_NODES, + vec![], + 30400, + ); info!("Checking star topology"); let first_address = network.full_nodes[0].2.clone(); for (_, service, _) in network.full_nodes.iter().skip(1) { service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } - network.run_until_all_full(|_index, service| - service.network().peers_debug_info().len() == NUM_NODES as usize - 1 + for (_, service, _) in network.light_nodes.iter() { + service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); + } + network.run_until_all_full( + |_index, service| service.network().peers_debug_info().len() == NUM_FULL_NODES as usize - 1 + + NUM_LIGHT_NODES as usize, + |_index, service| service.network().peers_debug_info().len() == NUM_FULL_NODES as usize, ); network.runtime }; @@ -219,16 +252,35 @@ pub fn connectivity(spec: FactoryChainSpec) { { let temp = TempDir::new("substrate-connectivity-test").expect("Error creating test dir"); { - let mut network = TestNet::::new(&temp, spec, NUM_NODES, 0, vec![], 30400); + let mut network = TestNet::::new( + &temp, + spec, + NUM_FULL_NODES, + NUM_LIGHT_NODES, + vec![], + 30400, + ); info!("Checking linked topology"); let mut address = network.full_nodes[0].2.clone(); - for (_, service, node_id) in network.full_nodes.iter().skip(1) { - service.network().add_reserved_peer(address.to_string()).expect("Error adding reserved peer"); - address = node_id.clone(); + let max_nodes = ::std::cmp::max(NUM_FULL_NODES, NUM_LIGHT_NODES); + for i in 0..max_nodes { + if i != 0 { + if let Some((_, service, node_id)) = network.full_nodes.get(i as usize) { + service.network().add_reserved_peer(address.to_string()).expect("Error adding reserved peer"); + address = node_id.clone(); + } + } + + if let Some((_, service, node_id)) = network.light_nodes.get(i as usize) { + service.network().add_reserved_peer(address.to_string()).expect("Error adding reserved peer"); + address = node_id.clone(); + } } - network.run_until_all_full(|_index, service| { - service.network().peers_debug_info().len() == NUM_NODES as usize - 1 - }); + network.run_until_all_full( + |_index, service| service.network().peers_debug_info().len() == NUM_FULL_NODES as usize - 1 + + NUM_LIGHT_NODES as usize, + |_index, service| service.network().peers_debug_info().len() == NUM_FULL_NODES as usize, + ); } temp.close().expect("Error removing temp dir"); } @@ -244,10 +296,18 @@ where B: FnMut(&F::FullService) -> ImportBlock, E: FnMut(&F::FullService) -> FactoryExtrinsic, { - const NUM_NODES: u32 = 10; + const NUM_FULL_NODES: u32 = 10; + const NUM_LIGHT_NODES: u32 = 10; const NUM_BLOCKS: u32 = 512; let temp = TempDir::new("substrate-sync-test").expect("Error creating test dir"); - let mut network = TestNet::::new(&temp, spec.clone(), NUM_NODES, 0, vec![], 30500); + let mut network = TestNet::::new( + &temp, + spec.clone(), + NUM_FULL_NODES, + NUM_LIGHT_NODES, + vec![], + 30500, + ); info!("Checking block sync"); let first_address = { let first_service = &network.full_nodes[0].1; @@ -264,15 +324,22 @@ where for (_, service, _) in network.full_nodes.iter().skip(1) { service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } - network.run_until_all_full(|_index, service| - service.client().info().chain.best_number == NUM_BLOCKS.into() + for (_, service, _) in network.light_nodes.iter() { + service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); + } + network.run_until_all_full( + |_index, service| + service.client().info().chain.best_number == NUM_BLOCKS.into(), + |_index, service| + service.client().info().chain.best_number == NUM_BLOCKS.into(), ); info!("Checking extrinsic propagation"); let first_service = network.full_nodes[0].1.clone(); let best_block = BlockId::number(first_service.client().info().chain.best_number); first_service.transaction_pool().submit_one(&best_block, extrinsic_factory(&first_service)).unwrap(); - network.run_until_all_full(|_index, service| - service.transaction_pool().ready().count() == 1 + network.run_until_all_full( + |_index, service| service.transaction_pool().ready().count() == 1, + |_index, _service| true, ); } @@ -280,27 +347,47 @@ pub fn consensus(spec: FactoryChainSpec, authorities: Vec) where F: ServiceFactory, { - const NUM_NODES: u32 = 10; + const NUM_FULL_NODES: u32 = 10; + const NUM_LIGHT_NODES: u32 = 0; const NUM_BLOCKS: u32 = 10; // 10 * 2 sec block production time = ~20 seconds let temp = TempDir::new("substrate-conensus-test").expect("Error creating test dir"); - let mut network = TestNet::::new(&temp, spec.clone(), NUM_NODES / 2, 0, authorities, 30600); + let mut network = TestNet::::new( + &temp, + spec.clone(), + NUM_FULL_NODES / 2, + NUM_LIGHT_NODES / 2, + authorities, + 30600, + ); info!("Checking consensus"); let first_address = network.authority_nodes[0].2.clone(); for (_, service, _) in network.full_nodes.iter() { service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } + for (_, service, _) in network.light_nodes.iter() { + service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); + } for (_, service, _) in network.authority_nodes.iter().skip(1) { service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } - network.run_until_all_full(|_index, service| { - service.client().info().chain.finalized_number >= (NUM_BLOCKS / 2).into() - }); + network.run_until_all_full( + |_index, service| + service.client().info().chain.finalized_number >= (NUM_BLOCKS / 2).into(), + |_index, service| + service.client().info().chain.best_number >= (NUM_BLOCKS / 2).into(), + ); info!("Adding more peers"); - network.insert_nodes(&temp, NUM_NODES / 2, 0, vec![]); + network.insert_nodes(&temp, NUM_FULL_NODES / 2, NUM_LIGHT_NODES / 2, vec![]); for (_, service, _) in network.full_nodes.iter() { service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); } - network.run_until_all_full(|_index, service| - service.client().info().chain.finalized_number >= NUM_BLOCKS.into() + for (_, service, _) in network.light_nodes.iter() { + service.network().add_reserved_peer(first_address.to_string()).expect("Error adding reserved peer"); + } + network.run_until_all_full( + |_index, service| + service.client().info().chain.finalized_number >= NUM_BLOCKS.into(), + |_index, service| + service.client().info().chain.best_number >= NUM_BLOCKS.into(), ); } -- GitLab From 498452517f95d399ed1b422ea5097d2aa984fd02 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 5 Jun 2019 19:08:28 +0200 Subject: [PATCH 093/113] Fix subkey (#2798) * Fix ed25519 crypto * Add test * Remove unneeded import * Remove unneeded type * Remove unneeded clutter --- core/primitives/src/ed25519.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/primitives/src/ed25519.rs b/core/primitives/src/ed25519.rs index 135c551e45..e593e997a4 100644 --- a/core/primitives/src/ed25519.rs +++ b/core/primitives/src/ed25519.rs @@ -413,7 +413,7 @@ impl TraitPair for Pair { /// Derive a child key from a series of given junctions. fn derive>(&self, path: Iter) -> Result { - let mut acc = self.0.public.to_bytes(); + let mut acc = self.0.secret.to_bytes(); for j in path { match j { DeriveJunction::Soft(_cc) => return Err(DeriveError::SoftKeyInPath), @@ -473,7 +473,7 @@ impl TraitPair for Pair { impl Pair { /// Get the seed for this key. pub fn seed(&self) -> &Seed { - self.0.public.as_bytes() + self.0.secret.as_bytes() } /// Exactly as `from_string` except that if no matches are found then, the the first 32 @@ -502,6 +502,16 @@ mod test { ); } + #[test] + fn seed_and_derive_should_work() { + let seed = hex!("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60"); + let pair = Pair::from_seed(seed); + assert_eq!(pair.seed(), &seed); + let path = vec![DeriveJunction::Hard([0u8; 32])]; + let derived = pair.derive(path.into_iter()).ok().unwrap(); + assert_eq!(derived.seed(), &hex!("ede3354e133f9c8e337ddd6ee5415ed4b4ffe5fc7d21e933f4930a3730e5b21c")); + } + #[test] fn test_vector_should_work() { let pair: Pair = Pair::from_seed(hex!("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60")); -- GitLab From 0d364a3bc180e0abea52a3c0991531ddacf99f4f Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 6 Jun 2019 11:50:22 +0200 Subject: [PATCH 094/113] Update to libp2p 0.9.1 (#2804) --- Cargo.lock | 62 ++++++++++++++-------------- core/network-libp2p/Cargo.toml | 2 +- core/network-libp2p/src/transport.rs | 4 +- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1b933c3a6..b0c9eb1473 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1491,13 +1491,13 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1514,7 +1514,7 @@ dependencies = [ "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-websocket 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1528,7 +1528,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1577,7 +1577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1587,7 +1587,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1603,7 +1603,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1620,7 +1620,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1645,7 +1645,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1669,7 +1669,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1690,7 +1690,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1707,7 +1707,7 @@ dependencies = [ "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1726,7 +1726,7 @@ dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1743,7 +1743,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1755,7 +1755,7 @@ dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1774,7 +1774,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1799,7 +1799,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1812,7 +1812,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1824,7 +1824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1833,15 +1833,15 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "soketto 0.1.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)", + "soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1855,7 +1855,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3317,7 +3317,7 @@ dependencies = [ [[package]] name = "soketto" -version = "0.1.0-alpha.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4154,7 +4154,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4347,7 +4347,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4406,7 +4406,7 @@ name = "substrate-peerset" version = "2.0.0" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5872,8 +5872,8 @@ dependencies = [ "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" "checksum libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5692f82b51823e27c4118b3e5c0d98aee9be90633ebc71ad12afef380b50219" -"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" -"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6abde4e6fc777dc06ae2a15202ddedb1a38d7c71ed16bc10fa704b03f73aec37" +"checksum libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ceb4791289534d4c1ad8e4bd3c6f06d3670efa55ce71482951a287df93ddd1" "checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" "checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" "checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" @@ -5890,7 +5890,7 @@ dependencies = [ "checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" "checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" "checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" -"checksum libp2p-websocket 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a837bca8813fec5bd7dcb849d2f5f673ddca36e079ac485edfb8fa221a9d752" +"checksum libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d1bfe60577558f48a9fdf9f35c0ee2dc5baa01f685ff847d3b5cf4f12ee135" "checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" @@ -6033,7 +6033,7 @@ dependencies = [ "checksum slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" -"checksum soketto 0.1.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe8baac924db1b5f020050d7c8f8475c09d5ff11676101500fd0d3fdd184e67e" +"checksum soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cf3ae22c0bce5437c7dce6a2b00e492c19da1feb21ad64a7b6fd7058438c3f2" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" diff --git a/core/network-libp2p/Cargo.toml b/core/network-libp2p/Cargo.toml index 8a03a1c511..16978ed02c 100644 --- a/core/network-libp2p/Cargo.toml +++ b/core/network-libp2p/Cargo.toml @@ -12,7 +12,7 @@ byteorder = "1.3" bytes = "0.4" fnv = "1.0" futures = "0.1" -libp2p = { version = "0.9.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] } +libp2p = { version = "0.9.1", default-features = false, features = ["secp256k1", "libp2p-websocket"] } parking_lot = "0.8.0" lazy_static = "1.2" log = "0.4" diff --git a/core/network-libp2p/src/transport.rs b/core/network-libp2p/src/transport.rs index e1843476d9..f6790c98f4 100644 --- a/core/network-libp2p/src/transport.rs +++ b/core/network-libp2p/src/transport.rs @@ -68,9 +68,7 @@ pub fn build_transport( .map(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer))) }) .with_timeout(Duration::from_secs(20)) - // TODO: pass the error directly, instead of calling `to_string()` - // https://github.com/libp2p/rust-libp2p/issues/1162 - .map_err(|err| io::Error::new(io::ErrorKind::Other, err.to_string())) + .map_err(|err| io::Error::new(io::ErrorKind::Other, err)) .boxed(); (transport, sinks) -- GitLab From d6e91c1335995ba4d046ced403a62ec0338fcb37 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 6 Jun 2019 15:53:22 +0200 Subject: [PATCH 095/113] Require --locked when building runtime (#2813) * Require --locked when building runtime * Update locks * Do it in a different way * Accidentally reverted Cargo.lock * pass on arguments in build.sh scripts --- .gitlab-ci.yml | 8 ++++---- core/executor/wasm/build.sh | 2 +- core/test-runtime/wasm/Cargo.lock | 14 +++++++------- core/test-runtime/wasm/build.sh | 2 +- node-template/runtime/wasm/Cargo.lock | 12 ++++++------ node-template/runtime/wasm/build.sh | 2 +- node/runtime/wasm/Cargo.lock | 12 ++++++------ node/runtime/wasm/build.sh | 2 +- scripts/build.sh | 2 +- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b82a3f1392..ffe0de9cd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,7 +92,7 @@ test-linux-stable: &test variables: - $DEPLOY_TAG script: - - ./scripts/build.sh + - ./scripts/build.sh --locked - time cargo test --all --release --verbose --locked - sccache -s @@ -117,7 +117,7 @@ test-linux-stable-int: &test - $DEPLOY_TAG before_script: - sccache -s - - ./scripts/build.sh + - ./scripts/build.sh --locked script: - time RUST_LOG=sync=trace,consensus=trace,client=trace,state-db=trace,db=trace,forks=trace,state_db=trace,storage_cache=trace cargo test -p node-cli --release --verbose --locked -- --ignored --test-threads=1 - sccache -s @@ -172,7 +172,7 @@ build-linux-release: tags: - linux-docker script: - - ./scripts/build.sh + - ./scripts/build.sh --locked - time cargo build --release --verbose - mkdir -p ./artifacts - mv ./target/release/substrate ./artifacts/. @@ -204,7 +204,7 @@ build-rust-doc-release: tags: - linux-docker script: - - ./scripts/build.sh + - ./scripts/build.sh --locked - rm -f ./crate-docs/index.html # use it as an indicator if the job succeeds - time cargo +nightly doc --release --all --verbose - cp -R ./target/doc ./crate-docs diff --git a/core/executor/wasm/build.sh b/core/executor/wasm/build.sh index c23ac076e2..fe2faeec62 100755 --- a/core/executor/wasm/build.sh +++ b/core/executor/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ for i in test do wasm-gc target/wasm32-unknown-unknown/release/runtime_$i.wasm target/wasm32-unknown-unknown/release/runtime_$i.compact.wasm diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index 8763845ab7..ebf96f3fa6 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -2474,7 +2474,7 @@ dependencies = [ "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2531,7 +2531,7 @@ dependencies = [ "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -2547,7 +2547,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -2566,7 +2566,7 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-version 2.0.0", "substrate-panic-handler 2.0.0", @@ -2583,7 +2583,7 @@ name = "substrate-inherents" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -2659,7 +2659,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", "substrate-primitives 2.0.0", "substrate-trie 2.0.0", @@ -2673,7 +2673,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/core/test-runtime/wasm/build.sh b/core/test-runtime/wasm/build.sh index 635532babf..0529a974ff 100755 --- a/core/test-runtime/wasm/build.sh +++ b/core/test-runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ for i in substrate_test_runtime do wasm-gc "target/wasm32-unknown-unknown/release/$i.wasm" "target/wasm32-unknown-unknown/release/$i.compact.wasm" diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index 2dc001522c..ec014da1b9 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -2627,7 +2627,7 @@ dependencies = [ "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2674,7 +2674,7 @@ dependencies = [ "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -2693,7 +2693,7 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-version 2.0.0", "substrate-panic-handler 2.0.0", @@ -2710,7 +2710,7 @@ name = "substrate-inherents" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -2786,7 +2786,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", "substrate-primitives 2.0.0", "substrate-trie 2.0.0", @@ -2800,7 +2800,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/node-template/runtime/wasm/build.sh b/node-template/runtime/wasm/build.sh index f5761cbb1e..566e5de35d 100755 --- a/node-template/runtime/wasm/build.sh +++ b/node-template/runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ for i in node_template_runtime_wasm do wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index 8ec68521c2..d72146ad03 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -2762,7 +2762,7 @@ dependencies = [ "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2809,7 +2809,7 @@ dependencies = [ "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", @@ -2828,7 +2828,7 @@ dependencies = [ "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-version 2.0.0", "substrate-panic-handler 2.0.0", @@ -2856,7 +2856,7 @@ name = "substrate-inherents" version = "2.0.0" dependencies = [ "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -2932,7 +2932,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 2.0.0", "substrate-primitives 2.0.0", "substrate-trie 2.0.0", @@ -2946,7 +2946,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/node/runtime/wasm/build.sh b/node/runtime/wasm/build.sh index f0b7c961bd..9a9f412bfc 100755 --- a/node/runtime/wasm/build.sh +++ b/node/runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ for i in node_runtime do wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm diff --git a/scripts/build.sh b/scripts/build.sh index 46bc74b7a9..8b3557159b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,7 +19,7 @@ do echo "*** Building wasm binaries in $SRC" cd "$PROJECT_ROOT/$SRC" - ./build.sh + ./build.sh $@ cd - >> /dev/null done -- GitLab From e4bd5085054dec7066bd886713c81ae96462d9f8 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 6 Jun 2019 22:12:55 +0200 Subject: [PATCH 096/113] Don't pass the Endpoint as message (#2814) --- .../src/custom_proto/behaviour.rs | 10 +++++----- .../network-libp2p/src/custom_proto/handler.rs | 18 +++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/network-libp2p/src/custom_proto/behaviour.rs b/core/network-libp2p/src/custom_proto/behaviour.rs index 0aa6ed9544..41b3b32218 100644 --- a/core/network-libp2p/src/custom_proto/behaviour.rs +++ b/core/network-libp2p/src/custom_proto/behaviour.rs @@ -412,7 +412,7 @@ impl CustomProto { debug!(target: "sub-libp2p", "Handler({:?}) <= Enable", occ_entry.key()); self.events.push(NetworkBehaviourAction::SendEvent { peer_id: occ_entry.key().clone(), - event: CustomProtoHandlerIn::Enable(connected_point.clone().into()), + event: CustomProtoHandlerIn::Enable, }); *occ_entry.into_mut() = PeerState::Enabled { connected_point, open }; }, @@ -430,7 +430,7 @@ impl CustomProto { debug!(target: "sub-libp2p", "Handler({:?}) <= Enable", occ_entry.key()); self.events.push(NetworkBehaviourAction::SendEvent { peer_id: occ_entry.key().clone(), - event: CustomProtoHandlerIn::Enable(connected_point.clone().into()), + event: CustomProtoHandlerIn::Enable, }); *occ_entry.into_mut() = PeerState::Enabled { connected_point, open: false }; }, @@ -551,7 +551,7 @@ impl CustomProto { debug!(target: "sub-libp2p", "Handler({:?}) <= Enable", incoming.peer_id); self.events.push(NetworkBehaviourAction::SendEvent { peer_id: incoming.peer_id, - event: CustomProtoHandlerIn::Enable(connected_point.clone().into()), + event: CustomProtoHandlerIn::Enable, }); *state = PeerState::Enabled { open: false, connected_point }; @@ -634,7 +634,7 @@ where debug!(target: "sub-libp2p", "Handler({:?}) <= Enable", peer_id); self.events.push(NetworkBehaviourAction::SendEvent { peer_id: peer_id.clone(), - event: CustomProtoHandlerIn::Enable(connected_point.clone().into()), + event: CustomProtoHandlerIn::Enable, }); *st = PeerState::Enabled { open: false, connected_point }; } @@ -985,7 +985,7 @@ where debug!(target: "sub-libp2p", "Handler({:?}) <= Enable now that ban has expired", peer_id); self.events.push(NetworkBehaviourAction::SendEvent { peer_id: peer_id.clone(), - event: CustomProtoHandlerIn::Enable(connected_point.clone().into()), + event: CustomProtoHandlerIn::Enable, }); *peer_state = PeerState::Enabled { connected_point, open }; } diff --git a/core/network-libp2p/src/custom_proto/handler.rs b/core/network-libp2p/src/custom_proto/handler.rs index 01644f6214..0400c27f82 100644 --- a/core/network-libp2p/src/custom_proto/handler.rs +++ b/core/network-libp2p/src/custom_proto/handler.rs @@ -118,10 +118,11 @@ where self.protocol.clone() } - fn into_handler(self, remote_peer_id: &PeerId, _: &ConnectedPoint) -> Self::Handler { + fn into_handler(self, remote_peer_id: &PeerId, connected_point: &ConnectedPoint) -> Self::Handler { let clock = Clock::new(); CustomProtoHandler { protocol: self.protocol, + endpoint: connected_point.to_endpoint(), remote_peer_id: remote_peer_id.clone(), state: ProtocolState::Init { substreams: SmallVec::new(), @@ -145,6 +146,10 @@ pub struct CustomProtoHandler { /// any influence on the behaviour. remote_peer_id: PeerId, + /// Whether we are the connection dialer or listener. Used to determine who, between the local + /// node and the remote node, has priority. + endpoint: Endpoint, + /// Queue of events to send to the outside. /// /// This queue must only ever be modified to insert elements at the back, or remove the first @@ -208,9 +213,8 @@ enum ProtocolState { /// Event that can be received by a `CustomProtoHandler`. #[derive(Debug)] pub enum CustomProtoHandlerIn { - /// The node should start using custom protocols. Contains whether we are the dialer or the - /// listener of the connection. - Enable(Endpoint), + /// The node should start using custom protocols. + Enable, /// The node should stop using custom protocols. Disable, @@ -265,7 +269,7 @@ where TMessage: CustomMessage, { /// Enables the handler. - fn enable(&mut self, endpoint: Endpoint) { + fn enable(&mut self) { self.state = match mem::replace(&mut self.state, ProtocolState::Poisoned) { ProtocolState::Poisoned => { error!(target: "sub-libp2p", "Handler with {:?} is in poisoned state", @@ -275,7 +279,7 @@ where ProtocolState::Init { substreams: incoming, .. } => { if incoming.is_empty() { - if let Endpoint::Dialer = endpoint { + if let Endpoint::Dialer = self.endpoint { self.events_queue.push(ProtocolsHandlerEvent::OutboundSubstreamRequest { protocol: SubstreamProtocol::new(self.protocol.clone()), info: (), @@ -557,7 +561,7 @@ where TSubstream: AsyncRead + AsyncWrite, TMessage: CustomMessage { fn inject_event(&mut self, message: CustomProtoHandlerIn) { match message { CustomProtoHandlerIn::Disable => self.disable(), - CustomProtoHandlerIn::Enable(endpoint) => self.enable(endpoint), + CustomProtoHandlerIn::Enable => self.enable(), CustomProtoHandlerIn::SendCustomMessage { message } => self.send_message(message), } -- GitLab From f6cd473bfef46d1e8a92cb005884424939b72071 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 6 Jun 2019 22:15:38 +0200 Subject: [PATCH 097/113] Rewrite telemetry using libp2p (#2812) * Rewrite telemetry using libp2p * Update the Cargo.lock files * Apply suggestion --- .gitlab-ci.yml | 1 + Cargo.lock | 47 +-- core/service/src/lib.rs | 13 +- core/telemetry/Cargo.toml | 13 +- core/telemetry/src/lib.rs | 402 ++++++++++++-------------- core/telemetry/src/worker.rs | 203 +++++++++++++ core/telemetry/src/worker/node.rs | 220 ++++++++++++++ core/test-runtime/wasm/Cargo.lock | 279 +++++++++--------- node-template/runtime/wasm/Cargo.lock | 279 +++++++++--------- node/runtime/wasm/Cargo.lock | 279 +++++++++--------- 10 files changed, 1070 insertions(+), 666 deletions(-) create mode 100644 core/telemetry/src/worker.rs create mode 100644 core/telemetry/src/worker/node.rs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ffe0de9cd5..99b354a60b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -148,6 +148,7 @@ check-web-wasm: - time cargo web build -p substrate-serializer - time cargo web build -p substrate-state-db - time cargo web build -p substrate-state-machine + - time cargo web build -p substrate-telemetry - time cargo web build -p substrate-trie - sccache -s tags: diff --git a/Cargo.lock b/Cargo.lock index b0c9eb1473..7e92564208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3251,16 +3251,6 @@ dependencies = [ "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "slog-async" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slog-json" version = "2.3.0" @@ -4586,17 +4576,20 @@ dependencies = [ name = "substrate-telemetry" version = "2.0.0" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4739,11 +4732,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "target_info" version = "0.1.0" @@ -5581,24 +5569,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ws" version = "0.8.1" @@ -6027,7 +5997,6 @@ dependencies = [ "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" -"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60c04b4726fa04595ccf2c2dad7bcd15474242c4c5e109a8a376e8a2c9b1539a" "checksum slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" @@ -6052,7 +6021,6 @@ dependencies = [ "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum sysinfo 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65f0e28a49b7bf142cee89befd7077b40627d7cc70aa8a8acfe03afc26016c33" -"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" @@ -6140,7 +6108,6 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ec91ea61b83ce033c43c06c52ddc7532f465c0153281610d44c58b74083aee1a" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 5129944c54..b33608392d 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -81,7 +81,7 @@ pub struct Service { /// Configuration of this Service pub config: FactoryFullConfiguration, _rpc: Box, - _telemetry: Option>, + _telemetry: Option, _offchain_workers: Option, ComponentBlock>>>, _telemetry_on_connect_sinks: Arc>>>, } @@ -351,8 +351,9 @@ impl Service { let version = version.clone(); let chain_name = config.chain_spec.name().to_owned(); let telemetry_connection_sinks_ = telemetry_connection_sinks.clone(); - Arc::new(tel::init_telemetry(tel::TelemetryConfig { + let telemetry = tel::init_telemetry(tel::TelemetryConfig { endpoints, + wasm_external_transport: None, on_connect: Box::new(move || { telemetry!(SUBSTRATE_INFO; "system.connected"; "name" => name.clone(), @@ -369,7 +370,11 @@ impl Service { sink.unbounded_send(()).is_ok() }); }), - })) + }); + task_executor.spawn(telemetry.clone() + .select(exit.clone()) + .then(|_| Ok(()))); + telemetry }); Ok(Service { @@ -402,7 +407,7 @@ impl Service { } /// return a shared instance of Telemetry (if enabled) - pub fn telemetry(&self) -> Option> { + pub fn telemetry(&self) -> Option { self._telemetry.as_ref().map(|t| t.clone()) } } diff --git a/core/telemetry/Cargo.toml b/core/telemetry/Cargo.toml index f61d6bc4d3..1b19796836 100644 --- a/core/telemetry/Cargo.toml +++ b/core/telemetry/Cargo.toml @@ -6,14 +6,19 @@ description = "Telemetry utils" edition = "2018" [dependencies] +bytes = "0.4" parking_lot = "0.8.0" -lazy_static = "1.0" +futures = "0.1" +libp2p = { version = "0.9.1", default-features = false, features = ["libp2p-websocket"] } log = "0.4" rand = "0.6" serde = { version = "1.0.81", features = ["derive"] } -serde_json = "1.0" slog = { version = "^2", features = ["nested-values"] } slog-json = { version = "^2", features = ["nested-values"] } -slog-async = { version = "^2", features = ["nested-values"] } slog-scope = "^4" -ws = { version = "^0.7", features = ["ssl"] } +tokio-io = "0.1" +tokio-timer = "0.2" +void = "1.0" + +[dev-dependencies] +tokio = "0.1" diff --git a/core/telemetry/src/lib.rs b/core/telemetry/src/lib.rs index 3f980c5929..3e5d8278b0 100644 --- a/core/telemetry/src/lib.rs +++ b/core/telemetry/src/lib.rs @@ -14,38 +14,95 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Telemetry utils. +//! Telemetry utilities. +//! +//! Calling `init_telemetry` registers a global `slog` logger using `slog_scope::set_global_logger`. +//! After that, calling `slog_scope::with_logger` will return a logger that sends information to +//! the telemetry endpoints. The `telemetry!` macro is a short-cut for calling +//! `slog_scope::with_logger` followed with `slog_log!`. +//! +//! Note that you are supposed to only ever use `telemetry!` and not `slog_scope::with_logger` at +//! the moment. Substate may eventually be reworked to get proper `slog` support, including sending +//! information to the telemetry. +//! +//! The `Telemetry` struct implements `Future` and must be polled regularly (or sent to a +//! background thread/task) in order for the telemetry to properly function. Dropping the object +//! will also deregister the global logger and replace it with a logger that discards messages. +//! +//! # Example +//! +//! ```no_run +//! let telemetry = substrate_telemetry::init_telemetry(substrate_telemetry::TelemetryConfig { +//! endpoints: substrate_telemetry::TelemetryEndpoints::new(vec![ +//! // The `0` is the maximum verbosity level of messages to send to this endpoint. +//! ("wss://example.com".into(), 0) +//! ]), +//! on_connect: Box::new(|| {}), +//! // Can be used to pass an external implementation of WebSockets. +//! wasm_external_transport: None, +//! }); +//! +//! // The `telemetry` object implements `Future` and must be processed. +//! std::thread::spawn(move || { +//! tokio::run(telemetry); +//! }); +//! +//! // Sends a message on the telemetry. +//! substrate_telemetry::telemetry!(substrate_telemetry::SUBSTRATE_INFO; "test"; +//! "foo" => "bar", +//! ) +//! ``` //! -//! `telemetry` macro may be used anywhere in the Substrate codebase -//! in order to send real-time logging information to the telemetry -//! server (if there is one). We use the async drain adapter of `slog` -//! so that the logging thread doesn't get held up at all. -use std::{io, time, thread}; -use std::sync::Arc; +use futures::{prelude::*, task::AtomicTask}; +use libp2p::{Multiaddr, wasm_ext}; +use log::{trace, warn}; use parking_lot::Mutex; -use slog::{Drain, o, OwnedKVList, Record}; -use log::trace; -use rand::{thread_rng, Rng}; +use serde::{Serialize, Deserialize}; +use std::sync::{Arc, Weak}; +use std::time::{Duration, Instant}; + pub use slog_scope::with_logger; pub use slog; -use serde::{Serialize, Deserialize}; -use core::result; + +mod worker; /// Configuration for telemetry. pub struct TelemetryConfig { /// Collection of telemetry WebSocket servers with a corresponding verbosity level. pub endpoints: TelemetryEndpoints, - /// What do do when we connect to the servers. - /// Note that this closure is executed each time we connect to a telemetry endpoint. + + /// What to do when we connect to a server. + /// + /// This closure is executed each time we connect to a telemetry endpoint, either for the first + /// time or after being disconnected. pub on_connect: Box, + + /// Optional external implementation of a libp2p transport. Used in WASM contexts where we need + /// some binding between the networking provided by the operating system or environment and + /// libp2p. + /// + /// This parameter exists whatever the target platform is, but it is expected to be set to + /// `Some` only when compiling for WASM. + /// + /// > **Important**: Each individual call to `write` corresponds to one message. There is no + /// > internal buffering going on. In the context of WebSockets, each `write` + /// > must be one individual WebSockets frame. + pub wasm_external_transport: Option, } -/// Telemetry service guard. -pub type Telemetry = slog_scope::GlobalLoggerGuard; +/// List of telemetry servers we want to talk to. Contains the URL of the server, and the +/// maximum verbosity level. +/// +/// The URL string can be either a URL or a multiaddress. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TelemetryEndpoints(Vec<(String, u8)>); -/// Size of the channel for passing messages to telemetry thread. -const CHANNEL_SIZE: usize = 262_144; +impl TelemetryEndpoints { + pub fn new(endpoints: Vec<(String, u8)>) -> Self { + TelemetryEndpoints(endpoints) + } +} /// Log levels. pub const SUBSTRATE_DEBUG: &str = "9"; @@ -56,232 +113,145 @@ pub const CONSENSUS_DEBUG: &str = "5"; pub const CONSENSUS_WARN: &str = "4"; pub const CONSENSUS_INFO: &str = "0"; -/// Multiply logging to all drains. This is similar to `slog::Duplicate`, which is -/// limited to two drains though and doesn't support dynamic nesting at runtime. -#[derive(Debug, Clone)] -pub struct Multiply (pub Vec); - -impl Multiply { - pub fn new(v: Vec) -> Self { - Multiply(v) - } +/// Telemetry object. Implements `Future` and must be polled regularly. +/// Contains an `Arc` and can be cloned and pass around. Only one clone needs to be polled +/// regularly. +/// Dropping all the clones unregisters the telemetry. +#[derive(Clone)] +pub struct Telemetry { + inner: Arc, + /// Slog guard so that we don't get deregistered. + _guard: Arc, } -impl Drain for Multiply { - type Ok = Vec; - type Err = Vec; - - fn log(&self, record: &Record, logger_values: &OwnedKVList) -> result::Result { - let mut oks = Vec::new(); - let mut errs = Vec::new(); - - self.0.iter().for_each(|l| { - let res: Result<::Ok, ::Err> = (*l).log(record, logger_values); - match res { - Ok(o) => oks.push(o), - Err(e) => errs.push(e), - } - }); - - if !errs.is_empty() { - result::Result::Err(errs) - } else { - result::Result::Ok(oks) - } - } +// Implementation notes: considering that logging can happen at any moment, we only have two +// options: locking a mutex (which we currently do), or using a channel (which we should do). +// At the moment, `slog` doesn't provide any easy way to serialize records in order to send them +// over a channel, but ideally that's what should be done. + +/// Shared between `Telemetry` and `TelemetryDrain`. +struct TelemetryInner { + /// Worker for the telemetry. + worker: Mutex, + /// Same field as in the configuration. Called when we connected to an endpoint. + on_connect: Box, + /// Task to wake up when we add a log entry to the worker. + polling_task: AtomicTask, } -/// Initialize telemetry. -pub fn init_telemetry(config: TelemetryConfig) -> slog_scope::GlobalLoggerGuard { - let mut endpoint_drains: Vec>> = Vec::new(); - let mut out_syncs = Vec::new(); - - // Set up a filter/drain for each endpoint - config.endpoints.0.iter().for_each(|(url, verbosity)| { - let writer = TelemetryWriter::new(Arc::new(url.to_owned())); - let out_sync = writer.out.clone(); - out_syncs.push(out_sync); - - let until_verbosity = *verbosity; - let filter = slog::Filter( - slog_json::Json::default(writer).fuse(), - move |rec| { - let tag = rec.tag().parse::() - .expect("`telemetry!` macro requires tag."); - tag <= until_verbosity - }); - - let filter = Box::new(filter) as Box>; - endpoint_drains.push(filter); - }); - - // Set up logging to all endpoints - let drain = slog_async::Async::new(Multiply::new(endpoint_drains).fuse()); - let root = slog::Logger::root(drain.chan_size(CHANNEL_SIZE) - .overflow_strategy(slog_async::OverflowStrategy::DropAndReport) - .build().fuse(), o!() - ); - let logger_guard = slog_scope::set_global_logger(root); - - // Spawn a thread for each endpoint - let on_connect = Arc::new(config.on_connect); - config.endpoints.0.into_iter().for_each(|(url, verbosity)| { - let inner_verbosity = Arc::new(verbosity.to_owned()); - let inner_on_connect = Arc::clone(&on_connect); - - let out_sync = out_syncs.remove(0); - let out_sync = Arc::clone(&out_sync); - - thread::spawn(move || { - loop { - let on_connect = Arc::clone(&inner_on_connect); - let out_sync = Arc::clone(&out_sync); - let verbosity = Arc::clone(&inner_verbosity); - - trace!(target: "telemetry", - "Connecting to Telemetry at {} with verbosity {}", url, Arc::clone(&verbosity)); - - let _ = ws::connect(url.to_owned(), - |out| { - Connection::new(out, Arc::clone(&out_sync), Arc::clone(&on_connect), url.clone()) - }); - - // Sleep for a random time between 5-10 secs. If there are general connection - // issues not all threads should be synchronized in their re-connection time. - let random_sleep = thread_rng().gen_range(0, 5); - thread::sleep(time::Duration::from_secs(5) + time::Duration::from_secs(random_sleep)); - } - }); - }); - - logger_guard +/// Implements `slog::Drain`. +struct TelemetryDrain { + inner: std::panic::AssertUnwindSafe>, } -/// Translates to `slog_scope::info`, but contains an additional verbosity -/// parameter which the log record is tagged with. Additionally the verbosity -/// parameter is added to the record as a key-value pair. -#[macro_export] -macro_rules! telemetry { - ( $a:expr; $b:expr; $( $t:tt )* ) => { - $crate::with_logger(|l| { - $crate::slog::slog_info!(l, #$a, $b; $($t)* ) - }) - } -} - -struct Connection { - out: ws::Sender, - out_sync: Arc>>, - on_connect: Arc>, - url: String, -} - -impl Connection { - fn new( - out: ws::Sender, - out_sync: Arc>>, - on_connect: Arc>, - url: String - ) -> Self { - Connection { - out, - out_sync, - on_connect, - url, +/// Initializes the telemetry. See the crate root documentation for more information. +/// +/// Please be careful to not call this function twice in the same program. The `slog` crate +/// doesn't provide any way of knowing whether a global logger has already been registered. +pub fn init_telemetry(config: TelemetryConfig) -> Telemetry { + // Build the list of telemetry endpoints. + let mut endpoints = Vec::new(); + for &(ref url, verbosity) in &config.endpoints.0 { + match url_to_multiaddr(url) { + Ok(addr) => endpoints.push((addr, verbosity)), + Err(err) => warn!(target: "telemetry", "Invalid telemetry URL {}: {}", url, err), } } -} - -impl ws::Handler for Connection { - fn on_open(&mut self, _: ws::Handshake) -> ws::Result<()> { - trace!(target: "telemetry", "Connected to {}!", self.url); - - *self.out_sync.lock() = Some(self.out.clone()); - (self.on_connect)(); - Ok(()) - } - fn on_close(&mut self, code: ws::CloseCode, reason: &str) { - *self.out_sync.lock() = None; - - trace!(target: "telemetry", "Connection to {} closing due to ({:?}) {}", - self.url, code, reason); - } + let inner = Arc::new(TelemetryInner { + worker: Mutex::new(worker::TelemetryWorker::new(endpoints, config.wasm_external_transport)), + on_connect: config.on_connect, + polling_task: AtomicTask::new(), + }); - fn on_error(&mut self, _: ws::Error) { - *self.out_sync.lock() = None; + let guard = { + let logger = TelemetryDrain { inner: std::panic::AssertUnwindSafe(Arc::downgrade(&inner)) }; + let root = slog::Logger::root(slog::Drain::fuse(logger), slog::o!()); + slog_scope::set_global_logger(root) + }; - // Sleep to ensure that reconnecting isn't spamming logs. - // This happens in it's own thread so it won't block anything. - thread::sleep(time::Duration::from_millis(1000)); + Telemetry { + inner, + _guard: Arc::new(guard), } } -struct TelemetryWriter { - buffer: Vec, - out: Arc>>, - url: Arc, -} +impl Future for Telemetry { + type Item = (); + type Error = (); -impl TelemetryWriter { - fn new(url: Arc) -> Self { - let out = Arc::new(Mutex::new(None)); + fn poll(&mut self) -> Poll<(), ()> { + let before = Instant::now(); - TelemetryWriter { - buffer: Vec::new(), - out, - url, + let mut has_connected = false; + while let Async::Ready(event) = self.inner.worker.lock().poll() { + // Right now we only have one possible event. This line is here in order to not + // forget to handle any possible new event type. + let worker::TelemetryWorkerEvent::Connected = event; + has_connected = true; } - } -} -impl io::Write for TelemetryWriter { - fn write(&mut self, msg: &[u8]) -> io::Result { - let mut iter = msg.split(|x| *x == b'\n'); - let first = iter.next().expect("Split iterator always has at least one element; qed"); - - self.buffer.extend_from_slice(first); - - // Flush for each occurrence of new line character - for continued in iter { - let _ = self.flush(); - self.buffer.extend_from_slice(continued); + if before.elapsed() > Duration::from_millis(200) { + warn!(target: "telemetry", "Polling the telemetry took more than 200ms"); } - Ok(msg.len()) - } - - fn flush(&mut self) -> io::Result<()> { - if self.buffer.is_empty() { - return Ok(()); + // We use an intermediary variable `has_connected` so that the lock is released when we + // call `on_connect`. + if has_connected { + trace!(target: "telemetry", "Running on_connect handlers"); + (self.inner.on_connect)(); } - if let Ok(s) = ::std::str::from_utf8(&self.buffer[..]) { - let mut out = self.out.lock(); - - let error = if let Some(ref mut o) = *out { - let r = o.send(s); - trace!(target: "telemetry", "Sent to telemetry {}: {} -> {:?}", self.url, s, r); - r.is_err() - } else { - trace!(target: "telemetry", "Telemetry socket closed to {}, failed to send: {}", self.url, s); - false - }; + self.inner.polling_task.register(); + Ok(Async::NotReady) + } +} - if error { - *out = None; +impl slog::Drain for TelemetryDrain { + type Ok = (); + type Err = (); + + fn log(&self, record: &slog::Record, values: &slog::OwnedKVList) -> Result { + if let Some(inner) = self.inner.0.upgrade() { + let before = Instant::now(); + let result = inner.worker.lock().log(record, values); + inner.polling_task.notify(); + if before.elapsed() > Duration::from_millis(50) { + warn!(target: "telemetry", "Writing a telemetry log took more than 50ms"); } + result + } else { + Ok(()) } - self.buffer.clear(); - Ok(()) } } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct TelemetryEndpoints (Vec<(String, u8)>); +/// Parses a WebSocket URL into a libp2p `Multiaddr`. +fn url_to_multiaddr(url: &str) -> Result { + // First, assume that we have a `Multiaddr`. + let parse_error = match url.parse() { + Ok(ma) => return Ok(ma), + Err(err) => err, + }; + + // If not, try the `ws://path/url` format. + if let Ok(ma) = libp2p::multiaddr::from_url(url) { + return Ok(ma) + } -impl TelemetryEndpoints { - pub fn new(endpoints: Vec<(String, u8)>) -> Self { - TelemetryEndpoints(endpoints) + // If we have no clue about the format of that string, assume that we were expecting a + // `Multiaddr`. + Err(parse_error) +} + +/// Translates to `slog_scope::info`, but contains an additional verbosity +/// parameter which the log record is tagged with. Additionally the verbosity +/// parameter is added to the record as a key-value pair. +#[macro_export] +macro_rules! telemetry { + ( $a:expr; $b:expr; $( $t:tt )* ) => { + $crate::with_logger(|l| { + $crate::slog::slog_info!(l, #$a, $b; $($t)* ) + }) } } diff --git a/core/telemetry/src/worker.rs b/core/telemetry/src/worker.rs new file mode 100644 index 0000000000..87a3deb6ef --- /dev/null +++ b/core/telemetry/src/worker.rs @@ -0,0 +1,203 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Contains the object that makes the telemetry work. +//! +//! # Usage +//! +//! - Create a `TelemetryWorker` with `TelemetryWorker::new`. +//! - Send messages to the telemetry with `TelemetryWorker::send_message`. Messages will only be +//! sent to the appropriate targets. Messages may be ignored if the target happens to be +//! temporarily unreachable. +//! - You must appropriately poll the worker with `TelemetryWorker::poll`. Polling will/may produce +//! events indicating what happened since the latest polling. +//! + +use bytes::BytesMut; +use futures::prelude::*; +use libp2p::{core::transport::OptionalTransport, core::ConnectedPoint, Multiaddr, Transport, wasm_ext}; +use log::{trace, warn, error}; +use slog::Drain; +use std::{io, time}; +use tokio_io::AsyncWrite; + +mod node; + +/// Timeout after which a connection attempt is considered failed. Includes the WebSocket HTTP +/// upgrading. +const CONNECT_TIMEOUT: time::Duration = time::Duration::from_secs(20); + +/// Event generated when polling the worker. +#[derive(Debug)] +pub enum TelemetryWorkerEvent { + /// We have established a connection to one of the telemetry endpoint, either for the first + /// time or after having been disconnected earlier. + Connected, +} + +/// Telemetry processing machine. +#[derive(Debug)] +pub struct TelemetryWorker { + /// List of nodes with their maximum verbosity level. + nodes: Vec<(node::Node, u8)>, +} + +/// The pile of libp2p transports. +#[cfg(not(target_os = "unknown"))] +type WsTrans = libp2p::core::transport::timeout::TransportTimeout< + libp2p::core::transport::OrTransport< + libp2p::core::transport::map::Map< + OptionalTransport, + fn(wasm_ext::Connection, ConnectedPoint) -> StreamSink + >, + libp2p::websocket::framed::WsConfig> + > +>; +#[cfg(target_os = "unknown")] +type WsTrans = libp2p::core::transport::timeout::TransportTimeout< + libp2p::core::transport::map::Map< + OptionalTransport, + fn(wasm_ext::Connection, ConnectedPoint) -> StreamSink + > +>; + +impl TelemetryWorker { + /// Builds a new `TelemetryWorker`. + /// + /// The endpoints must be a list of targets, plus a verbosity level. When you send a message + /// to the telemetry, only the targets whose verbosity is higher than the verbosity of the + /// message will receive it. + pub fn new( + endpoints: impl IntoIterator, + wasm_external_transport: impl Into> + ) -> Self { + let transport = match wasm_external_transport.into() { + Some(t) => OptionalTransport::some(t), + None => OptionalTransport::none() + }.map((|inner, _| StreamSink(inner)) as fn(_, _) -> _); + + // The main transport is the `wasm_external_transport`, but if we're on desktop we add + // support for TCP+WebSocket+DNS as a fallback. In practice, you're not expected to pass + // an external transport on desktop and the fallback is used all the time. + #[cfg(not(target_os = "unknown"))] + let transport = transport.or_transport({ + let inner = libp2p::dns::DnsConfig::new(libp2p::tcp::TcpConfig::new()); + libp2p::websocket::framed::WsConfig::new(inner) + }); + + let transport = transport.with_timeout(CONNECT_TIMEOUT); + + TelemetryWorker { + nodes: endpoints.into_iter().map(|(addr, verbosity)| { + let node = node::Node::new(transport.clone(), addr); + (node, verbosity) + }).collect() + } + } + + /// Polls the worker for events that happened. + pub fn poll(&mut self) -> Async { + for (node, _) in &mut self.nodes { + loop { + match node.poll() { + Async::Ready(node::NodeEvent::Connected) => + return Async::Ready(TelemetryWorkerEvent::Connected), + Async::Ready(node::NodeEvent::Disconnected(_)) => continue, + Async::NotReady => break, + } + } + } + + Async::NotReady + } + + /// Equivalent to `slog::Drain::log`, but takes `self` by `&mut` instead, which is more convenient. + /// + /// Keep in mind that you should call `TelemetryWorker::poll` in order to process the messages. + /// You should call this function right after calling `slog::Drain::log`. + pub fn log(&mut self, record: &slog::Record, values: &slog::OwnedKVList) -> Result<(), ()> { + let msg_verbosity = match record.tag().parse::() { + Ok(v) => v, + Err(err) => { + warn!(target: "telemetry", "Failed to parse telemetry tag {:?}: {:?}", + record.tag(), err); + return Err(()) + } + }; + + // None of the nodes want that verbosity, so just return without doing any serialization. + if self.nodes.iter().all(|(_, node_max_verbosity)| msg_verbosity > *node_max_verbosity) { + trace!( + target: "telemetry", + "Skipping log entry because verbosity {:?} is too high for all endpoints", + msg_verbosity + ); + return Ok(()) + } + + // Turn the message into JSON. + let serialized = { + let mut out = Vec::new(); + slog_json::Json::default(&mut out).log(record, values).map_err(|_| ())?; + out + }; + + for (node, node_max_verbosity) in &mut self.nodes { + if msg_verbosity > *node_max_verbosity { + trace!(target: "telemetry", "Skipping {:?} for log entry with verbosity {:?}", + node.addr(), msg_verbosity); + continue; + } + + // `send_message` returns an error if we're not connected, which we silently ignore. + let _ = node.send_message(serialized.clone()); + } + + Ok(()) + } +} + +/// Wraps around an `AsyncWrite` and implements `Sink`. Guarantees that each item being sent maps +/// to one call of `write`. +/// +/// For some context, we put this object around the `wasm_ext::ExtTransport` in order to make sure +/// that each telemetry message maps to one single call to `write` in the WASM FFI. +struct StreamSink(T); +impl Sink for StreamSink { + type SinkItem = BytesMut; + type SinkError = io::Error; + + fn start_send(&mut self, item: Self::SinkItem) -> Result, io::Error> { + match self.0.write(&item[..]) { + Ok(n) if n == item.len() => Ok(AsyncSink::Ready), + Ok(_) => { + error!(target: "telemetry", + "Detected some internal buffering happening in the telemetry"); + Err(io::Error::new(io::ErrorKind::Other, "Internal buffering detected")) + }, + Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => Ok(AsyncSink::NotReady(item)), + Err(err) => Err(err), + } + } + + fn poll_complete(&mut self) -> Poll<(), io::Error> { + match self.0.flush() { + Ok(()) => Ok(Async::Ready(())), + Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => Ok(Async::NotReady), + Err(err) => Err(err), + } + } +} diff --git a/core/telemetry/src/worker/node.rs b/core/telemetry/src/worker/node.rs new file mode 100644 index 0000000000..a4d8f8d84e --- /dev/null +++ b/core/telemetry/src/worker/node.rs @@ -0,0 +1,220 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Contains the `Node` struct, which handles communications with a single telemetry endpoint. + +use bytes::BytesMut; +use futures::prelude::*; +use libp2p::Multiaddr; +use libp2p::core::transport::Transport; +use log::{trace, debug, warn, error}; +use rand::Rng as _; +use std::{collections::VecDeque, fmt, mem, time::Duration, time::Instant}; +use tokio_timer::Delay; + +/// Maximum number of pending telemetry messages. +const MAX_PENDING: usize = 10; + +/// Handler for a single telemetry node. +pub struct Node { + /// Address of the node. + addr: Multiaddr, + /// State of the connection. + socket: NodeSocket, + /// Transport used to establish new connections. + transport: TTrans, +} + +enum NodeSocket { + /// We're connected to the node. This is the normal state. + Connected(NodeSocketConnected), + /// We are currently dialing the node. + Dialing(TTrans::Dial), + /// A new connection should be started as soon as possible. + ReconnectNow, + /// Waiting before attempting to dial again. + WaitingReconnect(Delay), + /// Temporary transition state. + Poisoned, +} + +struct NodeSocketConnected { + /// Where to send data. + sink: TTrans::Output, + /// Queue of packets to send. + pending: VecDeque, + /// If true, we need to flush the sink. + need_flush: bool, +} + +/// Event that can happen with this node. +#[derive(Debug)] +pub enum NodeEvent { + /// We are now connected to this node. + Connected, + /// We are now disconnected from this node. + Disconnected(TSinkErr), +} + +impl Node { + /// Builds a new node handler. + pub fn new(transport: TTrans, addr: Multiaddr) -> Self { + Node { + addr, + socket: NodeSocket::ReconnectNow, + transport, + } + } + + /// Returns the address that was passed to `new`. + pub fn addr(&self) -> &Multiaddr { + &self.addr + } +} + +impl Node +where TTrans: Clone, TTrans::Output: Sink, + TSinkErr: fmt::Debug { + /// Sends a WebSocket frame to the node. Returns an error if we are not connected to the node. + /// + /// After calling this method, you should call `poll` in order for it to be properly processed. + pub fn send_message(&mut self, payload: Vec) -> Result<(), ()> { + if let NodeSocket::Connected(NodeSocketConnected { pending, .. }) = &mut self.socket { + if pending.len() <= MAX_PENDING { + trace!(target: "telemetry", "Adding log entry to queue for {:?}", self.addr); + pending.push_back(payload.into()); + Ok(()) + } else { + warn!(target: "telemetry", "Rejected log entry because queue is full for {:?}", + self.addr); + Err(()) + } + } else { + Err(()) + } + } + + /// Polls the node for updates. Must be performed regularly. + pub fn poll(&mut self) -> Async> { + let mut socket = mem::replace(&mut self.socket, NodeSocket::Poisoned); + self.socket = loop { + match socket { + NodeSocket::Connected(mut conn) => match conn.poll(&self.addr) { + Ok(Async::Ready(v)) => void::unreachable(v), + Ok(Async::NotReady) => break NodeSocket::Connected(conn), + Err(err) => { + debug!(target: "telemetry", "Disconnected from {}: {:?}", self.addr, err); + let timeout = gen_rand_reconnect_delay(); + self.socket = NodeSocket::WaitingReconnect(timeout); + return Async::Ready(NodeEvent::Disconnected(err)) + } + } + NodeSocket::Dialing(mut s) => match s.poll() { + Ok(Async::Ready(sink)) => { + debug!(target: "telemetry", "Connected to {}", self.addr); + let conn = NodeSocketConnected { sink, pending: VecDeque::new(), need_flush: false }; + self.socket = NodeSocket::Connected(conn); + return Async::Ready(NodeEvent::Connected) + }, + Ok(Async::NotReady) => break NodeSocket::Dialing(s), + Err(err) => { + debug!(target: "telemetry", "Error while dialing {}: {:?}", self.addr, err); + let timeout = gen_rand_reconnect_delay(); + socket = NodeSocket::WaitingReconnect(timeout); + } + } + NodeSocket::ReconnectNow => match self.transport.clone().dial(self.addr.clone()) { + Ok(d) => { + debug!(target: "telemetry", "Started dialing {}", self.addr); + socket = NodeSocket::Dialing(d); + } + Err(err) => { + debug!(target: "telemetry", "Error while dialing {}: {:?}", self.addr, err); + let timeout = gen_rand_reconnect_delay(); + socket = NodeSocket::WaitingReconnect(timeout); + } + } + NodeSocket::WaitingReconnect(mut s) => if let Ok(Async::Ready(_)) = s.poll() { + socket = NodeSocket::ReconnectNow; + } else { + break NodeSocket::WaitingReconnect(s) + } + NodeSocket::Poisoned => { + error!(target: "telemetry", "Poisoned connection with {}", self.addr); + break NodeSocket::Poisoned + } + } + }; + + Async::NotReady + } +} + +/// Generates a `Delay` object with a random timeout. +/// +/// If there are general connection issues, not all endpoints should be synchronized in their +/// re-connection time. +fn gen_rand_reconnect_delay() -> Delay { + let random_delay = rand::thread_rng().gen_range(5, 10); + Delay::new(Instant::now() + Duration::from_secs(random_delay)) +} + +impl NodeSocketConnected +where TTrans::Output: Sink { + /// Processes the queue of messages for the connected socket. + /// + /// The address is passed for logging purposes only. + fn poll(&mut self, my_addr: &Multiaddr) -> Poll { + loop { + if let Some(item) = self.pending.pop_front() { + let item_len = item.len(); + if let AsyncSink::NotReady(item) = self.sink.start_send(item)? { + self.pending.push_front(item); + break + } else { + trace!(target: "telemetry", "Successfully sent {:?} bytes message to {}", + item_len, my_addr); + self.need_flush = true; + } + + } else if self.need_flush && self.sink.poll_complete()?.is_ready() { + self.need_flush = false; + + } else { + break + } + } + + Ok(Async::NotReady) + } +} + +impl fmt::Debug for Node { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let state = match self.socket { + NodeSocket::Connected(_) => "Connected", + NodeSocket::Dialing(_) => "Dialing", + NodeSocket::ReconnectNow => "Pending reconnect", + NodeSocket::WaitingReconnect(_) => "Pending reconnect", + NodeSocket::Poisoned => "Poisoned", + }; + + f.debug_struct("Node") + .field("addr", &self.addr) + .field("state", &state) + .finish() + } +} diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index ebf96f3fa6..cbbc8402dc 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -128,6 +128,14 @@ name = "base58" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bigint" version = "4.4.1" @@ -617,19 +625,6 @@ name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -799,6 +794,16 @@ dependencies = [ "hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "httparse" version = "1.3.3" @@ -907,11 +912,6 @@ name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.55" @@ -919,13 +919,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -942,6 +942,7 @@ dependencies = [ "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -955,7 +956,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1004,7 +1005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1014,7 +1015,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1030,7 +1031,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1047,7 +1048,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1072,7 +1073,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1096,7 +1097,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1117,7 +1118,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1134,7 +1135,7 @@ dependencies = [ "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1153,7 +1154,7 @@ dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1170,7 +1171,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1182,7 +1183,7 @@ dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1201,7 +1202,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1226,7 +1227,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1239,7 +1240,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1251,20 +1252,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-websocket" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-yamux" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1394,17 +1413,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mio-extras" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mio-uds" version = "0.6.7" @@ -1512,31 +1520,6 @@ name = "opaque-debug" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "openssl" -version = "0.10.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl-sys" -version = "0.9.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "owning_ref" version = "0.3.3" @@ -1744,11 +1727,6 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "pkg-config" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "primitive-types" version = "0.2.4" @@ -2044,6 +2022,19 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustls" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rw-stream-sink" version = "0.1.2" @@ -2094,6 +2085,15 @@ name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sct" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.9.0" @@ -2204,16 +2204,6 @@ dependencies = [ "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "slog-async" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slog-json" version = "2.3.0" @@ -2258,6 +2248,24 @@ dependencies = [ "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "soketto" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sourcefile" version = "0.1.4" @@ -2528,7 +2536,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2671,17 +2679,19 @@ dependencies = [ name = "substrate-telemetry" version = "2.0.0" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2762,11 +2772,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "termcolor" version = "1.0.4" @@ -2938,6 +2943,19 @@ dependencies = [ "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-rustls" +version = "0.10.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-sync" version = "0.1.5" @@ -3148,11 +3166,6 @@ name = "utf8-ranges" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "vcpkg" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "version_check" version = "0.1.5" @@ -3279,6 +3292,24 @@ dependencies = [ "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "webpki" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webpki-roots" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "weedle" version = "0.9.0" @@ -3333,24 +3364,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -3426,6 +3439,7 @@ dependencies = [ "checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" +"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" @@ -3486,8 +3500,6 @@ dependencies = [ "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" "checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" @@ -3510,6 +3522,7 @@ dependencies = [ "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" +"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -3525,10 +3538,9 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" -"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6abde4e6fc777dc06ae2a15202ddedb1a38d7c71ed16bc10fa704b03f73aec37" +"checksum libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ceb4791289534d4c1ad8e4bd3c6f06d3670efa55ce71482951a287df93ddd1" "checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" "checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" "checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" @@ -3545,6 +3557,7 @@ dependencies = [ "checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" "checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" "checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d1bfe60577558f48a9fdf9f35c0ee2dc5baa01f685ff847d3b5cf4f12ee135" "checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" @@ -3560,7 +3573,6 @@ dependencies = [ "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f989d40aab0ed0d83c1cdb4856b5790e980b96548d1a921f280e985eb049f38d" @@ -3574,8 +3586,6 @@ dependencies = [ "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" -"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" @@ -3597,7 +3607,6 @@ dependencies = [ "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" "checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" @@ -3632,12 +3641,14 @@ dependencies = [ "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" "checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3651,11 +3662,11 @@ dependencies = [ "checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" -"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60c04b4726fa04595ccf2c2dad7bcd15474242c4c5e109a8a376e8a2c9b1539a" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" +"checksum soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cf3ae22c0bce5437c7dce6a2b00e492c19da1feb21ad64a7b6fd7058438c3f2" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" @@ -3669,7 +3680,6 @@ dependencies = [ "checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" @@ -3685,6 +3695,7 @@ dependencies = [ "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" +"checksum tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "316fdbc899efec48b3b492bd0f339e6d81c4ee96a409257572147ec341943452" "checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" @@ -3708,7 +3719,6 @@ dependencies = [ "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" @@ -3722,6 +3732,8 @@ dependencies = [ "checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" "checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f7e1cd7900a3a6b65a3e8780c51a3e6b59c0e2c55c6dc69578c288d69f7d082" +"checksum webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c10fa4212003ba19a564f25cd8ab572c6791f99a03cc219c13ed35ccab00de0e" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" @@ -3730,7 +3742,6 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index ec014da1b9..14398725e5 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -128,6 +128,14 @@ name = "base58" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bigint" version = "4.4.1" @@ -617,19 +625,6 @@ name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -799,6 +794,16 @@ dependencies = [ "hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "httparse" version = "1.3.3" @@ -907,11 +912,6 @@ name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.55" @@ -919,13 +919,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -942,6 +942,7 @@ dependencies = [ "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -955,7 +956,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1004,7 +1005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1014,7 +1015,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1030,7 +1031,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1047,7 +1048,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1072,7 +1073,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1096,7 +1097,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1117,7 +1118,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1134,7 +1135,7 @@ dependencies = [ "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1153,7 +1154,7 @@ dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1170,7 +1171,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1182,7 +1183,7 @@ dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1201,7 +1202,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1226,7 +1227,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1239,7 +1240,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1251,20 +1252,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-websocket" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-yamux" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1394,17 +1413,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mio-extras" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mio-uds" version = "0.6.7" @@ -1546,31 +1554,6 @@ name = "opaque-debug" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "openssl" -version = "0.10.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl-sys" -version = "0.9.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "owning_ref" version = "0.3.3" @@ -1778,11 +1761,6 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "pkg-config" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "primitive-types" version = "0.2.4" @@ -2078,6 +2056,19 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustls" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rw-stream-sink" version = "0.1.2" @@ -2128,6 +2119,15 @@ name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sct" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.9.0" @@ -2238,16 +2238,6 @@ dependencies = [ "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "slog-async" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slog-json" version = "2.3.0" @@ -2292,6 +2282,24 @@ dependencies = [ "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "soketto" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sourcefile" version = "0.1.4" @@ -2671,7 +2679,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2798,17 +2806,19 @@ dependencies = [ name = "substrate-telemetry" version = "2.0.0" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2855,11 +2865,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "termcolor" version = "1.0.4" @@ -3031,6 +3036,19 @@ dependencies = [ "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-rustls" +version = "0.10.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-sync" version = "0.1.5" @@ -3241,11 +3259,6 @@ name = "utf8-ranges" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "vcpkg" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "version_check" version = "0.1.5" @@ -3372,6 +3385,24 @@ dependencies = [ "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "webpki" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webpki-roots" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "weedle" version = "0.9.0" @@ -3426,24 +3457,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -3519,6 +3532,7 @@ dependencies = [ "checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" +"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" @@ -3579,8 +3593,6 @@ dependencies = [ "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" "checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" @@ -3603,6 +3615,7 @@ dependencies = [ "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" +"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -3618,10 +3631,9 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" -"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6abde4e6fc777dc06ae2a15202ddedb1a38d7c71ed16bc10fa704b03f73aec37" +"checksum libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ceb4791289534d4c1ad8e4bd3c6f06d3670efa55ce71482951a287df93ddd1" "checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" "checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" "checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" @@ -3638,6 +3650,7 @@ dependencies = [ "checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" "checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" "checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d1bfe60577558f48a9fdf9f35c0ee2dc5baa01f685ff847d3b5cf4f12ee135" "checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" @@ -3653,7 +3666,6 @@ dependencies = [ "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f989d40aab0ed0d83c1cdb4856b5790e980b96548d1a921f280e985eb049f38d" @@ -3667,8 +3679,6 @@ dependencies = [ "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" -"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" @@ -3690,7 +3700,6 @@ dependencies = [ "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" "checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" @@ -3725,12 +3734,14 @@ dependencies = [ "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" "checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3744,11 +3755,11 @@ dependencies = [ "checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" -"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60c04b4726fa04595ccf2c2dad7bcd15474242c4c5e109a8a376e8a2c9b1539a" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" +"checksum soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cf3ae22c0bce5437c7dce6a2b00e492c19da1feb21ad64a7b6fd7058438c3f2" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" @@ -3762,7 +3773,6 @@ dependencies = [ "checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" @@ -3778,6 +3788,7 @@ dependencies = [ "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" +"checksum tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "316fdbc899efec48b3b492bd0f339e6d81c4ee96a409257572147ec341943452" "checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" @@ -3801,7 +3812,6 @@ dependencies = [ "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" @@ -3815,6 +3825,8 @@ dependencies = [ "checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" "checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f7e1cd7900a3a6b65a3e8780c51a3e6b59c0e2c55c6dc69578c288d69f7d082" +"checksum webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c10fa4212003ba19a564f25cd8ab572c6791f99a03cc219c13ed35ccab00de0e" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" @@ -3823,7 +3835,6 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index d72146ad03..ab9b39afbd 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -128,6 +128,14 @@ name = "base58" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bigint" version = "4.4.1" @@ -617,19 +625,6 @@ name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -799,6 +794,16 @@ dependencies = [ "hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "httparse" version = "1.3.3" @@ -907,11 +912,6 @@ name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.55" @@ -919,13 +919,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -942,6 +942,7 @@ dependencies = [ "libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -955,7 +956,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1004,7 +1005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1014,7 +1015,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1030,7 +1031,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1047,7 +1048,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1072,7 +1073,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1096,7 +1097,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1117,7 +1118,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1134,7 +1135,7 @@ dependencies = [ "curve25519-dalek 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1153,7 +1154,7 @@ dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1170,7 +1171,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1182,7 +1183,7 @@ dependencies = [ "aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1201,7 +1202,7 @@ dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1226,7 +1227,7 @@ dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1239,7 +1240,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1251,20 +1252,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libp2p-websocket" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "libp2p-yamux" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1394,17 +1413,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mio-extras" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mio-uds" version = "0.6.7" @@ -1568,31 +1576,6 @@ name = "opaque-debug" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "openssl" -version = "0.10.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl-sys" -version = "0.9.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "owning_ref" version = "0.3.3" @@ -1800,11 +1783,6 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "pkg-config" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "primitive-types" version = "0.2.4" @@ -2110,6 +2088,19 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustls" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rw-stream-sink" version = "0.1.2" @@ -2160,6 +2151,15 @@ name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sct" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.9.0" @@ -2270,16 +2270,6 @@ dependencies = [ "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "slog-async" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slog-json" version = "2.3.0" @@ -2324,6 +2314,24 @@ dependencies = [ "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "soketto" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sourcefile" version = "0.1.4" @@ -2806,7 +2814,7 @@ dependencies = [ "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2944,17 +2952,19 @@ dependencies = [ name = "substrate-telemetry" version = "2.0.0" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3001,11 +3011,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "termcolor" version = "1.0.4" @@ -3177,6 +3182,19 @@ dependencies = [ "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-rustls" +version = "0.10.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-sync" version = "0.1.5" @@ -3387,11 +3405,6 @@ name = "utf8-ranges" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "vcpkg" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "version_check" version = "0.1.5" @@ -3519,6 +3532,24 @@ dependencies = [ "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "webpki" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "webpki-roots" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "weedle" version = "0.9.0" @@ -3573,24 +3604,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -3666,6 +3679,7 @@ dependencies = [ "checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" +"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" @@ -3726,8 +3740,6 @@ dependencies = [ "checksum fixed-hash 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a683d1234507e4f3bf2736eeddf0de1dc65996dc0164d57eba0a74bcf29489" "checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" @@ -3750,6 +3762,7 @@ dependencies = [ "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f127a908633569f208325f86f71255d3363c79721d7f9fe31cd5569908819771" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" +"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -3765,10 +3778,9 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" -"checksum libp2p 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f91d477f61c3451da12de273cbf281a1828eea686248999412e6e6fb23dcbc60" -"checksum libp2p-core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "805f65e99f0c4cc4d6234263325f288fb231468b128dd66e469d4851141f3a26" +"checksum libp2p 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6abde4e6fc777dc06ae2a15202ddedb1a38d7c71ed16bc10fa704b03f73aec37" +"checksum libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ceb4791289534d4c1ad8e4bd3c6f06d3670efa55ce71482951a287df93ddd1" "checksum libp2p-core-derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "851a59dcaab66c96777ae0cace96de88a700243c3b8360ab51c7e093f3727066" "checksum libp2p-deflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "902b44e92e1f8b7e697b3a186d15c841e0e38037f14286513207a5407650a635" "checksum libp2p-dns 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6630a84552b39e5f752e1f6a951d31f3211079465d2e7af73491b6f48fc3f" @@ -3785,6 +3797,7 @@ dependencies = [ "checksum libp2p-tcp 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c54cb75f17557de6ce0149aa03e729455e2d240f84d854272bc4b11012a324" "checksum libp2p-uds 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbedf4a1e72a5f67523915414e9e12d71d128731873f0f24d8b878398fb47aa4" "checksum libp2p-wasm-ext 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c1f615b56aa2a6f4ec07bf9667be9fff8877b9c5bd5335601af47490eda341" +"checksum libp2p-websocket 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d1bfe60577558f48a9fdf9f35c0ee2dc5baa01f685ff847d3b5cf4f12ee135" "checksum libp2p-yamux 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf4bfc7ff127cd622502dbe56f10513dd6776b970e33d8ebb6e367f0752324f6" "checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" @@ -3800,7 +3813,6 @@ dependencies = [ "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f989d40aab0ed0d83c1cdb4856b5790e980b96548d1a921f280e985eb049f38d" @@ -3814,8 +3826,6 @@ dependencies = [ "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" -"checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" -"checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" @@ -3837,7 +3847,6 @@ dependencies = [ "checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6" "checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6e8612a8dc70f26276fed6131c153ca277cf275ee0a5e2a50cd8a69c697beb8f" "checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" "checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8" @@ -3873,12 +3882,14 @@ dependencies = [ "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" "checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5eff518f9bed3d803a0d002af0ab96339b0ebbedde3bec98a684986134b7a39" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" @@ -3892,11 +3903,11 @@ dependencies = [ "checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e1a2eec401952cd7b12a84ea120e2d57281329940c3f93c2bf04f462539508e" -"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60c04b4726fa04595ccf2c2dad7bcd15474242c4c5e109a8a376e8a2c9b1539a" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" +"checksum soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cf3ae22c0bce5437c7dce6a2b00e492c19da1feb21ad64a7b6fd7058438c3f2" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" @@ -3910,7 +3921,6 @@ dependencies = [ "checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" @@ -3926,6 +3936,7 @@ dependencies = [ "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" +"checksum tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "316fdbc899efec48b3b492bd0f339e6d81c4ee96a409257572147ec341943452" "checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" @@ -3949,7 +3960,6 @@ dependencies = [ "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" @@ -3963,6 +3973,8 @@ dependencies = [ "checksum wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aebbaef470840d157a5c47c8c49f024da7b1b80e90ff729ca982b2b80447e78b" "checksum wasmi-validation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab380192444b3e8522ae79c0a1976e42a82920916ccdfbce3def89f456ea33f3" "checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f7e1cd7900a3a6b65a3e8780c51a3e6b59c0e2c55c6dc69578c288d69f7d082" +"checksum webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c10fa4212003ba19a564f25cd8ab572c6791f99a03cc219c13ed35ccab00de0e" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" @@ -3971,7 +3983,6 @@ dependencies = [ "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee1585dc1484373cbc1cee7aafda26634665cf449436fd6e24bfd1fad230538" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" -- GitLab From d91ea1c6c919a53cc40b721493f7272b0d1947f8 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Thu, 6 Jun 2019 16:16:24 -0400 Subject: [PATCH 098/113] Move Council and Democracy logic to block initialization (#2806) * s/on_finalize/on_initialize * bump impl_version --- node/runtime/src/lib.rs | 2 +- srml/council/src/seats.rs | 2 +- srml/democracy/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index f0c1a8ae7d..c5104f331e 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 92, - impl_version: 92, + impl_version: 93, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/council/src/seats.rs b/srml/council/src/seats.rs index 584a2fb800..15817df70b 100644 --- a/srml/council/src/seats.rs +++ b/srml/council/src/seats.rs @@ -305,7 +305,7 @@ decl_module! { >::put(count); } - fn on_finalize(n: T::BlockNumber) { + fn on_initialize(n: T::BlockNumber) { if let Err(e) = Self::end_block(n) { print("Guru meditation"); print(e); diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index 96d51849c9..2ccff71869 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -485,7 +485,7 @@ decl_module! { } } - fn on_finalize(n: T::BlockNumber) { + fn on_initialize(n: T::BlockNumber) { if let Err(e) = Self::end_block(n) { runtime_io::print(e); } -- GitLab From 1407e56f83c7cdc6e4788e5252457949abba68af Mon Sep 17 00:00:00 2001 From: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> Date: Thu, 6 Jun 2019 16:16:59 -0400 Subject: [PATCH 099/113] Add digest subtypes and update dependencies (#2734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add different digest types for different parts of the code * Add script to update dependencies * Remove an old changelog * `Inherent` → `PreRuntime` --- core/client/src/client.rs | 2 +- core/sr-primitives/src/generic/digest.rs | 171 +++++++++++++++++++---- core/sr-primitives/src/generic/mod.rs | 4 +- core/test-runtime/wasm/Cargo.lock | 6 +- node-template/runtime/wasm/Cargo.lock | 6 +- node/runtime/wasm/Cargo.lock | 6 +- scripts/update-deps.sh | 9 ++ 7 files changed, 166 insertions(+), 38 deletions(-) create mode 100755 scripts/update-deps.sh diff --git a/core/client/src/client.rs b/core/client/src/client.rs index b076d24b18..59af1b6419 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -482,7 +482,7 @@ impl Client where if first > last_num { return Err(error::Error::ChangesTrieAccessFailed("Invalid changes trie range".into())); } - let finalized_number = self.backend.blockchain().info().finalized_number; + let finalized_number = self.backend.blockchain().info().finalized_number; let oldest = storage.oldest_changes_trie_block(&config, finalized_number); let first = ::std::cmp::max(first, oldest); Ok(Some((first, last))) diff --git a/core/sr-primitives/src/generic/digest.rs b/core/sr-primitives/src/generic/digest.rs index 79a2991e5f..c0724bb134 100644 --- a/core/sr-primitives/src/generic/digest.rs +++ b/core/sr-primitives/src/generic/digest.rs @@ -58,34 +58,151 @@ impl traits::Digest for Digest where } } -/// Digest item that is able to encode/decode 'system' digest items and -/// provide opaque access to other items. -#[derive(PartialEq, Eq, Clone)] -#[cfg_attr(feature = "std", derive(Debug))] -pub enum DigestItem { - /// System digest item announcing that authorities set has been changed - /// in the block. Contains the new set of authorities. - AuthoritiesChange(Vec), - /// System digest item that contains the root of changes trie at given - /// block. It is created for every block iff runtime supports changes - /// trie creation. - ChangesTrieRoot(Hash), - /// A message from the runtime to the consensus engine. This should *never* - /// be generated by the native code of any consensus engine, but this is not - /// checked (yet). - Consensus(ConsensusEngineId, Vec), - /// Put a Seal on it. This is only used by native code, and is never seen - /// by runtimes. - Seal(ConsensusEngineId, SealSignature), - /// A pre-runtime digest. +// Macro black magic. +macro_rules! gen_digest_type { + ( + $( #[doc = $main_docs:tt] )* + pub enum $main:ident $(<$($main_params: tt),+>)? { } + $( + $( #[doc = $doc_attr:tt] )* + pub enum $n:ident $(<$($t: tt),+>)? { + $( + $( #[doc = $variant_doc:tt] )* + $variant:ident(($($interior: ty),*), $q: tt), + )* + } + )+ + ) => { + $( #[doc = $main_docs] )* + #[derive(PartialEq, Eq, Clone)] + #[cfg_attr(feature = "std", derive(Debug))] + pub enum $main $(<$($main_params),+>)? { + $( + $( + $( #[doc = $variant_doc] )* + $variant($($interior),*), + )* + )* + } + + gen_digest_type! { + @internal + $main : $main $(<$($main_params),+>)? => $( + $( #[doc = $doc_attr] )* + pub enum $n $(<$($t),+>)? { + $( + $( #[doc = $variant_doc] )* + $variant(($($interior),*), $q), + )* + } + )+ + } + }; + ( + @internal + $main_id:tt : $main:ty => $( + $( #[doc = $doc_attr:tt] )* + pub enum $n:ident $(<$($t: tt),+>)? { + $( + $( #[doc = $variant_doc:tt] )* + $variant:ident(($($interior: ty),*), $q: tt), + )* + } + )+ + ) => { + $( + $( #[doc = $doc_attr] )* + #[derive(PartialEq, Eq, Clone)] + #[cfg_attr(feature = "std", derive(Debug))] + pub enum $n $(<$($t),+>)? { + $( + $( #[doc = $variant_doc] )* + $variant($($interior),*), + )* + } + + impl From<$n $(<$($t),*>)?> + for $main { + fn from(digest: $n $(<$($t),+>)?) -> Self { + match digest { + $( + $n::$variant $q => $main_id::$variant $q, + )* + } + } + } + )* + }; +} + +gen_digest_type! { + /// Digest item that is able to encode/decode 'system' digest items and + /// provide opaque access to other items. /// - /// These are messages from the consensus engine to the runtime, although - /// the consensus engine can (and should) read them itself to avoid - /// code and state duplication. It is erroneous for a runtime to produce - /// these, but this is not (yet) checked. - PreRuntime(ConsensusEngineId, Vec), - /// Any 'non-system' digest item, opaque to the native code. - Other(Vec), + /// For all variants that include a `ConsensusEngineId`, consensus engine + /// implementations **MUST** ignore digests that have a `ConsensusEngineId` + /// that is not theirs. Node implementations **MUST** reject digests that + /// have a `ConsensusEngineId` that corresponds to a consensus engine not in + /// use. Node implementations **MUST** reject blocks as malformed if they + /// reject any of the block’s digest. If the runtime supports this, the + /// node that issued the block **SHOULD** be reported as having committed + /// severe misbehavior and punished accordingly. The invalid block, or its + /// hash, **SHOULD** constitute adequate proof of such misbehavior. + pub enum DigestItem {} + + /// A digest item that can be produced by consensus engines. Consensus + /// engine implementations **MUST NOT** push digests not in this variant. + /// This **SHOULD** be detected at compile time. If it is not, the behavior + /// of the blockchain is undefined. + pub enum ConsensusDigest { + /// Put a Seal on it. This **MUST** come after all other `DigestItem` + /// variants. There **MUST** be exactly one `Seal` per consensus engine, + /// and its `ConsensusEngineId` **MUST** be that of the consensus engine + /// that produced it. Runtimes will not see this variant. + Seal((ConsensusEngineId, SealSignature), (a, b)), + /// An inherent digest. + /// + /// These are messages from the consensus engine to the runtime, + /// although the consensus engine can (and should) read them itself to + /// avoid code and state duplication. It is erroneous for a runtime to + /// produce these, but this is checked at compile time. Runtimes can + /// (and should) trust these, as with any other inherent. Consensus + /// engines MUST verify them. + PreRuntime((ConsensusEngineId, Vec), (a, b)), + } + + /// A digest item that can be produced by runtimes. Runtime mplementations + /// **MUST NOT** push digests not in this variant. This **SHOULD** be + /// detected at compile time. If it is not, the behavior of the blockchain + /// is undefined. + pub enum RuntimeDigest { + /// A message from the runtime to the consensus engine. This MUST NOT be + /// generated by the native code of any consensus engine, but this is + /// caught at compile time. The `ConsensusEngineId` is that of the + /// consensus engine for which this digest is intended. Consensus + /// engines MUST ignore digests with `ConsensusEngineId`s other than + /// their own. + Consensus((ConsensusEngineId, Vec), (a, b)), + /// Any 'non-system' digest item, opaque to the native code. Runtimes + /// MUST verify these, and reject any they did not produce. These MUST + /// NOT be produced by native code. + Other((Vec), (a)), + } + + /// A digest item that is reserved for the SRML. Only the SRML is allowed to + /// push these digests. Consensus engines and third-party runtime code + /// **MUST NOT** push digests in this variant. This **SHOULD** be detected + /// at compile time. If it is not, the behavior of the blockchain is + /// undefined. + pub enum SystemDigest { + /// System digest item announcing that authorities set has been changed + /// in the block. Contains the new set of authorities. + AuthoritiesChange((Vec), (a)), + /// System digest item that contains the root of changes trie at given + /// block. It is created for every block iff runtime supports changes + /// trie creation. + ChangesTrieRoot((Hash), (a)), + } } #[cfg(feature = "std")] diff --git a/core/sr-primitives/src/generic/mod.rs b/core/sr-primitives/src/generic/mod.rs index 89c4291d79..d9c53c5fd4 100644 --- a/core/sr-primitives/src/generic/mod.rs +++ b/core/sr-primitives/src/generic/mod.rs @@ -36,7 +36,9 @@ pub use self::era::{Era, Phase}; pub use self::checked_extrinsic::CheckedExtrinsic; pub use self::header::Header; pub use self::block::{Block, SignedBlock, BlockId}; -pub use self::digest::{Digest, DigestItem, DigestItemRef}; +pub use self::digest::{ + Digest, DigestItem, DigestItemRef, ConsensusDigest, RuntimeDigest, SystemDigest, +}; use crate::codec::Encode; use rstd::prelude::*; diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index cbbc8402dc..be1e3ab84f 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2006,7 +2006,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3638,7 +3638,7 @@ dependencies = [ "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" +"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" diff --git a/node-template/runtime/wasm/Cargo.lock b/node-template/runtime/wasm/Cargo.lock index 14398725e5..c94150dc5b 100644 --- a/node-template/runtime/wasm/Cargo.lock +++ b/node-template/runtime/wasm/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2040,7 +2040,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3731,7 +3731,7 @@ dependencies = [ "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" +"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index ab9b39afbd..050cbdcb7e 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2072,7 +2072,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3879,7 +3879,7 @@ dependencies = [ "checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" +"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f271e3552cd835fa28c541c34a7e8fdd8cdff09d77fe4eb8f6c42e87a11b096e" diff --git a/scripts/update-deps.sh b/scripts/update-deps.sh new file mode 100755 index 0000000000..cd6b7c8538 --- /dev/null +++ b/scripts/update-deps.sh @@ -0,0 +1,9 @@ +#!/bin/sh -- +set -eu +case $0 in + (/*) dir=${0%/*}/;; + (*/*) dir=./${0%/*};; + (*) dir=.;; +esac + +find "$dir/.." -name Cargo.lock -execdir cargo update \; -- GitLab From 12f4f5d8a63df924937b0e7c69a862bf8ac82ffe Mon Sep 17 00:00:00 2001 From: Sergei Pepyakin Date: Fri, 7 Jun 2019 14:14:18 +0200 Subject: [PATCH 100/113] srml-contract: update complexity.md (#2795) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update COMPLEXITY.md * Update the doc. * Mention child tries. And format. * most probably → most likely * Update for state rent * Apply suggestions from code review Co-Authored-By: thiolliere * Update COMPLEXITY.md --- srml/contract/COMPLEXITY.md | 63 ++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/srml/contract/COMPLEXITY.md b/srml/contract/COMPLEXITY.md index c2d75efaba..d87525a982 100644 --- a/srml/contract/COMPLEXITY.md +++ b/srml/contract/COMPLEXITY.md @@ -83,7 +83,25 @@ The size of the arguments and the return value depends on the exact function in `AccountDb` is an abstraction that supports collecting changes to accounts with the ability to efficiently reverting them. Contract execution contexts operate on the AccountDb. All changes are flushed into underlying storage only after origin transaction succeeds. -Today `AccountDb` is implemented as a cascade of overlays with the direct storage at the bottom. Each overlay is represented by a `Map`. On a commit from an overlay to an overlay, maps are merged. On commit from an overlay to the bottommost `AccountDb` all changes are flushed to the storage. On revert, the overlay is just discarded. +## Relation to the underlying storage + +At present, `AccountDb` is implemented as a cascade of overlays with the direct storage at the bottom. The direct +storage `AccountDb` leverages child tries. Each overlay is represented by a `Map`. On a commit from an overlay to an +overlay, maps are merged. On commit from an overlay to the bottommost `AccountDb` all changes are flushed to the storage +and on revert, the overlay is just discarded. + +> ℹ️ The underlying storage has a overlay layer implemented as a `Map`. If the runtime reads a storage location and the +> respective key doesn't exist in the overlay, then the underlying storage performs a DB access, but the value won't be +> placed into the overlay. The overlay is only filled with writes. +> +> This means that the overlay can be abused in the following ways: +> +> - The overlay can be inflated by issuing a lot of writes to unique locations, +> - Deliberate cache misses can be induced by reading non-modified storage locations, + +It also worth noting that the performance degrades with more state stored in the trie. Due to this +there is not negligible chance that gas schedule will be updated for all operations that involve +storage access. ## get_storage, get_code_hash, get_rent_allowance, get_balance, contract_exists @@ -158,20 +176,36 @@ Assuming marshaled size of a balance value is of the constant size we can neglec This function receives input data for the contract execution. The execution consists of the following steps: -1. Loading code from the DB. -2. `transfer`-ing funds between the caller and the destination account. -3. Executing the code of the destination account. -4. Committing overlayed changed to the underlying `AccountDb`. +1. Checking rent payment. +2. Loading code from the DB. +3. `transfer`-ing funds between the caller and the destination account. +4. Executing the code of the destination account. +5. Committing overlayed changed to the underlying `AccountDb`. **Note** that the complexity of executing the contract code should be considered separately. -Loading code most probably will trigger a DB read, since the code is immutable and therefore will not get into the cache (unless a suicide removes it). +Checking for rent involves 2 unconditional DB reads: `ContractInfoOf` and `block_number` +and on top of that at most once per block: + +- DB read to `free_balance` and +- `rent_deposit_offset` and +- `rent_byte_price` and +- `Currency::minimum_balance` and +- `tombstone_deposit`. +- Calls to `ensure_can_withdraw`, `withdraw`, `make_free_balance_be` can perform arbitrary logic and should be considered separately, +- `child_storage_root` +- `kill_child_storage` +- mutation of `ContractInfoOf` + +Loading code most likely will trigger a DB read, since the code is immutable and therefore will not get into the cache (unless a suicide removes it, or it has been created in the same call chain). Also, `transfer` can make up to 2 DB reads and up to 2 DB writes (if flushed to the storage) in the standard case. If removal of the source account takes place then it will additionally perform a DB write per one storage entry that the account has. Finally, all changes are `commit`-ted into the underlying overlay. The complexity of this depends on the number of changes performed by the code. Thus, the pricing of storage modification should account for that. -**complexity**: Up to 3 DB reads. DB read of the code is of dynamic size. There can also be up to 2 DB writes (if flushed to the storage). Additionally, if the source account removal takes place a DB write will be performed per one storage entry that the account has. +**complexity**: +- Only for the first invocation of the contract: up to 5 DB reads and one DB write as well as logic executed by `ensure_can_withdraw`, `withdraw`, `make_free_balance_be`. +- On top of that for every invocation: Up to 5 DB reads. DB read of the code is of dynamic size. There can also be up to 2 DB writes (if flushed to the storage). Additionally, if the source account removal takes place a DB write will be performed per one storage entry that the account has. ## Create @@ -185,7 +219,7 @@ This function takes the code of the constructor and input data. Creation of a co **Note** that the complexity of executing the constructor code should be considered separately. -**Note** that the complexity of `DetermineContractAddress` hook should be considered separately as well. Most probably it will use some kind of hashing over the code of the constructor and input data. The default `SimpleAddressDeterminator` does precisely that. +**Note** that the complexity of `DetermineContractAddress` hook should be considered separately as well. Most likely it will use some kind of hashing over the code of the constructor and input data. The default `SimpleAddressDeterminator` does precisely that. **Note** that the constructor returns code in the owned form and it's obtained via return facilities, which should have take fee for the return value. @@ -224,9 +258,11 @@ This function receives a `key` as an argument. It consists of the following step Key is of a constant size. Therefore, the sandbox memory load can be considered to be of constant complexity. -However, a read from the contract's storage can hit the DB, and the size of this read is dynamical. +Unless the value is cached, a DB read will be performed. The size of the value is not known until the read is +performed. Moreover, the DB read has to be synchronous and no progress can be made until the value is fetched. -**complexity**: The memory and computing complexity is proportional to the size of the fetched value. +**complexity**: The memory and computing complexity is proportional to the size of the fetched value. This function performs a +DB read. ## ext_call @@ -242,7 +278,7 @@ It consists of the following steps: 1. Loading `callee` buffer from the sandbox memory (see sandboxing memory get) and then decoding it. 2. Loading `value` buffer from the sandbox memory and then decoding it. 3. Loading `input_data` buffer from the sandbox memory. -4. Invoking `call` executive function. +4. Invoking the executive function `call`. Loading of `callee` and `value` buffers should be charged. This is because the sizes of buffers are specified by the calling code, even though marshaled representations are, essentially, of constant size. This can be fixed by assigning an upper bound for sizes of `AccountId` and `Balance`. @@ -326,6 +362,8 @@ This function copies slice of data from the input buffer to the sandbox memory. ## ext_scratch_size +This function returns the size of the scratch buffer. + **complexity**: This function is of constant complexity. ## ext_scratch_copy @@ -356,4 +394,5 @@ It consists of the following steps: 1. Invoking `get_rent_allowance` AccountDB function. 2. Serializing the rent allowance of the current contract into the scratch buffer. -**complexity**: Assuming that the rent allowance is of constant size, this function has constant complexity. +**complexity**: Assuming that the rent allowance is of constant size, this function has constant complexity. This +function performs a DB read. -- GitLab From 840456893df7170c5bed55cb565ead678339b43b Mon Sep 17 00:00:00 2001 From: Kian Peymani Date: Fri, 7 Jun 2019 15:27:32 +0200 Subject: [PATCH 101/113] Enhanced Council. (#2407) * first --unclean-- working version of locks and weight decay * Refactor voter activity history. * Tuning offset calculation and tests * Remove print. * Configurable decay ratio. * Remove spaces. * Name for activity. * Fix some style * Re-write voters as chunked map-vec. * Adds panic todo. * Fix some of the grumbles. * Fix some of the grumbles. * Chunked approvals vector. * Introduce voter_index for set_approvas in favor of complexity. * Add a bit more docs * Add boolean approvals as scalar. * Some cleanups TODO removes. * enhance some error checking. * No more double_map * Combined voter info and fee. * Fix global tests * Bump. * Fix line length * Fix error message. * Kill As. * Final fix. * _Further_ kill As. * Proper imbalance for fee. * Bump. * Fix spacing. * Update * Address grumbles. * Line width. --- node/cli/src/chain_spec.rs | 7 +- node/runtime/src/lib.rs | 3 + srml/council/src/lib.rs | 116 ++- srml/council/src/motions.rs | 32 +- srml/council/src/seats.rs | 1659 +++++++++++++++++++++++++++++------ srml/indices/src/lib.rs | 2 +- 6 files changed, 1485 insertions(+), 334 deletions(-) diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index bc24de9ddf..242c5078f5 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -124,12 +124,14 @@ fn staging_testnet_config_genesis() -> GenesisConfig { active_council: vec![], candidacy_bond: 10 * DOLLARS, voter_bond: 1 * DOLLARS, + voting_fee: 2 * DOLLARS, present_slash_per_voter: 1 * CENTS, carry_count: 6, presentation_duration: 1 * DAYS, approval_voting_period: 2 * DAYS, term_duration: 28 * DAYS, desired_seats: 0, + decay_ratio: 0, inactive_grace_period: 1, // one additional vote should go by before an inactive voter can be reaped. }), timestamp: Some(TimestampConfig { @@ -234,6 +236,7 @@ pub fn testnet_genesis( const STASH: u128 = 1 << 20; const ENDOWMENT: u128 = 1 << 20; + let council_desired_seats = (endowed_accounts.len() / 2 - initial_authorities.len()) as u32; let mut contract_config = ContractConfig { signed_claim_handicap: 2, rent_byte_price: 4, @@ -299,12 +302,14 @@ pub fn testnet_genesis( .map(|a| (a.clone(), 1000000)).collect(), candidacy_bond: 10, voter_bond: 2, + voting_fee: 5, present_slash_per_voter: 1, carry_count: 4, presentation_duration: 10, approval_voting_period: 20, term_duration: 1000000, - desired_seats: (endowed_accounts.len() / 2 - initial_authorities.len()) as u32, + desired_seats: council_desired_seats, + decay_ratio: council_desired_seats / 3, inactive_grace_period: 1, }), timestamp: Some(TimestampConfig { diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index c5104f331e..427ee8d1fc 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -182,9 +182,12 @@ impl council::Trait for Runtime { type Event = Event; type BadPresentation = (); type BadReaper = (); + type BadVoterIndex = (); + type LoserCandidate = (); type OnMembersChanged = CouncilMotions; } + impl council::motions::Trait for Runtime { type Origin = Origin; type Proposal = Call; diff --git a/srml/council/src/lib.rs b/srml/council/src/lib.rs index a72e93c9eb..fd69805732 100644 --- a/srml/council/src/lib.rs +++ b/srml/council/src/lib.rs @@ -116,6 +116,8 @@ mod tests { type Event = Event; type BadPresentation = (); type BadReaper = (); + type BadVoterIndex = (); + type LoserCandidate = (); type OnMembersChanged = CouncilMotions; } impl motions::Trait for Test { @@ -124,35 +126,91 @@ mod tests { type Event = Event; } - pub fn new_test_ext(with_council: bool) -> runtime_io::TestExternalities { - let mut t = system::GenesisConfig::::default().build_storage().unwrap().0; - t.extend(balances::GenesisConfig::{ - transaction_base_fee: 0, - transaction_byte_fee: 0, - balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - existential_deposit: 0, - transfer_fee: 0, - creation_fee: 0, - vesting: vec![], - }.build_storage().unwrap().0); - t.extend(democracy::GenesisConfig::::default().build_storage().unwrap().0); - t.extend(seats::GenesisConfig:: { - candidacy_bond: 9, - voter_bond: 3, - present_slash_per_voter: 1, - carry_count: 2, - inactive_grace_period: 1, - active_council: if with_council { vec![ - (1, 10), - (2, 10), - (3, 10) - ] } else { vec![] }, - approval_voting_period: 4, - presentation_duration: 2, - desired_seats: 2, - term_duration: 5, - }.build_storage().unwrap().0); - runtime_io::TestExternalities::new(t) + pub struct ExtBuilder { + balance_factor: u64, + decay_ratio: u32, + voting_fee: u64, + voter_bond: u64, + bad_presentation_punishment: u64, + with_council: bool, + } + + impl Default for ExtBuilder { + fn default() -> Self { + Self { + balance_factor: 1, + decay_ratio: 24, + voting_fee: 0, + voter_bond: 0, + bad_presentation_punishment: 1, + with_council: false, + } + } + } + + impl ExtBuilder { + pub fn with_council(mut self, council: bool) -> Self { + self.with_council = council; + self + } + pub fn balance_factor(mut self, factor: u64) -> Self { + self.balance_factor = factor; + self + } + pub fn decay_ratio(mut self, ratio: u32) -> Self { + self.decay_ratio = ratio; + self + } + pub fn voting_fee(mut self, fee: u64) -> Self { + self.voting_fee = fee; + self + } + pub fn bad_presentation_punishment(mut self, fee: u64) -> Self { + self.bad_presentation_punishment = fee; + self + } + pub fn voter_bond(mut self, fee: u64) -> Self { + self.voter_bond = fee; + self + } + pub fn build(self) -> runtime_io::TestExternalities { + let mut t = system::GenesisConfig::::default().build_storage().unwrap().0; + t.extend(balances::GenesisConfig::{ + transaction_base_fee: 0, + transaction_byte_fee: 0, + balances: vec![ + (1, 10 * self.balance_factor), + (2, 20 * self.balance_factor), + (3, 30 * self.balance_factor), + (4, 40 * self.balance_factor), + (5, 50 * self.balance_factor), + (6, 60 * self.balance_factor) + ], + existential_deposit: 0, + transfer_fee: 0, + creation_fee: 0, + vesting: vec![], + }.build_storage().unwrap().0); + t.extend(seats::GenesisConfig:: { + candidacy_bond: 3, + voter_bond: self.voter_bond, + present_slash_per_voter: self.bad_presentation_punishment, + carry_count: 2, + inactive_grace_period: 1, + active_council: if self.with_council { vec![ + (1, 10), + (2, 10), + (3, 10) + ] } else { vec![] }, + approval_voting_period: 4, + presentation_duration: 2, + desired_seats: 2, + decay_ratio: self.decay_ratio, + voting_fee: self.voting_fee, + term_duration: 5, + }.build_storage().unwrap().0); + runtime_io::TestExternalities::new(t) + } } pub type System = system::Module; diff --git a/srml/council/src/motions.rs b/srml/council/src/motions.rs index 4ab4e84c12..df357ac8c8 100644 --- a/srml/council/src/motions.rs +++ b/srml/council/src/motions.rs @@ -326,8 +326,8 @@ mod tests { use hex_literal::hex; #[test] - fn basic_environment_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_basic_environment_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); assert_eq!(Balances::free_balance(&42), 0); assert_eq!(CouncilMotions::proposals(), Vec::::new()); @@ -340,7 +340,7 @@ mod tests { #[test] fn removal_of_old_voters_votes_works() { - with_externalities(&mut new_test_ext(true), || { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash = BlakeTwo256::hash_of(&proposal); @@ -374,7 +374,7 @@ mod tests { #[test] fn propose_works() { - with_externalities(&mut new_test_ext(true), || { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash = proposal.blake2_256().into(); @@ -397,8 +397,8 @@ mod tests { } #[test] - fn ignoring_non_council_proposals_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_ignoring_non_council_proposals_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); assert_noop!(CouncilMotions::propose(Origin::signed(42), 3, Box::new(proposal.clone())), "proposer not on council"); @@ -406,8 +406,8 @@ mod tests { } #[test] - fn ignoring_non_council_votes_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_ignoring_non_council_votes_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash: H256 = proposal.blake2_256().into(); @@ -417,8 +417,8 @@ mod tests { } #[test] - fn ignoring_bad_index_council_vote_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_ignoring_bad_index_council_vote_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(3); let proposal = set_balance_proposal(42); let hash: H256 = proposal.blake2_256().into(); @@ -428,8 +428,8 @@ mod tests { } #[test] - fn revoting_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_revoting_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash: H256 = proposal.blake2_256().into(); @@ -462,8 +462,8 @@ mod tests { } #[test] - fn disapproval_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_disapproval_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash: H256 = proposal.blake2_256().into(); @@ -491,8 +491,8 @@ mod tests { } #[test] - fn approval_works() { - with_externalities(&mut new_test_ext(true), || { + fn motions_approval_works() { + with_externalities(&mut ExtBuilder::default().with_council(true).build(), || { System::set_block_number(1); let proposal = set_balance_proposal(42); let hash: H256 = proposal.blake2_256().into(); diff --git a/srml/council/src/seats.rs b/srml/council/src/seats.rs index 15817df70b..3e80584900 100644 --- a/srml/council/src/seats.rs +++ b/srml/council/src/seats.rs @@ -17,13 +17,18 @@ //! Council system: Handles the voting in and maintenance of council members. use rstd::prelude::*; -use primitives::traits::{Zero, One, StaticLookup}; +use primitives::traits::{Zero, One, StaticLookup, Bounded, Saturating}; use runtime_io::print; use srml_support::{ - StorageValue, StorageMap, dispatch::Result, decl_storage, decl_event, ensure, - traits::{Currency, ReservableCurrency, OnUnbalanced} + StorageValue, StorageMap, + dispatch::Result, decl_storage, decl_event, ensure, decl_module, + traits::{ + Currency, ReservableCurrency, OnUnbalanced, LockIdentifier, + LockableCurrency, WithdrawReasons, WithdrawReason, ExistenceRequirement + } }; use democracy; +use parity_codec::{Encode, Decode}; use system::{self, ensure_signed}; use super::OnMembersChanged; @@ -81,13 +86,51 @@ use super::OnMembersChanged; // after each vote as all but K entries are cleared. newly registering candidates must use cleared // entries before they increase the capacity. -use srml_support::decl_module; -pub type VoteIndex = u32; +/// The activity status of a voter. +#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, Default)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct VoterInfo { + /// Last VoteIndex in which this voter assigned (or initialized) approvals. + last_active: VoteIndex, + /// Last VoteIndex in which one of this voter's approvals won. + /// Note that `last_win = N` indicates a last win at index `N-1`, hence `last_win = 0` means no win ever. + last_win: VoteIndex, + /// The amount of stored weight as a result of not winning but changing approvals. + pot: Balance, + /// Current staked amount. A lock equal to this value always exists. + stake: Balance, +} + +/// Used to demonstrate the status of a particular index in the global voter list. +#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(Debug))] +pub enum CellStatus { + /// Any out of bound index. Means a push a must happen to the chunk pointed by `NextVoterSet`. + /// Voting fee is applied in case a new chunk is created. + Head, + /// Already occupied by another voter. Voting fee is applied. + Occupied, + /// Empty hole which should be filled. No fee will be applied. + Hole, +} + +const COUNCIL_SEATS_ID: LockIdentifier = *b"councils"; + +pub const VOTER_SET_SIZE: usize = 64; +pub const APPROVAL_SET_SIZE: usize = 8; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; +type SetIndex = u32; +pub type VoteIndex = u32; + +// all three must be in sync. +type ApprovalFlag = u32; +pub const APPROVAL_FLAG_MASK: ApprovalFlag = 0x8000_0000; +pub const APPROVAL_FLAG_LEN: usize = 32; + pub trait Trait: democracy::Trait { type Event: From> + Into<::Event>; @@ -97,6 +140,11 @@ pub trait Trait: democracy::Trait { /// Handler for the unbalanced reduction when slashing an invalid reaping attempt. type BadReaper: OnUnbalanced>; + /// Handler for the unbalanced reduction when submitting a bad `voter_index`. + type BadVoterIndex: OnUnbalanced>; + + /// Handler for the unbalanced reduction when a candidate has lost (and is not a runner up) + type LoserCandidate: OnUnbalanced>; /// What to do when the members change. type OnMembersChanged: OnMembersChanged; } @@ -107,22 +155,40 @@ decl_module! { /// Set candidate approvals. Approval slots stay valid as long as candidates in those slots /// are registered. - fn set_approvals(origin, votes: Vec, #[compact] index: VoteIndex) -> Result { + /// + /// Locks the total balance of caller indefinitely. + /// Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance. + /// + /// `hint` argument is interpreted differently based on: + /// - if `origin` is setting approvals for the first time: The index will be checked + /// for being a valid _hole_ in the voter list. + /// - if the hint is correctly pointing to a hole, no fee is deducted from `origin`. + /// - Otherwise, the call will succeed but the index is ignored and simply a push to the last chunk + /// with free space happens. If the new push causes a new chunk to be created, a fee indicated by + /// [`VotingFee`] is deducted. + /// - if `origin` is already a voter: the index __must__ be valid and point to the correct + /// position of the `origin` in the current voters list. + /// + /// Note that any trailing `false` votes in `votes` is ignored; In approval voting, not voting for a candidate + /// and voting false, are equal. + fn set_approvals(origin, votes: Vec, #[compact] index: VoteIndex, hint: SetIndex) -> Result { let who = ensure_signed(origin)?; - Self::do_set_approvals(who, votes, index) + Self::do_set_approvals(who, votes, index, hint) } /// Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots /// are registered. - fn proxy_set_approvals(origin, votes: Vec, #[compact] index: VoteIndex) -> Result { + fn proxy_set_approvals(origin, votes: Vec, #[compact] index: VoteIndex, hint: SetIndex) -> Result { let who = >::proxy(ensure_signed(origin)?).ok_or("not a proxy")?; - Self::do_set_approvals(who, votes, index) + Self::do_set_approvals(who, votes, index, hint) } /// Remove a voter. For it not to be a bond-consuming no-op, all approved candidate indices /// must now be either unregistered or registered to a candidate that registered the slot after /// the voter gave their last approval set. /// + /// Both indices must be provided as explained in [`voter_at`] function. + /// /// May be called by anyone. Returns the voter deposit to `signed`. fn reap_inactive_voter( origin, @@ -132,34 +198,49 @@ decl_module! { #[compact] assumed_vote_index: VoteIndex ) { let reporter = ensure_signed(origin)?; - let who = T::Lookup::lookup(who)?; + ensure!(!Self::presentation_active(), "cannot reap during presentation period"); - ensure!(Self::voter_last_active(&reporter).is_some(), "reporter must be a voter"); - let last_active = Self::voter_last_active(&who).ok_or("target for inactivity cleanup must be active")?; + ensure!(Self::voter_info(&reporter).is_some(), "reporter must be a voter"); + + let info = Self::voter_info(&who).ok_or("target for inactivity cleanup must be active")?; + let last_active = info.last_active; + ensure!(assumed_vote_index == Self::vote_index(), "vote index not current"); - ensure!(assumed_vote_index > last_active + Self::inactivity_grace_period(), "cannot reap during grace period"); - let voters = Self::voters(); + ensure!( + assumed_vote_index > last_active+ Self::inactivity_grace_period(), + "cannot reap during grace period" + ); + let reporter_index = reporter_index as usize; let who_index = who_index as usize; - ensure!(reporter_index < voters.len() && voters[reporter_index] == reporter, "bad reporter index"); - ensure!(who_index < voters.len() && voters[who_index] == who, "bad target index"); + let assumed_reporter = Self::voter_at(reporter_index).ok_or("invalid reporter index")?; + let assumed_who = Self::voter_at(who_index).ok_or("invalid target index")?; + + ensure!(assumed_reporter == reporter, "bad reporter index"); + ensure!(assumed_who == who, "bad target index"); - // will definitely kill one of signed or who now. + // will definitely kill one of reporter or who now. - let valid = !Self::approvals_of(&who).iter() + let valid = !Self::all_approvals_of(&who).iter() .zip(Self::candidates().iter()) .any(|(&appr, addr)| appr && *addr != T::AccountId::default() && - Self::candidate_reg_info(addr).map_or(false, |x| x.0 <= last_active)/*defensive only: all items in candidates list are registered*/ + // defensive only: all items in candidates list are registered + Self::candidate_reg_info(addr).map_or(false, |x| x.0 <= last_active) ); Self::remove_voter( if valid { &who } else { &reporter }, - if valid { who_index } else { reporter_index }, - voters + if valid { who_index } else { reporter_index } ); + + T::Currency::remove_lock( + COUNCIL_SEATS_ID, + if valid { &who } else { &reporter } + ); + if valid { // This only fails if `reporter` doesn't exist, which it clearly must do since its the origin. // Still, it's no more harmful to propagate any error at this point. @@ -173,23 +254,32 @@ decl_module! { } /// Remove a voter. All votes are cancelled and the voter deposit is returned. + /// + /// The index must be provided as explained in [`voter_at`] function. + /// + /// Also removes the lock on the balance of the voter. See [`do_set_approvals()`]. fn retract_voter(origin, #[compact] index: u32) { let who = ensure_signed(origin)?; ensure!(!Self::presentation_active(), "cannot retract when presenting"); - ensure!(>::exists(&who), "cannot retract non-voter"); - let voters = Self::voters(); + ensure!(>::exists(&who), "cannot retract non-voter"); let index = index as usize; - ensure!(index < voters.len(), "retraction index invalid"); - ensure!(voters[index] == who, "retraction index mismatch"); + let voter = Self::voter_at(index).ok_or("retraction index invalid")?; + ensure!(voter == who, "retraction index mismatch"); - Self::remove_voter(&who, index, voters); + Self::remove_voter(&who, index); T::Currency::unreserve(&who, Self::voting_bond()); + T::Currency::remove_lock(COUNCIL_SEATS_ID, &who); } /// Submit oneself for candidacy. /// /// Account must have enough transferrable funds in it to pay the bond. + /// + /// NOTE: if `origin` has already assigned approvals via [`set_approvals`], + /// it will NOT have any usable funds to pass candidacy bond and must first retract. + /// Note that setting approvals will lock the entire balance of the voter until + /// retraction or being reported. fn submit_candidacy(origin, #[compact] slot: u32) { let who = ensure_signed(origin)?; @@ -218,7 +308,7 @@ decl_module! { } /// Claim that `signed` is one of the top Self::carry_count() + current_vote().1 candidates. - /// Only works if the `block_number >= current_vote().0` and `< current_vote().0 + presentation_duration()`` + /// Only works if the `block_number >= current_vote().0` and `< current_vote().0 + presentation_duration()` /// `signed` should have at least fn present_winner( origin, @@ -227,15 +317,21 @@ decl_module! { #[compact] index: VoteIndex ) -> Result { let who = ensure_signed(origin)?; - ensure!(!total.is_zero(), "stake deposited to present winner and be added to leaderboard should be non-zero"); + ensure!( + !total.is_zero(), + "stake deposited to present winner and be added to leaderboard should be non-zero" + ); let candidate = T::Lookup::lookup(candidate)?; ensure!(index == Self::vote_index(), "index not current"); let (_, _, expiring) = Self::next_finalize().ok_or("cannot present outside of presentation period")?; - let stakes = Self::snapshoted_stakes(); - let voters = Self::voters(); - let bad_presentation_punishment = Self::present_slash_per_voter() * BalanceOf::::from(voters.len() as u32); - ensure!(T::Currency::can_slash(&who, bad_presentation_punishment), "presenter must have sufficient slashable funds"); + let bad_presentation_punishment = + Self::present_slash_per_voter() + * BalanceOf::::from(Self::voter_count() as u32); + ensure!( + T::Currency::can_slash(&who, bad_presentation_punishment), + "presenter must have sufficient slashable funds" + ); let mut leaderboard = Self::leaderboard().ok_or("leaderboard must exist while present phase active")?; ensure!(total > leaderboard[0].0, "candidate not worthy of leaderboard"); @@ -244,17 +340,24 @@ decl_module! { ensure!(p < expiring.len(), "candidate must not form a duplicated member if elected"); } + let voters = Self::all_voters(); let (registered_since, candidate_index): (VoteIndex, u32) = Self::candidate_reg_info(&candidate).ok_or("presented candidate must be current")?; let actual_total = voters.iter() - .zip(stakes.iter()) - .filter_map(|(voter, stake)| - match Self::voter_last_active(voter) { - Some(b) if b >= registered_since => - Self::approvals_of(voter).get(candidate_index as usize) - .and_then(|approved| if *approved { Some(*stake) } else { None }), - _ => None, - }) + .filter_map(|maybe_voter| maybe_voter.as_ref()) + .filter_map(|voter| match Self::voter_info(voter) { + Some(b) if b.last_active >= registered_since => { + let last_win = b.last_win; + let now = Self::vote_index(); + let stake = b.stake; + let offset = Self::get_offset(stake, now - last_win); + let weight = stake + offset + b.pot; + if Self::approvals_of_at(voter, candidate_index as usize) { + Some(weight) + } else { None } + }, + _ => None, + }) .fold(Zero::zero(), |acc, n| acc + n); let dupe = leaderboard.iter().find(|&&(_, ref c)| c == &candidate).is_some(); if total == actual_total && !dupe { @@ -317,18 +420,20 @@ decl_module! { decl_storage! { trait Store for Module as Council { - // parameters + // ---- parameters /// How much should be locked up in order to submit one's candidacy. pub CandidacyBond get(candidacy_bond) config(): BalanceOf = 9.into(); /// How much should be locked up in order to be able to submit votes. pub VotingBond get(voting_bond) config(voter_bond): BalanceOf; + /// The amount of fee paid upon each vote submission, unless if they submit a _hole_ index and replace it. + pub VotingFee get(voting_fee) config(voting_fee): BalanceOf; /// The punishment, per voter, if you provide an invalid presentation. pub PresentSlashPerVoter get(present_slash_per_voter) config(): BalanceOf = 1.into(); /// How many runners-up should have their approvals persist until the next vote. pub CarryCount get(carry_count) config(): u32 = 2; /// How long to give each top candidate to present themselves after the vote ends. pub PresentationDuration get(presentation_duration) config(): T::BlockNumber = 1000.into(); - /// How many vote indexes need to go by after a target voter's last vote before they can be reaped if their + /// How many vote indices need to go by after a target voter's last vote before they can be reaped if their /// approvals are moot. pub InactiveGracePeriod get(inactivity_grace_period) config(inactive_grace_period): VoteIndex = 1; /// How often (in blocks) to check for new votes. @@ -337,37 +442,49 @@ decl_storage! { pub TermDuration get(term_duration) config(): T::BlockNumber = 5.into(); /// Number of accounts that should be sitting on the council. pub DesiredSeats get(desired_seats) config(): u32; + /// Decay factor of weight when being accumulated. It should typically be set to + /// __at least__ `council_size -1` to keep the council secure. + /// When set to `N`, it indicates `(1/N)^t` of staked is decayed at weight increment step `t`. + /// 0 will result in no weight being added at all (normal approval voting). + pub DecayRatio get(decay_ratio) config(decay_ratio): u32 = 24; - // permanent state (always relevant, changes only at the finalization of voting) + // ---- permanent state (always relevant, changes only at the finalization of voting) /// The current council. When there's a vote going on, this should still be used for executive /// matters. The block number (second element in the tuple) is the block that their position is /// active until (calculated by the sum of the block number when the council member was elected /// and their term duration). pub ActiveCouncil get(active_council) config(): Vec<(T::AccountId, T::BlockNumber)>; - /// The total number of votes that have happened or are in progress. + /// The total number of vote rounds that have happened or are in progress. pub VoteCount get(vote_index): VoteIndex; - // persistent state (always relevant, changes constantly) - /// A list of votes for each voter, respecting the last cleared vote index that this voter was - /// last active at. - pub ApprovalsOf get(approvals_of): map T::AccountId => Vec; + // ---- persistent state (always relevant, changes constantly) + /// A list of votes for each voter. The votes are stored as numeric values and parsed in a bit-wise manner. + /// + /// In order to get a human-readable representation (`Vec`), use [`all_approvals_of`]. + /// + /// Furthermore, each vector of scalars is chunked with the cap of `APPROVAL_SET_SIZE`. + pub ApprovalsOf get(approvals_of): map (T::AccountId, SetIndex) => Vec; /// The vote index and list slot that the candidate `who` was registered or `None` if they are not /// currently registered. pub RegisterInfoOf get(candidate_reg_info): map T::AccountId => Option<(VoteIndex, u32)>; - /// The last cleared vote index that this voter was last active at. - pub LastActiveOf get(voter_last_active): map T::AccountId => Option; - /// The present voter list. - pub Voters get(voters): Vec; + /// Basic information about a voter. + pub VoterInfoOf get(voter_info): map T::AccountId => Option>>; + /// The present voter list (chunked and capped at [`VOTER_SET_SIZE`]). + pub Voters get(voters): map SetIndex => Vec>; + /// the next free set to store a voter in. This will keep growing. + pub NextVoterSet get(next_nonfull_voter_set): SetIndex = 0; + /// Current number of Voters. + pub VoterCount get(voter_count): SetIndex = 0; /// The present candidate list. pub Candidates get(candidates): Vec; // has holes + /// Current number of active candidates pub CandidateCount get(candidate_count): u32; - // temporary state (only relevant during finalization/presentation) + // ---- temporary state (only relevant during finalization/presentation) /// The accounts holding the seats that will become free on the next tally. pub NextFinalize get(next_finalize): Option<(T::BlockNumber, u32, Vec)>; - /// The stakes as they were at the point that the vote ended. - pub SnapshotedStakes get(snapshoted_stakes): Vec>; - /// Get the leaderboard if we;re in the presentation phase. + /// Get the leaderboard if we're in the presentation phase. The first element is the weight of each entry; + /// It may be the direct summed approval stakes, or a weighted version of it. pub Leaderboard get(leaderboard): Option, T::AccountId)> >; // ORDERED low -> high } } @@ -460,15 +577,21 @@ impl Module { Ok(()) } - /// Remove a voter from the system. Trusts that Self::voters()[index] != voter. - fn remove_voter(voter: &T::AccountId, index: usize, mut voters: Vec) { - >::put({ voters.swap_remove(index); voters }); - >::remove(voter); - >::remove(voter); + /// Remove a voter at a specified index from the system. + fn remove_voter(voter: &T::AccountId, index: usize) { + let (set_index, vec_index) = Self::split_index(index, VOTER_SET_SIZE); + let mut set = Self::voters(set_index); + set[vec_index] = None; + >::insert(set_index, set); + >::mutate(|c| *c = *c - 1); + Self::remove_all_approvals_of(voter); + >::remove(voter); } - // Actually do the voting. - fn do_set_approvals(who: T::AccountId, votes: Vec, index: VoteIndex) -> Result { + /// Actually do the voting. + /// + /// The voter index must be provided as explained in [`voter_at`] function. + fn do_set_approvals(who: T::AccountId, votes: Vec, index: VoteIndex, hint: SetIndex) -> Result { let candidates = Self::candidates(); ensure!(!Self::presentation_active(), "no approval changes during presentation period"); @@ -477,39 +600,98 @@ impl Module { // Prevent a vote from voters that provide a list of votes that exceeds the candidates length // since otherwise an attacker may be able to submit a very long list of `votes` that far exceeds // the amount of candidates and waste more computation than a reasonable voting bond would cover. - ensure!(candidates.len() >= votes.len(), "amount of candidate approval votes cannot exceed amount of candidates"); + ensure!(candidates.len() >= votes.len(), "amount of candidate votes cannot exceed amount of candidates"); + + // Amount to be locked up. + let mut locked_balance = T::Currency::total_balance(&who); + let mut pot_to_set = Zero::zero(); + let hint = hint as usize; + + if let Some(info) = Self::voter_info(&who) { + // already a voter. Index must be valid. No fee. update pot. O(1) + let voter = Self::voter_at(hint).ok_or("invalid voter index")?; + ensure!(voter == who, "wrong voter index"); + + // write new accumulated offset. + let last_win = info.last_win; + let now = index; + let offset = Self::get_offset(info.stake, now - last_win); + pot_to_set = info.pot + offset; + } else { + // not yet a voter. Index _could be valid_. Fee might apply. Bond will be reserved O(1). + ensure!( + T::Currency::free_balance(&who) > Self::voting_bond(), + "new voter must have sufficient funds to pay the bond" + ); - if !>::exists(&who) { - // not yet a voter - deduct bond. - // NOTE: this must be the last potential bailer, since it changes state. - T::Currency::reserve(&who, Self::voting_bond())?; + let (set_index, vec_index) = Self::split_index(hint, VOTER_SET_SIZE); + match Self::cell_status(set_index, vec_index) { + CellStatus::Hole => { + // requested cell was a valid hole. + >::mutate(set_index, |set| set[vec_index] = Some(who.clone())); + }, + CellStatus::Head | CellStatus::Occupied => { + // Either occupied or out-of-range. + let next = Self::next_nonfull_voter_set(); + let mut set = Self::voters(next); + // Caused a new set to be created. Pay for it. + // This is the last potential error. Writes will begin afterwards. + if set.is_empty() { + let imbalance = T::Currency::withdraw( + &who, + Self::voting_fee(), + WithdrawReason::Fee, + ExistenceRequirement::KeepAlive, + )?; + T::BadVoterIndex::on_unbalanced(imbalance); + // NOTE: this is safe since the `withdraw()` will check this. + locked_balance -= Self::voting_fee(); + } + Self::checked_push_voter(&mut set, who.clone(), next); + >::insert(next, set); + } + } - >::mutate(|v| v.push(who.clone())); + T::Currency::reserve(&who, Self::voting_bond())?; + >::mutate(|c| *c = *c + 1); } - >::insert(&who, index); - >::insert(&who, votes); + + T::Currency::set_lock( + COUNCIL_SEATS_ID, + &who, + locked_balance, + T::BlockNumber::max_value(), + WithdrawReasons::all() + ); + + >::insert( + &who, + VoterInfo::> { + last_active: index, + last_win: index, + stake: locked_balance, + pot: pot_to_set, + } + ); + Self::set_approvals_chunked(&who, votes); Ok(()) } - /// Close the voting, snapshot the staking and the number of seats that are actually up for grabs. + /// Close the voting, record the number of seats that are actually up for grabs. fn start_tally() { let active_council = Self::active_council(); let desired_seats = Self::desired_seats() as usize; let number = >::block_number(); - let expiring = active_council.iter().take_while(|i| i.1 == number).map(|i| i.0.clone()).collect::>(); + let expiring = active_council.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::>(); let retaining_seats = active_council.len() - expiring.len(); if retaining_seats < desired_seats { let empty_seats = desired_seats - retaining_seats; >::put((number + Self::presentation_duration(), empty_seats as u32, expiring)); - let voters = Self::voters(); - let votes = voters.iter().map(T::Currency::total_balance).collect::>(); - >::put(votes); - // initialize leaderboard. let leaderboard_size = empty_seats + Self::carry_count() as usize; - >::put(vec![(BalanceOf::::zero(), T::AccountId::default()); leaderboard_size]); + >::put(vec![(Zero::zero(), T::AccountId::default()); leaderboard_size]); Self::deposit_event(RawEvent::TallyStarted(empty_seats as u32)); } @@ -520,7 +702,6 @@ impl Module { /// a new vote is started. /// Clears all presented candidates, returning the bond of the elected ones. fn finalize_tally() -> Result { - >::kill(); let (_, coming, expiring): (T::BlockNumber, u32, Vec) = >::take().ok_or("finalize can only be called after a tally is started.")?; let leaderboard: Vec<(BalanceOf, T::AccountId)> = >::take().unwrap_or_default(); @@ -534,8 +715,20 @@ impl Module { .take(coming as usize) .map(|(_, a)| a) .cloned() - .inspect(|a| {T::Currency::unreserve(a, candidacy_bond);}) + .inspect(|a| { T::Currency::unreserve(a, candidacy_bond); }) .collect(); + + // Update last win index for anyone voted for any of the incomings. + incoming.iter().filter_map(|i| Self::candidate_reg_info(i)).for_each(|r| { + let index = r.1 as usize; + Self::all_voters() + .iter() + .filter_map(|mv| mv.as_ref()) + .filter(|v| Self::approvals_of_at(*v, index)) + .for_each(|v| >::mutate(v, |a| { + if let Some(activity) = a { activity.last_win = Self::vote_index() + 1; } + })); + }); let active_council = Self::active_council(); let outgoing: Vec<_> = active_council.iter() .take(expiring.len()) @@ -583,6 +776,205 @@ impl Module { >::put(Self::vote_index() + 1); Ok(()) } + + fn checked_push_voter(set: &mut Vec>, who: T::AccountId, index: u32) { + let len = set.len(); + + // Defensive only: this should never happen. Don't push since it will break more things. + if len == VOTER_SET_SIZE { return; } + + set.push(Some(who)); + if len + 1 == VOTER_SET_SIZE { + >::put(index + 1); + } + } + + /// Get the set and vector index of a global voter index. + /// + /// Note that this function does not take holes into account. + /// See [`voter_at`]. + fn split_index(index: usize, scale: usize) -> (SetIndex, usize) { + let set_index = (index / scale) as u32; + let vec_index = index % scale; + (set_index, vec_index) + } + + /// Return a concatenated vector over all voter sets. + fn all_voters() -> Vec> { + let mut all = >::get(0); + let mut index = 1; + // NOTE: we could also use `Self::next_nonfull_voter_set()` here but that might change based + // on how we do chunking. This is more generic. + loop { + let next_set = >::get(index); + if next_set.is_empty() { + break; + } else { + index += 1; + all.extend(next_set); + } + } + all + } + + /// Shorthand for fetching a voter at a specific (global) index. + /// + /// NOTE: this function is used for checking indices. Yet, it does not take holes into account. + /// This means that any account submitting an index at any point in time should submit: + /// `VOTER_SET_SIZE * set_index + local_index`, meaning that you are ignoring all holes in the + /// first `set_index` sets. + fn voter_at(index: usize) -> Option { + let (set_index, vec_index) = Self::split_index(index, VOTER_SET_SIZE); + let set = Self::voters(set_index); + if vec_index < set.len() { + set[vec_index].clone() + } else { + None + } + } + + /// A more sophisticated version of `voter_at`. Will be kept separate as most often it is an overdue + /// compared to `voter_at`. Only used when setting approvals. + fn cell_status(set_index: SetIndex, vec_index: usize) -> CellStatus { + let set = Self::voters(set_index); + if vec_index < set.len() { + if let Some(_) = set[vec_index] { + CellStatus::Occupied + } else { + CellStatus::Hole + } + } else { + CellStatus::Head + } + } + + /// Sets the approval of a voter in a chunked manner. + fn set_approvals_chunked(who: &T::AccountId, approvals: Vec) { + let approvals_flag_vec = Self::bool_to_flag(approvals); + approvals_flag_vec + .chunks(APPROVAL_SET_SIZE) + .enumerate() + .for_each(|(index, slice)| >::insert((who.clone(), index as SetIndex), slice.to_vec())); + } + + /// shorthand for fetching a specific approval of a voter at a specific (global) index. + /// + /// Using this function to read a vote is preferred as it reads `APPROVAL_SET_SIZE` items of type + /// `ApprovalFlag` from storage at most; not all of them. + /// + /// Note that false is returned in case of no-vote or an explicit `false`. + fn approvals_of_at(who: &T::AccountId, index: usize) -> bool { + let (flag_index, bit) = Self::split_index(index, APPROVAL_FLAG_LEN); + let (set_index, vec_index) = Self::split_index(flag_index as usize, APPROVAL_SET_SIZE); + let set = Self::approvals_of((who.clone(), set_index)); + if vec_index < set.len() { + // This is because bit_at treats numbers in lsb -> msb order. + let reversed_index = set.len() - 1 - vec_index; + Self::bit_at(set[reversed_index], bit) + } else { + false + } + } + + /// Return true of the bit `n` of scalar `x` is set to `1` and false otherwise. + fn bit_at(x: ApprovalFlag, n: usize) -> bool { + if n < APPROVAL_FLAG_LEN { + // x & ( APPROVAL_FLAG_MASK >> n ) != 0 + x & ( 1 << n ) != 0 + } else { + false + } + } + + /// Convert a vec of boolean approval flags to a vec of integers, as denoted by + /// the type `ApprovalFlag`. see `bool_to_flag_should_work` test for examples. + pub fn bool_to_flag(x: Vec) -> Vec { + let mut result: Vec = Vec::with_capacity(x.len() / APPROVAL_FLAG_LEN); + if x.is_empty() { + return result; + } + result.push(0); + let mut index = 0; + let mut counter = 0; + loop { + let shl_index = counter % APPROVAL_FLAG_LEN; + result[index] += (if x[counter] { 1 } else { 0 }) << shl_index; + counter += 1; + if counter > x.len() - 1 { break; } + if counter % APPROVAL_FLAG_LEN == 0 { + result.push(0); + index += 1; + } + } + result + } + + /// Convert a vec of flags (u32) to boolean. + pub fn flag_to_bool(chunk: Vec) -> Vec { + let mut result = Vec::with_capacity(chunk.len()); + if chunk.is_empty() { return vec![] } + chunk.into_iter() + .map(|num| (0..APPROVAL_FLAG_LEN).map(|bit| Self::bit_at(num, bit)).collect::>()) + .for_each(|c| { + let last_approve = match c.iter().rposition(|n| *n) { + Some(index) => index + 1, + None => 0 + }; + result.extend(c.into_iter().take(last_approve)); + }); + result + } + + /// Return a concatenated vector over all approvals of a voter as boolean. + /// The trailing zeros are removed. + fn all_approvals_of(who: &T::AccountId) -> Vec { + let mut all: Vec = vec![]; + let mut index = 0_u32; + loop { + let chunk = Self::approvals_of((who.clone(), index)); + if chunk.is_empty() { break; } + all.extend(Self::flag_to_bool(chunk)); + index += 1; + } + all + } + + /// Remove all approvals associated with one account. + fn remove_all_approvals_of(who: &T::AccountId) { + let mut index = 0; + loop { + let set = Self::approvals_of((who.clone(), index)); + if set.len() > 0 { + >::remove((who.clone(), index)); + index += 1; + } else { + break + } + } + } + + /// Calculates the offset value (stored pot) of a stake, based on the distance + /// to the last win_index, `t`. Regardless of the internal implementation, + /// it should always be used with the following structure: + /// + /// Given Stake of voter `V` being `x` and distance to last_win index `t`, the new weight + /// of `V` is `x + get_offset(x, t)`. + /// + /// In other words, this function returns everything extra that should be added + /// to a voter's stake value to get the correct weight. Indeed, zero is + /// returned if `t` is zero. + fn get_offset(stake: BalanceOf, t: VoteIndex) -> BalanceOf { + let decay_ratio: BalanceOf = Self::decay_ratio().into(); + if t > 150 { return stake * decay_ratio } + let mut offset = stake; + let mut r = Zero::zero(); + let decay = decay_ratio + One::one(); + for _ in 0..t { + offset = offset.saturating_sub(offset / decay); + r += offset + } + r + } } #[cfg(test)] @@ -591,16 +983,86 @@ mod tests { use crate::tests::*; use srml_support::{assert_ok, assert_noop, assert_err}; + fn voter_ids() -> Vec { + Council::all_voters().iter().map(|v| v.unwrap_or(0) ).collect::>() + } + + fn vote(i: u64, l: usize) { + let _ = Balances::make_free_balance_be(&i, 20); + assert_ok!(Council::set_approvals(Origin::signed(i), (0..l).map(|_| true).collect::>(), 0, 0)); + } + + fn vote_at(i: u64, l: usize, index: VoteIndex) { + let _ = Balances::make_free_balance_be(&i, 20); + assert_ok!(Council::set_approvals(Origin::signed(i), (0..l).map(|_| true).collect::>(), 0, index)); + } + + fn create_candidate(i: u64, index: u32) { + let _ = Balances::make_free_balance_be(&i, 20); + assert_ok!(Council::submit_candidacy(Origin::signed(i), index)); + } + + fn bond() -> u64 { + Council::voting_bond() + } + + + #[test] + fn bool_to_flag_should_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_eq!(Council::bool_to_flag(vec![]), vec![]); + assert_eq!(Council::bool_to_flag(vec![false]), vec![0]); + assert_eq!(Council::bool_to_flag(vec![true]), vec![1]); + assert_eq!(Council::bool_to_flag(vec![true, true, true, true]), vec![15]); + assert_eq!(Council::bool_to_flag(vec![true, true, true, true, true]), vec![15 + 16]); + + let set_1 = vec![ + true, false, false, false, // 0x1 + false, true, true, true, // 0xE + ]; + assert_eq!( + Council::bool_to_flag(set_1.clone()), + vec![0x00_00_00_E1_u32] + ); + assert_eq!( + Council::flag_to_bool(vec![0x00_00_00_E1_u32]), + set_1 + ); + + let set_2 = vec![ + false, false, false, true, // 0x8 + false, true, false, true, // 0xA + ]; + assert_eq!( + Council::bool_to_flag(set_2.clone()), + vec![0x00_00_00_A8_u32] + ); + assert_eq!( + Council::flag_to_bool(vec![0x00_00_00_A8_u32]), + set_2 + ); + + let mut rhs = (0..100/APPROVAL_FLAG_LEN).map(|_| 0xFFFFFFFF_u32).collect::>(); + // NOTE: this might be need change based on `APPROVAL_FLAG_LEN`. + rhs.extend(vec![0x00_00_00_0F]); + assert_eq!( + Council::bool_to_flag((0..100).map(|_| true).collect()), + rhs + ) + }) + } + #[test] fn params_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::next_vote_from(1), 4); assert_eq!(Council::next_vote_from(4), 4); assert_eq!(Council::next_vote_from(5), 8); assert_eq!(Council::vote_index(), 0); - assert_eq!(Council::candidacy_bond(), 9); - assert_eq!(Council::voting_bond(), 3); + assert_eq!(Council::candidacy_bond(), 3); + assert_eq!(Council::voting_bond(), 0); + assert_eq!(Council::voting_fee(), 0); assert_eq!(Council::present_slash_per_voter(), 1); assert_eq!(Council::presentation_duration(), 2); assert_eq!(Council::inactivity_grace_period(), 1); @@ -618,15 +1080,225 @@ mod tests { assert_eq!(Council::is_a_candidate(&1), false); assert_eq!(Council::candidate_reg_info(1), None); - assert_eq!(Council::voters(), Vec::::new()); - assert_eq!(Council::voter_last_active(1), None); - assert_eq!(Council::approvals_of(1), vec![]); + assert_eq!(Council::voters(0), Vec::>::new()); + assert_eq!(Council::voter_info(1), None); + assert_eq!(Council::all_approvals_of(&1), vec![]); }); } + #[test] + fn voter_set_growth_should_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); + + // create 65. 64 (set0) + 1 (set1) + (1..=63).for_each(|i| vote(i, 2)); + assert_eq!(Council::next_nonfull_voter_set(), 0); + vote(64, 2); + assert_eq!(Council::next_nonfull_voter_set(), 1); + vote(65, 2); + + let set1 = Council::voters(0); + let set2 = Council::voters(1); + + assert_eq!(set1.len(), 64); + assert_eq!(set2.len(), 1); + + assert_eq!(set1[0], Some(1)); + assert_eq!(set1[10], Some(11)); + assert_eq!(set2[0], Some(65)); + }) + } + + #[test] + fn voter_set_reclaim_should_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); + + (1..=129).for_each(|i| vote(i, 2)); + assert_eq!(Council::next_nonfull_voter_set(), 2); + + assert_ok!(Council::retract_voter(Origin::signed(11), 10)); + + assert_ok!(Council::retract_voter(Origin::signed(66), 65)); + assert_ok!(Council::retract_voter(Origin::signed(67), 66)); + + // length does not show it but holes do exist. + assert_eq!(Council::voters(0).len(), 64); + assert_eq!(Council::voters(1).len(), 64); + assert_eq!(Council::voters(2).len(), 1); + + assert_eq!(Council::voters(0)[10], None); + assert_eq!(Council::voters(1)[1], None); + assert_eq!(Council::voters(1)[2], None); + // Next set with capacity is 2. + assert_eq!(Council::next_nonfull_voter_set(), 2); + + // But we can fill a hole. + vote_at(130, 2, 10); + + // Nothing added to set 2. A hole was filled. + assert_eq!(Council::voters(0).len(), 64); + assert_eq!(Council::voters(1).len(), 64); + assert_eq!(Council::voters(2).len(), 1); + + // and the next two (scheduled) to the second set. + assert_eq!(Council::next_nonfull_voter_set(), 2); + }) + } + + #[test] + fn approvals_set_growth_should_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + // create candidates and voters. + (1..=250).for_each(|i| create_candidate(i, (i-1) as u32)); + (1..=250).for_each(|i| vote(i, i as usize)); + + // all approvals of should return the exact expected vector. + assert_eq!(Council::all_approvals_of(&180), (0..180).map(|_| true).collect::>()); + + assert_eq!(Council::all_approvals_of(&32), (0..32).map(|_| true).collect::>()); + assert_eq!(Council::all_approvals_of(&8), (0..8).map(|_| true).collect::>()); + assert_eq!(Council::all_approvals_of(&64), (0..64).map(|_| true).collect::>()); + assert_eq!(Council::all_approvals_of(&65), (0..65).map(|_| true).collect::>()); + assert_eq!(Council::all_approvals_of(&63), (0..63).map(|_| true).collect::>()); + + // NOTE: assuming that APPROVAL_SET_SIZE is more or less small-ish. Might fail otherwise. + let full_sets = (180 / APPROVAL_FLAG_LEN) / APPROVAL_SET_SIZE; + let left_over = (180 / APPROVAL_FLAG_LEN) / APPROVAL_SET_SIZE; + let rem = 180 % APPROVAL_FLAG_LEN; + + // grab and check the last full set, if it exists. + if full_sets > 0 { + assert_eq!( + Council::approvals_of((180, (full_sets-1) as SetIndex )), + Council::bool_to_flag((0..APPROVAL_SET_SIZE * APPROVAL_FLAG_LEN).map(|_| true).collect::>()) + ); + } + + // grab and check the last, half-empty, set. + if left_over > 0 { + assert_eq!( + Council::approvals_of((180, full_sets as SetIndex)), + Council::bool_to_flag((0..left_over * APPROVAL_FLAG_LEN + rem).map(|_| true).collect::>()) + ); + } + }) + } + + + #[test] + fn cell_status_works() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); + + (1..=63).for_each(|i| vote(i, 2)); + + assert_ok!(Council::retract_voter(Origin::signed(11), 10)); + assert_ok!(Council::retract_voter(Origin::signed(21), 20)); + + assert_eq!(Council::cell_status(0, 10), CellStatus::Hole); + assert_eq!(Council::cell_status(0, 0), CellStatus::Occupied); + assert_eq!(Council::cell_status(0, 20), CellStatus::Hole); + assert_eq!(Council::cell_status(0, 63), CellStatus::Head); + assert_eq!(Council::cell_status(1, 0), CellStatus::Head); + assert_eq!(Council::cell_status(1, 10), CellStatus::Head); + }) + } + + #[test] + fn initial_set_approvals_ignores_voter_index() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + + // Last argument is essentially irrelevant. You might get or miss a tip. + assert_ok!(Council::set_approvals(Origin::signed(3), vec![true], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0, 5)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 0, 100)); + + // indices are more or less ignored. all is pushed. + assert_eq!(voter_ids(), vec![3, 4, 5]); + }) + } + + #[test] + fn bad_approval_index_slashes_voters_and_bond_reduces_stake() { + with_externalities(&mut ExtBuilder::default().voting_fee(5).voter_bond(2).build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); + + (1..=63).for_each(|i| vote(i, 2)); + assert_eq!(Balances::free_balance(&1), 20 - 5 - 2); // -5 fee -2 bond + assert_eq!(Balances::free_balance(&10), 20 - 2); + assert_eq!(Balances::free_balance(&60), 20 - 2); + + // still no fee + vote(64, 2); + assert_eq!(Balances::free_balance(&64), 20 - 2); // -2 bond + assert_eq!( + Council::voter_info(&64).unwrap(), + VoterInfo { last_win: 0, last_active: 0, stake: 20, pot:0 } + ); + + assert_eq!(Council::next_nonfull_voter_set(), 1); + + // now we charge the next voter. + vote(65, 2); + assert_eq!(Balances::free_balance(&65), 20 - 5 - 2); + assert_eq!( + Council::voter_info(&65).unwrap(), + VoterInfo { last_win: 0, last_active: 0, stake: 15, pot:0 } + ); + }); + } + + #[test] + fn subsequent_set_approvals_checks_voter_index() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + + assert_ok!(Council::set_approvals(Origin::signed(3), vec![true], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0, 5)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 0, 100)); + + // invalid index + assert_noop!(Council::set_approvals(Origin::signed(4), vec![true], 0, 5), "invalid voter index"); + // wrong index + assert_noop!(Council::set_approvals(Origin::signed(4), vec![true], 0, 0), "wrong voter index"); + // correct + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0, 1)); + }) + } + + #[test] + fn voter_index_does_not_take_holes_into_account() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); + + // create 65. 64 (set0) + 1 (set1) + (1..=65).for_each(|i| vote(i, 2)); + + // account 65 has global index 65. + assert_eq!(Council::voter_at(64).unwrap(), 65); + + assert_ok!(Council::retract_voter(Origin::signed(1), 0)); + assert_ok!(Council::retract_voter(Origin::signed(2), 1)); + + // still the same. These holes are in some other set. + assert_eq!(Council::voter_at(64).unwrap(), 65); + // proof: can submit a new approval with the old index. + assert_noop!(Council::set_approvals(Origin::signed(65), vec![false, true], 0, 64 - 2), "wrong voter index"); + assert_ok!(Council::set_approvals(Origin::signed(65), vec![false, true], 0, 64)); + }) + } + #[test] fn simple_candidate_submission_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::candidates(), Vec::::new()); assert_eq!(Council::candidate_reg_info(1), None); @@ -651,7 +1323,7 @@ mod tests { } fn new_test_ext_with_candidate_holes() -> runtime_io::TestExternalities { - let mut t = new_test_ext(false); + let mut t = ExtBuilder::default().build(); with_externalities(&mut t, || { >::put(vec![0, 0, 1]); >::put(1); @@ -694,7 +1366,9 @@ mod tests { #[test] fn candidate_submission_not_using_free_slot_should_not_work() { - with_externalities(&mut new_test_ext_with_candidate_holes(), || { + let mut t = new_test_ext_with_candidate_holes(); + + with_externalities(&mut t, || { System::set_block_number(1); assert_noop!(Council::submit_candidacy(Origin::signed(4), 3), "invalid candidate slot"); }); @@ -702,7 +1376,7 @@ mod tests { #[test] fn bad_candidate_slot_submission_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::candidates(), Vec::::new()); assert_noop!(Council::submit_candidacy(Origin::signed(1), 1), "invalid candidate slot"); @@ -711,7 +1385,7 @@ mod tests { #[test] fn non_free_candidate_slot_submission_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::candidates(), Vec::::new()); assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); @@ -722,7 +1396,7 @@ mod tests { #[test] fn dupe_candidate_submission_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::candidates(), Vec::::new()); assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); @@ -733,45 +1407,367 @@ mod tests { #[test] fn poor_candidate_submission_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::candidates(), Vec::::new()); assert_noop!(Council::submit_candidacy(Origin::signed(7), 0), "candidate has not enough funds"); }); } + #[test] + fn balance_should_lock_to_the_maximum() { + with_externalities(&mut ExtBuilder::default().build(), || { + System::set_block_number(1); + assert_eq!(Council::candidates(), Vec::::new()); + assert_eq!(Balances::free_balance(&2), 20); + + assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); + + assert_eq!(Balances::free_balance(&2), 20 - bond() ); + assert_noop!(Balances::reserve(&2, 1), "account liquidity restrictions prevent withdrawal"); // locked. + + // deposit a bit more. + let _ = Balances::deposit_creating(&2, 100); + assert_ok!(Balances::reserve(&2, 1)); // locked but now has enough. + + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); + assert_noop!(Balances::reserve(&2, 1), "account liquidity restrictions prevent withdrawal"); // locked. + assert_eq!(Balances::locks(&2).len(), 1); + assert_eq!(Balances::locks(&2)[0].amount, 100 + 20); + + assert_ok!(Council::retract_voter(Origin::signed(2), 0)); + + assert_eq!(Balances::locks(&2).len(), 0); + assert_eq!(Balances::free_balance(&2), 120 - 1); // 1 ok call to .reserve() happened. + assert_ok!(Balances::reserve(&2, 1)); // unlocked. + }); + } + + #[test] + fn balance_should_lock_on_submit_approvals_unlock_on_retract() { + with_externalities(&mut ExtBuilder::default().voter_bond(8).voting_fee(0).build(), || { + System::set_block_number(1); + assert_eq!(Council::candidates(), Vec::::new()); + assert_eq!(Balances::free_balance(&2), 20); + + assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); + + assert_eq!(Balances::free_balance(&2), 12); // 20 - 8 (bond) + assert_noop!(Balances::reserve(&2, 10), "account liquidity restrictions prevent withdrawal"); // locked. + + assert_ok!(Council::retract_voter(Origin::signed(2), 0)); + + assert_eq!(Balances::free_balance(&2), 20); + assert_ok!(Balances::reserve(&2, 10)); // unlocked. + }); + } + + #[test] + fn accumulating_weight_and_decaying_should_work() { + with_externalities(&mut ExtBuilder::default().balance_factor(10).build(), || { + System::set_block_number(4); + assert!(!Council::presentation_active()); + + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(1), 2)); + + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![false, false, true], 0, 0)); + + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(6); + assert!(Council::presentation_active()); + + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(5), 5, 500, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(1), 1, 100, 0), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (100, 1), (500, 5), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 11), (5, 11)]); + assert_eq!(Council::voter_info(6).unwrap(), VoterInfo { last_win: 1, last_active: 0, stake: 600, pot: 0}); + assert_eq!(Council::voter_info(5).unwrap(), VoterInfo { last_win: 1, last_active: 0, stake: 500, pot: 0}); + assert_eq!(Council::voter_info(1).unwrap(), VoterInfo { last_win: 0, last_active: 0, stake: 100, pot: 0}); + + System::set_block_number(12); + // retract needed to unlock approval funds => submit candidacy again. + assert_ok!(Council::retract_voter(Origin::signed(6), 0)); + assert_ok!(Council::retract_voter(Origin::signed(5), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false], 1, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true, false], 1, 1)); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(14); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(5), 5, 500, 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(1), 1, 100 + Council::get_offset(100, 1), 1), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (100 + 96, 1), (500, 5), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 19), (5, 19)]); + assert_eq!( + Council::voter_info(6).unwrap(), + VoterInfo { last_win: 2, last_active: 1, stake: 600, pot:0 } + ); + assert_eq!(Council::voter_info(5).unwrap(), VoterInfo { last_win: 2, last_active: 1, stake: 500, pot:0 }); + assert_eq!(Council::voter_info(1).unwrap(), VoterInfo { last_win: 0, last_active: 0, stake: 100, pot:0 }); + + System::set_block_number(20); + assert_ok!(Council::retract_voter(Origin::signed(6), 0)); + assert_ok!(Council::retract_voter(Origin::signed(5), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false], 2, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true, false], 2, 1)); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(22); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 2), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(5), 5, 500, 2), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(1), 1, 100 + Council::get_offset(100, 2), 2), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (100 + 96 + 93, 1), (500, 5), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 27), (5, 27)]); + assert_eq!( + Council::voter_info(6).unwrap(), + VoterInfo { last_win: 3, last_active: 2, stake: 600, pot: 0} + ); + assert_eq!(Council::voter_info(5).unwrap(), VoterInfo { last_win: 3, last_active: 2, stake: 500, pot: 0}); + assert_eq!(Council::voter_info(1).unwrap(), VoterInfo { last_win: 0, last_active: 0, stake: 100, pot: 0}); + + + System::set_block_number(28); + assert_ok!(Council::retract_voter(Origin::signed(6), 0)); + assert_ok!(Council::retract_voter(Origin::signed(5), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false], 3, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true, false], 3, 1)); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(30); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 3), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(5), 5, 500, 3), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(1), 1, 100 + Council::get_offset(100, 3), 3), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (100 + 96 + 93 + 90, 1), (500, 5), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 35), (5, 35)]); + assert_eq!( + Council::voter_info(6).unwrap(), + VoterInfo { last_win: 4, last_active: 3, stake: 600, pot: 0} + ); + assert_eq!(Council::voter_info(5).unwrap(), VoterInfo { last_win: 4, last_active: 3, stake: 500, pot: 0}); + assert_eq!(Council::voter_info(1).unwrap(), VoterInfo { last_win: 0, last_active: 0, stake: 100, pot: 0}); + }) + } + + #[test] + fn winning_resets_accumulated_pot() { + with_externalities(&mut ExtBuilder::default().balance_factor(10).build(), || { + System::set_block_number(4); + assert!(!Council::presentation_active()); + + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(4), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); + assert_ok!(Council::submit_candidacy(Origin::signed(2), 3)); + + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, true, false, false], 0, 1)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true, true], 0, 2)); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(6); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(4), 4, 400, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(3), 3, 300, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(2), 2, 300, 0), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(300, 2), (300, 3), (400, 4), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 11), (4, 11)]); + + System::set_block_number(12); + assert_ok!(Council::retract_voter(Origin::signed(6), 0)); + assert_ok!(Council::retract_voter(Origin::signed(4), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(4), 1)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false, false], 1, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, true, false, false], 1, 1)); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(14); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(4), 4, 400, 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(3), 3, 300 + Council::get_offset(300, 1), 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(2), 2, 300 + Council::get_offset(300, 1), 1), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(400, 4), (588, 2), (588, 3), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 19), (3, 19)]); + + System::set_block_number(20); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(22); + // 2 will not get re-elected with 300 + 288, instead just 300. + // because one of 3's candidates (3) won in previous round + // 4 on the other hand will get extra weight since it was unlucky. + assert_eq!(Council::present_winner(Origin::signed(3), 2, 300, 2), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(4), 4, 400 + Council::get_offset(400, 1), 2), Ok(())); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(4, 27), (2, 27)]); + }) + } + + #[test] + fn resubmitting_approvals_stores_pot() { + with_externalities(&mut ExtBuilder::default() + .voter_bond(0) + .voting_fee(0) + .balance_factor(10) + .build(), + || { System::set_block_number(4); + assert!(!Council::presentation_active()); + + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(1), 2)); + + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true, false], 0, 1)); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![false, false, true], 0, 2)); + + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(6); + assert!(Council::presentation_active()); + + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(5), 5, 500, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(1), 1, 100, 0), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (100, 1), (500, 5), (600, 6)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 11), (5, 11)]); + + System::set_block_number(12); + assert_ok!(Council::retract_voter(Origin::signed(6), 0)); + assert_ok!(Council::retract_voter(Origin::signed(5), 1)); + assert_ok!(Council::submit_candidacy(Origin::signed(6), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true, false, false], 1, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true, false], 1, 1)); + // give 1 some new high balance + let _ = Balances::make_free_balance_be(&1, 997); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![false, false, true], 1, 2)); + assert_eq!(Council::voter_info(1).unwrap(), + VoterInfo { + stake: 1000, // 997 + 3 which is candidacy bond. + pot: Council::get_offset(100, 1), + last_active: 1, + last_win: 1, + } + ); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(6, 11), (5, 11)]); + + System::set_block_number(14); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(6), 6, 600, 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(5), 5, 500, 1), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(1), 1, 1000 + 96 /* pot */, 1), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (500, 5), (600, 6), (1096, 1)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(1, 19), (6, 19)]); + }) + } + + #[test] + fn get_offset_should_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_eq!(Council::get_offset(100, 0), 0); + assert_eq!(Council::get_offset(100, 1), 96); + assert_eq!(Council::get_offset(100, 2), 96 + 93); + assert_eq!(Council::get_offset(100, 3), 96 + 93 + 90); + assert_eq!(Council::get_offset(100, 4), 96 + 93 + 90 + 87); + // limit + assert_eq!(Council::get_offset(100, 1000), 100 * 24); + + assert_eq!(Council::get_offset(50_000_000_000, 0), 0); + assert_eq!(Council::get_offset(50_000_000_000, 1), 48_000_000_000); + assert_eq!(Council::get_offset(50_000_000_000, 2), 48_000_000_000 + 46_080_000_000); + assert_eq!(Council::get_offset(50_000_000_000, 3), 48_000_000_000 + 46_080_000_000 + 44_236_800_000); + assert_eq!( + Council::get_offset(50_000_000_000, 4), + 48_000_000_000 + 46_080_000_000 + 44_236_800_000 + 42_467_328_000 + ); + // limit + assert_eq!(Council::get_offset(50_000_000_000, 1000), 50_000_000_000 * 24); + }) + } + + #[test] + fn get_offset_with_zero_decay() { + with_externalities(&mut ExtBuilder::default().decay_ratio(0).build(), || { + assert_eq!(Council::get_offset(100, 0), 0); + assert_eq!(Council::get_offset(100, 1), 0); + assert_eq!(Council::get_offset(100, 2), 0); + assert_eq!(Council::get_offset(100, 3), 0); + // limit + assert_eq!(Council::get_offset(100, 1000), 0); + }) + } + #[test] fn voting_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0, 1)); - assert_eq!(Council::approvals_of(1), vec![true]); - assert_eq!(Council::approvals_of(4), vec![true]); - assert_eq!(Council::voters(), vec![1, 4]); + assert_eq!(Council::all_approvals_of(&1), vec![true]); + assert_eq!(Council::all_approvals_of(&4), vec![true]); + assert_eq!(voter_ids(), vec![1, 4]); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0, 2)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0, 3)); - assert_eq!(Council::approvals_of(1), vec![true]); - assert_eq!(Council::approvals_of(4), vec![true]); - assert_eq!(Council::approvals_of(2), vec![false, true, true]); - assert_eq!(Council::approvals_of(3), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&1), vec![true]); + assert_eq!(Council::all_approvals_of(&4), vec![true]); + assert_eq!(Council::all_approvals_of(&2), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&3), vec![false, true, true]); - assert_eq!(Council::voters(), vec![1, 4, 2, 3]); + assert_eq!(voter_ids(), vec![1, 4, 2, 3]); }); } #[test] fn proxy_voting_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); @@ -780,74 +1776,79 @@ mod tests { Democracy::force_proxy(2, 12); Democracy::force_proxy(3, 13); Democracy::force_proxy(4, 14); + assert_ok!(Council::proxy_set_approvals(Origin::signed(11), vec![true], 0, 0)); + assert_ok!(Council::proxy_set_approvals(Origin::signed(14), vec![true], 0, 1)); - assert_ok!(Council::proxy_set_approvals(Origin::signed(11), vec![true], 0)); - assert_ok!(Council::proxy_set_approvals(Origin::signed(14), vec![true], 0)); - - assert_eq!(Council::approvals_of(1), vec![true]); - assert_eq!(Council::approvals_of(4), vec![true]); - assert_eq!(Council::voters(), vec![1, 4]); + assert_eq!(Council::all_approvals_of(&1), vec![true]); + assert_eq!(Council::all_approvals_of(&4), vec![true]); + assert_eq!(voter_ids(), vec![1, 4]); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); - assert_ok!(Council::proxy_set_approvals(Origin::signed(12), vec![false, true, true], 0)); - assert_ok!(Council::proxy_set_approvals(Origin::signed(13), vec![false, true, true], 0)); + assert_ok!(Council::proxy_set_approvals(Origin::signed(12), vec![false, true, true], 0, 2)); + assert_ok!(Council::proxy_set_approvals(Origin::signed(13), vec![false, true, true], 0, 3)); - assert_eq!(Council::approvals_of(1), vec![true]); - assert_eq!(Council::approvals_of(4), vec![true]); - assert_eq!(Council::approvals_of(2), vec![false, true, true]); - assert_eq!(Council::approvals_of(3), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&1), vec![true]); + assert_eq!(Council::all_approvals_of(&4), vec![true]); + assert_eq!(Council::all_approvals_of(&2), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&3), vec![false, true, true]); - assert_eq!(Council::voters(), vec![1, 4, 2, 3]); + assert_eq!(voter_ids(), vec![1, 4, 2, 3]); }); } #[test] fn setting_any_approval_vote_count_without_any_candidate_count_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_eq!(Council::candidates().len(), 0); - assert_noop!(Council::set_approvals(Origin::signed(4), vec![], 0), "amount of candidates to receive approval votes should be non-zero"); + assert_noop!( + Council::set_approvals(Origin::signed(4), vec![], 0, 0), + "amount of candidates to receive approval votes should be non-zero" + ); }); } #[test] fn setting_an_approval_vote_count_more_than_candidate_count_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); assert_eq!(Council::candidates().len(), 1); - assert_noop!(Council::set_approvals(Origin::signed(4), vec![true, true], 0), "amount of candidate approval votes cannot exceed amount of candidates"); + assert_noop!( + Council::set_approvals(Origin::signed(4),vec![true, true], 0, 0), + "amount of candidate votes cannot exceed amount of candidates" + ); }); } #[test] fn resubmitting_voting_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true], 0, 0)); - assert_eq!(Council::approvals_of(4), vec![true]); + assert_eq!(Council::all_approvals_of(&4), vec![true]); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); assert_eq!(Council::candidates().len(), 3); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0, 0)); - assert_eq!(Council::approvals_of(4), vec![true, false, true]); + assert_eq!(Council::all_approvals_of(&4), vec![true, false, true]); }); } #[test] fn retracting_voter_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); @@ -855,88 +1856,108 @@ mod tests { assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); assert_eq!(Council::candidates().len(), 3); - assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true, true], 0, 1)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, true], 0, 2)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![true, false, true], 0, 3)); - assert_eq!(Council::voters(), vec![1, 2, 3, 4]); - assert_eq!(Council::approvals_of(1), vec![true]); - assert_eq!(Council::approvals_of(2), vec![false, true, true]); - assert_eq!(Council::approvals_of(3), vec![false, true, true]); - assert_eq!(Council::approvals_of(4), vec![true, false, true]); + assert_eq!(voter_ids(), vec![1, 2, 3, 4]); + assert_eq!(Council::all_approvals_of(&1), vec![true]); + assert_eq!(Council::all_approvals_of(&2), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&3), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&4), vec![true, false, true]); assert_ok!(Council::retract_voter(Origin::signed(1), 0)); - assert_eq!(Council::voters(), vec![4, 2, 3]); - assert_eq!(Council::approvals_of(1), Vec::::new()); - assert_eq!(Council::approvals_of(2), vec![false, true, true]); - assert_eq!(Council::approvals_of(3), vec![false, true, true]); - assert_eq!(Council::approvals_of(4), vec![true, false, true]); + assert_eq!(voter_ids(), vec![0, 2, 3, 4]); + assert_eq!(Council::all_approvals_of(&1), Vec::::new()); + assert_eq!(Council::all_approvals_of(&2), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&3), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&4), vec![true, false, true]); assert_ok!(Council::retract_voter(Origin::signed(2), 1)); - assert_eq!(Council::voters(), vec![4, 3]); - assert_eq!(Council::approvals_of(1), Vec::::new()); - assert_eq!(Council::approvals_of(2), Vec::::new()); - assert_eq!(Council::approvals_of(3), vec![false, true, true]); - assert_eq!(Council::approvals_of(4), vec![true, false, true]); + assert_eq!(voter_ids(), vec![0, 0, 3, 4]); + assert_eq!(Council::all_approvals_of(&1), Vec::::new()); + assert_eq!(Council::all_approvals_of(&2), Vec::::new()); + assert_eq!(Council::all_approvals_of(&3), vec![false, true, true]); + assert_eq!(Council::all_approvals_of(&4), vec![true, false, true]); - assert_ok!(Council::retract_voter(Origin::signed(3), 1)); + assert_ok!(Council::retract_voter(Origin::signed(3), 2)); - assert_eq!(Council::voters(), vec![4]); - assert_eq!(Council::approvals_of(1), Vec::::new()); - assert_eq!(Council::approvals_of(2), Vec::::new()); - assert_eq!(Council::approvals_of(3), Vec::::new()); - assert_eq!(Council::approvals_of(4), vec![true, false, true]); + assert_eq!(voter_ids(), vec![0, 0, 0, 4]); + assert_eq!(Council::all_approvals_of(&1), Vec::::new()); + assert_eq!(Council::all_approvals_of(&2), Vec::::new()); + assert_eq!(Council::all_approvals_of(&3), Vec::::new()); + assert_eq!(Council::all_approvals_of(&4), vec![true, false, true]); }); } #[test] fn invalid_retraction_index_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(3), 0)); - assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); - assert_eq!(Council::voters(), vec![1, 2]); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); + assert_eq!(voter_ids(), vec![1, 2]); assert_noop!(Council::retract_voter(Origin::signed(1), 1), "retraction index mismatch"); }); } #[test] fn overflow_retraction_index_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(3), 0)); - assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0, 0)); assert_noop!(Council::retract_voter(Origin::signed(1), 1), "retraction index invalid"); }); } #[test] fn non_voter_retraction_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(1); assert_ok!(Council::submit_candidacy(Origin::signed(3), 0)); - assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0, 0)); assert_noop!(Council::retract_voter(Origin::signed(2), 0), "cannot retract non-voter"); }); } + #[test] + fn approval_storage_should_work() { + with_externalities(&mut ExtBuilder::default().build(), || { + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); + + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![], 0, 0)); + + assert_eq!(Council::all_approvals_of(&2), vec![true]); + // NOTE: these two are stored in mem differently though. + assert_eq!(Council::all_approvals_of(&3), vec![]); + assert_eq!(Council::all_approvals_of(&4), vec![]); + + assert_eq!(Council::approvals_of((3, 0)), vec![0]); + assert_eq!(Council::approvals_of((4, 0)), vec![]); + }); + } + #[test] fn simple_tally_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert!(!Council::presentation_active()); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0)); - assert_eq!(Council::voters(), vec![2, 5]); - assert_eq!(Council::approvals_of(2), vec![true, false]); - assert_eq!(Council::approvals_of(5), vec![false, true]); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0, 0)); + assert_eq!(voter_ids(), vec![2, 5]); + assert_eq!(Council::all_approvals_of(&2), vec![true]); + assert_eq!(Council::all_approvals_of(&5), vec![false, true]); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -953,34 +1974,71 @@ mod tests { assert!(!Council::is_a_candidate(&2)); assert!(!Council::is_a_candidate(&5)); assert_eq!(Council::vote_index(), 1); - assert_eq!(Council::voter_last_active(2), Some(0)); - assert_eq!(Council::voter_last_active(5), Some(0)); + assert_eq!(Council::voter_info(2), Some(VoterInfo { last_win: 1, last_active: 0, stake: 20, pot: 0 })); + assert_eq!(Council::voter_info(5), Some(VoterInfo { last_win: 1, last_active: 0, stake: 50, pot: 0 })); + }); + } + + #[test] + fn seats_should_be_released() { + with_externalities(&mut ExtBuilder::default().build(), || { + System::set_block_number(4); + assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); + assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0, 0)); + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(6); + assert!(Council::presentation_active()); + assert_eq!(Council::present_winner(Origin::signed(4), 2, 20, 0), Ok(())); + assert_eq!(Council::present_winner(Origin::signed(4), 5, 50, 0), Ok(())); + assert_eq!(Council::leaderboard(), Some(vec![(0, 0), (0, 0), (20, 2), (50, 5)])); + assert_ok!(Council::end_block(System::block_number())); + + assert_eq!(Council::active_council(), vec![(5, 11), (2, 11)]); + let mut current = System::block_number(); + let free_block; + loop { + current += 1; + System::set_block_number(current); + assert_ok!(Council::end_block(System::block_number())); + if Council::active_council().len() == 0 { + free_block = current; + break; + } + } + // 11 + 2 which is the next voting period. + assert_eq!(free_block, 14); }); } #[test] fn presentations_with_zero_staked_deposit_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); - assert_noop!(Council::present_winner(Origin::signed(4), 2, 0, 0), "stake deposited to present winner and be added to leaderboard should be non-zero"); + assert_noop!( + Council::present_winner(Origin::signed(4), 2, 0, 0), + "stake deposited to present winner and be added to leaderboard should be non-zero" + ); }); } #[test] fn double_presentations_should_be_punished() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { assert!(Balances::can_slash(&4, 10)); System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -996,10 +2054,10 @@ mod tests { #[test] fn retracting_inactive_voter_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1008,7 +2066,7 @@ mod tests { System::set_block_number(8); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); @@ -1016,24 +2074,24 @@ mod tests { assert_ok!(Council::end_block(System::block_number())); assert_ok!(Council::reap_inactive_voter(Origin::signed(5), - (Council::voters().iter().position(|&i| i == 5).unwrap() as u32).into(), - 2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(), + (voter_ids().iter().position(|&i| i == 5).unwrap() as u32).into(), + 2, (voter_ids().iter().position(|&i| i == 2).unwrap() as u32).into(), 2 )); - assert_eq!(Council::voters(), vec![5]); - assert_eq!(Council::approvals_of(2).len(), 0); - assert_eq!(Balances::total_balance(&2), 17); - assert_eq!(Balances::total_balance(&5), 53); + assert_eq!(voter_ids(), vec![0, 5]); + assert_eq!(Council::all_approvals_of(&2).len(), 0); + assert_eq!(Balances::total_balance(&2), 20); + assert_eq!(Balances::total_balance(&5), 50); }); } #[test] fn presenting_for_double_election_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_eq!(Council::submit_candidacy(Origin::signed(2), 0), Ok(())); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1041,21 +2099,26 @@ mod tests { assert_ok!(Council::end_block(System::block_number())); System::set_block_number(8); + // NOTE: This is now mandatory to disable the lock + assert_ok!(Council::retract_voter(Origin::signed(2), 0)); assert_eq!(Council::submit_candidacy(Origin::signed(2), 0), Ok(())); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 1)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 1, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); - assert_noop!(Council::present_winner(Origin::signed(4), 2, 20, 1), "candidate must not form a duplicated member if elected"); + assert_noop!( + Council::present_winner(Origin::signed(4), 2, 20, 1), + "candidate must not form a duplicated member if elected" + ); }); } #[test] fn retracting_inactive_voter_with_other_candidates_in_slots_should_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().voter_bond(2).build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1064,7 +2127,7 @@ mod tests { System::set_block_number(8); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); @@ -1075,24 +2138,24 @@ mod tests { assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); assert_ok!(Council::reap_inactive_voter(Origin::signed(5), - (Council::voters().iter().position(|&i| i == 5).unwrap() as u32).into(), - 2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(), + (voter_ids().iter().position(|&i| i == 5).unwrap() as u32).into(), + 2, (voter_ids().iter().position(|&i| i == 2).unwrap() as u32).into(), 2 )); - assert_eq!(Council::voters(), vec![5]); - assert_eq!(Council::approvals_of(2).len(), 0); - assert_eq!(Balances::total_balance(&2), 17); - assert_eq!(Balances::total_balance(&5), 53); + assert_eq!(voter_ids(), vec![0, 5]); + assert_eq!(Council::all_approvals_of(&2).len(), 0); + assert_eq!(Balances::total_balance(&2), 18); + assert_eq!(Balances::total_balance(&5), 52); }); } #[test] fn retracting_inactive_voter_with_bad_reporter_index_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1101,7 +2164,7 @@ mod tests { System::set_block_number(8); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); @@ -1110,18 +2173,18 @@ mod tests { assert_noop!(Council::reap_inactive_voter(Origin::signed(2), 42, - 2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(), + 2, (voter_ids().iter().position(|&i| i == 2).unwrap() as u32).into(), 2 - ), "bad reporter index"); + ), "invalid reporter index"); }); } #[test] fn retracting_inactive_voter_with_bad_target_index_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1130,7 +2193,7 @@ mod tests { System::set_block_number(8); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); @@ -1138,25 +2201,25 @@ mod tests { assert_ok!(Council::end_block(System::block_number())); assert_noop!(Council::reap_inactive_voter(Origin::signed(2), - (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(), + (voter_ids().iter().position(|&i| i == 2).unwrap() as u32).into(), 2, 42, 2 - ), "bad target index"); + ), "invalid target index"); }); } #[test] fn attempting_to_retract_active_voter_should_slash_reporter() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 1)); assert_ok!(Council::submit_candidacy(Origin::signed(4), 2)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 3)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false, false, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, false, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, true, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false, false, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, true, false, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1171,34 +2234,34 @@ mod tests { assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); - assert_ok!(Council::present_winner(Origin::signed(4), 2, 20, 1)); - assert_ok!(Council::present_winner(Origin::signed(4), 3, 30, 1)); + assert_ok!(Council::present_winner(Origin::signed(4), 2, 20 + Council::get_offset(20, 1), 1)); + assert_ok!(Council::present_winner(Origin::signed(4), 3, 30 + Council::get_offset(30, 1), 1)); assert_ok!(Council::end_block(System::block_number())); assert_eq!(Council::vote_index(), 2); assert_eq!(Council::inactivity_grace_period(), 1); assert_eq!(Council::voting_period(), 4); - assert_eq!(Council::voter_last_active(4), Some(0)); + assert_eq!(Council::voter_info(4), Some(VoterInfo { last_win: 1, last_active: 0, stake: 40, pot: 0 })); assert_ok!(Council::reap_inactive_voter(Origin::signed(4), - (Council::voters().iter().position(|&i| i == 4).unwrap() as u32).into(), + (voter_ids().iter().position(|&i| i == 4).unwrap() as u32).into(), 2, - (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(), + (voter_ids().iter().position(|&i| i == 2).unwrap() as u32).into(), 2 )); - assert_eq!(Council::voters(), vec![2, 3, 5]); - assert_eq!(Council::approvals_of(4).len(), 0); - assert_eq!(Balances::total_balance(&4), 37); + assert_eq!(voter_ids(), vec![2, 3, 0, 5]); + assert_eq!(Council::all_approvals_of(&4).len(), 0); + assert_eq!(Balances::total_balance(&4), 40); }); } #[test] fn attempting_to_retract_inactive_voter_by_nonvoter_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1207,7 +2270,7 @@ mod tests { System::set_block_number(8); assert_ok!(Council::submit_candidacy(Origin::signed(5), 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![true], 1, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); @@ -1216,7 +2279,7 @@ mod tests { assert_noop!(Council::reap_inactive_voter(Origin::signed(4), 0, - 2, (Council::voters().iter().position(|&i| i == 2).unwrap() as u32).into(), + 2, (voter_ids().iter().position(|&i| i == 2).unwrap() as u32).into(), 2 ), "reporter must be a voter"); }); @@ -1224,18 +2287,18 @@ mod tests { #[test] fn presenting_loser_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); - assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(4), 3)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 4)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1257,18 +2320,18 @@ mod tests { #[test] fn presenting_loser_first_should_not_matter() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); - assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(4), 3)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 4)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1289,21 +2352,24 @@ mod tests { #[test] fn present_outside_of_presentation_period_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert!(!Council::presentation_active()); - assert_noop!(Council::present_winner(Origin::signed(5), 5, 1, 0), "cannot present outside of presentation period"); + assert_noop!( + Council::present_winner(Origin::signed(5), 5, 1, 0), + "cannot present outside of presentation period" + ); }); } #[test] fn present_with_invalid_vote_index_should_not_work() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1313,34 +2379,50 @@ mod tests { #[test] fn present_when_presenter_is_poor_should_not_work() { - with_externalities(&mut new_test_ext(false), || { - System::set_block_number(4); - assert!(!Council::presentation_active()); - - assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); - assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0)); - assert_ok!(Council::end_block(System::block_number())); - - System::set_block_number(6); - assert_eq!(Balances::free_balance(&1), 1); - assert_eq!(Balances::reserved_balance(&1), 9); - assert_noop!(Council::present_winner(Origin::signed(1), 1, 20, 0), "presenter must have sufficient slashable funds"); - }); + let test_present = |p| { + with_externalities(&mut ExtBuilder::default() + .voting_fee(5) + .voter_bond(2) + .bad_presentation_punishment(p) + .build(), + || { + System::set_block_number(4); + let _ = Balances::make_free_balance_be(&1, 15); + assert!(!Council::presentation_active()); + + assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); // -3 + assert_eq!(Balances::free_balance(&1), 12); + assert_ok!(Council::set_approvals(Origin::signed(1), vec![true], 0, 0)); // -2 -5 + assert_ok!(Council::end_block(System::block_number())); + + System::set_block_number(6); + assert_eq!(Balances::free_balance(&1), 5); + assert_eq!(Balances::reserved_balance(&1), 5); + if p > 5 { + assert_noop!(Council::present_winner( + Origin::signed(1), 1, 10, 0), + "presenter must have sufficient slashable funds" + ); + } else { + assert_ok!(Council::present_winner(Origin::signed(1), 1, 10, 0)); + } + }); + }; + test_present(4); + test_present(6); } #[test] fn invalid_present_tally_should_slash() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert!(!Council::presentation_active()); assert_eq!(Balances::total_balance(&4), 40); assert_ok!(Council::submit_candidacy(Origin::signed(2), 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![true, false], 0, 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1352,20 +2434,20 @@ mod tests { #[test] fn runners_up_should_be_kept() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert!(!Council::presentation_active()); assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); - assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(4), 3)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 4)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); @@ -1373,7 +2455,7 @@ mod tests { assert!(Council::presentation_active()); assert_ok!(Council::present_winner(Origin::signed(4), 1, 60, 0)); // leaderboard length is the empty seats plus the carry count (i.e. 5 + 2), where those - // to be carried are the lowest and stored in lowest indexes + // to be carried are the lowest and stored in lowest indices assert_eq!(Council::leaderboard(), Some(vec![ (0, 0), (0, 0), @@ -1401,11 +2483,11 @@ mod tests { assert!(Council::is_a_candidate(&3)); assert!(Council::is_a_candidate(&4)); assert_eq!(Council::vote_index(), 1); - assert_eq!(Council::voter_last_active(2), Some(0)); - assert_eq!(Council::voter_last_active(3), Some(0)); - assert_eq!(Council::voter_last_active(4), Some(0)); - assert_eq!(Council::voter_last_active(5), Some(0)); - assert_eq!(Council::voter_last_active(6), Some(0)); + assert_eq!(Council::voter_info(2), Some(VoterInfo { last_win: 0, last_active: 0, stake: 20, pot: 0 })); + assert_eq!(Council::voter_info(3), Some(VoterInfo { last_win: 0, last_active: 0, stake: 30, pot: 0 })); + assert_eq!(Council::voter_info(4), Some(VoterInfo { last_win: 0, last_active: 0, stake: 40, pot: 0 })); + assert_eq!(Council::voter_info(5), Some(VoterInfo { last_win: 1, last_active: 0, stake: 50, pot: 0 })); + assert_eq!(Council::voter_info(6), Some(VoterInfo { last_win: 1, last_active: 0, stake: 60, pot: 0 })); assert_eq!(Council::candidate_reg_info(3), Some((0, 2))); assert_eq!(Council::candidate_reg_info(4), Some((0, 3))); }); @@ -1413,18 +2495,18 @@ mod tests { #[test] fn second_tally_should_use_runners_up() { - with_externalities(&mut new_test_ext(false), || { + with_externalities(&mut ExtBuilder::default().build(), || { System::set_block_number(4); assert_ok!(Council::submit_candidacy(Origin::signed(1), 0)); - assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(2), 1)); - assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(2), vec![false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(3), 2)); - assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(3), vec![false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(4), 3)); - assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(4), vec![false, false, false, true], 0, 0)); assert_ok!(Council::submit_candidacy(Origin::signed(5), 4)); - assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0)); + assert_ok!(Council::set_approvals(Origin::signed(5), vec![false, false, false, false, true], 0, 0)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(6); @@ -1435,13 +2517,13 @@ mod tests { assert_ok!(Council::end_block(System::block_number())); System::set_block_number(8); - assert_ok!(Council::set_approvals(Origin::signed(6), vec![false, false, true, false], 1)); + assert_ok!(Council::set_approvals(Origin::signed(6), vec![false, false, true, false], 1, 0)); assert_ok!(Council::set_desired_seats(3)); assert_ok!(Council::end_block(System::block_number())); System::set_block_number(10); - assert_ok!(Council::present_winner(Origin::signed(4), 3, 90, 1)); - assert_ok!(Council::present_winner(Origin::signed(4), 4, 40, 1)); + assert_ok!(Council::present_winner(Origin::signed(4), 3, 30 + Council::get_offset(30, 1) + 60, 1)); + assert_ok!(Council::present_winner(Origin::signed(4), 4, 40 + Council::get_offset(40, 1), 1)); assert_ok!(Council::end_block(System::block_number())); assert!(!Council::presentation_active()); @@ -1453,11 +2535,14 @@ mod tests { assert!(!Council::is_a_candidate(&5)); assert!(Council::is_a_candidate(&4)); assert_eq!(Council::vote_index(), 2); - assert_eq!(Council::voter_last_active(2), Some(0)); - assert_eq!(Council::voter_last_active(3), Some(0)); - assert_eq!(Council::voter_last_active(4), Some(0)); - assert_eq!(Council::voter_last_active(5), Some(0)); - assert_eq!(Council::voter_last_active(6), Some(1)); + assert_eq!(Council::voter_info(2), Some( VoterInfo { last_win: 0, last_active: 0, stake: 20, pot: 0})); + assert_eq!(Council::voter_info(3), Some( VoterInfo { last_win: 2, last_active: 0, stake: 30, pot: 0})); + assert_eq!(Council::voter_info(4), Some( VoterInfo { last_win: 0, last_active: 0, stake: 40, pot: 0})); + assert_eq!(Council::voter_info(5), Some( VoterInfo { last_win: 1, last_active: 0, stake: 50, pot: 0})); + assert_eq!( + Council::voter_info(6), + Some(VoterInfo { last_win: 2, last_active: 1, stake: 60, pot: 0}) + ); assert_eq!(Council::candidate_reg_info(4), Some((0, 3))); }); diff --git a/srml/indices/src/lib.rs b/srml/indices/src/lib.rs index 509e5c1133..38f7ee668d 100644 --- a/srml/indices/src/lib.rs +++ b/srml/indices/src/lib.rs @@ -45,7 +45,7 @@ pub trait ResolveHint { fn resolve_hint(who: &AccountId) -> Option; } -/// Simple encode-based resolve hint implemenntation. +/// Simple encode-based resolve hint implementation. pub struct SimpleResolveHint(PhantomData<(AccountId, AccountIndex)>); impl> ResolveHint for SimpleResolveHint -- GitLab From dacdac6addf81c2e57b4b86cb3b595eddb0c2b74 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Fri, 7 Jun 2019 15:27:55 +0200 Subject: [PATCH 102/113] Fix construct_runtime multiple log issue (#2816) * Fix comma issue * multiple log test --- srml/support/src/runtime.rs | 2 +- srml/support/test/tests/instance.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/srml/support/src/runtime.rs b/srml/support/src/runtime.rs index 4bf574bae5..1ce95a3f3c 100644 --- a/srml/support/src/runtime.rs +++ b/srml/support/src/runtime.rs @@ -287,7 +287,7 @@ macro_rules! construct_runtime { $uncheckedextrinsic; ; $( - $name: $module::{ $( $modules $( ( $( $modules_args ),* ) )* ),* } + $name: $module::{ $( $modules $( ( $( $modules_args )* ) )* ),* } ),*; ); $crate::__impl_outer_validate_unsigned!( diff --git a/srml/support/test/tests/instance.rs b/srml/support/test/tests/instance.rs index 796934777d..df9f648c18 100644 --- a/srml/support/test/tests/instance.rs +++ b/srml/support/test/tests/instance.rs @@ -163,14 +163,17 @@ mod module1 { pub type Log = RawLog< T, I, + ::Hash, >; /// A logs in this module. #[cfg_attr(feature = "std", derive(serde::Serialize, Debug))] #[derive(parity_codec::Encode, parity_codec::Decode, PartialEq, Eq, Clone)] - pub enum RawLog { + pub enum RawLog { _Phantom(rstd::marker::PhantomData<(T, I)>), AmountChange(u32), + ChangesTrieRoot(Hash), + AuthoritiesChange(Vec<()>), } pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678"; @@ -341,8 +344,8 @@ srml_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Event, Log(ChangesTrieRoot)}, - Module1_1: module1::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, - Module1_2: module1::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module1_1: module1::::{Module, Call, Storage, Event, Config, Origin, Log(ChangesTrieRoot, AuthoritiesChange), Inherent}, + Module1_2: module1::::{Module, Call, Storage, Event, Config, Origin, Log(ChangesTrieRoot, AuthoritiesChange), Inherent}, Module2: module2::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, Module2_1: module2::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, Module2_2: module2::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, -- GitLab From c67dff53d0435c21fd45fd02e8fe7297cde7a7d9 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 7 Jun 2019 15:30:45 +0200 Subject: [PATCH 103/113] Move modules around in network (#2822) * Rename modules in protocol * Line widths --- core/network/src/lib.rs | 13 ++---- core/network/src/on_demand_layer.rs | 2 +- core/network/src/protocol.rs | 26 +++++++---- .../src/{ => protocol}/consensus_gossip.rs | 7 ++- core/network/src/{ => protocol}/message.rs | 0 core/network/src/{ => protocol}/on_demand.rs | 0 .../src/{ => protocol}/specialization.rs | 0 core/network/src/{ => protocol}/sync.rs | 46 +++++++++++++++---- .../network/src/{ => protocol/sync}/blocks.rs | 29 ++++++++---- .../src/{ => protocol}/sync/extra_requests.rs | 4 +- core/network/src/{ => protocol}/util.rs | 0 core/network/src/service.rs | 8 ++-- 12 files changed, 89 insertions(+), 46 deletions(-) rename core/network/src/{ => protocol}/consensus_gossip.rs (99%) rename core/network/src/{ => protocol}/message.rs (100%) rename core/network/src/{ => protocol}/on_demand.rs (100%) rename core/network/src/{ => protocol}/specialization.rs (100%) rename core/network/src/{ => protocol}/sync.rs (96%) rename core/network/src/{ => protocol/sync}/blocks.rs (89%) rename core/network/src/{ => protocol}/sync/extra_requests.rs (99%) rename core/network/src/{ => protocol}/util.rs (100%) diff --git a/core/network/src/lib.rs b/core/network/src/lib.rs index e2def15425..a65df59fd8 100644 --- a/core/network/src/lib.rs +++ b/core/network/src/lib.rs @@ -24,19 +24,12 @@ //! mod service; -mod sync; #[macro_use] mod protocol; mod chain; -mod blocks; -mod on_demand; mod on_demand_layer; -mod util; pub mod config; -pub mod consensus_gossip; pub mod error; -pub mod message; -pub mod specialization; #[cfg(any(test, feature = "test-helpers"))] pub mod test; @@ -46,8 +39,8 @@ pub use service::{ NetworkService, NetworkWorker, FetchFuture, TransactionPool, ManageNetwork, NetworkMsg, SyncProvider, ExHashT, ReportHandle, }; -pub use protocol::{ProtocolStatus, PeerInfo, Context}; -pub use sync::{Status as SyncStatus, SyncState}; +pub use protocol::{ProtocolStatus, PeerInfo, Context, consensus_gossip, message, specialization}; +pub use protocol::sync::{Status as SyncStatus, SyncState}; pub use network_libp2p::{ identity, multiaddr, ProtocolId, Multiaddr, @@ -57,7 +50,7 @@ pub use network_libp2p::{ }; pub use message::{generic as generic_message, RequestId, Status as StatusMessage}; pub use error::Error; -pub use on_demand::AlwaysBadChecker; +pub use protocol::on_demand::AlwaysBadChecker; pub use on_demand_layer::{OnDemand, RemoteResponse}; #[doc(hidden)] pub use runtime_primitives::traits::Block as BlockT; diff --git a/core/network/src/on_demand_layer.rs b/core/network/src/on_demand_layer.rs index e58e045f2e..86b3d6b7f4 100644 --- a/core/network/src/on_demand_layer.rs +++ b/core/network/src/on_demand_layer.rs @@ -16,7 +16,7 @@ //! On-demand requests service. -use crate::on_demand::RequestData; +use crate::protocol::on_demand::RequestData; use std::sync::Arc; use futures::{prelude::*, sync::mpsc, sync::oneshot}; use parking_lot::Mutex; diff --git a/core/network/src/protocol.rs b/core/network/src/protocol.rs index 651f064513..576d37a82f 100644 --- a/core/network/src/protocol.rs +++ b/core/network/src/protocol.rs @@ -24,16 +24,16 @@ use runtime_primitives::traits::{ CheckedSub, SaturatedConversion }; use consensus::import_queue::SharedFinalityProofRequestBuilder; -use crate::message::{ - self, BlockRequest as BlockRequestMessage, +use message::{ + BlockRequest as BlockRequestMessage, FinalityProofRequest as FinalityProofRequestMessage, Message, }; -use crate::message::{BlockAttributes, Direction, FromBlock, RequestId}; -use crate::message::generic::{Message as GenericMessage, ConsensusMessage}; -use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; -use crate::on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; -use crate::specialization::NetworkSpecialization; -use crate::sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; +use message::{BlockAttributes, Direction, FromBlock, RequestId}; +use message::generic::{Message as GenericMessage, ConsensusMessage}; +use consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; +use on_demand::{OnDemandCore, OnDemandNetwork, RequestData}; +use specialization::NetworkSpecialization; +use sync::{ChainSync, Context as SyncContext, Status as SyncStatus, SyncState}; use crate::service::{TransactionPool, ExHashT}; use crate::config::Roles; use rustc_hex::ToHex; @@ -43,7 +43,15 @@ use std::{cmp, num::NonZeroUsize, time}; use log::{trace, debug, warn, error}; use crate::chain::{Client, FinalityProofProvider}; use client::light::fetcher::{FetchChecker, ChangesProof}; -use crate::{error, util::LruHashSet}; +use crate::error; +use util::LruHashSet; + +mod util; +pub mod consensus_gossip; +pub mod message; +pub mod on_demand; +pub mod specialization; +pub mod sync; const REQUEST_TIMEOUT_SEC: u64 = 40; /// Interval at which we perform time based maintenance diff --git a/core/network/src/consensus_gossip.rs b/core/network/src/protocol/consensus_gossip.rs similarity index 99% rename from core/network/src/consensus_gossip.rs rename to core/network/src/protocol/consensus_gossip.rs index 9d654b5bfa..5de6fb2602 100644 --- a/core/network/src/consensus_gossip.rs +++ b/core/network/src/protocol/consensus_gossip.rs @@ -208,7 +208,12 @@ pub trait Validator: Send + Sync { } /// Validate consensus message. - fn validate(&self, context: &mut dyn ValidatorContext, sender: &PeerId, data: &[u8]) -> ValidationResult; + fn validate( + &self, + context: &mut dyn ValidatorContext, + sender: &PeerId, + data: &[u8] + ) -> ValidationResult; /// Produce a closure for validating messages on a given topic. fn message_expired<'a>(&'a self) -> Box bool + 'a> { diff --git a/core/network/src/message.rs b/core/network/src/protocol/message.rs similarity index 100% rename from core/network/src/message.rs rename to core/network/src/protocol/message.rs diff --git a/core/network/src/on_demand.rs b/core/network/src/protocol/on_demand.rs similarity index 100% rename from core/network/src/on_demand.rs rename to core/network/src/protocol/on_demand.rs diff --git a/core/network/src/specialization.rs b/core/network/src/protocol/specialization.rs similarity index 100% rename from core/network/src/specialization.rs rename to core/network/src/protocol/specialization.rs diff --git a/core/network/src/sync.rs b/core/network/src/protocol/sync.rs similarity index 96% rename from core/network/src/sync.rs rename to core/network/src/protocol/sync.rs index f3f62cac01..4ec8f18e35 100644 --- a/core/network/src/sync.rs +++ b/core/network/src/protocol/sync.rs @@ -39,8 +39,8 @@ use network_libp2p::PeerId; use client::{BlockStatus, ClientInfo}; use consensus::{BlockOrigin, import_queue::{IncomingBlock, SharedFinalityProofRequestBuilder}}; use client::error::Error as ClientError; -use crate::blocks::BlockCollection; -use crate::sync::extra_requests::ExtraRequestsAggregator; +use blocks::BlockCollection; +use extra_requests::ExtraRequestsAggregator; use runtime_primitives::traits::{ Block as BlockT, Header as HeaderT, NumberFor, Zero, One, CheckedSub, SaturatedConversion @@ -50,6 +50,7 @@ use crate::message; use crate::config::Roles; use std::collections::HashSet; +mod blocks; mod extra_requests; // Maximum blocks to request in a single packet. @@ -303,13 +304,18 @@ impl ChainSync { common_number: Zero::zero(), best_hash: info.best_hash, best_number: info.best_number, - state: PeerSyncState::AncestorSearch(common_best, AncestorSearchState::ExponentialBackoff(One::one())), + state: PeerSyncState::AncestorSearch( + common_best, + AncestorSearchState::ExponentialBackoff(One::one()) + ), recently_announced: Default::default(), }); Self::request_ancestry(protocol, who, common_best) } }, - (Ok(BlockStatus::Queued), _) | (Ok(BlockStatus::InChainWithState), _) | (Ok(BlockStatus::InChainPruned), _) => { + (Ok(BlockStatus::Queued), _) | + (Ok(BlockStatus::InChainWithState), _) | + (Ok(BlockStatus::InChainPruned), _) => { debug!(target:"sync", "New peer with known best hash {} ({}).", info.best_hash, info.best_number); self.peers.insert(who.clone(), PeerSync { common_number: info.best_number, @@ -441,7 +447,8 @@ impl ChainSync { protocol.disconnect_peer(who); return None } - if let Some((next_state, next_block_num)) = Self::handle_ancestor_search_state(state, num, block_hash_match) { + if let Some((next_state, next_block_num)) = + Self::handle_ancestor_search_state(state, num, block_hash_match) { peer.state = PeerSyncState::AncestorSearch(next_block_num, next_state); Self::request_ancestry(protocol, who, next_block_num); return None @@ -450,7 +457,9 @@ impl ChainSync { vec![] } }, - PeerSyncState::Available | PeerSyncState::DownloadingJustification(..) | PeerSyncState::DownloadingFinalityProof(..) => Vec::new(), + PeerSyncState::Available | + PeerSyncState::DownloadingJustification(..) | + PeerSyncState::DownloadingFinalityProof(..) => Vec::new(), } } else { Vec::new() @@ -770,11 +779,19 @@ impl ChainSync { if protocol.client().block_status(&BlockId::Number(*header.number())) .unwrap_or(BlockStatus::Unknown) == BlockStatus::InChainPruned { - trace!(target: "sync", "Ignored unknown ancient block announced from {}: {} {:?}", who, hash, header); + trace!( + target: "sync", + "Ignored unknown ancient block announced from {}: {} {:?}", + who, hash, header + ); return false; } - trace!(target: "sync", "Considering new unknown stale block announced from {}: {} {:?}", who, hash, header); + trace!( + target: "sync", + "Considering new unknown stale block announced from {}: {} {:?}", + who, hash, header + ); let request = self.download_unknown_stale(&who, &hash); match request { Some(request) => if requires_additional_data { @@ -787,7 +804,11 @@ impl ChainSync { } } else { if ancient_parent { - trace!(target: "sync", "Ignored ancient stale block announced from {}: {} {:?}", who, hash, header); + trace!( + target: "sync", + "Ignored ancient stale block announced from {}: {} {:?}", + who, hash, header + ); return false; } @@ -934,7 +955,12 @@ impl ChainSync { peer.common_number, peer.best_number, ); - let range = self.blocks.needed_blocks(who.clone(), MAX_BLOCKS_TO_REQUEST, peer.best_number, peer.common_number); + let range = self.blocks.needed_blocks( + who.clone(), + MAX_BLOCKS_TO_REQUEST, + peer.best_number, + peer.common_number + ); match range { Some(range) => { trace!(target: "sync", "Requesting blocks from {}, ({} to {})", who, range.start, range.end); diff --git a/core/network/src/blocks.rs b/core/network/src/protocol/sync/blocks.rs similarity index 89% rename from core/network/src/blocks.rs rename to core/network/src/protocol/sync/blocks.rs index d693afba17..66730fcc3e 100644 --- a/core/network/src/blocks.rs +++ b/core/network/src/protocol/sync/blocks.rs @@ -100,7 +100,8 @@ impl BlockCollection { } /// Returns a set of block hashes that require a header download. The returned set is marked as being downloaded. - pub fn needed_blocks(&mut self, who: PeerId, count: usize, peer_best: NumberFor, common: NumberFor) -> Option>> { + pub fn needed_blocks(&mut self, who: PeerId, count: usize, peer_best: NumberFor, common: NumberFor) + -> Option>> { // First block number that we need to download let first_different = common + >::one(); let count = (count as u32).into(); @@ -110,7 +111,8 @@ impl BlockCollection { loop { let next = downloading_iter.next(); break match &(prev, next) { - &(Some((start, &BlockRangeState::Downloading { ref len, downloading })), _) if downloading < MAX_PARALLEL_DOWNLOADS => + &(Some((start, &BlockRangeState::Downloading { ref len, downloading })), _) + if downloading < MAX_PARALLEL_DOWNLOADS => (*start .. *start + *len, downloading), &(Some((start, r)), Some((next_start, _))) if *start + r.len() < *next_start => (*start + r.len() .. cmp::min(*next_start, *start + r.len() + count), 0), // gap @@ -134,9 +136,13 @@ impl BlockCollection { } range.end = cmp::min(peer_best + One::one(), range.end); self.peer_requests.insert(who, range.start); - self.blocks.insert(range.start, BlockRangeState::Downloading { len: range.end - range.start, downloading: downloading + 1 }); + self.blocks.insert(range.start, BlockRangeState::Downloading { + len: range.end - range.start, + downloading: downloading + 1 + }); if range.end <= range.start { - panic!("Empty range {:?}, count={}, peer_best={}, common={}, blocks={:?}", range, count, peer_best, common, self.blocks); + panic!("Empty range {:?}, count={}, peer_best={}, common={}, blocks={:?}", + range, count, peer_best, common, self.blocks); } Some(range) } @@ -248,14 +254,17 @@ mod test { bc.insert(1, blocks[1..11].to_vec(), peer0.clone()); assert_eq!(bc.needed_blocks(peer0.clone(), 40, 150, 0), Some(11 .. 41)); - assert_eq!(bc.drain(1), blocks[1..11].iter().map(|b| BlockData { block: b.clone(), origin: Some(peer0.clone()) }).collect::>()); + assert_eq!(bc.drain(1), blocks[1..11].iter() + .map(|b| BlockData { block: b.clone(), origin: Some(peer0.clone()) }).collect::>()); bc.clear_peer_download(&peer0); bc.insert(11, blocks[11..41].to_vec(), peer0.clone()); let drained = bc.drain(12); - assert_eq!(drained[..30], blocks[11..41].iter().map(|b| BlockData { block: b.clone(), origin: Some(peer0.clone()) }).collect::>()[..]); - assert_eq!(drained[30..], blocks[41..81].iter().map(|b| BlockData { block: b.clone(), origin: Some(peer1.clone()) }).collect::>()[..]); + assert_eq!(drained[..30], blocks[11..41].iter() + .map(|b| BlockData { block: b.clone(), origin: Some(peer0.clone()) }).collect::>()[..]); + assert_eq!(drained[30..], blocks[41..81].iter() + .map(|b| BlockData { block: b.clone(), origin: Some(peer1.clone()) }).collect::>()[..]); bc.clear_peer_download(&peer2); assert_eq!(bc.needed_blocks(peer2.clone(), 40, 150, 80), Some(81 .. 121)); @@ -266,8 +275,10 @@ mod test { assert_eq!(bc.drain(80), vec![]); let drained = bc.drain(81); - assert_eq!(drained[..40], blocks[81..121].iter().map(|b| BlockData { block: b.clone(), origin: Some(peer2.clone()) }).collect::>()[..]); - assert_eq!(drained[40..], blocks[121..150].iter().map(|b| BlockData { block: b.clone(), origin: Some(peer1.clone()) }).collect::>()[..]); + assert_eq!(drained[..40], blocks[81..121].iter() + .map(|b| BlockData { block: b.clone(), origin: Some(peer2.clone()) }).collect::>()[..]); + assert_eq!(drained[40..], blocks[121..150].iter() + .map(|b| BlockData { block: b.clone(), origin: Some(peer1.clone()) }).collect::>()[..]); } #[test] diff --git a/core/network/src/sync/extra_requests.rs b/core/network/src/protocol/sync/extra_requests.rs similarity index 99% rename from core/network/src/sync/extra_requests.rs rename to core/network/src/protocol/sync/extra_requests.rs index ff8323166b..f41997a05c 100644 --- a/core/network/src/sync/extra_requests.rs +++ b/core/network/src/protocol/sync/extra_requests.rs @@ -23,8 +23,8 @@ use fork_tree::ForkTree; use network_libp2p::PeerId; use runtime_primitives::Justification; use runtime_primitives::traits::{Block as BlockT, NumberFor}; -use crate::message; -use crate::sync::{Context, PeerSync, PeerSyncState}; +use crate::protocol::message; +use crate::protocol::sync::{Context, PeerSync, PeerSyncState}; // Time to wait before trying to get the same extra data from the same peer. const EXTRA_RETRY_WAIT: Duration = Duration::from_secs(10); diff --git a/core/network/src/util.rs b/core/network/src/protocol/util.rs similarity index 100% rename from core/network/src/util.rs rename to core/network/src/protocol/util.rs diff --git a/core/network/src/service.rs b/core/network/src/service.rs index 88c13b4806..6a328e854d 100644 --- a/core/network/src/service.rs +++ b/core/network/src/service.rs @@ -31,14 +31,14 @@ use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId use crate::AlwaysBadChecker; use crate::chain::FinalityProofProvider; -use crate::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; -use crate::message::Message; -use crate::on_demand::RequestData; +use crate::protocol::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; +use crate::protocol::message::Message; +use crate::protocol::on_demand::RequestData; use crate::protocol::{self, Context, CustomMessageOutcome, Protocol, ConnectedPeer}; use crate::protocol::{ProtocolStatus, PeerInfo, NetworkOut}; use crate::config::Params; use crate::error::Error; -use crate::specialization::NetworkSpecialization; +use crate::protocol::specialization::NetworkSpecialization; /// Interval at which we send status updates on the SyncProvider status stream. const STATUS_INTERVAL: Duration = Duration::from_millis(5000); -- GitLab From 43164e24f23fe71d82906b4379e043bfdf9beba3 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 7 Jun 2019 16:06:15 +0200 Subject: [PATCH 104/113] More crate compiling for WASM-browser (#2825) * More crate compiling for WASM-browser * Update runtime Cargo.lock --- .gitlab-ci.yml | 4 +++ Cargo.lock | 4 ++- core/consensus/aura/Cargo.toml | 3 +- core/consensus/aura/src/lib.rs | 4 +-- core/consensus/babe/Cargo.toml | 3 +- core/consensus/babe/src/lib.rs | 4 +-- core/consensus/slots/Cargo.toml | 2 +- core/consensus/slots/src/lib.rs | 54 ------------------------------- core/consensus/slots/src/slots.rs | 2 +- core/test-runtime/wasm/Cargo.lock | 2 +- 10 files changed, 18 insertions(+), 64 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 99b354a60b..d3c9951df4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -137,10 +137,14 @@ check-web-wasm: - time cargo web build -p sr-io - time cargo web build -p sr-primitives - time cargo web build -p sr-std + - time cargo web build -p substrate-client + - time cargo web build -p substrate-consensus-aura + - time cargo web build -p substrate-consensus-babe - time cargo web build -p substrate-consensus-common - time cargo web build -p substrate-keyring - time cargo web build -p substrate-keystore - time cargo web build -p substrate-executor + - time cargo web build -p substrate-network - time cargo web build -p substrate-network-libp2p - time cargo web build -p substrate-panic-handler - time cargo web build -p substrate-peerset diff --git a/Cargo.lock b/Cargo.lock index 7e92564208..738ccb6694 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4068,6 +4068,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4125,6 +4126,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4196,7 +4198,7 @@ dependencies = [ "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/core/consensus/aura/Cargo.toml b/core/consensus/aura/Cargo.toml index 446dcbff3a..9c46b942a4 100644 --- a/core/consensus/aura/Cargo.toml +++ b/core/consensus/aura/Cargo.toml @@ -22,7 +22,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../common" authorities = { package = "substrate-consensus-authorities", path = "../authorities" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.17" -tokio = "0.1.7" +tokio-timer = "0.2.11" parking_lot = "0.8.0" log = "0.4" @@ -32,4 +32,5 @@ substrate-executor = { path = "../../executor" } network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} service = { package = "substrate-service", path = "../../service" } test_client = { package = "substrate-test-client", path = "../../test-client" } +tokio = "0.1.7" env_logger = "0.6" diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index e3fffad33f..ad618c2188 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -56,7 +56,7 @@ use inherents::{InherentDataProviders, InherentData}; use authorities::AuthoritiesApi; use futures::{Future, IntoFuture, future}; -use tokio::timer::Timeout; +use tokio_timer::Timeout; use log::{error, warn, debug, info, trace}; use srml_aura::{ @@ -914,7 +914,7 @@ mod tests { .map(|_| ()) .map_err(|_| ()); - let drive_to_completion = ::tokio::timer::Interval::new_interval(TEST_ROUTING_INTERVAL) + let drive_to_completion = ::tokio_timer::Interval::new_interval(TEST_ROUTING_INTERVAL) .for_each(move |_| { net.lock().send_import_notifications(); net.lock().sync_without_disconnects(); diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 04cd42c680..020497a104 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -23,7 +23,7 @@ authorities = { package = "substrate-consensus-authorities", path = "../authorit slots = { package = "substrate-consensus-slots", path = "../slots" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.26" -tokio = "0.1.18" +tokio-timer = "0.2.11" parking_lot = "0.8.0" log = "0.4.6" schnorrkel = "0.1.1" @@ -36,4 +36,5 @@ substrate-executor = { path = "../../executor" } network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} service = { package = "substrate-service", path = "../../service" } test_client = { package = "substrate-test-client", path = "../../test-client" } +tokio = "0.1.18" env_logger = "0.6.1" diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index c66eb68137..f28c23de54 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -79,7 +79,7 @@ use client::{ }; use slots::{CheckedHeader, check_equivocation}; use futures::{Future, IntoFuture, future}; -use tokio::timer::Timeout; +use tokio_timer::Timeout; use log::{error, warn, debug, info, trace}; use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, slot_now}; @@ -984,7 +984,7 @@ mod tests { .map(drop) .map_err(drop); - let drive_to_completion = ::tokio::timer::Interval::new_interval(TEST_ROUTING_INTERVAL) + let drive_to_completion = ::tokio_timer::Interval::new_interval(TEST_ROUTING_INTERVAL) .for_each(move |_| { net.lock().send_import_notifications(); net.lock().sync_without_disconnects(); diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index 7a3b487dc6..b82c2fc9d7 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -13,7 +13,7 @@ runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } consensus_common = { package = "substrate-consensus-common", path = "../common" } inherents = { package = "substrate-inherents", path = "../../inherents" } futures = "0.1.17" -tokio = "0.1.7" +tokio-timer = "0.2.11" parking_lot = "0.8.0" log = "0.4" diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index aee398a9ce..18ec2451be 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -41,8 +41,6 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ApiRef, Block, ProvideRuntimeApi}; use std::fmt::Debug; use std::ops::Deref; -use std::sync::mpsc; -use std::thread; /// A worker that should be invoked at every new slot. pub trait SlotWorker { @@ -66,58 +64,6 @@ pub trait SlotCompatible { ) -> Result<(u64, u64), consensus_common::Error>; } -/// Start a new slot worker in a separate thread. -#[deprecated(since = "1.1", note = "Please spawn a thread manually")] -pub fn start_slot_worker_thread( - slot_duration: SlotDuration, - select_chain: C, - worker: W, - sync_oracle: SO, - on_exit: OnExit, - inherent_data_providers: InherentDataProviders, -) -> Result<(), consensus_common::Error> -where - B: Block + 'static, - C: SelectChain + Clone + 'static, - W: SlotWorker + Send + Sync + 'static, - SO: SyncOracle + Send + Clone + 'static, - SC: SlotCompatible + 'static, - OnExit: Future + Send + 'static, - T: SlotData + Send + Clone + 'static, -{ - use tokio::runtime::current_thread::Runtime; - - let (result_sender, result_recv) = mpsc::channel(); - - thread::spawn(move || { - let mut runtime = match Runtime::new() { - Ok(r) => r, - Err(e) => { - warn!(target: "slots", "Unable to start authorship: {:?}", e); - return; - } - }; - - let slot_worker_future = start_slot_worker::<_, _, _, T, _, SC>( - slot_duration.clone(), - select_chain, - worker, - sync_oracle, - inherent_data_providers, - ); - - result_sender - .send(Ok(())) - .expect("Receive is not dropped before receiving a result; qed"); - - let _ = runtime.block_on(slot_worker_future.select(on_exit).map(|_| ())); - }); - - result_recv - .recv() - .expect("Slots start thread result sender dropped") -} - /// Start a new slot worker. /// /// Every time a new slot is triggered, `worker.on_slot` is called and the future it returns is diff --git a/core/consensus/slots/src/slots.rs b/core/consensus/slots/src/slots.rs index 964eeaff29..a848a96762 100644 --- a/core/consensus/slots/src/slots.rs +++ b/core/consensus/slots/src/slots.rs @@ -26,7 +26,7 @@ use inherents::{InherentData, InherentDataProviders}; use log::warn; use std::marker::PhantomData; use std::time::{Duration, Instant}; -use tokio::timer::Delay; +use tokio_timer::Delay; /// Returns current duration since unix epoch. pub fn duration_now() -> Option { diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index be1e3ab84f..19c6b36ebc 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -2561,7 +2561,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -- GitLab From 389d4f93f4cf52cf821403793555b33df11c092f Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sun, 9 Jun 2019 11:38:41 +0200 Subject: [PATCH 105/113] polite-grandpa: Ensure only votes from a set's voters are propagated (#2720) * make authorities available to gossip * make local view optional until set * address grumbles * micro-optimize: encode without lock held --- core/finality-grandpa/src/aux_schema.rs | 143 +++++++----- .../src/communication/gossip.rs | 213 +++++++++++++----- .../finality-grandpa/src/communication/mod.rs | 29 ++- core/finality-grandpa/src/environment.rs | 51 +++-- core/finality-grandpa/src/lib.rs | 18 +- core/finality-grandpa/src/observer.rs | 16 +- 6 files changed, 325 insertions(+), 145 deletions(-) diff --git a/core/finality-grandpa/src/aux_schema.rs b/core/finality-grandpa/src/aux_schema.rs index 4dd6e75dd9..824c65b9e6 100644 --- a/core/finality-grandpa/src/aux_schema.rs +++ b/core/finality-grandpa/src/aux_schema.rs @@ -151,16 +151,22 @@ fn migrate_from_version0( None => (0, genesis_round()), }; + let set_id = new_set.current().0; + let base = last_round_state.prevote_ghost .expect("state is for completed round; completed rounds must have a prevote ghost; qed."); let set_state = VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: last_round_number, - state: last_round_state, - votes: Vec::new(), - base, - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: last_round_number, + state: last_round_state, + votes: Vec::new(), + base, + }, + set_id, + &new_set, + ), current_round: HasVoted::No, }; @@ -189,6 +195,19 @@ fn migrate_from_version1( backend, AUTHORITY_SET_KEY, )? { + let set_id = set.current().0; + + let completed_rounds = |number, state, base| CompletedRounds::new( + CompletedRound { + number, + state, + votes: Vec::new(), + base, + }, + set_id, + &set, + ); + let set_state = match load_decode::<_, V1VoterSetState>>( backend, SET_STATE_KEY, @@ -198,12 +217,7 @@ fn migrate_from_version1( .expect("state is for completed round; completed rounds must have a prevote ghost; qed."); VoterSetState::Paused { - completed_rounds: CompletedRounds::new(CompletedRound { - number: last_round_number, - state: set_state, - votes: Vec::new(), - base, - }), + completed_rounds: completed_rounds(last_round_number, set_state, base), } }, Some(V1VoterSetState::Live(last_round_number, set_state)) => { @@ -211,12 +225,7 @@ fn migrate_from_version1( .expect("state is for completed round; completed rounds must have a prevote ghost; qed."); VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: last_round_number, - state: set_state, - votes: Vec::new(), - base, - }), + completed_rounds: completed_rounds(last_round_number, set_state, base), current_round: HasVoted::No, } }, @@ -226,12 +235,7 @@ fn migrate_from_version1( .expect("state is for completed round; completed rounds must have a prevote ghost; qed."); VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: 0, - state: set_state, - votes: Vec::new(), - base, - }), + completed_rounds: completed_rounds(0, set_state, base), current_round: HasVoted::No, } }, @@ -298,12 +302,16 @@ pub(crate) fn load_persistent( .expect("state is for completed round; completed rounds must have a prevote ghost; qed."); VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: 0, - votes: Vec::new(), - base, - state, - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: 0, + votes: Vec::new(), + base, + state, + }, + set.current().0, + &set, + ), current_round: HasVoted::No, } } @@ -325,18 +333,23 @@ pub(crate) fn load_persistent( info!(target: "afg", "Loading GRANDPA authority set \ from genesis on what appears to be first startup."); - let genesis_set = AuthoritySet::genesis(genesis_authorities()?); + let genesis_authorities = genesis_authorities()?; + let genesis_set = AuthoritySet::genesis(genesis_authorities.clone()); let state = make_genesis_round(); let base = state.prevote_ghost .expect("state is for completed round; completed rounds must have a prevote ghost; qed."); let genesis_state = VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: 0, - votes: Vec::new(), - state, - base, - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: 0, + votes: Vec::new(), + state, + base, + }, + 0, + &genesis_set, + ), current_round: HasVoted::No, }; backend.insert_aux( @@ -355,6 +368,10 @@ pub(crate) fn load_persistent( } /// Update the authority set on disk after a change. +/// +/// If there has just been a handoff, pass a `new_set` parameter that describes the +/// handoff. `set` in all cases should reflect the current authority set, with all +/// changes and handoffs applied. pub(crate) fn update_authority_set( set: &AuthoritySet>, new_set: Option<&NewAuthoritySet>>, @@ -385,12 +402,16 @@ pub(crate) fn update_authority_set( new_set.canon_number.clone(), )); let set_state = VoterSetState::::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: 0, - state: round_state, - votes: Vec::new(), - base: (new_set.canon_hash, new_set.canon_number), - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: 0, + state: round_state, + votes: Vec::new(), + base: (new_set.canon_hash, new_set.canon_number), + }, + new_set.set_id, + &set, + ), current_round: HasVoted::No, }; let encoded = set_state.encode(); @@ -500,7 +521,7 @@ mod test { assert_eq!( *authority_set.inner().read(), AuthoritySet { - current_authorities: authorities, + current_authorities: authorities.clone(), pending_standard_changes: ForkTree::new(), pending_forced_changes: Vec::new(), set_id, @@ -510,12 +531,16 @@ mod test { assert_eq!( &*set_state.read(), &VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: round_number, - state: round_state.clone(), - base: round_state.prevote_ghost.unwrap(), - votes: vec![], - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: round_number, + state: round_state.clone(), + base: round_state.prevote_ghost.unwrap(), + votes: vec![], + }, + set_id, + &*authority_set.inner().read(), + ), current_round: HasVoted::No, }, ); @@ -583,7 +608,7 @@ mod test { assert_eq!( *authority_set.inner().read(), AuthoritySet { - current_authorities: authorities, + current_authorities: authorities.clone(), pending_standard_changes: ForkTree::new(), pending_forced_changes: Vec::new(), set_id, @@ -593,12 +618,16 @@ mod test { assert_eq!( &*set_state.read(), &VoterSetState::Live { - completed_rounds: CompletedRounds::new(CompletedRound { - number: round_number, - state: round_state.clone(), - base: round_state.prevote_ghost.unwrap(), - votes: vec![], - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: round_number, + state: round_state.clone(), + base: round_state.prevote_ghost.unwrap(), + votes: vec![], + }, + set_id, + &*authority_set.inner().read(), + ), current_round: HasVoted::No, }, ); diff --git a/core/finality-grandpa/src/communication/gossip.rs b/core/finality-grandpa/src/communication/gossip.rs index 460998e707..ca529125ec 100644 --- a/core/finality-grandpa/src/communication/gossip.rs +++ b/core/finality-grandpa/src/communication/gossip.rs @@ -71,6 +71,7 @@ use runtime_primitives::traits::{NumberFor, Block as BlockT, Zero}; use network::consensus_gossip::{self as network_gossip, MessageIntent, ValidatorContext}; use network::{config::Roles, PeerId}; use parity_codec::{Encode, Decode}; +use crate::ed25519::Public as AuthorityId; use substrate_telemetry::{telemetry, CONSENSUS_DEBUG}; use log::{trace, debug, warn}; @@ -94,6 +95,8 @@ enum Consider { RejectPast, /// Message is from the future. Reject. RejectFuture, + /// Message cannot be evaluated. Reject. + RejectOutOfScope, } /// A view of protocol state. @@ -300,6 +303,10 @@ pub(super) enum Misbehavior { // A message received that's from the future relative to our view. // always misbehavior. FutureMessage, + // A message received that cannot be evaluated relative to our view. + // This happens before we have a view and have sent out neighbor packets. + // always misbehavior. + OutOfScopeMessage, } impl Misbehavior { @@ -319,6 +326,7 @@ impl Misbehavior { (benefit as i32).saturating_add(cost as i32) }, FutureMessage => cost::FUTURE_MESSAGE, + OutOfScopeMessage => cost::OUT_OF_SCOPE_MESSAGE, } } } @@ -407,7 +415,7 @@ impl Peers { } } -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub(super) enum Action { // repropagate under given topic, to the given peers, applying cost/benefit to originator. Keep(H, i32), @@ -418,9 +426,10 @@ pub(super) enum Action { } struct Inner { - local_view: View>, + local_view: Option>>, peers: Peers>, live_topics: KeepTopics, + authorities: Vec, config: crate::Config, next_rebroadcast: Instant, } @@ -430,58 +439,87 @@ type MaybeMessage = Option<(Vec, NeighborPacket> impl Inner { fn new(config: crate::Config) -> Self { Inner { - local_view: View::default(), + local_view: None, peers: Peers::default(), live_topics: KeepTopics::new(), next_rebroadcast: Instant::now() + REBROADCAST_AFTER, + authorities: Vec::new(), config, } } - /// Note a round in a set has started. - fn note_round(&mut self, round: Round, set_id: SetId) -> MaybeMessage { - if self.local_view.round == round && self.local_view.set_id == set_id { - return None; - } + /// Note a round in the current set has started. + fn note_round(&mut self, round: Round) -> MaybeMessage { + { + let local_view = match self.local_view { + None => return None, + Some(ref mut v) => if v.round == round { + return None + } else { + v + }, + }; + + let set_id = local_view.set_id; - debug!(target: "afg", "Voter {} noting beginning of round {:?} to network.", - self.config.name(), (round, set_id)); + debug!(target: "afg", "Voter {} noting beginning of round {:?} to network.", + self.config.name(), (round,set_id)); - self.local_view.round = round; - self.local_view.set_id = set_id; + local_view.round = round; - self.live_topics.push(round, set_id); + self.live_topics.push(round, set_id); + } self.multicast_neighbor_packet() } /// Note that a voter set with given ID has started. Does nothing if the last /// call to the function was with the same `set_id`. - fn note_set(&mut self, set_id: SetId) -> MaybeMessage { - if self.local_view.set_id == set_id { - return None; - } + fn note_set(&mut self, set_id: SetId, authorities: Vec) -> MaybeMessage { + { + let local_view = match self.local_view { + ref mut x @ None => x.get_or_insert(View { + round: Round(0), + set_id, + last_commit: None, + }), + Some(ref mut v) => if v.set_id == set_id { + return None + } else { + v + }, + }; - self.local_view.update_set(set_id); - self.live_topics.push(Round(0), set_id); + local_view.update_set(set_id); + self.live_topics.push(Round(0), set_id); + self.authorities = authorities; + } self.multicast_neighbor_packet() } /// Note that we've imported a commit finalizing a given block. fn note_commit_finalized(&mut self, finalized: NumberFor) -> MaybeMessage { - if self.local_view.last_commit.as_ref() < Some(&finalized) { - self.local_view.last_commit = Some(finalized); - self.multicast_neighbor_packet() - } else { - None + { + match self.local_view { + None => return None, + Some(ref mut v) => if v.last_commit.as_ref() < Some(&finalized) { + v.last_commit = Some(finalized); + } else { + return None + }, + }; } + + self.multicast_neighbor_packet() } fn consider_vote(&self, round: Round, set_id: SetId) -> Consider { - self.local_view.consider_vote(round, set_id) + self.local_view.as_ref().map(|v| v.consider_vote(round, set_id)) + .unwrap_or(Consider::RejectOutOfScope) } fn consider_global(&self, set_id: SetId, number: NumberFor) -> Consider { - self.local_view.consider_global(set_id, number) + self.local_view.as_ref().map(|v| v.consider_global(set_id, number)) + .unwrap_or(Consider::RejectOutOfScope) } fn cost_past_rejection(&self, _who: &PeerId, _round: Round, _set_id: SetId) -> i32 { @@ -494,11 +532,18 @@ impl Inner { { match self.consider_vote(full.round, full.set_id) { Consider::RejectFuture => return Action::Discard(Misbehavior::FutureMessage.cost()), + Consider::RejectOutOfScope => return Action::Discard(Misbehavior::OutOfScopeMessage.cost()), Consider::RejectPast => return Action::Discard(self.cost_past_rejection(who, full.round, full.set_id)), Consider::Accept => {}, } + // ensure authority is part of the set. + if !self.authorities.contains(&full.message.id) { + telemetry!(CONSENSUS_DEBUG; "afg.bad_msg_signature"; "signature" => ?full.message.id); + return Action::Discard(cost::UNKNOWN_VOTER); + } + if let Err(()) = super::check_message_sig::( &full.message.message, &full.message.id, @@ -527,7 +572,9 @@ impl Inner { Consider::RejectFuture => return Action::Discard(Misbehavior::FutureMessage.cost()), Consider::RejectPast => return Action::Discard(self.cost_past_rejection(who, full.round, full.set_id)), + Consider::RejectOutOfScope => return Action::Discard(Misbehavior::OutOfScopeMessage.cost()), Consider::Accept => {}, + } if full.message.precommits.len() != full.message.auth_data.len() || full.message.precommits.is_empty() { @@ -561,14 +608,16 @@ impl Inner { } fn multicast_neighbor_packet(&self) -> MaybeMessage { - let packet = NeighborPacket { - round: self.local_view.round, - set_id: self.local_view.set_id, - commit_finalized_height: self.local_view.last_commit.unwrap_or(Zero::zero()), - }; + self.local_view.as_ref().map(|local_view| { + let packet = NeighborPacket { + round: local_view.round, + set_id: local_view.set_id, + commit_finalized_height: local_view.last_commit.unwrap_or(Zero::zero()), + }; - let peers = self.peers.inner.keys().cloned().collect(); - Some((peers, packet)) + let peers = self.peers.inner.keys().cloned().collect(); + (peers, packet) + }) } } @@ -579,7 +628,7 @@ pub(super) struct GossipValidator { } impl GossipValidator { - /// Create a new gossip-validator. + /// Create a new gossip-validator. This initialized the current set to 0. pub(super) fn new(config: crate::Config) -> (GossipValidator, ReportStream) { let (tx, rx) = mpsc::unbounded(); let val = GossipValidator { @@ -590,21 +639,22 @@ impl GossipValidator { (val, ReportStream { reports: rx }) } - /// Note a round in a set has started. - pub(super) fn note_round(&self, round: Round, set_id: SetId, send_neighbor: F) + /// Note a round in the current set has started. + pub(super) fn note_round(&self, round: Round, send_neighbor: F) where F: FnOnce(Vec, NeighborPacket>) { - let maybe_msg = self.inner.write().note_round(round, set_id); + let maybe_msg = self.inner.write().note_round(round); if let Some((to, msg)) = maybe_msg { send_neighbor(to, msg); } } - /// Note that a voter set with given ID has started. - pub(super) fn note_set(&self, set_id: SetId, send_neighbor: F) + /// Note that a voter set with given ID has started. Updates the current set to given + /// value and initializes the round to 0. + pub(super) fn note_set(&self, set_id: SetId, authorities: Vec, send_neighbor: F) where F: FnOnce(Vec, NeighborPacket>) { - let maybe_msg = self.inner.write().note_set(set_id); + let maybe_msg = self.inner.write().note_set(set_id, authorities); if let Some((to, msg)) = maybe_msg { send_neighbor(to, msg); } @@ -658,19 +708,23 @@ impl GossipValidator { impl network_gossip::Validator for GossipValidator { fn new_peer(&self, context: &mut dyn ValidatorContext, who: &PeerId, _roles: Roles) { - let packet_data = { + let packet = { let mut inner = self.inner.write(); inner.peers.new_peer(who.clone()); - let packet = NeighborPacket { - round: inner.local_view.round, - set_id: inner.local_view.set_id, - commit_finalized_height: inner.local_view.last_commit.unwrap_or(Zero::zero()), - }; - - GossipMessage::::from(packet).encode() + inner.local_view.as_ref().map(|v| { + NeighborPacket { + round: v.round, + set_id: v.set_id, + commit_finalized_height: v.last_commit.unwrap_or(Zero::zero()), + } + }) }; - context.send_message(who, packet_data); + + if let Some(packet) = packet { + let packet_data = GossipMessage::::from(packet).encode(); + context.send_message(who, packet_data); + } } fn peer_disconnected(&self, _context: &mut dyn ValidatorContext, who: &PeerId) { @@ -746,7 +800,12 @@ impl network_gossip::Validator for GossipValidator } // global message. - let our_best_commit = inner.local_view.last_commit; + let local_view = match inner.local_view { + Some(ref v) => v, + None => return false, // cannot evaluate until we have a local view. + }; + + let our_best_commit = local_view.last_commit; let peer_best_commit = peer.view.last_commit; match GossipMessage::::decode(&mut data) { @@ -774,8 +833,13 @@ impl network_gossip::Validator for GossipValidator Some((None, _)) => {}, }; + let local_view = match inner.local_view { + Some(ref v) => v, + None => return true, // no local view means we can't evaluate or hold any topic. + }; + // global messages -- only keep the best commit. - let best_commit = inner.local_view.last_commit; + let best_commit = local_view.last_commit; match GossipMessage::::decode(&mut data) { None => true, @@ -1004,8 +1068,10 @@ mod tests { let set_id = 1; + val.note_set(SetId(set_id), Vec::new(), |_, _| {}); + for round_num in 1u64..10 { - val.note_round(Round(round_num), SetId(set_id), |_, _| {}); + val.note_round(Round(round_num), |_, _| {}); } { @@ -1025,4 +1091,47 @@ mod tests { } } } + + #[test] + fn message_from_unknown_authority_discarded() { + assert!(cost::UNKNOWN_VOTER != cost::BAD_SIGNATURE); + + let (val, _) = GossipValidator::::new(config()); + let set_id = 1; + let auth = AuthorityId::from_raw([1u8; 32]); + let peer = PeerId::random(); + + val.note_set(SetId(set_id), vec![auth.clone()], |_, _| {}); + val.note_round(Round(0), |_, _| {}); + + let inner = val.inner.read(); + let unknown_voter = inner.validate_round_message(&peer, &VoteOrPrecommitMessage { + round: Round(0), + set_id: SetId(set_id), + message: SignedMessage:: { + message: grandpa::Message::Prevote(grandpa::Prevote { + target_hash: Default::default(), + target_number: 10, + }), + signature: Default::default(), + id: AuthorityId::from_raw([2u8; 32]), + } + }); + + let bad_sig = inner.validate_round_message(&peer, &VoteOrPrecommitMessage { + round: Round(0), + set_id: SetId(set_id), + message: SignedMessage:: { + message: grandpa::Message::Prevote(grandpa::Prevote { + target_hash: Default::default(), + target_number: 10, + }), + signature: Default::default(), + id: auth.clone(), + } + }); + + assert_eq!(unknown_voter, Action::Discard(cost::UNKNOWN_VOTER)); + assert_eq!(bad_sig, Action::Discard(cost::BAD_SIGNATURE)); + } } diff --git a/core/finality-grandpa/src/communication/mod.rs b/core/finality-grandpa/src/communication/mod.rs index 05033c2c41..58d9cd6421 100644 --- a/core/finality-grandpa/src/communication/mod.rs +++ b/core/finality-grandpa/src/communication/mod.rs @@ -64,12 +64,14 @@ mod cost { pub(super) const BAD_SIGNATURE: i32 = -100; pub(super) const MALFORMED_COMMIT: i32 = -1000; pub(super) const FUTURE_MESSAGE: i32 = -500; + pub(super) const UNKNOWN_VOTER: i32 = -150; pub(super) const INVALID_VIEW_CHANGE: i32 = -500; pub(super) const PER_UNDECODABLE_BYTE: i32 = -5; pub(super) const PER_SIGNATURE_CHECKED: i32 = -25; pub(super) const PER_BLOCK_LOADED: i32 = -10; pub(super) const INVALID_COMMIT: i32 = -5000; + pub(super) const OUT_OF_SCOPE_MESSAGE: i32 = -500; } // benefit scalars for reporting peers. @@ -233,7 +235,7 @@ impl> NetworkBridge { pub(crate) fn new( service: N, config: crate::Config, - set_state: Option<(u64, &crate::environment::VoterSetState)>, + set_state: Option<&crate::environment::VoterSetState>, on_exit: impl Future + Clone + Send + 'static, ) -> ( Self, @@ -244,15 +246,18 @@ impl> NetworkBridge { let validator = Arc::new(validator); service.register_validator(validator.clone()); - if let Some((set_id, set_state)) = set_state { + if let Some(set_state) = set_state { // register all previous votes with the gossip service so that they're // available to peers potentially stuck on a previous round. - for round in set_state.completed_rounds().iter() { + let completed = set_state.completed_rounds(); + let (set_id, voters) = completed.set_info(); + validator.note_set(SetId(set_id), voters.to_vec(), |_, _| {}); + for round in completed.iter() { let topic = round_topic::(round.number, set_id); // we need to note the round with the gossip validator otherwise // messages will be ignored. - validator.note_round(Round(round.number), SetId(set_id), |_, _| {}); + validator.note_round(Round(round.number), |_, _| {}); for signed in round.votes.iter() { let message = gossip::GossipMessage::VoteOrPrecommit( @@ -295,7 +300,7 @@ impl> NetworkBridge { (bridge, startup_work) } - /// Get the round messages for a round in a given set ID. These are signature-checked. + /// Get the round messages for a round in the current set ID. These are signature-checked. pub(crate) fn round_communication( &self, round: Round, @@ -307,9 +312,18 @@ impl> NetworkBridge { impl Stream,Error=Error>, impl Sink,SinkError=Error>, ) { + // is a no-op if currently in that set. + self.validator.note_set( + set_id, + voters.voters().iter().map(|(v, _)| v.clone()).collect(), + |to, neighbor| self.service.send_message( + to, + GossipMessage::::from(neighbor).encode() + ), + ); + self.validator.note_round( round, - set_id, |to, neighbor| self.service.send_message( to, GossipMessage::::from(neighbor).encode() @@ -410,6 +424,7 @@ impl> NetworkBridge { ) { self.validator.note_set( set_id, + voters.voters().iter().map(|(v, _)| v.clone()).collect(), |to, neighbor| self.service.send_message(to, GossipMessage::::from(neighbor).encode()), ); @@ -650,7 +665,7 @@ fn check_compact_commit( let f = voters.total_weight() - voters.threshold(); let full_threshold = voters.total_weight() + f; - // check total weight is not too high. + // check total weight is not out of range. let mut total_weight = 0; for (_, ref id) in &msg.auth_data { if let Some(weight) = voters.info(id).map(|info| info.weight()) { diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 4aab32be8a..690c1011a7 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -46,7 +46,7 @@ use crate::{ use consensus_common::SelectChain; -use crate::authorities::SharedAuthoritySet; +use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; @@ -66,11 +66,13 @@ pub struct CompletedRound { pub votes: Vec>, } -// Data about last completed rounds. Stores NUM_LAST_COMPLETED_ROUNDS and always +// Data about last completed rounds within a single voter set. Stores NUM_LAST_COMPLETED_ROUNDS and always // contains data about at least one round (genesis). #[derive(Debug, Clone, PartialEq)] pub struct CompletedRounds { - inner: VecDeque>, + rounds: VecDeque>, + set_id: u64, + voters: Vec, } // NOTE: the current strategy for persisting completed rounds is very naive @@ -80,34 +82,51 @@ const NUM_LAST_COMPLETED_ROUNDS: usize = 2; impl Encode for CompletedRounds { fn encode(&self) -> Vec { - Vec::from_iter(&self.inner).encode() + let v = Vec::from_iter(&self.rounds); + (&v, &self.set_id, &self.voters).encode() } } impl Decode for CompletedRounds { fn decode(value: &mut I) -> Option { - Vec::>::decode(value) - .map(|completed_rounds| CompletedRounds { - inner: completed_rounds.into(), + <(Vec>, u64, Vec)>::decode(value) + .map(|(rounds, set_id, voters)| CompletedRounds { + rounds: rounds.into(), + set_id, + voters, }) } } impl CompletedRounds { /// Create a new completed rounds tracker with NUM_LAST_COMPLETED_ROUNDS capacity. - pub fn new(genesis: CompletedRound) -> CompletedRounds { - let mut inner = VecDeque::with_capacity(NUM_LAST_COMPLETED_ROUNDS); - inner.push_back(genesis); - CompletedRounds { inner } + pub(crate) fn new( + genesis: CompletedRound, + set_id: u64, + voters: &AuthoritySet>, + ) + -> CompletedRounds + { + let mut rounds = VecDeque::with_capacity(NUM_LAST_COMPLETED_ROUNDS); + rounds.push_back(genesis); + + let voters = voters.current().1.iter().map(|(a, _)| a.clone()).collect(); + CompletedRounds { rounds, set_id, voters } + } + + /// Get the set-id and voter set of the completed rounds. + pub fn set_info(&self) -> (u64, &[AuthorityId]) { + (self.set_id, &self.voters[..]) } + /// Iterate over all completed rounds. pub fn iter(&self) -> impl Iterator> { - self.inner.iter() + self.rounds.iter() } /// Returns the last (latest) completed round. pub fn last(&self) -> &CompletedRound { - self.inner.back() + self.rounds.back() .expect("inner is never empty; always contains at least genesis; qed") } @@ -118,11 +137,11 @@ impl CompletedRounds { return false; } - if self.inner.len() == NUM_LAST_COMPLETED_ROUNDS { - self.inner.pop_front(); + if self.rounds.len() == NUM_LAST_COMPLETED_ROUNDS { + self.rounds.pop_front(); } - self.inner.push_back(completed_round); + self.rounds.push_back(completed_round); true } diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 2a1da15499..7e3f19940b 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -501,7 +501,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( let (network, network_startup) = NetworkBridge::new( network, config.clone(), - Some((authority_set.set_id(), &set_state.read())), + Some(&set_state.read()), on_exit.clone(), ); @@ -640,12 +640,16 @@ pub fn run_grandpa_voter, N, RA, SC, X>( let set_state = VoterSetState::Live { // always start at round 0 when changing sets. - completed_rounds: CompletedRounds::new(CompletedRound { - number: 0, - state: genesis_state, - base: (new.canon_hash, new.canon_number), - votes: Vec::new(), - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: 0, + state: genesis_state, + base: (new.canon_hash, new.canon_number), + votes: Vec::new(), + }, + new.set_id, + &*authority_set.inner().read(), + ), current_round: HasVoted::No, }; diff --git a/core/finality-grandpa/src/observer.rs b/core/finality-grandpa/src/observer.rs index f172e58ee9..9ed1cc8c62 100644 --- a/core/finality-grandpa/src/observer.rs +++ b/core/finality-grandpa/src/observer.rs @@ -225,12 +225,16 @@ pub fn run_grandpa_observer, N, RA, SC>( let set_state = VoterSetState::Live:: { // always start at round 0 when changing sets. - completed_rounds: CompletedRounds::new(CompletedRound { - number: 0, - state: genesis_state, - base: (new.canon_hash, new.canon_number), - votes: Vec::new(), - }), + completed_rounds: CompletedRounds::new( + CompletedRound { + number: 0, + state: genesis_state, + base: (new.canon_hash, new.canon_number), + votes: Vec::new(), + }, + new.set_id, + &*authority_set.inner().read(), + ), current_round: HasVoted::No, }; -- GitLab From 5088c0067e6c21f62c7412ab1d995497121cf595 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 10 Jun 2019 18:09:14 +0200 Subject: [PATCH 106/113] Make it build for Android (#2833) --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 738ccb6694..e5e0991212 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -659,10 +659,10 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2119,7 +2119,7 @@ dependencies = [ [[package]] name = "nix" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2264,7 +2264,7 @@ dependencies = [ name = "node-template" version = "2.0.0" dependencies = [ - "ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3916,7 +3916,7 @@ dependencies = [ name = "substrate" version = "2.0.0" dependencies = [ - "ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "node-cli 2.0.0", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3979,7 +3979,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-state-machine 2.0.0", "substrate-telemetry 2.0.0", - "sysinfo 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "sysinfo 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4725,7 +4725,7 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5751,7 +5751,7 @@ dependencies = [ "checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65" "checksum ctor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3b4c17619643c1252b5f690084b82639dd7fac141c57c8e77a00e0148132092c" "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" -"checksum ctrlc 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5531b7f0698d9220b4729f8811931dbe0e91a05be2f7b3245fdc50dd856bae26" +"checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" "checksum curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440b7acc6264fde2eee18bae135625129c88ff244f3ded035e3caa585a6bf0a" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" @@ -5891,7 +5891,7 @@ dependencies = [ "checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b" +"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d138afcce92d219ccb6eb53d9b1e8a96ac0d633cfd3c53cd9856d96d1741bb8" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" @@ -6022,7 +6022,7 @@ dependencies = [ "checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum sysinfo 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65f0e28a49b7bf142cee89befd7077b40627d7cc70aa8a8acfe03afc26016c33" +"checksum sysinfo 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cf62641ed7e88e20242b948d17b9fcc37e80b5599cf09cde190d6d4bb4bf289" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" -- GitLab From a56cb77ced07e6c8f73ac71c0e078dbaada19dc0 Mon Sep 17 00:00:00 2001 From: TriplEight Date: Tue, 11 Jun 2019 10:29:17 +0200 Subject: [PATCH 107/113] subkey build, cargo audit (#2752) * subkey build, cargo audit * some fixes * cleanup * review * not to be launched on PRs * not to be launched on PRs 2 * check-runtime should run on PRs only * changed only to except, easier to read * fix no jobs ran * only: rewrites when it's last * only: -branches wasn't needed * benching subkey build * benching subkey build 2 * subkey check * not for 1.0 * cleanup --- .gitlab-ci.yml | 72 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3c9951df4..5b1291ac2d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,18 +7,18 @@ stages: + - pre-test - test - build - publish - kubernetes - flaming-fir -image: parity/rust-builder:latest - variables: GIT_STRATEGY: fetch CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}" SCCACHE_DIR: "/ci-cache/${CI_PROJECT_NAME}/sccache" + CARGO_INCREMENTAL: 0 CI_SERVER_NAME: "GitLab CI" DOCKER_OS: "debian:stretch" ARCH: "x86_64" @@ -38,17 +38,27 @@ variables: environment: name: parity-build -.compiler_info: &compiler_info +.docker-env: &docker-env + image: parity/rust-builder:latest before_script: - rustup show - cargo --version - sccache -s + only: + - tags + - master + - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 + - schedules + - web + - /^[0-9]+$/ # PRs + tags: + - linux-docker #### stage: test check-runtime: - stage: test + stage: pre-test image: parity/tools:latest <<: *kubernetes-build only: @@ -61,7 +71,7 @@ check-runtime: check-line-width: - stage: test + stage: pre-test image: parity/tools:latest <<: *kubernetes-build only: @@ -71,23 +81,34 @@ check-line-width: allow_failure: false -test-linux-stable: &test +cargo-audit: + stage: pre-test + <<: *docker-env + except: + - /^[0-9]+$/ + script: + - cargo audit + allow_failure: true + + +cargo-check-subkey: + stage: test + <<: *docker-env + except: + - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 + script: + - cd ./subkey + - time cargo check --release # makes sense to save artifacts for building it + - sccache -s + + +test-linux-stable: stage: test - <<: *compiler_info + <<: *docker-env variables: - RUST_TOOLCHAIN: stable # Enable debug assertions since we are running optimized builds for testing # but still want to have debug assertions. RUSTFLAGS: -Cdebug-assertions=y - TARGET: native - tags: - - linux-docker - only: - - tags - - master - - schedules - - web - - /^[0-9]+$/ except: variables: - $DEPLOY_TAG @@ -126,11 +147,10 @@ test-linux-stable-int: &test check-web-wasm: stage: test - <<: *compiler_info + <<: *docker-env allow_failure: true - only: - - master - - /^[0-9]+$/ + except: + - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 script: # WASM support is in progress. As more and more crates support WASM, we # should add entries here. See https://github.com/paritytech/substrate/issues/2416 @@ -155,8 +175,6 @@ check-web-wasm: - time cargo web build -p substrate-telemetry - time cargo web build -p substrate-trie - sccache -s - tags: - - linux-docker .build-only: &build-only only: @@ -169,13 +187,11 @@ check-web-wasm: build-linux-release: stage: build <<: *collect-artifacts + <<: *docker-env <<: *build-only - <<: *compiler_info except: variables: - $DEPLOY_TAG - tags: - - linux-docker script: - ./scripts/build.sh --locked - time cargo build --release --verbose @@ -197,7 +213,7 @@ build-linux-release: build-rust-doc-release: stage: build - <<: *compiler_info + <<: *docker-env allow_failure: true artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc" @@ -206,8 +222,6 @@ build-rust-doc-release: paths: - ./crate-docs <<: *build-only - tags: - - linux-docker script: - ./scripts/build.sh --locked - rm -f ./crate-docs/index.html # use it as an indicator if the job succeeds -- GitLab From 45cb40b2adbb8f331aa1c7220f6005c12bf19d3c Mon Sep 17 00:00:00 2001 From: TriplEight Date: Tue, 11 Jun 2019 15:14:51 +0200 Subject: [PATCH 108/113] fix job (#2842) --- .gitlab-ci.yml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b1291ac2d..d792fc6ebf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,7 +102,7 @@ cargo-check-subkey: - sccache -s -test-linux-stable: +test-linux-stable: &test-linux stage: test <<: *docker-env variables: @@ -117,30 +117,17 @@ test-linux-stable: - time cargo test --all --release --verbose --locked - sccache -s -test-linux-stable-int: &test - stage: test - variables: - RUST_TOOLCHAIN: stable - # Enable debug assertions since we are running optimized builds for testing - # but still want to have debug assertions. - RUSTFLAGS: -Cdebug-assertions=y - TARGET: native - tags: - - linux-docker - only: - - tags - - master - - schedules - - web - - /^[0-9]+$/ +test-linux-stable-int: + <<: *test-linux except: + refs: + - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 variables: - $DEPLOY_TAG - before_script: - - sccache -s - - ./scripts/build.sh --locked script: - - time RUST_LOG=sync=trace,consensus=trace,client=trace,state-db=trace,db=trace,forks=trace,state_db=trace,storage_cache=trace cargo test -p node-cli --release --verbose --locked -- --ignored --test-threads=1 + - ./scripts/build.sh --locked + - time RUST_LOG=sync=trace,consensus=trace,client=trace,state-db=trace,db=trace,forks=trace,state_db=trace,storage_cache=trace + cargo test -p node-cli --release --verbose --locked -- --ignored --test-threads=1 - sccache -s allow_failure: true -- GitLab From db9b69c158f234c0a9df706ebee0bbe6645ddeac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AC=A7?= Date: Tue, 11 Jun 2019 22:00:27 +0800 Subject: [PATCH 109/113] Passthru build.sh/script.sh command line arguments (#2837) --- ci/script.sh | 4 ++-- core/executor/wasm/build.sh | 2 +- core/test-runtime/wasm/build.sh | 2 +- node-template/runtime/wasm/build.sh | 2 +- node-template/scripts/build.sh | 2 +- node/runtime/wasm/build.sh | 2 +- scripts/build.sh | 2 +- scripts/update.sh | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ci/script.sh b/ci/script.sh index 0ab5f34fb2..b1b7dd3edf 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -20,12 +20,12 @@ case $TARGET in sudo apt-get -y update sudo apt-get install -y cmake pkg-config libssl-dev - cargo test --all --release --locked + cargo test --all --release --locked "$@" ;; "wasm") # Install prerequisites and build all wasm projects ./scripts/init.sh - ./scripts/build.sh + ./scripts/build.sh "$@" ;; esac diff --git a/core/executor/wasm/build.sh b/core/executor/wasm/build.sh index fe2faeec62..9414c8037b 100755 --- a/core/executor/wasm/build.sh +++ b/core/executor/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release "$@" for i in test do wasm-gc target/wasm32-unknown-unknown/release/runtime_$i.wasm target/wasm32-unknown-unknown/release/runtime_$i.compact.wasm diff --git a/core/test-runtime/wasm/build.sh b/core/test-runtime/wasm/build.sh index 0529a974ff..059e475c71 100755 --- a/core/test-runtime/wasm/build.sh +++ b/core/test-runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release "$@" for i in substrate_test_runtime do wasm-gc "target/wasm32-unknown-unknown/release/$i.wasm" "target/wasm32-unknown-unknown/release/$i.compact.wasm" diff --git a/node-template/runtime/wasm/build.sh b/node-template/runtime/wasm/build.sh index 566e5de35d..a549eeb50a 100755 --- a/node-template/runtime/wasm/build.sh +++ b/node-template/runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release "$@" for i in node_template_runtime_wasm do wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm diff --git a/node-template/scripts/build.sh b/node-template/scripts/build.sh index 01d0fee354..980a8fa802 100755 --- a/node-template/scripts/build.sh +++ b/node-template/scripts/build.sh @@ -17,7 +17,7 @@ do echo "${bold}Building webassembly binary in $SRC...${normal}" cd "$PROJECT_ROOT/$SRC" - ./build.sh + ./build.sh "$@" cd - >> /dev/null done diff --git a/node/runtime/wasm/build.sh b/node/runtime/wasm/build.sh index 9a9f412bfc..4a81e47f9e 100755 --- a/node/runtime/wasm/build.sh +++ b/node/runtime/wasm/build.sh @@ -6,7 +6,7 @@ if cargo --version | grep -q "nightly"; then else CARGO_CMD="cargo +nightly" fi -CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release $@ +CARGO_INCREMENTAL=0 RUSTFLAGS="-C link-arg=--export-table" $CARGO_CMD build --target=wasm32-unknown-unknown --release "$@" for i in node_runtime do wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm diff --git a/scripts/build.sh b/scripts/build.sh index 8b3557159b..d79ebe5230 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,7 +19,7 @@ do echo "*** Building wasm binaries in $SRC" cd "$PROJECT_ROOT/$SRC" - ./build.sh $@ + ./build.sh "$@" cd - >> /dev/null done diff --git a/scripts/update.sh b/scripts/update.sh index cbf81b57cd..a264fab43d 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -20,7 +20,7 @@ do cd "$PROJECT_ROOT/$SRC" cargo update - ./build.sh + ./build.sh "$@" cd - >> /dev/null done -- GitLab From 2afbd267a648266b59713b68cffe94e44e68af45 Mon Sep 17 00:00:00 2001 From: ddorgan Date: Tue, 11 Jun 2019 16:26:13 +0100 Subject: [PATCH 110/113] Allow check-runtime to fail (#2845) * Allow check-runtime to fail * Do not allow the line-width to fail * Allow failure on line-check --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d792fc6ebf..82fb604112 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,6 +68,7 @@ check-runtime: GITHUB_API_PROJECT: "parity%2Finfrastructure%2Fgithub-api" script: - ./scripts/gitlab/check_runtime.sh + allow_failure: true check-line-width: @@ -78,7 +79,7 @@ check-line-width: - /^[0-9]+$/ script: - ./scripts/gitlab/check_line_width.sh - allow_failure: false + allow_failure: true cargo-audit: -- GitLab From b1c50952704c89079c8df41cea2be2ef0825a90d Mon Sep 17 00:00:00 2001 From: kaichao Date: Wed, 12 Jun 2019 03:34:10 +0800 Subject: [PATCH 111/113] Make use of StorageHasher and HasherKind (#2836) * Make use of StorageHasher and HasherKind. * Use Storagehasher hasher function for key2 of double map. * Refactor to reuse hasher from implementation. * Bump up since there is srml changes. * Update metadata version. --- node/runtime/src/lib.rs | 2 +- srml/metadata/src/lib.rs | 10 ++++++---- srml/support/procedural/src/storage/impls.rs | 4 +++- srml/support/procedural/src/storage/mod.rs | 9 ++++++++- srml/support/procedural/src/storage/transformation.rs | 10 +++++----- srml/support/src/double_map.rs | 2 +- srml/support/src/lib.rs | 8 ++++---- srml/support/src/metadata.rs | 10 +++++----- 8 files changed, 33 insertions(+), 22 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 427ee8d1fc..1c9c0ca4fd 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 92, - impl_version: 93, + impl_version: 94, apis: RUNTIME_API_VERSIONS, }; diff --git a/srml/metadata/src/lib.rs b/srml/metadata/src/lib.rs index 28a513cc07..b1ab57b506 100644 --- a/srml/metadata/src/lib.rs +++ b/srml/metadata/src/lib.rs @@ -280,7 +280,7 @@ pub enum StorageFunctionType { key1: DecodeDifferentStr, key2: DecodeDifferentStr, value: DecodeDifferentStr, - key2_hasher: DecodeDifferentStr, + key2_hasher: StorageHasher, }, } @@ -311,8 +311,10 @@ pub enum RuntimeMetadata { V2(RuntimeMetadataDeprecated), /// Version 3 for runtime metadata. No longer used. V3(RuntimeMetadataDeprecated), - /// Version 4 for runtime metadata. - V4(RuntimeMetadataV4), + /// Version 4 for runtime metadata. No longer used. + V4(RuntimeMetadataDeprecated), + /// Version 5 for runtime metadata. + V5(RuntimeMetadataV5), } /// Enum that should fail. @@ -335,7 +337,7 @@ impl Decode for RuntimeMetadataDeprecated { /// The metadata of a runtime. #[derive(Eq, Encode, PartialEq)] #[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))] -pub struct RuntimeMetadataV4 { +pub struct RuntimeMetadataV5 { pub modules: DecodeDifferentArray, } diff --git a/srml/support/procedural/src/storage/impls.rs b/srml/support/procedural/src/storage/impls.rs index 0e9e30e2a4..ee2275de7c 100644 --- a/srml/support/procedural/src/storage/impls.rs +++ b/srml/support/procedural/src/storage/impls.rs @@ -636,8 +636,10 @@ impl<'a, I: Iterator> Impls<'a, I> { } fn key_for(k1: &#k1ty, k2: &#k2ty) -> Vec { + use #scrate::storage::hashed::generator::StorageHasher; + let mut key = #as_double_map::prefix_for(k1); - key.extend(&#scrate::Hashable::#k2_hasher(k2)); + #scrate::codec::Encode::using_encoded(k2, |e| key.extend(&#scrate::#k2_hasher::hash(e))); key } diff --git a/srml/support/procedural/src/storage/mod.rs b/srml/support/procedural/src/storage/mod.rs index ce81dd95c5..742c47d259 100644 --- a/srml/support/procedural/src/storage/mod.rs +++ b/srml/support/procedural/src/storage/mod.rs @@ -214,7 +214,13 @@ enum HasherKind { impl From<&SetHasher> for HasherKind { fn from(set_hasher: &SetHasher) -> Self { - match set_hasher.inner.content { + (&set_hasher.inner.content).into() + } +} + +impl From<&Hasher> for HasherKind { + fn from(hasher: &Hasher) -> Self { + match hasher { Hasher::Blake2_256(_) => HasherKind::Blake2_256, Hasher::Blake2_128(_) => HasherKind::Blake2_128, Hasher::Twox256(_) => HasherKind::Twox256, @@ -223,6 +229,7 @@ impl From<&SetHasher> for HasherKind { } } } + impl HasherKind { fn into_storage_hasher_struct(&self) -> TokenStream2 { match self { diff --git a/srml/support/procedural/src/storage/transformation.rs b/srml/support/procedural/src/storage/transformation.rs index 933faa6ff9..1da6ae2108 100644 --- a/srml/support/procedural/src/storage/transformation.rs +++ b/srml/support/procedural/src/storage/transformation.rs @@ -606,7 +606,7 @@ fn decl_storage_items( i.linked_map(hasher.into_storage_hasher_struct(), key_type) }, DeclStorageTypeInfosKind::DoubleMap { key1_type, key2_type, key2_hasher, hasher } => { - i.double_map(hasher.into_storage_hasher_struct(), key1_type, key2_type, key2_hasher) + i.double_map(hasher.into_storage_hasher_struct(), key1_type, key2_type, key2_hasher.into_storage_hasher_struct()) }, }; impls.extend(implementation) @@ -758,14 +758,14 @@ fn store_functions_to_metadata ( let hasher = hasher.into_metadata(); let k1ty = clean_type_string("e!(#key1_type).to_string()); let k2ty = clean_type_string("e!(#key2_type).to_string()); - let k2_hasher = clean_type_string(&key2_hasher.to_string()); + let k2_hasher = key2_hasher.into_metadata(); quote!{ #scrate::metadata::StorageFunctionType::DoubleMap { hasher: #scrate::metadata::#hasher, key1: #scrate::metadata::DecodeDifferent::Encode(#k1ty), key2: #scrate::metadata::DecodeDifferent::Encode(#k2ty), value: #scrate::metadata::DecodeDifferent::Encode(#styp), - key2_hasher: #scrate::metadata::DecodeDifferent::Encode(#k2_hasher), + key2_hasher: #scrate::metadata::#k2_hasher, } } }, @@ -870,7 +870,7 @@ enum DeclStorageTypeInfosKind<'a> { hasher: HasherKind, key1_type: &'a syn::Type, key2_type: &'a syn::Type, - key2_hasher: TokenStream2, + key2_hasher: HasherKind, } } @@ -900,7 +900,7 @@ fn get_type_infos(storage_type: &DeclStorageType) -> DeclStorageTypeInfos { hasher: map.hasher.inner.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), key1_type: &map.key1, key2_type: &map.key2.content, - key2_hasher: { let h = &map.key2_hasher; quote! { #h } }, + key2_hasher: (&map.key2_hasher).into(), }), }; diff --git a/srml/support/src/double_map.rs b/srml/support/src/double_map.rs index 80d974064d..d35570ae4f 100644 --- a/srml/support/src/double_map.rs +++ b/srml/support/src/double_map.rs @@ -64,7 +64,7 @@ pub trait StorageDoubleMapWithHasher { /// Get an entry from this map. /// - /// If there is entry stored under the given keys, returns `None`. + /// If there is no entry stored under the given keys, returns `None`. fn get(k1: &Q, k2: &R) -> Option where Self::Key1: Borrow, diff --git a/srml/support/src/lib.rs b/srml/support/src/lib.rs index 64256d876d..fec7249c23 100644 --- a/srml/support/src/lib.rs +++ b/srml/support/src/lib.rs @@ -467,7 +467,7 @@ mod tests { key1: DecodeDifferent::Encode("u32"), key2: DecodeDifferent::Encode("u32"), value: DecodeDifferent::Encode("u64"), - key2_hasher: DecodeDifferent::Encode("blake2_256"), + key2_hasher: StorageHasher::Blake2_256, }, default: DecodeDifferent::Encode( DefaultByteGetter(&__GetByteStructDataDM(PhantomData::)) @@ -482,7 +482,7 @@ mod tests { key1: DecodeDifferent::Encode("T::BlockNumber"), key2: DecodeDifferent::Encode("T::BlockNumber"), value: DecodeDifferent::Encode("T::BlockNumber"), - key2_hasher: DecodeDifferent::Encode("twox_128"), + key2_hasher: StorageHasher::Twox128, }, default: DecodeDifferent::Encode( DefaultByteGetter(&__GetByteStructGenericDataDM(PhantomData::)) @@ -497,7 +497,7 @@ mod tests { key1: DecodeDifferent::Encode("T::BlockNumber"), key2: DecodeDifferent::Encode("T::BlockNumber"), value: DecodeDifferent::Encode("T::BlockNumber"), - key2_hasher: DecodeDifferent::Encode("twox_256"), + key2_hasher: StorageHasher::Twox256, }, default: DecodeDifferent::Encode( DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::)) @@ -512,7 +512,7 @@ mod tests { key1: DecodeDifferent::Encode("u32"), key2: DecodeDifferent::Encode("T::BlockNumber"), value: DecodeDifferent::Encode("Vec"), - key2_hasher: DecodeDifferent::Encode("blake2_256"), + key2_hasher: StorageHasher::Blake2_256, }, default: DecodeDifferent::Encode( DefaultByteGetter(&__GetByteStructGenericData2DM(PhantomData::)) diff --git a/srml/support/src/metadata.rs b/srml/support/src/metadata.rs index ed3e443afd..0e33d77272 100644 --- a/srml/support/src/metadata.rs +++ b/srml/support/src/metadata.rs @@ -16,7 +16,7 @@ pub use srml_metadata::{ DecodeDifferent, FnEncode, RuntimeMetadata, - ModuleMetadata, RuntimeMetadataV4, + ModuleMetadata, RuntimeMetadataV5, DefaultByteGetter, RuntimeMetadataPrefixed, StorageMetadata, StorageFunctionMetadata, StorageFunctionType, StorageFunctionModifier, @@ -40,8 +40,8 @@ macro_rules! impl_runtime_metadata { ) => { impl $runtime { pub fn metadata() -> $crate::metadata::RuntimeMetadataPrefixed { - $crate::metadata::RuntimeMetadata::V4 ( - $crate::metadata::RuntimeMetadataV4 { + $crate::metadata::RuntimeMetadata::V5 ( + $crate::metadata::RuntimeMetadataV5 { modules: $crate::__runtime_modules_to_metadata!($runtime;; $( $rest )*), } ).into() @@ -382,8 +382,8 @@ mod tests { event_module2::Module with Event Storage Call, ); - const EXPECTED_METADATA: RuntimeMetadata = RuntimeMetadata::V4( - RuntimeMetadataV4 { + const EXPECTED_METADATA: RuntimeMetadata = RuntimeMetadata::V5( + RuntimeMetadataV5 { modules: DecodeDifferent::Encode(&[ ModuleMetadata { name: DecodeDifferent::Encode("system"), -- GitLab From 6df8a813eb0f5db99efa777bc194b9cb06c5a7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 11 Jun 2019 21:54:34 +0200 Subject: [PATCH 112/113] Make test-client generic over runtime (#2824) * Make test-client generic over runtime. * Make sure genesis storage is constructed correctly. * Use prelude in tests. * Add an example of how to use test-client with node/runtime. * Bump version. * Rename test-clients. --- Cargo.lock | 45 ++- Cargo.toml | 12 +- core/basic-authorship/Cargo.toml | 2 +- core/client/Cargo.toml | 2 +- core/client/db/Cargo.toml | 2 +- core/client/src/client.rs | 5 +- core/client/src/light/call_executor.rs | 9 +- core/client/src/light/fetcher.rs | 2 +- core/consensus/aura/Cargo.toml | 2 +- core/consensus/babe/Cargo.toml | 2 +- core/consensus/common/Cargo.toml | 2 +- core/consensus/slots/Cargo.toml | 2 +- core/finality-grandpa/Cargo.toml | 2 +- core/network/Cargo.toml | 6 +- core/network/src/test/block_import.rs | 9 +- core/offchain/Cargo.toml | 2 +- core/rpc/Cargo.toml | 4 +- core/rpc/src/chain/tests.rs | 8 +- core/rpc/src/state/tests.rs | 22 +- core/service/Cargo.toml | 2 +- core/service/src/components.rs | 2 +- core/service/src/lib.rs | 2 +- core/sr-api-macros/Cargo.toml | 2 +- core/sr-api-macros/tests/runtime_calls.rs | 6 +- core/test-client/Cargo.toml | 24 +- core/test-client/src/client_ext.rs | 42 ++- core/test-client/src/lib.rs | 342 +++++++----------- core/test-runtime/Cargo.toml | 2 +- core/test-runtime/client/Cargo.toml | 20 + .../client}/src/block_builder_ext.rs | 4 +- core/test-runtime/client/src/lib.rs | 208 +++++++++++ .../client}/src/trait_tests.rs | 17 +- core/test-runtime/src/system.rs | 2 +- core/transaction-pool/Cargo.toml | 2 +- node/executor/Cargo.toml | 1 + node/executor/src/lib.rs | 15 + 36 files changed, 494 insertions(+), 339 deletions(-) create mode 100644 core/test-runtime/client/Cargo.toml rename core/{test-client => test-runtime/client}/src/block_builder_ext.rs (93%) create mode 100644 core/test-runtime/client/src/lib.rs rename core/{test-client => test-runtime/client}/src/trait_tests.rs (96%) diff --git a/Cargo.lock b/Cargo.lock index e5e0991212..b79b9c0827 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2191,6 +2191,7 @@ dependencies = [ "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", + "substrate-test-client 2.0.0", "substrate-trie 2.0.0", "trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3349,7 +3350,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3935,7 +3936,7 @@ dependencies = [ "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-telemetry 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", ] @@ -4010,7 +4011,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-telemetry 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-trie 2.0.0", ] @@ -4035,7 +4036,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-db 2.0.0", "substrate-state-machine 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-trie 2.0.0", ] @@ -4066,7 +4067,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "substrate-telemetry 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4124,7 +4125,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "substrate-telemetry 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4155,7 +4156,7 @@ dependencies = [ "sr-version 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4197,7 +4198,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4250,7 +4251,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-service 2.0.0", "substrate-telemetry 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4323,7 +4324,7 @@ dependencies = [ "substrate-network-libp2p 2.0.0", "substrate-peerset 2.0.0", "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4372,7 +4373,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4460,13 +4461,11 @@ dependencies = [ "sr-primitives 2.0.0", "sr-version 2.0.0", "substrate-client 2.0.0", - "substrate-consensus-common 2.0.0", "substrate-executor 2.0.0", "substrate-network 2.0.0", "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", - "substrate-test-client 2.0.0", - "substrate-test-runtime 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4522,7 +4521,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-rpc-servers 2.0.0", "substrate-telemetry 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4599,6 +4598,7 @@ name = "substrate-test-client" version = "2.0.0" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -4608,7 +4608,6 @@ dependencies = [ "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", - "substrate-test-runtime 2.0.0", ] [[package]] @@ -4635,11 +4634,21 @@ dependencies = [ "substrate-keyring 2.0.0", "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-trie 2.0.0", "trie-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "substrate-test-runtime-client" +version = "2.0.0" +dependencies = [ + "sr-primitives 2.0.0", + "substrate-primitives 2.0.0", + "substrate-test-client 2.0.0", + "substrate-test-runtime 2.0.0", +] + [[package]] name = "substrate-transaction-graph" version = "2.0.0" @@ -4670,7 +4679,7 @@ dependencies = [ "substrate-client 2.0.0", "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", + "substrate-test-runtime-client 2.0.0", "substrate-transaction-graph 2.0.0", ] diff --git a/Cargo.toml b/Cargo.toml index 5710d08aff..0f681dc766 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,15 +22,17 @@ members = [ "core/cli", "core/client", "core/client/db", - "core/consensus/common", "core/consensus/aura", "core/consensus/babe", + "core/consensus/common", "core/consensus/rhd", "core/consensus/slots", "core/executor", "core/finality-grandpa", "core/finality-grandpa/primitives", + "core/inherents", "core/keyring", + "core/keystore", "core/network", "core/panic-handler", "core/primitives", @@ -46,13 +48,13 @@ members = [ "core/sr-std", "core/sr-version", "core/state-machine", - "core/test-runtime", "core/telemetry", - "core/trie", - "core/keystore", + "core/test-client", + "core/test-runtime", + "core/test-runtime/client", "core/transaction-pool", "core/transaction-pool/graph", - "core/inherents", + "core/trie", "core/util/fork-tree", "srml/support", "srml/support/procedural", diff --git a/core/basic-authorship/Cargo.toml b/core/basic-authorship/Cargo.toml index 63408b4329..547fca9030 100644 --- a/core/basic-authorship/Cargo.toml +++ b/core/basic-authorship/Cargo.toml @@ -17,4 +17,4 @@ transaction_pool = { package = "substrate-transaction-pool", path = "../../core/ substrate-telemetry = { path = "../telemetry" } [dev-dependencies] -test-client = { package = "substrate-test-client", path = "../../core/test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../core/test-runtime/client" } diff --git a/core/client/Cargo.toml b/core/client/Cargo.toml index 0978b897ec..510ec50b8b 100644 --- a/core/client/Cargo.toml +++ b/core/client/Cargo.toml @@ -28,7 +28,7 @@ inherents = { package = "substrate-inherents", path = "../inherents", default-fe sr-api-macros = { path = "../sr-api-macros" } [dev-dependencies] -test-client = { package = "substrate-test-client", path = "../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client" } kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } [features] diff --git a/core/client/db/Cargo.toml b/core/client/db/Cargo.toml index 64051164b8..e40b1568f6 100644 --- a/core/client/db/Cargo.toml +++ b/core/client/db/Cargo.toml @@ -25,7 +25,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../../conse [dev-dependencies] substrate-keyring = { path = "../../keyring" } -test-client = { package = "substrate-test-client", path = "../../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-runtime/client" } env_logger = { version = "0.6" } [features] diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 59af1b6419..8336a90ca4 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -1709,8 +1709,9 @@ pub(crate) mod tests { use runtime_primitives::generic::DigestItem; use consensus::{BlockOrigin, SelectChain}; use test_client::{ - TestClient, AccountKeyring, client::backend::Backend as TestBackend, TestClientBuilder, - BlockBuilderExt, runtime::{self, Block, Transfer, RuntimeApi, TestAPI} + prelude::*, + client::backend::Backend as TestBackend, + runtime::{self, Block, Transfer, RuntimeApi, TestAPI}, }; /// Returns tuple, consisting of: diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index a6b381a8b1..a95b73a960 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -473,7 +473,7 @@ pub fn check_execution_proof( #[cfg(test)] mod tests { use consensus::BlockOrigin; - use test_client::{self, runtime::{Block, Header}, runtime::RuntimeApi, TestClient}; + use test_client::{self, runtime::Header, ClientExt, TestClient}; use executor::NativeExecutionDispatch; use crate::backend::{Backend, NewBlockState}; use crate::in_mem::Backend as InMemBackend; @@ -482,13 +482,6 @@ mod tests { #[test] fn execution_proof_is_generated_and_checked() { - type TestClient = test_client::client::Client< - test_client::Backend, - test_client::Executor, - Block, - RuntimeApi - >; - fn execute(remote_client: &TestClient, at: u64, method: &'static str) -> (Vec, Vec) { let remote_block_id = BlockId::Number(at); let remote_root = remote_client.state_at(&remote_block_id) diff --git a/core/client/src/light/fetcher.rs b/core/client/src/light/fetcher.rs index 985aa5bdaa..bacfb45a7e 100644 --- a/core/client/src/light/fetcher.rs +++ b/core/client/src/light/fetcher.rs @@ -491,7 +491,7 @@ pub mod tests { use executor::{self, NativeExecutionDispatch}; use crate::error::Error as ClientError; use test_client::{ - self, TestClient, blockchain::HeaderBackend, AccountKeyring, + self, ClientExt, blockchain::HeaderBackend, AccountKeyring, runtime::{self, Hash, Block, Header, Extrinsic} }; use consensus::BlockOrigin; diff --git a/core/consensus/aura/Cargo.toml b/core/consensus/aura/Cargo.toml index 9c46b942a4..c8711d0289 100644 --- a/core/consensus/aura/Cargo.toml +++ b/core/consensus/aura/Cargo.toml @@ -31,6 +31,6 @@ keyring = { package = "substrate-keyring", path = "../../keyring" } substrate-executor = { path = "../../executor" } network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} service = { package = "substrate-service", path = "../../service" } -test_client = { package = "substrate-test-client", path = "../../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-runtime/client" } tokio = "0.1.7" env_logger = "0.6" diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 020497a104..1eaf05e4a0 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -35,6 +35,6 @@ keyring = { package = "substrate-keyring", path = "../../keyring" } substrate-executor = { path = "../../executor" } network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} service = { package = "substrate-service", path = "../../service" } -test_client = { package = "substrate-test-client", path = "../../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-runtime/client" } tokio = "0.1.18" env_logger = "0.6.1" diff --git a/core/consensus/common/Cargo.toml b/core/consensus/common/Cargo.toml index 3d133461e7..2852f4aa0f 100644 --- a/core/consensus/common/Cargo.toml +++ b/core/consensus/common/Cargo.toml @@ -21,7 +21,7 @@ parity-codec = { version = "3.3", features = ["derive"] } parking_lot = "0.8.0" [dev-dependencies] -test_client = { package = "substrate-test-client", path = "../../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-runtime/client" } [features] default = [] diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index b82c2fc9d7..5c187024c9 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -18,4 +18,4 @@ parking_lot = "0.8.0" log = "0.4" [dev-dependencies] -test_client = { package = "substrate-test-client", path = "../../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-runtime/client" } diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index b00c646286..bbd6297d35 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -29,7 +29,7 @@ grandpa = { package = "finality-grandpa", version = "0.7.2", features = ["derive consensus_common = { package = "substrate-consensus-common", path = "../consensus/common", features = ["test-helpers"] } network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } keyring = { package = "substrate-keyring", path = "../keyring" } -test_client = { package = "substrate-test-client", path = "../test-client"} +test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client"} env_logger = "0.6" [features] diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index 8fbf7daa9c..1b3a473288 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -30,16 +30,16 @@ peerset = { package = "substrate-peerset", path = "../../core/peerset" } tokio-timer = "0.2.11" tokio = { version = "0.1.11", optional = true } keyring = { package = "substrate-keyring", path = "../../core/keyring", optional = true } -test_client = { package = "substrate-test-client", path = "../../core/test-client", optional = true } +test-client = { package = "substrate-test-runtime-client", path = "../../core/test-runtime/client", optional = true } void = "1.0" [dev-dependencies] env_logger = { version = "0.6" } keyring = { package = "substrate-keyring", path = "../../core/keyring" } -test_client = { package = "substrate-test-client", path = "../../core/test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../core/test-runtime/client" } consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common", features = ["test-helpers"] } tokio = "0.1.11" [features] default = [] -test-helpers = ["keyring", "test_client", "consensus/test-helpers", "tokio"] +test-helpers = ["keyring", "test-client", "consensus/test-helpers", "tokio"] diff --git a/core/network/src/test/block_import.rs b/core/network/src/test/block_import.rs index 4cf639484f..f10338a62d 100644 --- a/core/network/src/test/block_import.rs +++ b/core/network/src/test/block_import.rs @@ -17,7 +17,7 @@ //! Testing block import logic. use consensus::import_queue::{import_single_block, BasicQueue, BlockImportError, BlockImportResult}; -use test_client::{self, TestClient}; +use test_client::{self, prelude::*}; use test_client::runtime::{Block, Hash}; use runtime_primitives::generic::BlockId; use super::*; @@ -26,12 +26,7 @@ struct TestLink {} impl Link for TestLink {} -fn prepare_good_block() -> (client::Client< - test_client::Backend, - test_client::Executor, - Block, - test_client::runtime::RuntimeApi, - >, Hash, u64, PeerId, IncomingBlock) { +fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock) { let client = test_client::new(); let block = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::File, block).unwrap(); diff --git a/core/offchain/Cargo.toml b/core/offchain/Cargo.toml index 0672ebcc0c..a7b94bdc56 100644 --- a/core/offchain/Cargo.toml +++ b/core/offchain/Cargo.toml @@ -21,7 +21,7 @@ transaction_pool = { package = "substrate-transaction-pool", path = "../../core/ [dev-dependencies] env_logger = "0.6" -test_client = { package = "substrate-test-client", path = "../../core/test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../core/test-runtime/client" } [features] default = [] diff --git a/core/rpc/Cargo.toml b/core/rpc/Cargo.toml index c621f71a43..6ef9af2a0a 100644 --- a/core/rpc/Cargo.toml +++ b/core/rpc/Cargo.toml @@ -29,7 +29,5 @@ tokio = "0.1.7" assert_matches = "1.1" futures = "0.1.17" sr-io = { path = "../sr-io" } -test_client = { package = "substrate-test-client", path = "../test-client" } -test_runtime = { package = "substrate-test-runtime", path = "../test-runtime" } -consensus = { package = "substrate-consensus-common", path = "../consensus/common" } +test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client" } rustc-hex = "2.0" diff --git a/core/rpc/src/chain/tests.rs b/core/rpc/src/chain/tests.rs index 02507442d5..eed9ae836b 100644 --- a/core/rpc/src/chain/tests.rs +++ b/core/rpc/src/chain/tests.rs @@ -16,9 +16,11 @@ use super::*; use assert_matches::assert_matches; -use test_client::{self, TestClient}; -use test_client::runtime::{H256, Block, Header}; -use consensus::BlockOrigin; +use test_client::{ + prelude::*, + consensus::BlockOrigin, + runtime::{H256, Block, Header}, +}; #[test] fn should_return_header() { diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index b40ac06c60..498b58b40b 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -18,10 +18,13 @@ use super::*; use self::error::Error; use assert_matches::assert_matches; -use consensus::BlockOrigin; use primitives::storage::well_known_keys; use sr_io::blake2_256; -use test_client::{self, runtime, AccountKeyring, TestClient, BlockBuilderExt, LocalExecutor, TestClientBuilder}; +use test_client::{ + prelude::*, + consensus::BlockOrigin, + runtime, +}; use substrate_executor::NativeExecutionDispatch; #[test] @@ -50,7 +53,9 @@ fn should_return_storage() { #[test] fn should_return_child_storage() { let core = tokio::runtime::Runtime::new().unwrap(); - let client = Arc::new(test_client::new()); + let client = Arc::new(test_client::TestClientBuilder::new() + .add_child_storage("test", "key", vec![42_u8]) + .build()); let genesis_hash = client.genesis_hash(); let client = State::new(client, Subscriptions::new(core.executor())); let child_key = StorageKey(well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect()); @@ -125,7 +130,7 @@ fn should_send_initial_storage_changes_and_notifications() { { let api = State::new(Arc::new(test_client::new()), Subscriptions::new(remote)); - let alice_balance_key = blake2_256(&test_runtime::system::balance_of_key(AccountKeyring::Alice.into())); + let alice_balance_key = blake2_256(&runtime::system::balance_of_key(AccountKeyring::Alice.into())); api.subscribe_storage(Default::default(), subscriber, Some(vec![ StorageKey(alice_balance_key.to_vec()), @@ -156,13 +161,6 @@ fn should_send_initial_storage_changes_and_notifications() { #[test] fn should_query_storage() { - type TestClient = test_client::client::Client< - test_client::Backend, - test_client::Executor, - runtime::Block, - runtime::RuntimeApi - >; - fn run_tests(client: Arc) { let core = tokio::runtime::Runtime::new().unwrap(); let api = State::new(client.clone(), Subscriptions::new(core.executor())); @@ -184,7 +182,7 @@ fn should_query_storage() { let block2_hash = add_block(1); let genesis_hash = client.genesis_hash(); - let alice_balance_key = blake2_256(&test_runtime::system::balance_of_key(AccountKeyring::Alice.into())); + let alice_balance_key = blake2_256(&runtime::system::balance_of_key(AccountKeyring::Alice.into())); let mut expected = vec![ StorageChangeSet { diff --git a/core/service/Cargo.toml b/core/service/Cargo.toml index 0a0cd91553..471594aad8 100644 --- a/core/service/Cargo.toml +++ b/core/service/Cargo.toml @@ -32,7 +32,7 @@ tel = { package = "substrate-telemetry", path = "../../core/telemetry" } offchain = { package = "substrate-offchain", path = "../../core/offchain" } [dev-dependencies] -substrate-test-client = { path = "../test-client" } +substrate-test-runtime-client = { path = "../test-runtime/client" } node-executor = { path = "../../node/executor" } node-primitives = { path = "../../node/primitives" } node-runtime = { path = "../../node/runtime" } diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 30cb1cb764..0f5afb7772 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -634,7 +634,7 @@ impl Components for LightComponents { mod tests { use super::*; use consensus_common::BlockOrigin; - use substrate_test_client::{TestClient, AccountKeyring, runtime::Transfer, TestClientBuilder}; + use substrate_test_runtime_client::{prelude::*, runtime::Transfer}; #[test] fn should_remove_transactions_from_the_pool() { diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index b33608392d..92ddcd0b58 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -757,7 +757,7 @@ mod tests { use super::*; use consensus_common::SelectChain; use runtime_primitives::traits::BlindCheckable; - use substrate_test_client::{AccountKeyring, runtime::{Extrinsic, Transfer}, TestClientBuilder}; + use substrate_test_runtime_client::{prelude::*, runtime::{Extrinsic, Transfer}}; #[test] fn should_not_propagate_transactions_that_are_marked_as_such() { diff --git a/core/sr-api-macros/Cargo.toml b/core/sr-api-macros/Cargo.toml index a87b53b732..9f2145d958 100644 --- a/core/sr-api-macros/Cargo.toml +++ b/core/sr-api-macros/Cargo.toml @@ -16,7 +16,7 @@ proc-macro-crate = "0.1.3" [dev-dependencies] client = { package = "substrate-client", path = "../client" } -test_client = { package = "substrate-test-client", path = "../test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client" } state_machine = { package = "substrate-state-machine", path = "../state-machine" } runtime_primitives = { package = "sr-primitives", path = "../sr-primitives" } sr-version = { path = "../sr-version" } diff --git a/core/sr-api-macros/tests/runtime_calls.rs b/core/sr-api-macros/tests/runtime_calls.rs index 0671c4f41d..6fa155437b 100644 --- a/core/sr-api-macros/tests/runtime_calls.rs +++ b/core/sr-api-macros/tests/runtime_calls.rs @@ -15,8 +15,8 @@ // along with Substrate. If not, see . use test_client::{ - AccountKeyring, runtime::{TestAPI, DecodeFails, Transfer, Header}, - NativeExecutor, LocalExecutor, TestClientBuilder + prelude::*, + runtime::{TestAPI, DecodeFails, Transfer, Header}, }; use runtime_primitives::{ generic::BlockId, @@ -190,4 +190,4 @@ fn record_proof_works() { "Core_execute_block", &block.encode(), ).expect("Executes block while using the proof backend"); -} \ No newline at end of file +} diff --git a/core/test-client/Cargo.toml b/core/test-client/Cargo.toml index 8de313f9cb..b459e02fbc 100644 --- a/core/test-client/Cargo.toml +++ b/core/test-client/Cargo.toml @@ -7,25 +7,13 @@ edition = "2018" [dependencies] client = { package = "substrate-client", path = "../client" } client-db = { package = "substrate-client-db", path = "../client/db", features = ["test-helpers"] } -futures = { version = "0.1.17" } -parity-codec = "3.5.1" -executor = { package = "substrate-executor", path = "../executor" } consensus = { package = "substrate-consensus-common", path = "../consensus/common" } -keyring = { package = "substrate-keyring", path = "../../core/keyring" } +executor = { package = "substrate-executor", path = "../executor" } +futures = { version = "0.1.27" } +hash-db = "0.12" +keyring = { package = "substrate-keyring", path = "../keyring" } +parity-codec = "3.5.1" primitives = { package = "substrate-primitives", path = "../primitives" } -state_machine = { package = "substrate-state-machine", path = "../state-machine" } -runtime = { package = "substrate-test-runtime", path = "../test-runtime", default-features = false } runtime_primitives = { package = "sr-primitives", path = "../sr-primitives" } +state_machine = { package = "substrate-state-machine", path = "../state-machine" } -[features] -default = [ - "include-wasm-blob", - "std", -] -std = [ - "runtime/std", -] -# If enabled, the WASM blob is added to the `GenesisConfig`. -include-wasm-blob = [ - "runtime/include-wasm-blob", -] \ No newline at end of file diff --git a/core/test-client/src/client_ext.rs b/core/test-client/src/client_ext.rs index d285bb726b..7d05b1f570 100644 --- a/core/test-client/src/client_ext.rs +++ b/core/test-client/src/client_ext.rs @@ -21,52 +21,55 @@ use consensus::{ ImportBlock, BlockImport, BlockOrigin, Error as ConsensusError, ForkChoiceStrategy, }; +use hash_db::Hasher; use runtime_primitives::Justification; +use runtime_primitives::traits::{Block as BlockT}; use runtime_primitives::generic::BlockId; use primitives::Blake2Hasher; -use runtime; use parity_codec::alloc::collections::hash_map::HashMap; /// Extension trait for a test client. -pub trait TestClient: Sized { +pub trait ClientExt: Sized { /// Import block to the chain. No finality. - fn import(&self, origin: BlockOrigin, block: runtime::Block) + fn import(&self, origin: BlockOrigin, block: Block) -> Result<(), ConsensusError>; /// Import block with justification, finalizes block. fn import_justified( &self, origin: BlockOrigin, - block: runtime::Block, + block: Block, justification: Justification ) -> Result<(), ConsensusError>; /// Finalize a block. fn finalize_block( &self, - id: BlockId, + id: BlockId, justification: Option, ) -> client::error::Result<()>; /// Returns hash of the genesis block. - fn genesis_hash(&self) -> runtime::Hash; + fn genesis_hash(&self) -> ::Hash; } -impl TestClient for Client +impl ClientExt for Client where - B: client::backend::Backend, - E: client::CallExecutor, - Self: BlockImport, + B: client::backend::Backend, + E: client::CallExecutor, + Self: BlockImport, + Block: BlockT::Out>, { - fn import(&self, origin: BlockOrigin, block: runtime::Block) + fn import(&self, origin: BlockOrigin, block: Block) -> Result<(), ConsensusError> { + let (header, extrinsics) = block.deconstruct(); let import = ImportBlock { origin, - header: block.header, + header, justification: None, post_digests: vec![], - body: Some(block.extrinsics), + body: Some(extrinsics), finalized: false, auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, @@ -78,15 +81,16 @@ impl TestClient for Client fn import_justified( &self, origin: BlockOrigin, - block: runtime::Block, + block: Block, justification: Justification, ) -> Result<(), ConsensusError> { + let (header, extrinsics) = block.deconstruct(); let import = ImportBlock { origin, - header: block.header, + header, justification: Some(justification), post_digests: vec![], - body: Some(block.extrinsics), + body: Some(extrinsics), finalized: true, auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, @@ -97,13 +101,13 @@ impl TestClient for Client fn finalize_block( &self, - id: BlockId, + id: BlockId, justification: Option, ) -> client::error::Result<()> { self.finalize_block(id, justification, true) } - fn genesis_hash(&self) -> runtime::Hash { - self.block_hash(0).unwrap().unwrap() + fn genesis_hash(&self) -> ::Hash { + self.block_hash(0.into()).unwrap().unwrap() } } diff --git a/core/test-client/src/lib.rs b/core/test-client/src/lib.rs index f39ad86b64..40fbd10d9e 100644 --- a/core/test-client/src/lib.rs +++ b/core/test-client/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2019 Parity Technologies (UK) Ltd. +// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -19,61 +19,30 @@ #![warn(missing_docs)] pub mod client_ext; -#[cfg(feature = "include-wasm-blob")] -pub mod trait_tests; -mod block_builder_ext; -pub use client_ext::TestClient; -pub use block_builder_ext::BlockBuilderExt; pub use client::{ExecutionStrategies, blockchain, backend, self}; -pub use executor::{NativeExecutor, self}; -pub use runtime; +pub use client_db::{Backend, self}; +pub use client_ext::ClientExt; pub use consensus; +pub use executor::{NativeExecutor, self}; pub use keyring::{sr25519::Keyring as AuthorityKeyring, AccountKeyring}; +pub use primitives::Blake2Hasher; +pub use runtime_primitives::{StorageOverlay, ChildrenStorageOverlay}; +pub use state_machine::ExecutionStrategy; -use std::{sync::Arc, collections::HashMap}; +use std::sync::Arc; +use std::collections::HashMap; use futures::future::FutureResult; -use primitives::Blake2Hasher; +use hash_db::Hasher; use primitives::storage::well_known_keys; -use runtime_primitives::{StorageOverlay, ChildrenStorageOverlay}; use runtime_primitives::traits::{ - Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor + Block as BlockT, NumberFor }; -use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; -use state_machine::ExecutionStrategy; use client::LocalCallExecutor; -#[cfg(feature = "include-wasm-blob")] -mod local_executor { - #![allow(missing_docs)] - use runtime; - use executor::native_executor_instance; - // FIXME #1576 change the macro and pass in the `BlakeHasher` that dispatch needs from here instead - native_executor_instance!( - pub LocalExecutor, - runtime::api::dispatch, - runtime::native_version, - include_bytes!("../../test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm") - ); -} - -/// Native executor used for tests. -#[cfg(feature = "include-wasm-blob")] -pub use local_executor::LocalExecutor; - -/// Test client database backend. -pub type Backend = client_db::Backend; - -/// Test client executor. -#[cfg(feature = "include-wasm-blob")] -pub type Executor = client::LocalCallExecutor< - Backend, - executor::NativeExecutor, ->; - /// Test client light database backend. -pub type LightBackend = client::light::backend::Backend< - client_db::light::LightStorage, +pub type LightBackend = client::light::backend::Backend< + client_db::light::LightStorage, LightFetcher, Blake2Hasher, >; @@ -81,101 +50,85 @@ pub type LightBackend = client::light::backend::Backend< /// Test client light fetcher. pub struct LightFetcher; -/// Test client light executor. -#[cfg(feature = "include-wasm-blob")] -pub type LightExecutor = client::light::call_executor::RemoteOrLocalCallExecutor< - runtime::Block, - LightBackend, - client::light::call_executor::RemoteCallExecutor< - client::light::blockchain::Blockchain< - client_db::light::LightStorage, - LightFetcher - >, - LightFetcher - >, - client::LocalCallExecutor< - client::light::backend::Backend< - client_db::light::LightStorage, - LightFetcher, - Blake2Hasher - >, - executor::NativeExecutor - > ->; +/// A genesis storage initialisation trait. +pub trait GenesisInit: Default { + /// Construct genesis storage. + fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay); +} + +impl GenesisInit for () { + fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) { + Default::default() + } +} /// A builder for creating a test client instance. -pub struct TestClientBuilder { +pub struct TestClientBuilder { execution_strategies: ExecutionStrategies, - genesis_extension: HashMap, Vec>, - support_changes_trie: bool, - backend: Arc, - _phantom: std::marker::PhantomData, + genesis_init: G, + child_storage_extension: HashMap, Vec<(Vec, Vec)>>, + backend: Arc, + _executor: std::marker::PhantomData, } -#[cfg(feature = "include-wasm-blob")] -impl TestClientBuilder where - B: backend::LocalBackend, +impl Default for TestClientBuilder< + Executor, + Backend, +> where + Block: BlockT::Out>, { - /// Create a new instance of the test client builder using the given backend. - pub fn new_with_backend(backend: Arc) -> Self { - TestClientBuilder { - execution_strategies: ExecutionStrategies::default(), - genesis_extension: HashMap::default(), - support_changes_trie: false, - backend, - _phantom: Default::default(), - } - } -} - -#[cfg(feature = "include-wasm-blob")] -impl TestClientBuilder { - /// Create a new instance of the test client builder. - pub fn new() -> Self { - TestClientBuilder { - execution_strategies: ExecutionStrategies::default(), - genesis_extension: HashMap::default(), - support_changes_trie: false, - backend: Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)), - _phantom: Default::default(), - } + fn default() -> Self { + Self::with_default_backend() } } -#[cfg(not(feature = "include-wasm-blob"))] -impl TestClientBuilder where - B: backend::LocalBackend, +impl TestClientBuilder< + Executor, + Backend, + G, +> where + Block: BlockT::Out>, { - /// Create a new instance of the test client builder using the given backend. - pub fn new_with_backend(backend: Arc) -> Self { - TestClientBuilder { - execution_strategies: ExecutionStrategies::default(), - genesis_extension: HashMap::default(), - support_changes_trie: false, - backend, - _phantom: Default::default(), - } + /// Create new `TestClientBuilder` with default backend. + pub fn with_default_backend() -> Self { + let backend = Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)); + Self::with_backend(backend) } } -#[cfg(not(feature = "include-wasm-blob"))] -impl TestClientBuilder { +impl TestClientBuilder< + Executor, + Backend, + G, +> { /// Create a new instance of the test client builder. - pub fn new() -> Self { + pub fn with_backend(backend: Arc) -> Self { TestClientBuilder { + backend, execution_strategies: ExecutionStrategies::default(), - genesis_extension: HashMap::default(), - support_changes_trie: false, - backend: Arc::new(Backend::new_test(std::u32::MAX, std::u64::MAX)), - _phantom: Default::default(), + child_storage_extension: Default::default(), + genesis_init: Default::default(), + _executor: Default::default(), } } -} -impl TestClientBuilder where - B: backend::LocalBackend, - E: executor::NativeExecutionDispatch -{ + /// Alter the genesis storage parameters. + pub fn genesis_init_mut(&mut self) -> &mut G { + &mut self.genesis_init + } + + /// Extend child storage + pub fn add_child_storage( + mut self, + key: impl AsRef<[u8]>, + child_key: impl AsRef<[u8]>, + value: impl AsRef<[u8]>, + ) -> Self { + let entry = self.child_storage_extension.entry(key.as_ref().to_vec()).or_insert_with(Vec::new); + entry.push((child_key.as_ref().to_vec(), value.as_ref().to_vec())); + self + } + /// Set the execution strategy that should be used by all contexts. pub fn set_execution_strategy( mut self, @@ -191,112 +144,79 @@ impl TestClientBuilder where self } - /// Set an extension of the genesis storage. - pub fn set_genesis_extension( - mut self, - extension: HashMap, Vec> - ) -> Self { - self.genesis_extension = extension; - self - } - - /// Enable/Disable changes trie support. - pub fn set_support_changes_trie(mut self, enable: bool) -> Self { - self.support_changes_trie = enable; - self - } - - /// Build the test client. - pub fn build(self) -> client::Client< - B, - client::LocalCallExecutor>, - runtime::Block, - runtime::RuntimeApi, - > { - self.build_with_longest_chain().0 - } - - /// Build the test client and longest chain as select chain. - pub fn build_with_longest_chain(self) -> ( + /// Build the test client with the given native executor. + pub fn build_with_executor( + self, + executor: Executor, + ) -> ( client::Client< - B, - client::LocalCallExecutor>, - runtime::Block, - runtime::RuntimeApi, + Backend, + Executor, + Block, + RuntimeApi, >, - client::LongestChain, - ) { - let executor = NativeExecutor::::new(None); - let executor = LocalCallExecutor::new(self.backend.clone(), executor); + client::LongestChain, + ) where + Executor: client::CallExecutor, + Backend: client::backend::Backend, + Block: BlockT::Out>, + { + + let storage = { + let mut storage = self.genesis_init.genesis_storage(); + + // Add some child storage keys. + for (key, value) in self.child_storage_extension { + storage.1.insert( + well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().cloned().chain(key).collect(), + value.into_iter().collect(), + ); + } + + storage + }; let client = client::Client::new( self.backend.clone(), executor, - genesis_storage(self.support_changes_trie, self.genesis_extension), - self.execution_strategies, + storage, + self.execution_strategies ).expect("Creates new client"); - #[allow(deprecated)] let longest_chain = client::LongestChain::new(self.backend); (client, longest_chain) } } -/// Creates new client instance used for tests. -#[cfg(feature = "include-wasm-blob")] -pub fn new() -> client::Client { - TestClientBuilder::new().build() -} - -/// Creates new light client instance used for tests. -#[cfg(feature = "include-wasm-blob")] -pub fn new_light() -> client::Client { - let storage = client_db::light::LightStorage::new_test(); - let blockchain = Arc::new(client::light::blockchain::Blockchain::new(storage)); - let backend = Arc::new(LightBackend::new(blockchain.clone())); - let executor = NativeExecutor::new(None); - let fetcher = Arc::new(LightFetcher); - let remote_call_executor = client::light::call_executor::RemoteCallExecutor::new(blockchain.clone(), fetcher); - let local_call_executor = client::LocalCallExecutor::new(backend.clone(), executor); - let call_executor = LightExecutor::new(backend.clone(), remote_call_executor, local_call_executor); - client::Client::new(backend, call_executor, genesis_storage(false, Default::default()), Default::default()).unwrap() -} - -fn genesis_config(support_changes_trie: bool) -> GenesisConfig { - GenesisConfig::new(support_changes_trie, vec![ - AuthorityKeyring::Alice.into(), - AuthorityKeyring::Bob.into(), - AuthorityKeyring::Charlie.into(), - ], vec![ - AccountKeyring::Alice.into(), - AccountKeyring::Bob.into(), - AccountKeyring::Charlie.into(), - ], - 1000 - ) -} +impl TestClientBuilder< + client::LocalCallExecutor>, + Backend, + G, +> { + /// Build the test client with the given native executor. + pub fn build_with_native_executor( + self, + executor: I, + ) -> ( + client::Client< + Backend, + client::LocalCallExecutor>, + Block, + RuntimeApi + >, + client::LongestChain, + ) where + I: Into>>, + E: executor::NativeExecutionDispatch, + Backend: client::backend::Backend, + Block: BlockT::Out>, + { + let executor = executor.into().unwrap_or_else(|| executor::NativeExecutor::new(None)); + let executor = LocalCallExecutor::new(self.backend.clone(), executor); -fn genesis_storage( - support_changes_trie: bool, - extension: HashMap, Vec> -) -> (StorageOverlay, ChildrenStorageOverlay) { - let mut storage = genesis_config(support_changes_trie).genesis_map(); - storage.extend(extension.into_iter()); - - let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( - storage.clone().into_iter() - ); - let block: runtime::Block = client::genesis::construct_genesis_block(state_root); - storage.extend(additional_storage_with_genesis(&block)); - - let mut child_storage = ChildrenStorageOverlay::default(); - child_storage.insert( - well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect(), - vec![(b"key".to_vec(), vec![42_u8])].into_iter().collect() - ); - - (storage, child_storage) + self.build_with_executor(executor) + } } impl client::light::fetcher::Fetcher for LightFetcher { diff --git a/core/test-runtime/Cargo.toml b/core/test-runtime/Cargo.toml index 4244dcc58b..b0815c513b 100644 --- a/core/test-runtime/Cargo.toml +++ b/core/test-runtime/Cargo.toml @@ -29,7 +29,7 @@ consensus_authorities = { package = "substrate-consensus-authorities", path = ". [dev-dependencies] substrate-executor = { path = "../executor" } -substrate-test-client = { path = "../test-client" } +substrate-test-runtime-client = { path = "./client" } [features] default = [ diff --git a/core/test-runtime/client/Cargo.toml b/core/test-runtime/client/Cargo.toml new file mode 100644 index 0000000000..9ddeb7ba25 --- /dev/null +++ b/core/test-runtime/client/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "substrate-test-runtime-client" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +generic-test-client = { package = "substrate-test-client", path = "../../test-client" } +primitives = { package = "substrate-primitives", path = "../../primitives" } +runtime = { package = "substrate-test-runtime", path = "../../test-runtime", default-features = false } +runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } + +[features] +default = [ + "std", + "runtime/include-wasm-blob", +] +std = [ + "runtime/std", +] diff --git a/core/test-client/src/block_builder_ext.rs b/core/test-runtime/client/src/block_builder_ext.rs similarity index 93% rename from core/test-client/src/block_builder_ext.rs rename to core/test-runtime/client/src/block_builder_ext.rs index 15861ce3d0..ae95ecd7ab 100644 --- a/core/test-client/src/block_builder_ext.rs +++ b/core/test-runtime/client/src/block_builder_ext.rs @@ -16,10 +16,10 @@ //! Block Builder extensions for tests. -use client; use runtime; use runtime_primitives::traits::ProvideRuntimeApi; -use client::block_builder::api::BlockBuilder; +use generic_test_client::client; +use generic_test_client::client::block_builder::api::BlockBuilder; /// Extension trait for test block builder. pub trait BlockBuilderExt { diff --git a/core/test-runtime/client/src/lib.rs b/core/test-runtime/client/src/lib.rs new file mode 100644 index 0000000000..ee1ad24214 --- /dev/null +++ b/core/test-runtime/client/src/lib.rs @@ -0,0 +1,208 @@ +// Copyright 2018-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Client testing utilities. + +#![warn(missing_docs)] + +pub mod trait_tests; + +mod block_builder_ext; + +pub use block_builder_ext::BlockBuilderExt; +pub use generic_test_client::*; +pub use runtime; + +use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; +use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT}; + +/// A prelude to import in tests. +pub mod prelude { + // Trait extensions + pub use super::{BlockBuilderExt, DefaultTestClientBuilderExt, TestClientBuilderExt, ClientExt}; + // Client structs + pub use super::{ + TestClient, TestClientBuilder, Backend, LightBackend, + Executor, LightExecutor, LocalExecutor, NativeExecutor, + }; + // Keyring + pub use super::{AccountKeyring, AuthorityKeyring}; +} + +mod local_executor { + #![allow(missing_docs)] + use runtime; + use crate::executor::native_executor_instance; + // FIXME #1576 change the macro and pass in the `BlakeHasher` that dispatch needs from here instead + native_executor_instance!( + pub LocalExecutor, + runtime::api::dispatch, + runtime::native_version, + include_bytes!("../../wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm") + ); +} + +/// Native executor used for tests. +pub use local_executor::LocalExecutor; + +/// Test client database backend. +pub type Backend = generic_test_client::Backend; + +/// Test client executor. +pub type Executor = client::LocalCallExecutor< + Backend, + NativeExecutor, +>; + +/// Test client light database backend. +pub type LightBackend = generic_test_client::LightBackend; + +/// Test client light executor. +pub type LightExecutor = client::light::call_executor::RemoteOrLocalCallExecutor< + runtime::Block, + LightBackend, + client::light::call_executor::RemoteCallExecutor< + client::light::blockchain::Blockchain< + client_db::light::LightStorage, + LightFetcher + >, + LightFetcher + >, + client::LocalCallExecutor< + client::light::backend::Backend< + client_db::light::LightStorage, + LightFetcher, + Blake2Hasher + >, + NativeExecutor + > +>; + +/// Parameters of test-client builder with test-runtime. +#[derive(Default)] +pub struct GenesisParameters { + support_changes_trie: bool, +} + +impl generic_test_client::GenesisInit for GenesisParameters { + fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) { + let mut storage = genesis_config(self.support_changes_trie).genesis_map(); + + let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( + storage.clone().into_iter() + ); + let block: runtime::Block = client::genesis::construct_genesis_block(state_root); + storage.extend(additional_storage_with_genesis(&block)); + + (storage, Default::default()) + } +} + +/// A `TestClient` with `test-runtime` builder. +pub type TestClientBuilder = generic_test_client::TestClientBuilder; + +/// Test client type with `LocalExecutor` and generic Backend. +pub type Client = client::Client< + B, + client::LocalCallExecutor>, + runtime::Block, + runtime::RuntimeApi, +>; + +/// A test client with default backend. +pub type TestClient = Client; + +/// A `TestClientBuilder` with default backend and executor. +pub trait DefaultTestClientBuilderExt: Sized { + /// Create new `TestClientBuilder` + fn new() -> Self; +} + +impl DefaultTestClientBuilderExt for TestClientBuilder< + Executor, + Backend, +> { + fn new() -> Self { + Self::with_default_backend() + } +} + +/// A `test-runtime` extensions to `TestClientBuilder`. +pub trait TestClientBuilderExt: Sized { + /// Enable or disable support for changes trie in genesis. + fn set_support_changes_trie(self, support_changes_trie: bool) -> Self; + + /// Build the test client. + fn build(self) -> Client { + self.build_with_longest_chain().0 + } + + /// Build the test client and longest chain selector. + fn build_with_longest_chain(self) -> (Client, client::LongestChain); +} + +impl TestClientBuilderExt for TestClientBuilder< + client::LocalCallExecutor>, + B +> where + B: client::backend::Backend, +{ + fn set_support_changes_trie(mut self, support_changes_trie: bool) -> Self { + self.genesis_init_mut().support_changes_trie = support_changes_trie; + self + } + + fn build_with_longest_chain(self) -> (Client, client::LongestChain) { + self.build_with_native_executor(None) + } +} + +fn genesis_config(support_changes_trie: bool) -> GenesisConfig { + GenesisConfig::new(support_changes_trie, vec![ + AuthorityKeyring::Alice.into(), + AuthorityKeyring::Bob.into(), + AuthorityKeyring::Charlie.into(), + ], vec![ + AccountKeyring::Alice.into(), + AccountKeyring::Bob.into(), + AccountKeyring::Charlie.into(), + ], + 1000 + ) +} + +/// Creates new client instance used for tests. +pub fn new() -> Client { + TestClientBuilder::new().build() +} + +/// Creates new light client instance used for tests. +pub fn new_light() -> client::Client { + use std::sync::Arc; + + let storage = client_db::light::LightStorage::new_test(); + let blockchain = Arc::new(client::light::blockchain::Blockchain::new(storage)); + let backend = Arc::new(LightBackend::new(blockchain.clone())); + let executor = NativeExecutor::new(None); + let fetcher = Arc::new(LightFetcher); + let remote_call_executor = client::light::call_executor::RemoteCallExecutor::new(blockchain.clone(), fetcher); + let local_call_executor = client::LocalCallExecutor::new(backend.clone(), executor); + let call_executor = LightExecutor::new(backend.clone(), remote_call_executor, local_call_executor); + + TestClientBuilder::with_backend(backend) + .build_with_executor(call_executor) + .0 +} diff --git a/core/test-client/src/trait_tests.rs b/core/test-runtime/client/src/trait_tests.rs similarity index 96% rename from core/test-client/src/trait_tests.rs rename to core/test-runtime/client/src/trait_tests.rs index f39d85a1ca..3d013e3e74 100644 --- a/core/test-client/src/trait_tests.rs +++ b/core/test-runtime/client/src/trait_tests.rs @@ -20,15 +20,16 @@ #![allow(missing_docs)] use std::sync::Arc; -use consensus::BlockOrigin; -use primitives::Blake2Hasher; -use crate::{TestClient, AccountKeyring}; -use runtime_primitives::traits::Block as BlockT; + use crate::backend; +use crate::block_builder_ext::BlockBuilderExt; use crate::blockchain::{Backend as BlockChainBackendT, HeaderBackend}; -use crate::{BlockBuilderExt, TestClientBuilder}; +use crate::{AccountKeyring, ClientExt, TestClientBuilder, TestClientBuilderExt}; +use generic_test_client::consensus::BlockOrigin; +use primitives::Blake2Hasher; use runtime::{self, Transfer}; use runtime_primitives::generic::BlockId; +use runtime_primitives::traits::Block as BlockT; /// helper to test the `leaves` implementation for various backends pub fn test_leaves_for_backend(backend: Arc) where @@ -40,7 +41,7 @@ pub fn test_leaves_for_backend(backend: Arc) where // B2 -> C3 // A1 -> D2 - let client = TestClientBuilder::new_with_backend(backend.clone()).build(); + let client = TestClientBuilder::with_backend(backend.clone()).build(); let blockchain = backend.blockchain(); let genesis_hash = client.info().chain.genesis_hash; @@ -156,7 +157,7 @@ pub fn test_children_for_backend(backend: Arc) where // B2 -> C3 // A1 -> D2 - let client = TestClientBuilder::new_with_backend(backend.clone()).build(); + let client = TestClientBuilder::with_backend(backend.clone()).build(); let blockchain = backend.blockchain(); // G -> A1 @@ -246,7 +247,7 @@ pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc B2 -> B3 -> B4 // B2 -> C3 // A1 -> D2 - let client = TestClientBuilder::new_with_backend(backend.clone()).build(); + let client = TestClientBuilder::with_backend(backend.clone()).build(); let blockchain = backend.blockchain(); // G -> A1 diff --git a/core/test-runtime/src/system.rs b/core/test-runtime/src/system.rs index 491ca0db36..57a5cb9ea2 100644 --- a/core/test-runtime/src/system.rs +++ b/core/test-runtime/src/system.rs @@ -311,7 +311,7 @@ mod tests { use runtime_io::{with_externalities, twox_128, blake2_256, TestExternalities}; use parity_codec::{Joiner, KeyedVec}; - use substrate_test_client::{AuthorityKeyring, AccountKeyring}; + use substrate_test_runtime_client::{AuthorityKeyring, AccountKeyring}; use crate::{Header, Transfer}; use primitives::{Blake2Hasher, map}; use primitives::storage::well_known_keys; diff --git a/core/transaction-pool/Cargo.toml b/core/transaction-pool/Cargo.toml index ed2cd27833..2bcad4d4d6 100644 --- a/core/transaction-pool/Cargo.toml +++ b/core/transaction-pool/Cargo.toml @@ -17,4 +17,4 @@ txpool = { package = "substrate-transaction-graph", path = "./graph" } [dev-dependencies] keyring = { package = "substrate-keyring", path = "../../core/keyring" } -test_client = { package = "substrate-test-client", path = "../../core/test-client" } +test-client = { package = "substrate-test-runtime-client", path = "../../core/test-runtime/client" } diff --git a/node/executor/Cargo.toml b/node/executor/Cargo.toml index 89b448ec90..ee126d19ea 100644 --- a/node/executor/Cargo.toml +++ b/node/executor/Cargo.toml @@ -17,6 +17,7 @@ node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } [dev-dependencies] +test-client = { package = "substrate-test-client", path = "../../core/test-client" } keyring = { package = "substrate-keyring", path = "../../core/keyring" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } runtime_support = { package = "srml-support", path = "../../srml/support" } diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index 05dc424d49..aabee6805e 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -895,6 +895,21 @@ mod tests { assert!(t.storage_changes_root(GENESIS_HASH.into()).unwrap().is_some()); } + #[test] + fn should_import_block_with_test_client() { + use test_client::{ClientExt, TestClientBuilder, consensus::BlockOrigin}; + + let client = TestClientBuilder::default() + .build_with_native_executor::(executor()) + .0; + + let block1 = changes_trie_block(); + let block_data = block1.0; + let block = Block::decode(&mut &block_data[..]).unwrap(); + + client.import(BlockOrigin::Own, block).unwrap(); + } + #[cfg(feature = "benchmarks")] mod benches { use super::*; -- GitLab From e9bbcff05394553ffc7a97c1fa4af9262061eec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 11 Jun 2019 22:42:28 +0200 Subject: [PATCH 113/113] Remove compilation warnings. (#2835) * Remove compilation warnings. * Allow unused only not in tests. * Remove unnecessary mut. * Make CI happy. * Revert "Make CI happy." This reverts commit abb865fe4b9fe9af1ae3ec801da9d4305ea35765. --- Cargo.lock | 272 +++++++++--------- core/client/src/runtime_api.rs | 1 - core/consensus/aura/src/lib.rs | 2 +- core/network/src/test/mod.rs | 7 + .../procedural/src/storage/transformation.rs | 2 +- 5 files changed, 145 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b79b9c0827..ef24acc3d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -103,7 +103,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -157,7 +157,7 @@ name = "base64" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -166,7 +166,7 @@ name = "base64" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -174,7 +174,7 @@ name = "bigint" version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -183,7 +183,7 @@ name = "bindgen" version = "0.47.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -195,13 +195,13 @@ dependencies = [ "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -245,7 +245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -305,7 +305,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -313,7 +313,7 @@ name = "bytes" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -386,7 +386,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -407,7 +407,7 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -476,7 +476,7 @@ dependencies = [ "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -484,7 +484,7 @@ name = "criterion-plot" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -500,7 +500,7 @@ dependencies = [ "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -510,7 +510,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -645,7 +645,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -677,10 +677,10 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -700,7 +700,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -729,7 +729,7 @@ name = "dns-parser" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -739,7 +739,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -766,7 +766,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -817,7 +817,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -853,7 +853,7 @@ name = "fixed-hash" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -920,7 +920,7 @@ name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -940,7 +940,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1004,7 +1004,7 @@ dependencies = [ "bstr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1012,7 +1012,7 @@ name = "h2" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1042,7 +1042,7 @@ name = "hashbrown" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1179,7 +1179,7 @@ dependencies = [ "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1345,7 +1345,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1383,7 +1383,7 @@ dependencies = [ "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1414,7 +1414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1454,9 +1454,9 @@ dependencies = [ "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1519,7 +1519,7 @@ dependencies = [ "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1551,7 +1551,7 @@ dependencies = [ "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1567,7 +1567,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1606,7 +1606,7 @@ dependencies = [ "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1625,7 +1625,7 @@ dependencies = [ "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1653,7 +1653,7 @@ dependencies = [ "protobuf 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1674,7 +1674,7 @@ dependencies = [ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1704,7 +1704,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1977,7 +1977,7 @@ name = "merlin" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2076,7 +2076,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2122,7 +2122,7 @@ name = "nix" version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2147,7 +2147,7 @@ dependencies = [ "srml-finality-tracker 2.0.0", "srml-indices 2.0.0", "srml-timestamp 2.0.0", - "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-basic-authorship 2.0.0", "substrate-cli 2.0.0", "substrate-client 2.0.0", @@ -2354,7 +2354,7 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2392,7 +2392,7 @@ name = "openssl" version = "0.10.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2464,7 +2464,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2474,7 +2474,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2507,7 +2507,7 @@ name = "parity-wasm" version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2554,7 +2554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2566,7 +2566,7 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2578,7 +2578,7 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2593,7 +2593,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2614,7 +2614,7 @@ dependencies = [ "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2622,7 +2622,7 @@ name = "pbkdf2" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2696,7 +2696,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2722,7 +2722,7 @@ name = "pwasm-utils" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2879,7 +2879,7 @@ name = "rand_xoshiro" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2901,7 +2901,7 @@ dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2932,19 +2932,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3084,7 +3084,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3166,7 +3166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3281,12 +3281,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "smallvec" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3295,13 +3295,13 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3319,7 +3319,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3351,8 +3351,8 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-test-runtime-client 2.0.0", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3369,7 +3369,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3741,7 +3741,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3752,7 +3752,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3761,7 +3761,7 @@ version = "2.0.0" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3774,7 +3774,7 @@ dependencies = [ "srml-support 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3860,22 +3860,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3891,7 +3891,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3967,11 +3967,11 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", - "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-client 2.0.0", "substrate-keyring 2.0.0", "substrate-network 2.0.0", @@ -4207,7 +4207,7 @@ name = "substrate-executor" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4222,7 +4222,7 @@ dependencies = [ "substrate-serializer 2.0.0", "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4304,7 +4304,7 @@ dependencies = [ name = "substrate-network" version = "2.0.0" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", @@ -4334,7 +4334,7 @@ dependencies = [ name = "substrate-network-libp2p" version = "2.0.0" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4348,7 +4348,7 @@ dependencies = [ "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-peerset 2.0.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4414,7 +4414,7 @@ version = "2.0.0" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4427,7 +4427,7 @@ dependencies = [ "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4713,7 +4713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.34" +version = "0.15.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4728,7 +4728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4831,7 +4831,7 @@ dependencies = [ [[package]] name = "tiny-keccak" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4865,14 +4865,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4960,12 +4960,12 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4983,7 +4983,7 @@ dependencies = [ [[package]] name = "tokio-sync" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5013,7 +5013,7 @@ dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5157,7 +5157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trybuild" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5174,7 +5174,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5206,7 +5206,7 @@ name = "uint" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5241,7 +5241,7 @@ name = "unicode-normalization" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5285,7 +5285,7 @@ dependencies = [ [[package]] name = "utf8-ranges" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -5303,7 +5303,7 @@ name = "vergen" version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5341,7 +5341,7 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.2.7" +version = "2.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5377,7 +5377,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5407,7 +5407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5427,7 +5427,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5500,8 +5500,8 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5585,7 +5585,7 @@ name = "ws" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5612,7 +5612,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5670,7 +5670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5680,7 +5680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5707,7 +5707,7 @@ dependencies = [ "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebecac13b3c745150d7b6c3ea7572d372f09d627c2077e893bf26c5c7f70d282" "checksum bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df683a55b54b41d5ea8ebfaebb5aa7e6b84e3f3006a78f010dadc9ca88469260" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" "checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" @@ -5722,7 +5722,7 @@ dependencies = [ "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" -"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" @@ -5762,7 +5762,7 @@ dependencies = [ "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440b7acc6264fde2eee18bae135625129c88ff244f3ded035e3caa585a6bf0a" +"checksum curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5d4b820e8711c211745880150f5fac78ab07d6e3851d8ce9f5a02cedc199174c" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" @@ -5906,7 +5906,7 @@ dependencies = [ "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" -"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" +"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" @@ -5971,8 +5971,8 @@ dependencies = [ "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d813022b2e00774a48eaf43caaa3c20b45f040ba8cbf398e2e8911a06668dbe6" -"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" -"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" +"checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" +"checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rhododendron 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9381ed76c1ec4e8994f1f7d2c6d7e33eed3ff7176e16fece09c2e993fc4a5a" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" @@ -6011,7 +6011,7 @@ dependencies = [ "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60c04b4726fa04595ccf2c2dad7bcd15474242c4c5e109a8a376e8a2c9b1539a" "checksum slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" -"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" +"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" "checksum soketto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cf3ae22c0bce5437c7dce6a2b00e492c19da1feb21ad64a7b6fd7058438c3f2" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" @@ -6022,14 +6022,14 @@ dependencies = [ "checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc" "checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c767a8971f53d7324583085deee2e230903be09e52fb27df9af94c5cb2b43c31" -"checksum structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c57a30c87454ced2186f62f940e981746e8cbbe026d52090c8c4352b636f8235" +"checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" +"checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" "checksum strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1810e25f576e7ffce1ff5243b37066da5ded0310b3274c20baaeccb1145b2806" "checksum strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572a2f4e53dd4c3483fd79e5cc10ddd773a3acb1169bbfe8762365e107110579" "checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" -"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)" = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum sysinfo 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cf62641ed7e88e20242b948d17b9fcc37e80b5599cf09cde190d6d4bb4bf289" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" @@ -6041,7 +6041,7 @@ dependencies = [ "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c5676413eaeb1ea35300a0224416f57abc3bd251657e0fafc12c47ff98c060" -"checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" +"checksum tiny-keccak 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbdebb0b801c7fa4260b6b9ac5a15980276d7d7bcc2dc2959a7c4dc8b426a1a" "checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" "checksum tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5462b0f968c0457efe38fcd2df7e487096b992419e4f5337b06775a614bbda4b" "checksum tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ec2ffcf4bcfc641413fa0f1427bf8f91dfc78f56a6559cbf50e04837ae442a87" @@ -6054,7 +6054,7 @@ dependencies = [ "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" "checksum tokio-rustls 0.10.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "316fdbc899efec48b3b492bd0f339e6d81c4ee96a409257572147ec341943452" -"checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" +"checksum tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" @@ -6069,7 +6069,7 @@ dependencies = [ "checksum trie-root 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa2e20c4f1418ac2e71ddc418e35e1b56e34022e2146209ffdbf1b2de8b1bd9" "checksum trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ebaa4b340046196efad8872b2dffe585b5ea330230dc44ee14e399f77da29f51" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" -"checksum trybuild 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0b0df728de48978b759da185ed7ef76676ef0c878ae4800c9e90024c998dc75b" +"checksum trybuild 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d1506db833ec4a139b8e3d2e88125d8999270cc944046ca1fb138f6bbfbc2e43" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" "checksum twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7bcecad121018bdcd6b709fa2325b004878fcb3d3067934ce90749f0faff9a" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" @@ -6086,7 +6086,7 @@ dependencies = [ "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" +"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6aba5e34f93dc7051dfad05b98a18e9156f27e7b431fe1d2398cb6061c0a1dba" @@ -6094,7 +6094,7 @@ dependencies = [ "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "74e463a508e390cc7447e70f640fbf44ad52e1bd095314ace1fdf99516d32add" "checksum wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a6265b25719e82598d104b3717375e37661d41753e2c84cde3f51050c7ed7e3c" -"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" +"checksum walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c7904a7e2bb3cdf0cf5e783f44204a85a37a93151738fa349f06680f59a98b45" "checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" "checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" "checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" diff --git a/core/client/src/runtime_api.rs b/core/client/src/runtime_api.rs index e456c166dc..4f2f841461 100644 --- a/core/client/src/runtime_api.rs +++ b/core/client/src/runtime_api.rs @@ -46,7 +46,6 @@ use sr_api_macros::decl_runtime_apis; use primitives::OpaqueMetadata; #[cfg(feature = "std")] use std::{panic::UnwindSafe, cell::RefCell, rc::Rc}; -use rstd::vec::Vec; #[cfg(feature = "std")] use primitives::Hasher as HasherT; diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index ad618c2188..fa878ef104 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -40,7 +40,7 @@ use consensus_common::import_queue::{ use client::{ block_builder::api::BlockBuilder as BlockBuilderApi, blockchain::ProvideCache, - runtime_api::{ApiExt, Core as CoreApi}, + runtime_api::ApiExt, error::Result as CResult, backend::AuxStore, }; diff --git a/core/network/src/test/mod.rs b/core/network/src/test/mod.rs index 886a09fa2a..b27214d07b 100644 --- a/core/network/src/test/mod.rs +++ b/core/network/src/test/mod.rs @@ -282,6 +282,10 @@ pub struct Peer> { peer_id: PeerId, client: PeersClient, net_proto_channel: ProtocolChannel, + /// This field is used only in test code, but maintaining different + /// instantiation paths or field names is too much hassle, hence + /// we allow it to be unused. + #[cfg_attr(not(test), allow(unused))] protocol_status: Arc>>, import_queue: Box>, pub data: D, @@ -471,6 +475,7 @@ impl> Peer { self.net_proto_channel.send_from_client(ProtocolMsg::BlockImported(info.chain.best_hash, header)); } + #[cfg(test)] fn on_block_imported( &self, hash: ::Hash, @@ -492,6 +497,7 @@ impl> Peer { } /// Get protocol status. + #[cfg(test)] fn protocol_status(&self) -> ProtocolStatus { self.protocol_status.read().clone() } @@ -608,6 +614,7 @@ impl> Peer { } /// Announce a block to peers. + #[cfg(test)] fn announce_block(&self, block: Hash) { self.net_proto_channel.send_from_client(ProtocolMsg::AnnounceBlock(block)); } diff --git a/srml/support/procedural/src/storage/transformation.rs b/srml/support/procedural/src/storage/transformation.rs index 1da6ae2108..2827259420 100644 --- a/srml/support/procedural/src/storage/transformation.rs +++ b/srml/support/procedural/src/storage/transformation.rs @@ -217,7 +217,7 @@ fn decl_store_extra_genesis( let type_infos = get_type_infos(storage_type); - let mut opt_build; + let opt_build; // need build line if let Some(ref config) = config.inner { let ident = if let Some(ident) = config.expr.content.as_ref() { -- GitLab