From 78a38e98259404d19dbe38e5fe407b92e5144098 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 8 Aug 2018 10:56:54 +0200 Subject: [PATCH 1/9] ethcore sync decodes rlp less often (#9264) * deserialize block only once during verification * ethcore-sync uses Unverified * ethcore-sync uses Unverified * fixed build error * removed Block::is_good * applied review suggestions * ethcore-sync deserializes headers and blocks only once --- ethcore/src/verification/queue/kind.rs | 1 + ethcore/sync/src/block_sync.rs | 54 ++---- ethcore/sync/src/blocks.rs | 253 +++++++++++++++++-------- 3 files changed, 193 insertions(+), 115 deletions(-) diff --git a/ethcore/src/verification/queue/kind.rs b/ethcore/src/verification/queue/kind.rs index fbc6346c9c0..9735187265a 100644 --- a/ethcore/src/verification/queue/kind.rs +++ b/ethcore/src/verification/queue/kind.rs @@ -113,6 +113,7 @@ pub mod blocks { } /// An unverified block. + #[derive(PartialEq, Debug)] pub struct Unverified { /// Unverified block header. pub header: Header, diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index 588bfc0c711..4c229cd87ae 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -23,12 +23,11 @@ use std::cmp; use heapsize::HeapSizeOf; use ethereum_types::H256; use rlp::{self, Rlp}; -use ethcore::header::{BlockNumber, Header as BlockHeader}; +use ethcore::header::BlockNumber; use ethcore::client::{BlockStatus, BlockId, BlockImportError, BlockImportErrorKind}; use ethcore::error::{ImportErrorKind, BlockError}; -use ethcore::verification::queue::kind::blocks::Unverified; use sync_io::SyncIo; -use blocks::BlockCollection; +use blocks::{BlockCollection, SyncBody, SyncHeader}; const MAX_HEADERS_TO_REQUEST: usize = 128; const MAX_BODIES_TO_REQUEST: usize = 32; @@ -236,45 +235,39 @@ impl BlockDownloader { let mut valid_response = item_count == 0; //empty response is valid let mut any_known = false; for i in 0..item_count { - let info: BlockHeader = r.val_at(i).map_err(|e| { - trace!(target: "sync", "Error decoding block header RLP: {:?}", e); - BlockDownloaderImportError::Invalid - })?; - let number = BlockNumber::from(info.number()); + let info = SyncHeader::from_rlp(r.at(i)?.as_raw().to_vec())?; + let number = BlockNumber::from(info.header.number()); + let hash = info.header.hash(); // Check if any of the headers matches the hash we requested if !valid_response { if let Some(expected) = expected_hash { - valid_response = expected == info.hash() + valid_response = expected == hash; } } - any_known = any_known || self.blocks.contains_head(&info.hash()); - if self.blocks.contains(&info.hash()) { - trace!(target: "sync", "Skipping existing block header {} ({:?})", number, info.hash()); + any_known = any_known || self.blocks.contains_head(&hash); + if self.blocks.contains(&hash) { + trace!(target: "sync", "Skipping existing block header {} ({:?})", number, hash); continue; } if self.highest_block.as_ref().map_or(true, |n| number > *n) { self.highest_block = Some(number); } - let hash = info.hash(); - let hdr = r.at(i).map_err(|e| { - trace!(target: "sync", "Error decoding block header RLP: {:?}", e); - BlockDownloaderImportError::Invalid - })?; + match io.chain().block_status(BlockId::Hash(hash.clone())) { BlockStatus::InChain | BlockStatus::Queued => { match self.state { State::Blocks => trace!(target: "sync", "Header already in chain {} ({})", number, hash), _ => trace!(target: "sync", "Header already in chain {} ({}), state = {:?}", number, hash, self.state), } - headers.push(hdr.as_raw().to_vec()); + headers.push(info); hashes.push(hash); }, BlockStatus::Bad => { return Err(BlockDownloaderImportError::Invalid); }, BlockStatus::Unknown | BlockStatus::Pending => { - headers.push(hdr.as_raw().to_vec()); + headers.push(info); hashes.push(hash); } } @@ -325,19 +318,15 @@ impl BlockDownloader { let item_count = r.item_count().unwrap_or(0); if item_count == 0 { return Err(BlockDownloaderImportError::Useless); - } - else if self.state != State::Blocks { + } else if self.state != State::Blocks { trace!(target: "sync", "Ignored unexpected block bodies"); - } - else { + } else { let mut bodies = Vec::with_capacity(item_count); for i in 0..item_count { - let body = r.at(i).map_err(|e| { - trace!(target: "sync", "Error decoding block boides RLP: {:?}", e); - BlockDownloaderImportError::Invalid - })?; - bodies.push(body.as_raw().to_vec()); + let body = SyncBody::from_rlp(r.at(i)?.as_raw())?; + bodies.push(body); } + if self.blocks.insert_bodies(bodies) != item_count { trace!(target: "sync", "Deactivating peer for giving invalid block bodies"); return Err(BlockDownloaderImportError::Invalid); @@ -483,15 +472,6 @@ impl BlockDownloader { let block = block_and_receipts.block; let receipts = block_and_receipts.receipts; - let block = match Unverified::from_rlp(block) { - Ok(block) => block, - Err(_) => { - debug!(target: "sync", "Bad block rlp"); - bad = true; - break; - } - }; - let h = block.header.hash(); let number = block.header.number(); let parent = *block.header.parent_hash(); diff --git a/ethcore/sync/src/blocks.rs b/ethcore/sync/src/blocks.rs index 248180b281d..a502cee9c55 100644 --- a/ethcore/sync/src/blocks.rs +++ b/ethcore/sync/src/blocks.rs @@ -23,36 +23,116 @@ use triehash_ethereum::ordered_trie_root; use bytes::Bytes; use rlp::{Rlp, RlpStream, DecoderError}; use network; -use ethcore::encoded::Block; -use ethcore::views::{HeaderView, BodyView}; use ethcore::header::Header as BlockHeader; +use ethcore::verification::queue::kind::blocks::Unverified; +use transaction::UnverifiedTransaction; known_heap_size!(0, HeaderId); type SmallHashVec = SmallVec<[H256; 1]>; +pub struct SyncHeader { + pub bytes: Bytes, + pub header: BlockHeader, +} + +impl HeapSizeOf for SyncHeader { + fn heap_size_of_children(&self) -> usize { + self.bytes.heap_size_of_children() + + self.header.heap_size_of_children() + } +} + +impl SyncHeader { + pub fn from_rlp(bytes: Bytes) -> Result { + let result = SyncHeader { + header: ::rlp::decode(&bytes)?, + bytes, + }; + + Ok(result) + } +} + +pub struct SyncBody { + pub transactions_bytes: Bytes, + pub transactions: Vec, + pub uncles_bytes: Bytes, + pub uncles: Vec, +} + +impl SyncBody { + pub fn from_rlp(bytes: &[u8]) -> Result { + let rlp = Rlp::new(bytes); + let transactions_rlp = rlp.at(0)?; + let uncles_rlp = rlp.at(1)?; + + let result = SyncBody { + transactions_bytes: transactions_rlp.as_raw().to_vec(), + transactions: transactions_rlp.as_list()?, + uncles_bytes: uncles_rlp.as_raw().to_vec(), + uncles: uncles_rlp.as_list()?, + }; + + Ok(result) + } + + fn empty_body() -> Self { + SyncBody { + transactions_bytes: ::rlp::EMPTY_LIST_RLP.to_vec(), + transactions: Vec::with_capacity(0), + uncles_bytes: ::rlp::EMPTY_LIST_RLP.to_vec(), + uncles: Vec::with_capacity(0), + } + } +} + +impl HeapSizeOf for SyncBody { + fn heap_size_of_children(&self) -> usize { + self.transactions_bytes.heap_size_of_children() + + self.transactions.heap_size_of_children() + + self.uncles_bytes.heap_size_of_children() + + self.uncles.heap_size_of_children() + } +} + /// Block data with optional body. struct SyncBlock { - header: Bytes, - body: Option, + header: SyncHeader, + body: Option, receipts: Option, receipts_root: H256, } +impl HeapSizeOf for SyncBlock { + fn heap_size_of_children(&self) -> usize { + self.header.heap_size_of_children() + self.body.heap_size_of_children() + } +} + +fn unverified_from_sync(header: SyncHeader, body: Option) -> Unverified { + let mut stream = RlpStream::new_list(3); + stream.append_raw(&header.bytes, 1); + let body = body.unwrap_or_else(SyncBody::empty_body); + stream.append_raw(&body.transactions_bytes, 1); + stream.append_raw(&body.uncles_bytes, 1); + + Unverified { + header: header.header, + transactions: body.transactions, + uncles: body.uncles, + bytes: stream.out().to_vec(), + } +} + /// Block with optional receipt pub struct BlockAndReceipts { /// Block data. - pub block: Bytes, + pub block: Unverified, /// Block receipts RLP list. pub receipts: Option, } -impl HeapSizeOf for SyncBlock { - fn heap_size_of_children(&self) -> usize { - self.header.heap_size_of_children() + self.body.heap_size_of_children() - } -} - /// Used to identify header by transactions and uncles hashes #[derive(Eq, PartialEq, Hash)] struct HeaderId { @@ -124,7 +204,7 @@ impl BlockCollection { } /// Insert a set of headers into collection and advance subchain head pointers. - pub fn insert_headers(&mut self, headers: Vec) { + pub fn insert_headers(&mut self, headers: Vec) { for h in headers { if let Err(e) = self.insert_header(h) { trace!(target: "sync", "Ignored invalid header: {:?}", e); @@ -134,7 +214,7 @@ impl BlockCollection { } /// Insert a collection of block bodies for previously downloaded headers. - pub fn insert_bodies(&mut self, bodies: Vec) -> usize { + pub fn insert_bodies(&mut self, bodies: Vec) -> usize { let mut inserted = 0; for b in bodies { if let Err(e) = self.insert_body(b) { @@ -278,30 +358,33 @@ impl BlockCollection { while let Some(h) = head { head = self.parents.get(&h).cloned(); if let Some(head) = head { - match self.blocks.get(&head) { - Some(block) if block.body.is_some() && (!self.need_receipts || block.receipts.is_some()) => { - blocks.push(block); - hashes.push(head); - self.head = Some(head); - } - _ => break, + match self.blocks.remove(&head) { + Some(block) => { + if block.body.is_some() && (!self.need_receipts || block.receipts.is_some()) { + blocks.push(block); + hashes.push(head); + self.head = Some(head); + } else { + self.blocks.insert(head, block); + break; + } + }, + _ => { + break; + }, } } } - for block in blocks { - let body = view!(BodyView, block.body.as_ref().expect("blocks contains only full blocks; qed")); - let header = view!(HeaderView, &block.header); - let block_view = Block::new_from_header_and_body(&header, &body); + for block in blocks.into_iter() { + let unverified = unverified_from_sync(block.header, block.body); drained.push(BlockAndReceipts { - block: block_view.into_inner(), + block: unverified, receipts: block.receipts.clone(), }); } } - for h in hashes { - self.blocks.remove(&h); - } + trace!(target: "sync", "Drained {} blocks, new head :{:?}", drained.len(), self.head); drained } @@ -337,26 +420,23 @@ impl BlockCollection { self.downloading_headers.contains(hash) || self.downloading_bodies.contains(hash) } - fn insert_body(&mut self, b: Bytes) -> Result<(), network::Error> { + fn insert_body(&mut self, body: SyncBody) -> Result<(), network::Error> { let header_id = { - let body = Rlp::new(&b); - let tx = body.at(0)?; - let tx_root = ordered_trie_root(tx.iter().map(|r| r.as_raw())); - let uncles = keccak(body.at(1)?.as_raw()); + let tx_root = ordered_trie_root(Rlp::new(&body.transactions_bytes).iter().map(|r| r.as_raw())); + let uncles = keccak(&body.uncles_bytes); HeaderId { transactions_root: tx_root, uncles: uncles } }; - match self.header_ids.get(&header_id).cloned() { + match self.header_ids.remove(&header_id) { Some(h) => { - self.header_ids.remove(&header_id); self.downloading_bodies.remove(&h); match self.blocks.get_mut(&h) { Some(ref mut block) => { trace!(target: "sync", "Got body {}", h); - block.body = Some(b); + block.body = Some(body); Ok(()) }, None => { @@ -401,54 +481,63 @@ impl BlockCollection { } } - fn insert_header(&mut self, header: Bytes) -> Result { - let info: BlockHeader = Rlp::new(&header).as_val()?; - let hash = info.hash(); + fn insert_header(&mut self, info: SyncHeader) -> Result { + let hash = info.header.hash(); if self.blocks.contains_key(&hash) { return Ok(hash); } + match self.head { None if hash == self.heads[0] => { trace!(target: "sync", "New head {}", hash); - self.head = Some(info.parent_hash().clone()); + self.head = Some(info.header.parent_hash().clone()); }, _ => () } - let mut block = SyncBlock { - header: header, - body: None, - receipts: None, - receipts_root: H256::new(), - }; let header_id = HeaderId { - transactions_root: info.transactions_root().clone(), - uncles: info.uncles_hash().clone(), + transactions_root: *info.header.transactions_root(), + uncles: *info.header.uncles_hash(), }; - if header_id.transactions_root == KECCAK_NULL_RLP && header_id.uncles == KECCAK_EMPTY_LIST_RLP { + + let body = if header_id.transactions_root == KECCAK_NULL_RLP && header_id.uncles == KECCAK_EMPTY_LIST_RLP { // empty body, just mark as downloaded - let mut body_stream = RlpStream::new_list(2); - body_stream.append_raw(&::rlp::EMPTY_LIST_RLP, 1); - body_stream.append_raw(&::rlp::EMPTY_LIST_RLP, 1); - block.body = Some(body_stream.out()); - } - else { - trace!("Queueing body tx_root = {:?}, uncles = {:?}, block = {:?}, number = {}", header_id.transactions_root, header_id.uncles, hash, info.number()); - self.header_ids.insert(header_id, hash.clone()); - } - if self.need_receipts { - let receipt_root = info.receipts_root().clone(); + Some(SyncBody::empty_body()) + } else { + trace!( + "Queueing body tx_root = {:?}, uncles = {:?}, block = {:?}, number = {}", + header_id.transactions_root, + header_id.uncles, + hash, + info.header.number() + ); + self.header_ids.insert(header_id, hash); + None + }; + + let (receipts, receipts_root) = if self.need_receipts { + let receipt_root = *info.header.receipts_root(); if receipt_root == KECCAK_NULL_RLP { let receipts_stream = RlpStream::new_list(0); - block.receipts = Some(receipts_stream.out()); + (Some(receipts_stream.out()), receipt_root) } else { - self.receipt_ids.entry(receipt_root).or_insert_with(|| SmallHashVec::new()).push(hash.clone()); + self.receipt_ids.entry(receipt_root).or_insert_with(|| SmallHashVec::new()).push(hash); + (None, receipt_root) } - block.receipts_root = receipt_root; - } + } else { + (None, H256::new()) + }; + + self.parents.insert(*info.header.parent_hash(), hash); + + let block = SyncBlock { + header: info, + body, + receipts, + receipts_root, + }; - self.parents.insert(info.parent_hash().clone(), hash.clone()); - self.blocks.insert(hash.clone(), block); + self.blocks.insert(hash, block); trace!(target: "sync", "New header: {:x}", hash); Ok(hash) } @@ -485,10 +574,11 @@ impl BlockCollection { #[cfg(test)] mod test { - use super::BlockCollection; + use super::{BlockCollection, SyncHeader}; use ethcore::client::{TestBlockChainClient, EachBlockWith, BlockId, BlockChainClient}; - use ethcore::views::HeaderView; use ethcore::header::BlockNumber; + use ethcore::verification::queue::kind::blocks::Unverified; + use ethcore::views::HeaderView; use rlp::*; fn is_empty(bc: &BlockCollection) -> bool { @@ -541,7 +631,7 @@ mod test { assert_eq!(bc.downloading_headers.len(), 1); assert!(bc.drain().is_empty()); - bc.insert_headers(headers[0..6].to_vec()); + bc.insert_headers(headers[0..6].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); assert_eq!(hashes[5], bc.heads[0]); for h in &hashes[0..6] { bc.clear_header_download(h) @@ -550,7 +640,10 @@ mod test { assert!(!bc.is_downloading(&hashes[0])); assert!(bc.contains(&hashes[0])); - assert_eq!(&bc.drain().into_iter().map(|b| b.block).collect::>()[..], &blocks[0..6]); + assert_eq!( + bc.drain().into_iter().map(|b| b.block).collect::>(), + blocks[0..6].iter().map(|b| Unverified::from_rlp(b.to_vec()).unwrap()).collect::>() + ); assert!(!bc.contains(&hashes[0])); assert_eq!(hashes[5], bc.head.unwrap()); @@ -558,13 +651,17 @@ mod test { assert_eq!(hashes[5], h); let (h, _) = bc.needed_headers(6, false).unwrap(); assert_eq!(hashes[20], h); - bc.insert_headers(headers[10..16].to_vec()); + bc.insert_headers(headers[10..16].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); assert!(bc.drain().is_empty()); - bc.insert_headers(headers[5..10].to_vec()); - assert_eq!(&bc.drain().into_iter().map(|b| b.block).collect::>()[..], &blocks[6..16]); + bc.insert_headers(headers[5..10].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); + assert_eq!( + bc.drain().into_iter().map(|b| b.block).collect::>(), + blocks[6..16].iter().map(|b| Unverified::from_rlp(b.to_vec()).unwrap()).collect::>() + ); + assert_eq!(hashes[15], bc.heads[0]); - bc.insert_headers(headers[15..].to_vec()); + bc.insert_headers(headers[15..].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); bc.drain(); assert!(bc.is_empty()); } @@ -584,11 +681,11 @@ mod test { let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect(); bc.reset_to(heads); - bc.insert_headers(headers[2..22].to_vec()); + bc.insert_headers(headers[2..22].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); assert_eq!(hashes[0], bc.heads[0]); assert_eq!(hashes[21], bc.heads[1]); assert!(bc.head.is_none()); - bc.insert_headers(headers[0..2].to_vec()); + bc.insert_headers(headers[0..2].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); assert!(bc.head.is_some()); assert_eq!(hashes[21], bc.heads[0]); } @@ -608,9 +705,9 @@ mod test { let heads: Vec<_> = hashes.iter().enumerate().filter_map(|(i, h)| if i % 20 == 0 { Some(h.clone()) } else { None }).collect(); bc.reset_to(heads); - bc.insert_headers(headers[1..2].to_vec()); + bc.insert_headers(headers[1..2].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); assert!(bc.drain().is_empty()); - bc.insert_headers(headers[0..1].to_vec()); + bc.insert_headers(headers[0..1].iter().map(|h| SyncHeader::from_rlp(h.to_vec()).unwrap()).collect()); assert_eq!(bc.drain().len(), 2); } } From e2095d4a5d5749ee26828f65c80e509e024b9535 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 9 Aug 2018 09:51:48 +0200 Subject: [PATCH 2/9] Move ethereum-specific H256FastMap type to own crate (#9307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add a `fastmap` crate that provides the H256FastMap specialized HashMap * Use `fastmap` instead of `plain_hasher` * Update submodules for Reasons™ * Submodule update --- Cargo.lock | 14 +++++++-- Cargo.toml | 1 + ethcore/light/Cargo.toml | 2 +- ethcore/light/src/client/header_chain.rs | 2 +- ethcore/light/src/lib.rs | 2 +- ethcore/light/src/transaction_queue.rs | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/sync/src/chain/mod.rs | 2 +- ethcore/sync/src/lib.rs | 2 +- ethcore/sync/src/transactions_stats.rs | 2 +- util/fastmap/Cargo.toml | 10 ++++++ util/fastmap/src/lib.rs | 39 ++++++++++++++++++++++++ util/journaldb/Cargo.toml | 2 +- util/journaldb/src/lib.rs | 2 +- util/journaldb/src/overlayrecentdb.rs | 2 +- 15 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 util/fastmap/Cargo.toml create mode 100644 util/fastmap/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 54a05ba05be..1760b3b922c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -597,6 +597,7 @@ dependencies = [ "ethcore-network 1.12.0", "ethcore-transaction 0.1.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fastmap 0.1.0", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.2.0 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -612,7 +613,6 @@ dependencies = [ "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", "patricia-trie-ethereum 0.1.0", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rlp_derive 0.1.0", @@ -845,6 +845,7 @@ dependencies = [ "ethcore-transaction 0.1.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", + "fastmap 0.1.0", "hashdb 0.2.0 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -856,7 +857,6 @@ dependencies = [ "macros 0.1.0", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1044,6 +1044,14 @@ dependencies = [ "ethkey 0.3.0", ] +[[package]] +name = "fastmap" +version = "0.1.0" +dependencies = [ + "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", +] + [[package]] name = "fdlimit" version = "0.1.1" @@ -1323,6 +1331,7 @@ version = "0.2.0" dependencies = [ "ethcore-logger 1.12.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fastmap 0.1.0", "hashdb 0.2.0 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", @@ -1333,7 +1342,6 @@ dependencies = [ "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", ] diff --git a/Cargo.toml b/Cargo.toml index 697afeab3ae..26b387e80b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -136,6 +136,7 @@ members = [ "util/triehash-ethereum", "util/keccak-hasher", "util/patricia-trie-ethereum", + "util/fastmap", ] [patch.crates-io] diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 6c3a454e20a..16f70de620c 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -20,7 +20,7 @@ ethcore-io = { path = "../../util/io" } hashdb = { git = "https://github.com/paritytech/parity-common" } heapsize = "0.4" vm = { path = "../vm" } -plain_hasher = { git = "https://github.com/paritytech/parity-common" } +fastmap = { path = "../../util/fastmap" } rlp = { git = "https://github.com/paritytech/parity-common" } rlp_derive = { path = "../../util/rlp_derive" } smallvec = "0.4" diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index 957a1ea4330..4611adbfe0b 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -41,7 +41,7 @@ use ethereum_types::{H256, H264, U256}; use heapsize::HeapSizeOf; use kvdb::{DBTransaction, KeyValueDB}; use parking_lot::{Mutex, RwLock}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp}; use smallvec::SmallVec; diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index 24c95cfdeb7..e151267a9c9 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -68,7 +68,7 @@ extern crate keccak_hasher; extern crate memorydb; extern crate patricia_trie as trie; extern crate patricia_trie_ethereum as ethtrie; -extern crate plain_hasher; +extern crate fastmap; extern crate rand; extern crate rlp; extern crate parking_lot; diff --git a/ethcore/light/src/transaction_queue.rs b/ethcore/light/src/transaction_queue.rs index e8880037a17..cb017bcb1b1 100644 --- a/ethcore/light/src/transaction_queue.rs +++ b/ethcore/light/src/transaction_queue.rs @@ -29,7 +29,7 @@ use std::collections::hash_map::Entry; use transaction::{self, Condition, PendingTransaction, SignedTransaction}; use ethereum_types::{H256, U256, Address}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; // Knowledge of an account's current nonce. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index dfd45777233..9cdd0d84b07 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -17,7 +17,7 @@ ethcore-transaction = { path = "../transaction" } ethcore = { path = ".." } ethereum-types = "0.3" hashdb = { git = "https://github.com/paritytech/parity-common" } -plain_hasher = { git = "https://github.com/paritytech/parity-common" } +fastmap = { path = "../../util/fastmap" } rlp = { git = "https://github.com/paritytech/parity-common" } rustc-hex = "1.0" keccak-hash = { git = "https://github.com/paritytech/parity-common" } diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index 520226a9c7e..625ccb30d22 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -99,7 +99,7 @@ use std::time::{Duration, Instant}; use hash::keccak; use heapsize::HeapSizeOf; use ethereum_types::{H256, U256}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; use parking_lot::RwLock; use bytes::Bytes; use rlp::{Rlp, RlpStream, DecoderError}; diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index f9f8a3e3e93..eb38d09d9d5 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -31,7 +31,7 @@ extern crate ethcore; extern crate ethereum_types; extern crate env_logger; extern crate hashdb; -extern crate plain_hasher; +extern crate fastmap; extern crate rand; extern crate semver; extern crate parking_lot; diff --git a/ethcore/sync/src/transactions_stats.rs b/ethcore/sync/src/transactions_stats.rs index c45b1ad8b3c..4d11dcf6809 100644 --- a/ethcore/sync/src/transactions_stats.rs +++ b/ethcore/sync/src/transactions_stats.rs @@ -17,7 +17,7 @@ use api::TransactionStats; use std::collections::{HashSet, HashMap}; use ethereum_types::{H256, H512}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; type NodeId = H512; type BlockNumber = u64; diff --git a/util/fastmap/Cargo.toml b/util/fastmap/Cargo.toml new file mode 100644 index 00000000000..3889c670008 --- /dev/null +++ b/util/fastmap/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "fastmap" +version = "0.1.0" +authors = ["Parity Technologies "] +description = "Specialized version of `HashMap` with H256 keys and fast hashing function." +license = "GPL-3.0" + +[dependencies] +ethereum-types = "0.3" +plain_hasher = { git = "https://github.com/paritytech/parity-common" } diff --git a/util/fastmap/src/lib.rs b/util/fastmap/src/lib.rs new file mode 100644 index 00000000000..135ce54babe --- /dev/null +++ b/util/fastmap/src/lib.rs @@ -0,0 +1,39 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity 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. + +// Parity 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 Parity. If not, see . + +//! Provides a `H256FastMap` type with H256 keys and fast hashing function. + +extern crate ethereum_types; +extern crate plain_hasher; + +use ethereum_types::H256; +use std::hash; +use std::collections::HashMap; +use plain_hasher::PlainHasher; + +/// Specialized version of `HashMap` with H256 keys and fast hashing function. +pub type H256FastMap = HashMap>; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_works() { + let mut h = H256FastMap::default(); + h.insert(H256::from(123), "abc"); + } +} \ No newline at end of file diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 27b0ae195b7..7e559e229c0 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -15,7 +15,7 @@ kvdb = { git = "https://github.com/paritytech/parity-common" } log = "0.3" memorydb = { git = "https://github.com/paritytech/parity-common" } parking_lot = "0.6" -plain_hasher = { git = "https://github.com/paritytech/parity-common" } +fastmap = { path = "../../util/fastmap" } rlp = { git = "https://github.com/paritytech/parity-common" } [dev-dependencies] diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index b14ef88e923..e88b437d828 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -27,7 +27,7 @@ extern crate keccak_hasher; extern crate kvdb; extern crate memorydb; extern crate parking_lot; -extern crate plain_hasher; +extern crate fastmap; extern crate rlp; #[cfg(test)] diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index b63168e547c..1549d3baa34 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -29,7 +29,7 @@ use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction}; use memorydb::*; use parking_lot::RwLock; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; use rlp::{Rlp, RlpStream, encode, decode, DecoderError, Decodable, Encodable}; use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, JournalDB, error_negatively_reference_hash}; use util::DatabaseKey; From 88141951224afdfb0b592816e5587b70dca6df5f Mon Sep 17 00:00:00 2001 From: Max Riveiro Date: Thu, 9 Aug 2018 18:54:08 +0300 Subject: [PATCH 3/9] Fix codecov.io badge in README (#9327) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9355cde7d22..6c7378c5752 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### [» Download the latest release «](https://github.com/paritytech/parity-ethereum/releases/latest) [![build status](https://gitlab.parity.io/parity/parity/badges/master/build.svg)](https://gitlab.parity.io/parity/parity/commits/master) -[![codecov](https://codecov.io/gh/paritytech/parity/branch/master/graph/badge.svg)](https://codecov.io/gh/paritytech/parity) +[![codecov](https://codecov.io/gh/paritytech/parity-ethereum/branch/master/graph/badge.svg)](https://codecov.io/gh/paritytech/parity-ethereum) [![Snap Status](https://build.snapcraft.io/badge/paritytech/parity.svg)](https://build.snapcraft.io/user/paritytech/parity) [![GPLv3](https://img.shields.io/badge/license-GPL%20v3-green.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) From 62fdfb937a4cc7e8b805c77f2fc53f39b2b33cda Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Thu, 9 Aug 2018 23:13:28 +0200 Subject: [PATCH 4/9] Allow tx pool to be Send (#9315) --- transaction-pool/Cargo.toml | 2 +- transaction-pool/src/lib.rs | 2 +- transaction-pool/src/scoring.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/transaction-pool/Cargo.toml b/transaction-pool/Cargo.toml index 8af887d3cb9..f56a7023686 100644 --- a/transaction-pool/Cargo.toml +++ b/transaction-pool/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Generic transaction pool." name = "transaction-pool" -version = "1.12.1" +version = "1.12.2" license = "GPL-3.0" authors = ["Parity Technologies "] diff --git a/transaction-pool/src/lib.rs b/transaction-pool/src/lib.rs index ea77debfa2f..c23c6662cc2 100644 --- a/transaction-pool/src/lib.rs +++ b/transaction-pool/src/lib.rs @@ -111,7 +111,7 @@ pub trait VerifiedTransaction: fmt::Debug { type Hash: fmt::Debug + fmt::LowerHex + Eq + Clone + Hash; /// Transaction sender type. - type Sender: fmt::Debug + Eq + Clone + Hash; + type Sender: fmt::Debug + Eq + Clone + Hash + Send; /// Transaction hash fn hash(&self) -> &Self::Hash; diff --git a/transaction-pool/src/scoring.rs b/transaction-pool/src/scoring.rs index 25189604cd2..8bc44a73230 100644 --- a/transaction-pool/src/scoring.rs +++ b/transaction-pool/src/scoring.rs @@ -83,7 +83,7 @@ pub enum Change { /// pub trait Scoring: fmt::Debug { /// A score of a transaction. - type Score: cmp::Ord + Clone + Default + fmt::Debug; + type Score: cmp::Ord + Clone + Default + fmt::Debug + Send; /// Custom scoring update event type. type Event: fmt::Debug; From b28e742683737ec776c154b79cde7f0d67033a0b Mon Sep 17 00:00:00 2001 From: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com> Date: Thu, 9 Aug 2018 23:14:45 +0200 Subject: [PATCH 5/9] Update tobalaba.json (#9313) --- ethcore/res/ethereum/tobalaba.json | 31 ++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/ethcore/res/ethereum/tobalaba.json b/ethcore/res/ethereum/tobalaba.json index e9345c69615..0f5778601a9 100644 --- a/ethcore/res/ethereum/tobalaba.json +++ b/ethcore/res/ethereum/tobalaba.json @@ -16,7 +16,16 @@ "gasLimitBoundDivisor": "0x400", "minGasLimit": "0x1388", "networkID": "0x62121", - "wasmActivationTransition": 4000000 + "wasmActivationTransition": 6666666, + "eip140Transition": 6666666, + "eip211Transition": 6666666, + "eip214Transition": 6666666, + "eip658Transition": 6666666, + + "maxCodeSize": 24576, + "maxCodeSizeTransition": 6666666, + + "registrar": "0xb8624dc8cb3ca3147c178ac4c21734eb49e04071" }, "genesis": { "seal": { @@ -43,12 +52,22 @@ }, "0x4ba15b56452521c0826a35a6f2022e1210fc519b": { "balance": "0x7E37BE2022B2B09472D89C0000" - } + }, + + "0x0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "activate_at": 6666666, "pricing": { "linear": { "base": 3000, "word": 0 } } } }, + "0x0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "activate_at": 6666666, "pricing": { "linear": { "base": 60, "word": 12 } } } }, + "0x0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "activate_at": 6666666, "pricing": { "linear": { "base": 600, "word": 120 } } } }, + "0x0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "activate_at": 6666666, "pricing": { "linear": { "base": 15, "word": 3 } } } }, + "0x0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": 6666666, "pricing": { "modexp": { "divisor": 20 } } } }, + "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": 6666666, "pricing": { "linear": { "base": 500, "word": 0 } } } }, + "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": 6666666, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, + "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": 6666666, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } }, + "nodes": [ - "enode://147573f46fe9f5cc38fbe070089a31390baec5dd2827c8f2ef168833e4d0254fbee3969a02c5b9910ea5d5b23d86a6ed5eabcda17cc12007b7d9178b6c697aa5@37.120.168.56:30303", - "enode://a370d5fd55959f20af6d1565b151a760c1372f5a2aaf674d4892cd4fd2de0d1f672781cd40e0d4e4b51c5823527ddec73b31cc14ac685449d9f0866996a16b9f@13.76.165.180:30303", - "enode://da019fa5fb1fda105100d68a986938ec15ac5c6ff69d6e4ad3e350e377057f3e67e33aea5feb22d5cdcfc22041d141c8453c77baa64a216fff98f191ca76b3ec@18.220.108.238:30303", - "enode://49498fb8cdcd79c813ccdaa9496a3a4be0a187a3183e99adbc04d9c90b9a62ad59f0b6832f6e43b48e63fbebf74ec5438eb0d6d9098330edf36413d276fedf81@13.80.148.117:30303" + "enode://eda34244538d72f42605a6fc8b8a34b15714c683989e8b29dc9e7a2b2088da490a5b32f2c149bec5a5c482bf03ec2c4f38b833ae31e36fcb26fb05fd094b2a88@18.197.33.9:30303", + "enode://12e903e900137b02b22e01f7918bd6e7310773c313e4e577281f35597e394a3e0b54c7314a8970a9776c5a3e5dc4daee289215dea3897bcb6d5cf0bb1dd2d356@18.197.31.231:30303", + "enode://423fdb91b37ec0714af0c19f625ec4af3ada2844367a36e45a05703577a84f7f0e9483585d4950a35c9e3738dba8c6abd7e1ce278d9a1f3f28065bc009f409cd@52.221.203.209:30303", + "enode://a9327d37d07799817d4a3e13d49fb4f5cc1486d4adf3ec8a6b98be62c4d7a5453914a5139dbe124809a388514cb0be37f9fa799539abe2250672f6d3d778b821@18.191.209.251:30303" ] } From e590874a8174a1cf47e1d82410deaa50cc4c64f3 Mon Sep 17 00:00:00 2001 From: Nick Sanders Date: Thu, 9 Aug 2018 16:04:10 -0700 Subject: [PATCH 6/9] Update `log` -> 0.4, `env_logger` -> 0.5. (#9294) * Rename a few types & methods. * Change `(Log)Builder::format` (closure) arg. --- Cargo.lock | 144 ++++++++++++++++++++--------- Cargo.toml | 4 +- ethash/Cargo.toml | 2 +- ethcore/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/node_filter/Cargo.toml | 2 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/service/Cargo.toml | 2 +- ethcore/src/block.rs | 4 +- ethcore/stratum/Cargo.toml | 4 +- ethcore/sync/Cargo.toml | 4 +- ethcore/sync/src/tests/chain.rs | 18 ++-- ethcore/sync/src/tests/snapshot.rs | 2 +- ethcore/vm/Cargo.toml | 2 +- ethcore/wasm/Cargo.toml | 2 +- ethkey/Cargo.toml | 2 +- ethkey/cli/Cargo.toml | 2 +- ethkey/cli/src/main.rs | 2 +- ethstore/Cargo.toml | 2 +- hash-fetch/Cargo.toml | 2 +- hw/Cargo.toml | 2 +- local-store/Cargo.toml | 2 +- logger/Cargo.toml | 4 +- logger/src/lib.rs | 22 ++--- logger/src/rotating.rs | 8 +- miner/Cargo.toml | 4 +- price-info/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- rpc_client/Cargo.toml | 2 +- secret_store/Cargo.toml | 2 +- transaction-pool/Cargo.toml | 2 +- updater/Cargo.toml | 2 +- util/io/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 2 +- util/migration-rocksdb/Cargo.toml | 2 +- util/network-devp2p/Cargo.toml | 2 +- util/stats/Cargo.toml | 2 +- util/trace-time/Cargo.toml | 2 +- whisper/Cargo.toml | 2 +- whisper/cli/Cargo.toml | 2 +- 41 files changed, 168 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1760b3b922c..f529f2bc63f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -401,11 +401,14 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.4.3" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -471,7 +474,7 @@ dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -528,7 +531,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", @@ -577,7 +580,7 @@ version = "1.12.0" dependencies = [ "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -606,7 +609,7 @@ dependencies = [ "keccak-hasher 0.1.0", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", @@ -632,9 +635,9 @@ dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -645,7 +648,7 @@ name = "ethcore-miner" version = "1.12.0" dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.12.0", "ethcore-transaction 0.1.0", @@ -658,7 +661,7 @@ dependencies = [ "hyper 0.11.24 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", "linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-reactor 0.1.0", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "price-info 1.12.0", @@ -702,7 +705,7 @@ dependencies = [ "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", @@ -740,7 +743,7 @@ dependencies = [ "fetch 0.1.0", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -778,7 +781,7 @@ dependencies = [ "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -808,7 +811,7 @@ dependencies = [ "ethcore-sync 1.12.0", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "stop-guard 0.1.0", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.0", @@ -818,14 +821,14 @@ dependencies = [ name = "ethcore-stratum" version = "1.12.0" dependencies = [ - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-logger 1.12.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -835,7 +838,7 @@ dependencies = [ name = "ethcore-sync" version = "1.12.0" dependencies = [ - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.12.0", "ethcore-io 1.12.0", "ethcore-light 1.12.0", @@ -853,7 +856,7 @@ dependencies = [ "keccak-hasher 0.1.0", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -923,7 +926,7 @@ dependencies = [ "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mem 0.1.0", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -940,7 +943,7 @@ name = "ethkey-cli" version = "0.1.0" dependencies = [ "docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "panic_hook 0.1.0", "parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -959,7 +962,7 @@ dependencies = [ "ethkey 0.3.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1000,7 +1003,7 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1169,7 +1172,7 @@ dependencies = [ "ethkey 0.3.0", "hidapi 0.3.1 (git+https://github.com/paritytech/hidapi-rs)", "libusb 0.3.0 (git+https://github.com/paritytech/libusb-rs)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1221,6 +1224,14 @@ name = "httparse" version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "humantime" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hyper" version = "0.11.24" @@ -1338,7 +1349,7 @@ dependencies = [ "keccak-hasher 0.1.0", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1676,7 +1687,7 @@ version = "0.1.0" dependencies = [ "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1805,7 +1816,7 @@ dependencies = [ "ethcore-network-devp2p 1.12.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1963,7 +1974,7 @@ dependencies = [ "daemonize 0.2.3 (git+https://github.com/paritytech/daemonize)", "dir 0.1.1", "docopt 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.12.0", "ethcore-io 1.12.0", "ethcore-light 1.12.0", @@ -1987,7 +1998,7 @@ dependencies = [ "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mem 0.1.0", "migration-rocksdb 0.1.0", "node-filter 1.12.0", @@ -2039,7 +2050,7 @@ dependencies = [ "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.24 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", @@ -2075,7 +2086,7 @@ dependencies = [ "ethkey 0.3.0", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2133,7 +2144,7 @@ dependencies = [ "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "multihash 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2169,7 +2180,7 @@ dependencies = [ "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.12.0", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2207,7 +2218,7 @@ dependencies = [ "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parity-hash-fetch 1.12.0", @@ -2253,7 +2264,7 @@ dependencies = [ "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mem 0.1.0", "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", @@ -2409,7 +2420,7 @@ dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.24 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2598,11 +2609,31 @@ dependencies = [ "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex-syntax" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "regex-syntax" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "registrar" version = "0.0.1" @@ -2939,7 +2970,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "stats" version = "0.1.0" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3001,6 +3032,14 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termion" version = "1.5.1" @@ -3282,7 +3321,7 @@ dependencies = [ name = "trace-time" version = "0.1.0" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3291,7 +3330,7 @@ version = "1.12.1" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.0", ] @@ -3343,6 +3382,11 @@ dependencies = [ "triehash 0.2.0 (git+https://github.com/paritytech/parity-common)", ] +[[package]] +name = "ucd-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "uint" version = "0.2.1" @@ -3470,7 +3514,7 @@ dependencies = [ "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", "patricia-trie-ethereum 0.1.0", @@ -3490,7 +3534,7 @@ dependencies = [ "ethcore-logger 1.12.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -3537,7 +3581,7 @@ dependencies = [ "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", "parity-whisper 0.1.0", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3573,6 +3617,14 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws" version = "0.7.5" @@ -3665,7 +3717,7 @@ dependencies = [ "checksum edit-distance 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6a34f5204fbc13582de418611cf3a7dcdd07c6d312a5b631597ba72c06b9d9c9" "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" "checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb" -"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" +"checksum env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d7e69c283751083d53d01eac767407343b8b69c4bd70058e08adc2637cb257" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "" @@ -3694,6 +3746,7 @@ dependencies = [ "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" "checksum hidapi 0.3.1 (git+https://github.com/paritytech/hidapi-rs)" = "" "checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum hyper 0.11.24 (registry+https://github.com/rust-lang/crates.io-index)" = "df4dd5dae401458087396b6db7fabc4d6760aa456a5fa8e92bda549f39cae661" "checksum hyper-rustls 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d6cdc1751771a14b8175764394f025e309a28c825ed9eaf97fa62bb831dc8c5" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" @@ -3800,7 +3853,9 @@ dependencies = [ "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "744554e01ccbd98fff8c457c3b092cd67af62a555a43bfe97ae8a0451f7799fa" +"checksum regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5bbbea44c5490a1e84357ff28b7d518b4619a159fed5d25f6c1de2d19cc42814" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" +"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" "checksum ring 0.12.1 (git+https://github.com/paritytech/ring)" = "" "checksum rlp 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" @@ -3846,6 +3901,7 @@ dependencies = [ "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" "checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" +"checksum termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "722426c4a0539da2c4ffd9b419d90ad540b4cff4a053be9069c908d4d07e2836" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" @@ -3875,6 +3931,7 @@ dependencies = [ "checksum trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)" = "" "checksum trie-standardmap 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum triehash 0.2.0 (git+https://github.com/paritytech/parity-common)" = "" +"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum uint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "38051a96565903d81c9a9210ce11076b2218f3b352926baa1f5f6abbdfce8273" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a" @@ -3900,6 +3957,7 @@ dependencies = [ "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-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9dc3aa9dcda98b5a16150c54619c1ead22e3d3a5d458778ae914be760aa981a" "checksum ws 0.7.5 (git+https://github.com/tomusdrw/ws-rs)" = "" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" diff --git a/Cargo.toml b/Cargo.toml index 26b387e80b9..b4355a1fd54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ authors = ["Parity Technologies "] [dependencies] blooms-db = { path = "util/blooms-db" } -log = "0.3" -env_logger = "0.4" +log = "0.4" +env_logger = "0.5" rustc-hex = "1.0" docopt = "0.8" clap = "2" diff --git a/ethash/Cargo.toml b/ethash/Cargo.toml index df0f17e0f37..f4a99cd5e96 100644 --- a/ethash/Cargo.toml +++ b/ethash/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Parity Technologies "] [lib] [dependencies] -log = "0.3" +log = "0.4" keccak-hash = { git = "https://github.com/paritytech/parity-common" } primal = "0.2.3" parking_lot = "0.6" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 82dd2230dd6..2c57e8b60a1 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -39,7 +39,7 @@ evm = { path = "evm" } heapsize = "0.4" itertools = "0.5" lazy_static = "1.0" -log = "0.3" +log = "0.4" lru-cache = "0.1" num = { version = "0.1", default-features = false, features = ["bigint"] } num_cpus = "1.2" diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 18c9a3907a6..ce9f644cc85 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -8,7 +8,7 @@ bit-set = "0.4" ethereum-types = "0.3" heapsize = "0.4" lazy_static = "1.0" -log = "0.3" +log = "0.4" vm = { path = "../vm" } keccak-hash = { git = "https://github.com/paritytech/parity-common" } parking_lot = "0.6" diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 16f70de620c..9224f07e95c 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -7,7 +7,7 @@ version = "1.12.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +log = "0.4" ethcore = { path = ".."} parity-bytes = { git = "https://github.com/paritytech/parity-common" } ethcore-transaction = { path = "../transaction" } diff --git a/ethcore/node_filter/Cargo.toml b/ethcore/node_filter/Cargo.toml index b6e3cfe55e9..adba8ee09ef 100644 --- a/ethcore/node_filter/Cargo.toml +++ b/ethcore/node_filter/Cargo.toml @@ -11,7 +11,7 @@ ethcore = { path = ".."} ethcore-network = { path = "../../util/network" } ethcore-network-devp2p = { path = "../../util/network-devp2p" } ethereum-types = "0.3" -log = "0.3" +log = "0.4" parking_lot = "0.6" ethabi = "5.1" ethabi-derive = "5.0" diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index e547c980870..2383443e734 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -23,7 +23,7 @@ ethkey = { path = "../../ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" keccak-hash = { git = "https://github.com/paritytech/parity-common" } -log = "0.3" +log = "0.4" parking_lot = "0.6" patricia-trie = { git = "https://github.com/paritytech/parity-common" } patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/service/Cargo.toml b/ethcore/service/Cargo.toml index 245bce78778..e1ba1c81f62 100644 --- a/ethcore/service/Cargo.toml +++ b/ethcore/service/Cargo.toml @@ -11,7 +11,7 @@ ethcore-io = { path = "../../util/io" } ethcore-private-tx = { path = "../private-tx" } ethcore-sync = { path = "../sync" } kvdb = { git = "https://github.com/paritytech/parity-common" } -log = "0.3" +log = "0.4" stop-guard = { path = "../../util/stop-guard" } trace-time = { path = "../../util/trace-time" } diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 9fd3957fb34..fc2873ba3b9 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -564,7 +564,7 @@ fn enact( ancestry: &mut Iterator, ) -> Result { { - if ::log::max_log_level() >= ::log::LogLevel::Trace { + if ::log::max_level() >= ::log::Level::Trace { let s = State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?; trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n", header.number(), s.root(), header.author(), s.balance(&header.author())?); @@ -659,7 +659,7 @@ mod tests { let transactions = transactions?; { - if ::log::max_log_level() >= ::log::LogLevel::Trace { + if ::log::max_level() >= ::log::Level::Trace { let s = State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?; trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n", header.number(), s.root(), header.author(), s.balance(&header.author())?); diff --git a/ethcore/stratum/Cargo.toml b/ethcore/stratum/Cargo.toml index 1da27c01a9f..0d64aa926f4 100644 --- a/ethcore/stratum/Cargo.toml +++ b/ethcore/stratum/Cargo.toml @@ -11,11 +11,11 @@ keccak-hash = { git = "https://github.com/paritytech/parity-common" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } -log = "0.3" +log = "0.4" parking_lot = "0.6" [dev-dependencies] -env_logger = "0.4" +env_logger = "0.5" tokio-core = "0.1" tokio-io = "0.1" ethcore-logger = { path = "../../logger" } diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 9cdd0d84b07..6cc87df31f2 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -25,8 +25,8 @@ keccak-hasher = { path = "../../util/keccak-hasher" } triehash-ethereum = {version = "0.2", path = "../../util/triehash-ethereum" } kvdb = { git = "https://github.com/paritytech/parity-common" } macros = { path = "../../util/macros" } -log = "0.3" -env_logger = "0.4" +log = "0.4" +env_logger = "0.5" rand = "0.4" heapsize = "0.4" semver = "0.9" diff --git a/ethcore/sync/src/tests/chain.rs b/ethcore/sync/src/tests/chain.rs index 0d9c83f2fb4..0b6c8f7c284 100644 --- a/ethcore/sync/src/tests/chain.rs +++ b/ethcore/sync/src/tests/chain.rs @@ -22,7 +22,7 @@ use {SyncConfig, WarpSync}; #[test] fn two_peers() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(3); net.peer(1).chain.add_blocks(1000, EachBlockWith::Uncle); net.peer(2).chain.add_blocks(1000, EachBlockWith::Uncle); @@ -33,7 +33,7 @@ fn two_peers() { #[test] fn long_chain() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(2); net.peer(1).chain.add_blocks(50000, EachBlockWith::Nothing); net.sync(); @@ -43,7 +43,7 @@ fn long_chain() { #[test] fn status_after_sync() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(3); net.peer(1).chain.add_blocks(1000, EachBlockWith::Uncle); net.peer(2).chain.add_blocks(1000, EachBlockWith::Uncle); @@ -63,7 +63,7 @@ fn takes_few_steps() { #[test] fn empty_blocks() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(3); for n in 0..200 { let with = if n % 2 == 0 { EachBlockWith::Nothing } else { EachBlockWith::Uncle }; @@ -77,7 +77,7 @@ fn empty_blocks() { #[test] fn forked() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(3); net.peer(0).chain.add_blocks(30, EachBlockWith::Uncle); net.peer(1).chain.add_blocks(30, EachBlockWith::Uncle); @@ -98,7 +98,7 @@ fn forked() { #[test] fn forked_with_misbehaving_peer() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(3); let mut alt_spec = ::ethcore::spec::Spec::new_test(); @@ -122,7 +122,7 @@ fn forked_with_misbehaving_peer() { #[test] fn net_hard_fork() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let ref_client = TestBlockChainClient::new(); ref_client.add_blocks(50, EachBlockWith::Uncle); { @@ -141,7 +141,7 @@ fn net_hard_fork() { #[test] fn restart() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(3); net.peer(1).chain.add_blocks(1000, EachBlockWith::Uncle); net.peer(2).chain.add_blocks(1000, EachBlockWith::Uncle); @@ -255,7 +255,7 @@ fn high_td_attach() { #[test] fn disconnect_on_unrelated_chain() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut net = TestNet::new(2); net.peer(0).chain.set_history(Some(20)); net.peer(1).chain.set_history(Some(20)); diff --git a/ethcore/sync/src/tests/snapshot.rs b/ethcore/sync/src/tests/snapshot.rs index e6636c02f42..2316745c1bc 100644 --- a/ethcore/sync/src/tests/snapshot.rs +++ b/ethcore/sync/src/tests/snapshot.rs @@ -141,7 +141,7 @@ impl SnapshotService for TestSnapshotService { #[test] fn snapshot_sync() { - ::env_logger::init().ok(); + ::env_logger::try_init().ok(); let mut config = SyncConfig::default(); config.warp_sync = WarpSync::Enabled; let mut net = TestNet::new_with_config(5, config); diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index 194f4600d82..b455fb42d18 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -9,7 +9,7 @@ parity-bytes = { git = "https://github.com/paritytech/parity-common" } ethereum-types = "0.3" patricia-trie = { git = "https://github.com/paritytech/parity-common" } patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } -log = "0.3" +log = "0.4" common-types = { path = "../types" } ethjson = { path = "../../json" } rlp = { git = "https://github.com/paritytech/parity-common" } diff --git a/ethcore/wasm/Cargo.toml b/ethcore/wasm/Cargo.toml index 5ca2f31220a..f6268af66c9 100644 --- a/ethcore/wasm/Cargo.toml +++ b/ethcore/wasm/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Parity Technologies "] [dependencies] byteorder = "1.0" ethereum-types = "0.3" -log = "0.3" +log = "0.4" parity-wasm = "0.31" libc = "0.2" pwasm-utils = "0.2.2" diff --git a/ethkey/Cargo.toml b/ethkey/Cargo.toml index 8449a54c3b2..37f7ca86605 100644 --- a/ethkey/Cargo.toml +++ b/ethkey/Cargo.toml @@ -10,7 +10,7 @@ parity-crypto = { git = "https://github.com/paritytech/parity-common" } eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethereum-types = "0.3" lazy_static = "1.0" -log = "0.3" +log = "0.4" mem = { path = "../util/mem" } parity-wordlist = "1.2" quick-error = "1.2.2" diff --git a/ethkey/cli/Cargo.toml b/ethkey/cli/Cargo.toml index 779ca2872b9..522d3f17a6d 100644 --- a/ethkey/cli/Cargo.toml +++ b/ethkey/cli/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] [dependencies] docopt = "0.8" -env_logger = "0.4" +env_logger = "0.5" ethkey = { path = "../" } panic_hook = { path = "../../util/panic_hook" } parity-wordlist="1.2" diff --git a/ethkey/cli/src/main.rs b/ethkey/cli/src/main.rs index 555bc2d2010..73273250444 100644 --- a/ethkey/cli/src/main.rs +++ b/ethkey/cli/src/main.rs @@ -162,7 +162,7 @@ impl DisplayMode { fn main() { panic_hook::set_abort(); - env_logger::init().expect("Logger initialized only once."); + env_logger::try_init().expect("Logger initialized only once."); match execute(env::args()) { Ok(ok) => println!("{}", ok), diff --git a/ethstore/Cargo.toml b/ethstore/Cargo.toml index deeb5a946b8..f7bca47f5b4 100644 --- a/ethstore/Cargo.toml +++ b/ethstore/Cargo.toml @@ -4,7 +4,7 @@ version = "0.2.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +log = "0.4" libc = "0.2" rand = "0.4" ethkey = { path = "../ethkey" } diff --git a/hash-fetch/Cargo.toml b/hash-fetch/Cargo.toml index c4eb7acd3af..d539fd67279 100644 --- a/hash-fetch/Cargo.toml +++ b/hash-fetch/Cargo.toml @@ -9,7 +9,7 @@ authors = ["Parity Technologies "] [dependencies] futures = "0.1" futures-cpupool = "0.1" -log = "0.3" +log = "0.4" mime = "0.3" mime_guess = "2.0.0-alpha.2" rand = "0.4" diff --git a/hw/Cargo.toml b/hw/Cargo.toml index b7d90648eac..47dc06c4107 100644 --- a/hw/Cargo.toml +++ b/hw/Cargo.toml @@ -7,7 +7,7 @@ version = "1.12.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +log = "0.4" parking_lot = "0.6" protobuf = "1.4" hidapi = { git = "https://github.com/paritytech/hidapi-rs" } diff --git a/local-store/Cargo.toml b/local-store/Cargo.toml index 75717bed08b..9197aa4e7e2 100644 --- a/local-store/Cargo.toml +++ b/local-store/Cargo.toml @@ -9,7 +9,7 @@ ethcore = { path = "../ethcore" } ethcore-io = { path = "../util/io" } ethcore-transaction = { path = "../ethcore/transaction" } kvdb = { git = "https://github.com/paritytech/parity-common" } -log = "0.3" +log = "0.4" rlp = { git = "https://github.com/paritytech/parity-common" } serde = "1.0" serde_derive = "1.0" diff --git a/logger/Cargo.toml b/logger/Cargo.toml index 3db404bf645..fd59fad7a60 100644 --- a/logger/Cargo.toml +++ b/logger/Cargo.toml @@ -6,8 +6,8 @@ license = "GPL-3.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" -env_logger = "0.4" +log = "0.4" +env_logger = "0.5" atty = "0.2" lazy_static = "1.0" regex = "0.2" diff --git a/logger/src/lib.rs b/logger/src/lib.rs index 6918397886d..152d691f972 100644 --- a/logger/src/lib.rs +++ b/logger/src/lib.rs @@ -33,7 +33,7 @@ mod rotating; use std::{env, thread, fs}; use std::sync::{Weak, Arc}; use std::io::Write; -use env_logger::LogBuilder; +use env_logger::{Builder as LogBuilder, Formatter}; use regex::Regex; use ansi_term::Colour; use parking_lot::Mutex; @@ -68,12 +68,12 @@ pub fn setup_log(config: &Config) -> Result, String> { let mut levels = String::new(); let mut builder = LogBuilder::new(); // Disable info logging by default for some modules: - builder.filter(Some("ws"), LogLevelFilter::Warn); - builder.filter(Some("reqwest"), LogLevelFilter::Warn); - builder.filter(Some("hyper"), LogLevelFilter::Warn); - builder.filter(Some("rustls"), LogLevelFilter::Error); + builder.filter(Some("ws"), LevelFilter::Warn); + builder.filter(Some("reqwest"), LevelFilter::Warn); + builder.filter(Some("hyper"), LevelFilter::Warn); + builder.filter(Some("rustls"), LevelFilter::Error); // Enable info for others. - builder.filter(None, LogLevelFilter::Info); + builder.filter(None, LevelFilter::Info); if let Ok(lvl) = env::var("RUST_LOG") { levels.push_str(&lvl); @@ -99,10 +99,10 @@ pub fn setup_log(config: &Config) -> Result, String> { None => None, }; - let format = move |record: &LogRecord| { + let format = move |buf: &mut Formatter, record: &Record| { let timestamp = time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap(); - let with_color = if max_log_level() <= LogLevelFilter::Info { + let with_color = if max_level() <= LevelFilter::Info { format!("{} {}", Colour::Black.bold().paint(timestamp), record.args()) } else { let name = thread::current().name().map_or_else(Default::default, |x| format!("{}", Colour::Blue.bold().paint(x))); @@ -122,16 +122,16 @@ pub fn setup_log(config: &Config) -> Result, String> { let _ = file.write_all(b"\n"); } logger.append(removed_color); - if !isatty && record.level() <= LogLevel::Info && atty::is(atty::Stream::Stdout) { + if !isatty && record.level() <= Level::Info && atty::is(atty::Stream::Stdout) { // duplicate INFO/WARN output to console println!("{}", ret); } - ret + write!(buf, "{}", ret) }; builder.format(format); - builder.init() + builder.try_init() .and_then(|_| { *ROTATING_LOGGER.lock() = Arc::downgrade(&logs); Ok(logs) diff --git a/logger/src/rotating.rs b/logger/src/rotating.rs index ddc24792aec..e8fde50d446 100644 --- a/logger/src/rotating.rs +++ b/logger/src/rotating.rs @@ -17,8 +17,8 @@ //! Common log helper functions use std::env; -use rlog::LogLevelFilter; -use env_logger::LogBuilder; +use rlog::LevelFilter; +use env_logger::Builder as LogBuilder; use arrayvec::ArrayVec; use parking_lot::{RwLock, RwLockReadGuard}; @@ -26,13 +26,13 @@ use parking_lot::{RwLock, RwLockReadGuard}; lazy_static! { static ref LOG_DUMMY: () = { let mut builder = LogBuilder::new(); - builder.filter(None, LogLevelFilter::Info); + builder.filter(None, LevelFilter::Info); if let Ok(log) = env::var("RUST_LOG") { builder.parse(&log); } - if !builder.init().is_ok() { + if !builder.try_init().is_ok() { println!("logger initialization failed!"); } }; diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 0f4c2c2dba7..90d2c52f742 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -24,7 +24,7 @@ futures-cpupool = "0.1" heapsize = "0.4" keccak-hash = { git = "https://github.com/paritytech/parity-common" } linked-hash-map = "0.5" -log = "0.3" +log = "0.4" parking_lot = "0.6" price-info = { path = "../price-info", optional = true } rlp = { git = "https://github.com/paritytech/parity-common" } @@ -32,7 +32,7 @@ trace-time = { path = "../util/trace-time" } transaction-pool = { path = "../transaction-pool" } [dev-dependencies] -env_logger = "0.4" +env_logger = "0.5" ethkey = { path = "../ethkey" } rustc-hex = "1.0" diff --git a/price-info/Cargo.toml b/price-info/Cargo.toml index 7dc648516fd..b7ab6508fba 100644 --- a/price-info/Cargo.toml +++ b/price-info/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Parity Technologies "] fetch = { path = "../util/fetch" } futures = "0.1" futures-cpupool = "0.1" -log = "0.3" +log = "0.4" serde_json = "1.0" [dev-dependencies] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 7e25871a350..b896a44aeb7 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -12,7 +12,7 @@ ansi_term = "0.10" cid = "0.2" futures = "0.1.6" futures-cpupool = "0.1" -log = "0.3" +log = "0.4" multihash ="0.7" order-stat = "0.1" parking_lot = "0.6" diff --git a/rpc_client/Cargo.toml b/rpc_client/Cargo.toml index 6b0f4c2cc5e..ae3eca54def 100644 --- a/rpc_client/Cargo.toml +++ b/rpc_client/Cargo.toml @@ -8,7 +8,7 @@ version = "1.4.0" [dependencies] futures = "0.1" -log = "0.3.6" +log = "0.4" serde = "1.0" serde_json = "1.0" url = "1.2.0" diff --git a/secret_store/Cargo.toml b/secret_store/Cargo.toml index 85eda93e3ce..0c8c277c586 100644 --- a/secret_store/Cargo.toml +++ b/secret_store/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] byteorder = "1.0" -log = "0.3" +log = "0.4" parking_lot = "0.6" hyper = { version = "0.11", default-features = false } serde = "1.0" diff --git a/transaction-pool/Cargo.toml b/transaction-pool/Cargo.toml index f56a7023686..4540f62a7de 100644 --- a/transaction-pool/Cargo.toml +++ b/transaction-pool/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] error-chain = "0.12" -log = "0.3" +log = "0.4" smallvec = "0.4" trace-time = { path = "../util/trace-time", version = "0.1" } diff --git a/updater/Cargo.toml b/updater/Cargo.toml index b7c1aded9a2..b8d5c02a460 100644 --- a/updater/Cargo.toml +++ b/updater/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] [dependencies] keccak-hash = { git = "https://github.com/paritytech/parity-common" } lazy_static = "1.0" -log = "0.3" +log = "0.4" ethabi = "5.1" ethabi-derive = "5.0" ethabi-contract = "5.0" diff --git a/util/io/Cargo.toml b/util/io/Cargo.toml index 0e1dfbbc10a..ad50881ddfa 100644 --- a/util/io/Cargo.toml +++ b/util/io/Cargo.toml @@ -11,7 +11,7 @@ fnv = "1.0" mio = { version = "0.6.8", optional = true } crossbeam = "0.3" parking_lot = "0.6" -log = "0.3" +log = "0.4" slab = "0.4" num_cpus = "1.8" timer = "0.2" diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 7e559e229c0..ce495e6dc5e 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -12,7 +12,7 @@ hashdb = { git = "https://github.com/paritytech/parity-common" } heapsize = "0.4" keccak-hasher = { path = "../keccak-hasher" } kvdb = { git = "https://github.com/paritytech/parity-common" } -log = "0.3" +log = "0.4" memorydb = { git = "https://github.com/paritytech/parity-common" } parking_lot = "0.6" fastmap = { path = "../../util/fastmap" } diff --git a/util/migration-rocksdb/Cargo.toml b/util/migration-rocksdb/Cargo.toml index 39ff50cfbb7..5d4c450a66f 100644 --- a/util/migration-rocksdb/Cargo.toml +++ b/util/migration-rocksdb/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +log = "0.4" macros = { path = "../macros" } kvdb = { git = "https://github.com/paritytech/parity-common" } kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common" } diff --git a/util/network-devp2p/Cargo.toml b/util/network-devp2p/Cargo.toml index 99fdc164591..e7e4a3ae101 100644 --- a/util/network-devp2p/Cargo.toml +++ b/util/network-devp2p/Cargo.toml @@ -7,7 +7,7 @@ version = "1.12.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +log = "0.4" mio = "0.6.8" bytes = "0.4" rand = "0.4" diff --git a/util/stats/Cargo.toml b/util/stats/Cargo.toml index 99e81c9e784..9997c7846d2 100644 --- a/util/stats/Cargo.toml +++ b/util/stats/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -log = "0.3" +log = "0.4" diff --git a/util/trace-time/Cargo.toml b/util/trace-time/Cargo.toml index 288a2c4e47c..7a2a93faa51 100644 --- a/util/trace-time/Cargo.toml +++ b/util/trace-time/Cargo.toml @@ -6,4 +6,4 @@ authors = ["Parity Technologies "] license = "GPL-3.0" [dependencies] -log = "0.3" +log = "0.4" diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index 44882b4f541..4720bd6f8ce 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -12,7 +12,7 @@ ethcore-network = { path = "../util/network" } parity-crypto = { git = "https://github.com/paritytech/parity-common" } ethkey = { path = "../ethkey" } hex = "0.2" -log = "0.3" +log = "0.4" mem = { path = "../util/mem" } ordered-float = "0.5" parking_lot = "0.6" diff --git a/whisper/cli/Cargo.toml b/whisper/cli/Cargo.toml index 9aea1a8776e..ac44c53bc3e 100644 --- a/whisper/cli/Cargo.toml +++ b/whisper/cli/Cargo.toml @@ -17,7 +17,7 @@ panic_hook = { path = "../../util/panic_hook" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } -log = "0.3" +log = "0.4" [[bin]] name = "whisper" From 65a1d889072554dd8d41202366ad4177c1892731 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Fri, 10 Aug 2018 11:45:04 +0300 Subject: [PATCH 7/9] Docker alpine: use multi-stage concept (#9269) * Docker alpine: use multi-stage concept * Docker alpine: create config directory --- docker/alpine/Dockerfile | 52 +++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index ad375e5a91a..47b37372ebf 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -1,29 +1,43 @@ -FROM alpine:edge +FROM alpine:edge AS builder + +# show backtraces +ENV RUST_BACKTRACE 1 + +RUN apk add --no-cache \ + build-base \ + cargo \ + cmake \ + eudev-dev \ + linux-headers \ + perl \ + rust -WORKDIR /build +WORKDIR /parity +COPY . /parity +RUN cargo build --release --target x86_64-alpine-linux-musl --verbose +RUN strip target/x86_64-alpine-linux-musl/release/parity -# install tools and dependencies -RUN apk add --no-cache gcc musl-dev pkgconfig g++ make curl \ - eudev-dev rust cargo git file binutils \ - libusb-dev linux-headers perl cmake + +FROM alpine:edge # show backtraces ENV RUST_BACKTRACE 1 -# show tools -RUN rustc -vV && \ -cargo -V && \ -gcc -v &&\ -g++ -v +RUN apk add --no-cache \ + libstdc++ \ + eudev-libs \ + libgcc -# build parity -ADD . /build/parity -RUN cd parity && \ - cargo build --release --verbose && \ - ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity +RUN addgroup -g 1000 parity \ + && adduser -u 1000 -G parity -s /bin/sh -D parity -RUN file /build/parity/target/release/parity +USER parity EXPOSE 8080 8545 8180 -ENTRYPOINT ["/build/parity/target/release/parity"] + +WORKDIR /home/parity + +RUN mkdir -p /home/parity/.local/share/io.parity.ethereum/ +COPY --chown=parity:parity --from=builder /parity/target/x86_64-alpine-linux-musl/release/parity ./ + +ENTRYPOINT ["./parity"] From 30e40079ca67447b45c9de2b564d8c3604d888c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 10 Aug 2018 11:00:55 +0200 Subject: [PATCH 8/9] Prevent blockchain & miner racing when accessing pending block. (#9310) * Prevent blockchain & miner racing when accessing pending block. * Fix unavailability of pending block during reseal. --- ethcore/src/miner/miner.rs | 13 +++--- util/using_queue/src/lib.rs | 85 ++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 38acf9e1e50..23c868ca9b0 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -319,14 +319,15 @@ impl Miner { /// Retrieves an existing pending block iff it's not older than given block number. /// /// NOTE: This will not prepare a new pending block if it's not existing. - /// See `map_pending_block` for alternative behaviour. fn map_existing_pending_block(&self, f: F, latest_block_number: BlockNumber) -> Option where F: FnOnce(&ClosedBlock) -> T, { self.sealing.lock().queue .peek_last_ref() .and_then(|b| { - if b.block().header().number() > latest_block_number { + // to prevent a data race between block import and updating pending block + // we allow the number to be equal. + if b.block().header().number() >= latest_block_number { Some(f(b)) } else { None @@ -365,7 +366,7 @@ impl Miner { // if at least one was pushed successfully, close and enqueue new ClosedBlock; // otherwise, leave everything alone. // otherwise, author a fresh block. - let mut open_block = match sealing.queue.pop_if(|b| b.block().header().parent_hash() == &best_hash) { + let mut open_block = match sealing.queue.get_pending_if(|b| b.block().header().parent_hash() == &best_hash) { Some(old_block) => { trace!(target: "miner", "prepare_block: Already have previous work; updating and returning"); // add transactions to old_block @@ -628,7 +629,7 @@ impl Miner { { let mut sealing = self.sealing.lock(); sealing.next_mandatory_reseal = Instant::now() + self.options.reseal_max_period; - sealing.queue.push(block.clone()); + sealing.queue.set_pending(block.clone()); sealing.queue.use_last_ref(); } @@ -690,7 +691,7 @@ impl Miner { ); let is_new = original_work_hash.map_or(true, |h| h != block_hash); - sealing.queue.push(block); + sealing.queue.set_pending(block); #[cfg(feature = "work-notify")] { @@ -1108,7 +1109,7 @@ impl miner::MinerService for Miner { Some(false) => { trace!(target: "miner", "update_sealing: engine is not keen to seal internally right now"); // anyway, save the block for later use - self.sealing.lock().queue.push(block); + self.sealing.lock().queue.set_pending(block); }, None => { trace!(target: "miner", "update_sealing: engine does not seal internally, preparing work"); diff --git a/util/using_queue/src/lib.rs b/util/using_queue/src/lib.rs index b2c94b3f4a4..42fe1a33ad7 100644 --- a/util/using_queue/src/lib.rs +++ b/util/using_queue/src/lib.rs @@ -54,7 +54,7 @@ impl UsingQueue { /// Return a reference to the item at the top of the queue (or `None` if the queue is empty); /// this constitutes using the item and will remain in the queue for at least another - /// `max_size` invocations of `push()`. + /// `max_size` invocations of `set_pending() + use_last_ref()`. pub fn use_last_ref(&mut self) -> Option<&T> { if let Some(x) = self.pending.take() { self.in_use.push(x); @@ -65,9 +65,9 @@ impl UsingQueue { self.in_use.last() } - /// Place an item on the end of the queue. The previously `push()`ed item will be removed - /// if `use_last_ref()` since it was `push()`ed. - pub fn push(&mut self, b: T) { + /// Place an item on the end of the queue. The previously pending item will be removed + /// if `use_last_ref()` since it was set. + pub fn set_pending(&mut self, b: T) { self.pending = Some(b); } @@ -100,17 +100,16 @@ impl UsingQueue { } } - /// Returns the most recently pushed block if `f` returns `true` with a reference to it as + /// Returns a clone of the pending block if `f` returns `true` with a reference to it as /// a parameter, otherwise `None`. - /// Will not destroy a block if a reference to it has previously been returned by `use_last_ref`, - /// but rather clone it. - pub fn pop_if

(&mut self, predicate: P) -> Option where P: Fn(&T) -> bool, T: Clone { + /// + /// If pending block is not available will clone the first of the used blocks that match the predicate. + pub fn get_pending_if

(&mut self, predicate: P) -> Option where P: Fn(&T) -> bool, T: Clone { // a bit clumsy - TODO: think about a nicer way of expressing this. - if let Some(x) = self.pending.take() { - if predicate(&x) { - Some(x) + if let Some(ref x) = self.pending { + if predicate(x) { + Some(x.clone()) } else { - self.pending = Some(x); None } } else { @@ -122,21 +121,21 @@ impl UsingQueue { #[test] fn should_not_find_when_pushed() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); assert!(q.take_used_if(|i| i == &1).is_none()); } #[test] fn should_not_find_when_pushed_with_clone() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); assert!(q.clone_used_if(|i| i == &1).is_none()); } #[test] fn should_find_when_pushed_and_used() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); q.use_last_ref(); assert!(q.take_used_if(|i| i == &1).unwrap() == 1); } @@ -144,7 +143,7 @@ fn should_find_when_pushed_and_used() { #[test] fn should_have_same_semantics_for_get_take_clone() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); assert!(q.get_used_if(GetAction::Clone, |i| i == &1).is_none()); assert!(q.get_used_if(GetAction::Take, |i| i == &1).is_none()); q.use_last_ref(); @@ -158,7 +157,7 @@ fn should_have_same_semantics_for_get_take_clone() { #[test] fn should_find_when_pushed_and_used_with_clone() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); q.use_last_ref(); assert!(q.clone_used_if(|i| i == &1).unwrap() == 1); } @@ -166,7 +165,7 @@ fn should_find_when_pushed_and_used_with_clone() { #[test] fn should_not_find_again_when_pushed_and_taken() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); q.use_last_ref(); assert!(q.take_used_if(|i| i == &1).unwrap() == 1); assert!(q.clone_used_if(|i| i == &1).is_none()); @@ -175,7 +174,7 @@ fn should_not_find_again_when_pushed_and_taken() { #[test] fn should_find_again_when_pushed_and_cloned() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); q.use_last_ref(); assert!(q.clone_used_if(|i| i == &1).unwrap() == 1); assert!(q.clone_used_if(|i| i == &1).unwrap() == 1); @@ -185,9 +184,9 @@ fn should_find_again_when_pushed_and_cloned() { #[test] fn should_find_when_others_used() { let mut q = UsingQueue::new(2); - q.push(1); + q.set_pending(1); q.use_last_ref(); - q.push(2); + q.set_pending(2); q.use_last_ref(); assert!(q.take_used_if(|i| i == &1).is_some()); } @@ -195,9 +194,9 @@ fn should_find_when_others_used() { #[test] fn should_not_find_when_too_many_used() { let mut q = UsingQueue::new(1); - q.push(1); + q.set_pending(1); q.use_last_ref(); - q.push(2); + q.set_pending(2); q.use_last_ref(); assert!(q.take_used_if(|i| i == &1).is_none()); } @@ -205,8 +204,8 @@ fn should_not_find_when_too_many_used() { #[test] fn should_not_find_when_not_used_and_then_pushed() { let mut q = UsingQueue::new(3); - q.push(1); - q.push(2); + q.set_pending(1); + q.set_pending(2); q.use_last_ref(); assert!(q.take_used_if(|i| i == &1).is_none()); } @@ -214,19 +213,19 @@ fn should_not_find_when_not_used_and_then_pushed() { #[test] fn should_peek_correctly_after_push() { let mut q = UsingQueue::new(3); - q.push(1); + q.set_pending(1); assert_eq!(q.peek_last_ref(), Some(&1)); - q.push(2); + q.set_pending(2); assert_eq!(q.peek_last_ref(), Some(&2)); } #[test] fn should_inspect_correctly() { let mut q = UsingQueue::new(3); - q.push(1); + q.set_pending(1); assert_eq!(q.use_last_ref(), Some(&1)); assert_eq!(q.peek_last_ref(), Some(&1)); - q.push(2); + q.set_pending(2); assert_eq!(q.use_last_ref(), Some(&2)); assert_eq!(q.peek_last_ref(), Some(&2)); } @@ -234,9 +233,9 @@ fn should_inspect_correctly() { #[test] fn should_not_find_when_not_used_peeked_and_then_pushed() { let mut q = UsingQueue::new(3); - q.push(1); + q.set_pending(1); q.peek_last_ref(); - q.push(2); + q.set_pending(2); q.use_last_ref(); assert!(q.take_used_if(|i| i == &1).is_none()); } @@ -244,34 +243,34 @@ fn should_not_find_when_not_used_peeked_and_then_pushed() { #[test] fn should_pop_used() { let mut q = UsingQueue::new(3); - q.push(1); + q.set_pending(1); q.use_last_ref(); - let popped = q.pop_if(|i| i == &1); + let popped = q.get_pending_if(|i| i == &1); assert_eq!(popped, Some(1)); } #[test] -fn should_pop_unused() { +fn should_not_pop_last_pending() { let mut q = UsingQueue::new(3); - q.push(1); - assert_eq!(q.pop_if(|i| i == &1), Some(1)); - assert_eq!(q.pop_if(|i| i == &1), None); + q.set_pending(1); + assert_eq!(q.get_pending_if(|i| i == &1), Some(1)); + assert_eq!(q.get_pending_if(|i| i == &1), Some(1)); } #[test] fn should_not_pop_unused_before_used() { let mut q = UsingQueue::new(3); - q.push(1); - q.push(2); - let popped = q.pop_if(|i| i == &1); + q.set_pending(1); + q.set_pending(2); + let popped = q.get_pending_if(|i| i == &1); assert_eq!(popped, None); } #[test] fn should_not_remove_used_popped() { let mut q = UsingQueue::new(3); - q.push(1); + q.set_pending(1); q.use_last_ref(); - assert_eq!(q.pop_if(|i| i == &1), Some(1)); - assert_eq!(q.pop_if(|i| i == &1), Some(1)); + assert_eq!(q.get_pending_if(|i| i == &1), Some(1)); + assert_eq!(q.get_pending_if(|i| i == &1), Some(1)); } From 1564fae01152946f58e67658c0b5d884fedaecdc Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 10 Aug 2018 11:06:30 +0200 Subject: [PATCH 9/9] Allow setting the panic hook with parity-clib (#9292) * Allow setting the panic hook with parity-clib * Make all FFI functions unsafe * Fix comment * Fix concern --- Cargo.lock | 1 + parity-clib/Cargo.toml | 1 + parity-clib/parity.h | 17 +++ parity-clib/src/lib.rs | 223 +++++++++++++++++++------------------ parity/lib.rs | 1 - parity/main.rs | 3 +- util/panic_hook/src/lib.rs | 43 +++---- 7 files changed, 157 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f529f2bc63f..a933343a729 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1947,6 +1947,7 @@ source = "git+https://github.com/paritytech/parity-common#0045887fecd2fec39e56c9 name = "parity-clib" version = "1.12.0" dependencies = [ + "panic_hook 0.1.0", "parity-ethereum 2.1.0", ] diff --git a/parity-clib/Cargo.toml b/parity-clib/Cargo.toml index 3a1e95b5f3a..32ddf0ecd6e 100644 --- a/parity-clib/Cargo.toml +++ b/parity-clib/Cargo.toml @@ -10,6 +10,7 @@ name = "parity" crate-type = ["cdylib", "staticlib"] [dependencies] +panic_hook = { path = "../util/panic_hook" } parity-ethereum = { path = "../", default-features = false } [features] diff --git a/parity-clib/parity.h b/parity-clib/parity.h index f647395ce9a..9be077b4d30 100644 --- a/parity-clib/parity.h +++ b/parity-clib/parity.h @@ -102,6 +102,23 @@ void parity_destroy(void* parity); /// int parity_rpc(void* parity, const char* rpc, size_t len, char* out_str, size_t* out_len); +/// Sets a callback to call when a panic happens in the Rust code. +/// +/// The callback takes as parameter the custom param (the one passed to this function), plus the +/// panic message. You are expected to log the panic message somehow, in order to communicate it to +/// the user. A panic always indicates a bug in Parity. +/// +/// Note that this method sets the panic hook for the whole program, and not just for Parity. In +/// other words, if you use multiple Rust libraries at once (and not just Parity), then a panic +/// in any Rust code will call this callback as well. +/// +/// ## Thread safety +/// +/// The callback can be called from any thread and multiple times simultaneously. Make sure that +/// your code is thread safe. +/// +int parity_set_panic_hook(void (*cb)(void* param, const char* msg, size_t msg_len), void* param); + #ifdef __cplusplus } #endif diff --git a/parity-clib/src/lib.rs b/parity-clib/src/lib.rs index 563eafd7301..ad0c8a032aa 100644 --- a/parity-clib/src/lib.rs +++ b/parity-clib/src/lib.rs @@ -18,6 +18,7 @@ //! duplicating documentation. extern crate parity_ethereum; +extern crate panic_hook; use std::os::raw::{c_char, c_void, c_int}; use std::panic; @@ -33,132 +34,132 @@ pub struct ParityParams { } #[no_mangle] -pub extern fn parity_config_from_cli(args: *const *const c_char, args_lens: *const usize, len: usize, output: *mut *mut c_void) -> c_int { - unsafe { - panic::catch_unwind(|| { - *output = ptr::null_mut(); - - let args = { - let arg_ptrs = slice::from_raw_parts(args, len); - let arg_lens = slice::from_raw_parts(args_lens, len); - - let mut args = Vec::with_capacity(len + 1); - args.push("parity".to_owned()); - - for (&arg, &len) in arg_ptrs.iter().zip(arg_lens.iter()) { - let string = slice::from_raw_parts(arg as *const u8, len); - match String::from_utf8(string.to_owned()) { - Ok(a) => args.push(a), - Err(_) => return 1, - }; - } - - args - }; - - match parity_ethereum::Configuration::parse_cli(&args) { - Ok(mut cfg) => { - // Always disable the auto-updater when used as a library. - cfg.args.arg_auto_update = "none".to_owned(); - - let cfg = Box::into_raw(Box::new(cfg)); - *output = cfg as *mut _; - 0 - }, - Err(_) => { - 1 - }, +pub unsafe extern fn parity_config_from_cli(args: *const *const c_char, args_lens: *const usize, len: usize, output: *mut *mut c_void) -> c_int { + panic::catch_unwind(|| { + *output = ptr::null_mut(); + + let args = { + let arg_ptrs = slice::from_raw_parts(args, len); + let arg_lens = slice::from_raw_parts(args_lens, len); + + let mut args = Vec::with_capacity(len + 1); + args.push("parity".to_owned()); + + for (&arg, &len) in arg_ptrs.iter().zip(arg_lens.iter()) { + let string = slice::from_raw_parts(arg as *const u8, len); + match String::from_utf8(string.to_owned()) { + Ok(a) => args.push(a), + Err(_) => return 1, + }; } - }).unwrap_or(1) - } + + args + }; + + match parity_ethereum::Configuration::parse_cli(&args) { + Ok(mut cfg) => { + // Always disable the auto-updater when used as a library. + cfg.args.arg_auto_update = "none".to_owned(); + + let cfg = Box::into_raw(Box::new(cfg)); + *output = cfg as *mut _; + 0 + }, + Err(_) => { + 1 + }, + } + }).unwrap_or(1) } #[no_mangle] -pub extern fn parity_config_destroy(cfg: *mut c_void) { - unsafe { - let _ = panic::catch_unwind(|| { - let _cfg = Box::from_raw(cfg as *mut parity_ethereum::Configuration); - }); - } +pub unsafe extern fn parity_config_destroy(cfg: *mut c_void) { + let _ = panic::catch_unwind(|| { + let _cfg = Box::from_raw(cfg as *mut parity_ethereum::Configuration); + }); } #[no_mangle] -pub extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -> c_int { - unsafe { - panic::catch_unwind(|| { - *output = ptr::null_mut(); - let cfg: &ParityParams = &*cfg; - - let config = Box::from_raw(cfg.configuration as *mut parity_ethereum::Configuration); - - let on_client_restart_cb = { - struct Cb(Option, *mut c_void); - unsafe impl Send for Cb {} - unsafe impl Sync for Cb {} - impl Cb { - fn call(&self, new_chain: String) { - if let Some(ref cb) = self.0 { - cb(self.1, new_chain.as_bytes().as_ptr() as *const _, new_chain.len()) - } - } - } - let cb = Cb(cfg.on_client_restart_cb, cfg.on_client_restart_cb_custom); - move |new_chain: String| { cb.call(new_chain); } - }; - - let action = match parity_ethereum::start(*config, on_client_restart_cb, || {}) { - Ok(action) => action, - Err(_) => return 1, - }; - - match action { - parity_ethereum::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 }, - parity_ethereum::ExecutionAction::Instant(None) => 0, - parity_ethereum::ExecutionAction::Running(client) => { - *output = Box::into_raw(Box::::new(client)) as *mut c_void; - 0 - } +pub unsafe extern fn parity_start(cfg: *const ParityParams, output: *mut *mut c_void) -> c_int { + panic::catch_unwind(|| { + *output = ptr::null_mut(); + let cfg: &ParityParams = &*cfg; + + let config = Box::from_raw(cfg.configuration as *mut parity_ethereum::Configuration); + + let on_client_restart_cb = { + let cb = CallbackStr(cfg.on_client_restart_cb, cfg.on_client_restart_cb_custom); + move |new_chain: String| { cb.call(&new_chain); } + }; + + let action = match parity_ethereum::start(*config, on_client_restart_cb, || {}) { + Ok(action) => action, + Err(_) => return 1, + }; + + match action { + parity_ethereum::ExecutionAction::Instant(Some(s)) => { println!("{}", s); 0 }, + parity_ethereum::ExecutionAction::Instant(None) => 0, + parity_ethereum::ExecutionAction::Running(client) => { + *output = Box::into_raw(Box::::new(client)) as *mut c_void; + 0 } - }).unwrap_or(1) - } + } + }).unwrap_or(1) } #[no_mangle] -pub extern fn parity_destroy(client: *mut c_void) { - unsafe { - let _ = panic::catch_unwind(|| { - let client = Box::from_raw(client as *mut parity_ethereum::RunningClient); - client.shutdown(); - }); - } +pub unsafe extern fn parity_destroy(client: *mut c_void) { + let _ = panic::catch_unwind(|| { + let client = Box::from_raw(client as *mut parity_ethereum::RunningClient); + client.shutdown(); + }); } #[no_mangle] -pub extern fn parity_rpc(client: *mut c_void, query: *const char, len: usize, out_str: *mut c_char, out_len: *mut usize) -> c_int { - unsafe { - panic::catch_unwind(|| { - let client: &mut parity_ethereum::RunningClient = &mut *(client as *mut parity_ethereum::RunningClient); - - let query_str = { - let string = slice::from_raw_parts(query as *const u8, len); - match str::from_utf8(string) { - Ok(a) => a, - Err(_) => return 1, - } - }; - - if let Some(output) = client.rpc_query_sync(query_str) { - let q_out_len = output.as_bytes().len(); - if *out_len < q_out_len { - return 1; - } +pub unsafe extern fn parity_rpc(client: *mut c_void, query: *const char, len: usize, out_str: *mut c_char, out_len: *mut usize) -> c_int { + panic::catch_unwind(|| { + let client: &mut parity_ethereum::RunningClient = &mut *(client as *mut parity_ethereum::RunningClient); + + let query_str = { + let string = slice::from_raw_parts(query as *const u8, len); + match str::from_utf8(string) { + Ok(a) => a, + Err(_) => return 1, + } + }; - ptr::copy_nonoverlapping(output.as_bytes().as_ptr(), out_str as *mut u8, q_out_len); - *out_len = q_out_len; - 0 - } else { - 1 + if let Some(output) = client.rpc_query_sync(query_str) { + let q_out_len = output.as_bytes().len(); + if *out_len < q_out_len { + return 1; } - }).unwrap_or(1) + + ptr::copy_nonoverlapping(output.as_bytes().as_ptr(), out_str as *mut u8, q_out_len); + *out_len = q_out_len; + 0 + } else { + 1 + } + }).unwrap_or(1) +} + +#[no_mangle] +pub unsafe extern fn parity_set_panic_hook(callback: extern "C" fn(*mut c_void, *const c_char, usize), param: *mut c_void) { + let cb = CallbackStr(Some(callback), param); + panic_hook::set_with(move |panic_msg| { + cb.call(panic_msg); + }); +} + +// Internal structure for handling callbacks that get passed a string. +struct CallbackStr(Option, *mut c_void); +unsafe impl Send for CallbackStr {} +unsafe impl Sync for CallbackStr {} +impl CallbackStr { + fn call(&self, new_chain: &str) { + if let Some(ref cb) = self.0 { + cb(self.1, new_chain.as_bytes().as_ptr() as *const _, new_chain.len()) + } } } diff --git a/parity/lib.rs b/parity/lib.rs index 84cacf07e11..a2ea11ffe85 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -57,7 +57,6 @@ extern crate ethcore_transaction as transaction; extern crate ethereum_types; extern crate ethkey; extern crate kvdb; -extern crate panic_hook; extern crate parity_hash_fetch as hash_fetch; extern crate parity_ipfs_api; extern crate parity_local_store as local_store; diff --git a/parity/main.rs b/parity/main.rs index 9256373ca03..1254c34727b 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -253,7 +253,8 @@ fn main_direct(force_can_restart: bool) -> i32 { panic_hook::set_with({ let e = exit.clone(); let exiting = exiting.clone(); - move || { + move |panic_msg| { + let _ = stdio::stderr().write_all(panic_msg.as_bytes()); if !exiting.swap(true, Ordering::SeqCst) { *e.0.lock() = ExitStatus { panicking: true, diff --git a/util/panic_hook/src/lib.rs b/util/panic_hook/src/lib.rs index cc7ed7dedac..0c855250906 100644 --- a/util/panic_hook/src/lib.rs +++ b/util/panic_hook/src/lib.rs @@ -24,16 +24,26 @@ use std::thread; use std::process; use backtrace::Backtrace; -/// Set the panic hook +/// Set the panic hook to write to stderr and abort the process when a panic happens. pub fn set_abort() { - set_with(|| process::abort()); + set_with(|msg| { + let _ = io::stderr().write_all(msg.as_bytes()); + process::abort() + }); } -/// Set the panic hook with a closure to be called afterwards. -pub fn set_with(f: F) { +/// Set the panic hook with a closure to be called. The closure receives the panic message. +/// +/// Depending on how Parity was compiled, after the closure has been executed, either the process +/// aborts or unwinding starts. +/// +/// If you panic within the closure, a double panic happens and the process will stop. +pub fn set_with(f: F) +where F: Fn(&str) + Send + Sync + 'static +{ panic::set_hook(Box::new(move |info| { - panic_hook(info); - f(); + let msg = gen_panic_msg(info); + f(&msg); })); } @@ -43,7 +53,7 @@ This is a bug. Please report it at: https://github.com/paritytech/parity-ethereum/issues/new "; -fn panic_hook(info: &PanicInfo) { +fn gen_panic_msg(info: &PanicInfo) -> String { let location = info.location(); let file = location.as_ref().map(|l| l.file()).unwrap_or(""); let line = location.as_ref().map(|l| l.line()).unwrap_or(0); @@ -61,18 +71,13 @@ fn panic_hook(info: &PanicInfo) { let backtrace = Backtrace::new(); - let mut stderr = io::stderr(); + format!(r#" - let _ = writeln!(stderr, ""); - let _ = writeln!(stderr, "===================="); - let _ = writeln!(stderr, ""); - let _ = writeln!(stderr, "{:?}", backtrace); - let _ = writeln!(stderr, ""); - let _ = writeln!( - stderr, - "Thread '{}' panicked at '{}', {}:{}", - name, msg, file, line - ); +==================== - let _ = writeln!(stderr, "{}", ABOUT_PANIC); +{backtrace:?} + +Thread '{name}' panicked at '{msg}', {file}:{line} +{about} +"#, backtrace = backtrace, name = name, msg = msg, file = file, line = line, about = ABOUT_PANIC) }